Refactor LogSystemDetails and unit tests.

- Extracted GetCrosSystem
- Re-structured the unit tests to separate tests for Util and Gooftool
- Added more unit tests

BUG=None
TEST=manually on DUT

Change-Id: I1e1f41b53c73befd26f4d467365089c581dfd54a
Reviewed-on: https://gerrit.chromium.org/gerrit/39452
Commit-Ready: Andy Cheng <andycheng@chromium.org>
Reviewed-by: Andy Cheng <andycheng@chromium.org>
Tested-by: Andy Cheng <andycheng@chromium.org>
diff --git a/py/gooftool/gooftool.py b/py/gooftool/gooftool.py
index cece5e9..d087825 100755
--- a/py/gooftool/gooftool.py
+++ b/py/gooftool/gooftool.py
@@ -584,24 +584,7 @@
 def LogSystemDetails(options):  # pylint: disable=W0613
   """Write miscellaneous system details to the event log."""
 
-  raw_cs_data = Shell('crossystem').stdout.strip().splitlines()
-  # The crossytem output contains many lines like:
-  # 'key = value  # description'
-  # Use regexps to pull out the key-value pairs and build a dict.
-  cs_data = dict((k, v.strip()) for k, v in
-                 map(lambda x: re.findall(r'\A(\S+)\s+=\s+(.*)#.*\Z', x)[0],
-                     raw_cs_data))
-  _event_log.Log(
-      'system_details',
-      platform_name=Shell('mosys platform name').stdout.strip(),
-      crossystem=cs_data,
-      modem_status=Shell('modem status').stdout.splitlines(),
-      ec_wp_status=Shell(
-          'flashrom -p internal:bus=lpc --get-size 2>/dev/null && '
-          'flashrom -p internal:bus=lpc --wp-status || '
-          'echo "EC is not available."').stdout,
-      bios_wp_status = Shell(
-          'flashrom -p internal:bus=spi --wp-status').stdout)
+  _event_log.Log('system_details', **Gooftool().GetSystemDetails())
 
 
 _upload_method_cmd_arg = CmdArg(