Migrate to support unified builds with shared fw

Unified builds shared the same firmware across many models.

Migrated get_platform to use mosys to determine the model instead of
depending on the firmware convention.

BUG=b:66195068
TEST=unit tests

Change-Id: I2849d488a104ee2dd59a44825d4d8105d841caa2
Reviewed-on: https://chromium-review.googlesource.com/678563
Commit-Ready: C Shapiro <[email protected]>
Tested-by: C Shapiro <[email protected]>
Reviewed-by: Richard Barnette <[email protected]>
diff --git a/server/hosts/cros_host_unittest.py b/server/hosts/cros_host_unittest.py
old mode 100644
new mode 100755
index 2d1bf40..8896ee6
--- a/server/hosts/cros_host_unittest.py
+++ b/server/hosts/cros_host_unittest.py
@@ -2,11 +2,58 @@
 # pylint: disable=missing-docstring
 
 import unittest
+
 import common
 
 from autotest_lib.server.hosts import cros_host
 from autotest_lib.server.hosts import servo_host
 
+CROSSYSTEM_RESULT = '''
+fwb_tries              = 0                              # Fake comment
+fw_vboot2              = 1                              # Fake comment
+fwid                   = Google_Reef.9933.0.0           # Fake comment
+fwupdate_tries         = 0                              #
+fw_tried               = B                              #
+fw_try_count           = 0                              #
+'''
+
+class MockCmd(object):
+    """Simple mock command with base command and results"""
+
+    def __init__(self, cmd, exit_status, stdout):
+        self.cmd = cmd
+        self.stdout = stdout
+        self.exit_status = exit_status
+
+
+class MockHost(cros_host.CrosHost):
+    """Simple host for running mock'd host commands"""
+
+    def __init__(self, *args):
+        self._mock_cmds = {c.cmd: c for c in args}
+
+    def run(self, command, **kwargs):
+        """Finds the matching result by command value"""
+        mock_cmd = self._mock_cmds[command]
+        file_out = kwargs.get('stdout_tee', None)
+        if file_out:
+            file_out.write(mock_cmd.stdout)
+        return mock_cmd
+
+
+class GetPlatformModelTests(unittest.TestCase):
+    """Unit tests for CrosHost.get_platform_model"""
+
+    def test_mosys_succeeds(self):
+        host = MockHost(MockCmd('mosys platform model', 0, 'coral\n'))
+        self.assertEqual(host.get_platform(), 'coral')
+
+    def test_mosys_fails(self):
+        host = MockHost(
+            MockCmd('mosys platform model', 1, ''),
+            MockCmd('crossystem', 0, CROSSYSTEM_RESULT))
+        self.assertEqual(host.get_platform(), 'reef')
+
 
 class DictFilteringTestCase(unittest.TestCase):