summaryrefslogtreecommitdiff
path: root/tests/common/osutil/test_default.py
diff options
context:
space:
mode:
authorƁukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com>2017-01-16 10:10:41 +0100
committerusd-importer <ubuntu-server@lists.ubuntu.com>2017-01-17 17:53:13 +0000
commitd064ab0bffd429382ea4fafeb144784d403848bd (patch)
tree28b0940943acfa742f484c2c0016e8f22c17124c /tests/common/osutil/test_default.py
parent63d399807de30a64456e672063e7c20babf7aadc (diff)
downloadvyos-walinuxagent-d064ab0bffd429382ea4fafeb144784d403848bd.tar.gz
vyos-walinuxagent-d064ab0bffd429382ea4fafeb144784d403848bd.zip
Import patches-unapplied version 2.2.2-0ubuntu1 to ubuntu/zesty-proposed
Imported using git-ubuntu import. Changelog parent: 63d399807de30a64456e672063e7c20babf7aadc New changelog entries: * New upstream release (LP: #1651128) - d/patches/fix-auto-update.patch, d/patches/lp1623570-adjust-walinuxagent-service-after-and-wants.patch: - Dropped as changes have been applied upstream - Refreshed debian/patches/disable_import_test.patch
Diffstat (limited to 'tests/common/osutil/test_default.py')
-rw-r--r--tests/common/osutil/test_default.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/common/osutil/test_default.py b/tests/common/osutil/test_default.py
index d9d00f6..d982b7e 100644
--- a/tests/common/osutil/test_default.py
+++ b/tests/common/osutil/test_default.py
@@ -142,5 +142,27 @@ class TestOSUtil(AgentTestCase):
self.assertTrue(endpoint is not None)
self.assertEqual(endpoint, "second")
+ def test_get_total_mem(self):
+ """
+ Validate the returned value matches to the one retrieved by invoking shell command
+ """
+ cmd = "grep MemTotal /proc/meminfo |awk '{print $2}'"
+ ret = shellutil.run_get_output(cmd)
+ if ret[0] == 0:
+ self.assertEqual(int(ret[1]) / 1024, get_osutil().get_total_mem())
+ else:
+ self.fail("Cannot retrieve total memory using shell command.")
+
+ def test_get_processor_cores(self):
+ """
+ Validate the returned value matches to the one retrieved by invoking shell command
+ """
+ cmd = "grep 'processor.*:' /proc/cpuinfo |wc -l"
+ ret = shellutil.run_get_output(cmd)
+ if ret[0] == 0:
+ self.assertEqual(int(ret[1]), get_osutil().get_processor_cores())
+ else:
+ self.fail("Cannot retrieve number of process cores using shell command.")
+
if __name__ == '__main__':
unittest.main()