sysmon: Add osinfo metrics tests
BUG=chromium:736911
TEST=None
Change-Id: I18c733a97088a91aad3dbcc657d2e54ffda053c0
Reviewed-on: https://chromium-review.googlesource.com/570827
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/scripts/sysmon/osinfo_metrics.py b/scripts/sysmon/osinfo_metrics.py
index 4129e7a..e2a407b 100644
--- a/scripts/sysmon/osinfo_metrics.py
+++ b/scripts/sysmon/osinfo_metrics.py
@@ -51,53 +51,19 @@
Returns:
OSInfo instance
"""
- os_name = platform.system().lower()
- if 'windows' in os_name:
- return _get_windows_osinfo()
- elif 'linux' in os_name:
+ os_name = platform.system()
+ if os_name == 'Linux':
return _get_linux_osinfo()
- elif _is_mac():
- # On mac platform.system() reports 'darwin'.
- #
- # TODO(ayatane): I'm not sure how true the above comment is, but I
- # have no reason to remove it nor change the existing logic right
- # now.
- return _get_mac_osinfo()
else:
return OSInfo(name='', version='')
-def _get_windows_osinfo():
- os_name = 'windows'
- # release will be something like '7', 'vista', or 'xp'
- os_version = platform.release()
- return OSInfo(name=os_name, version=os_version)
-
-
def _get_linux_osinfo():
# will return something like ('Ubuntu', '14.04', 'trusty')
os_name, os_version, _ = platform.dist()
return OSInfo(name=os_name, version=os_version)
-def _get_mac_osinfo():
- return OSInfo(name='mac', version=_get_mac_version())
-
-
-def _is_mac():
- """Return whether the current system is a Mac."""
- return bool(_get_mac_version())
-
-
-def _get_mac_version():
- """Get Mac system version.
-
- Returns:
- Version string, which is empty if not a valid Mac system.
- """
- return platform.mac_ver()[0]
-
-
def _get_python_arch():
if sys.maxsize > 2**32:
return '64'