Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(864)

Unified Diff: tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py

Issue 684713003: Telemetry: Linux-based backends should return CPU results in seconds, not jiffies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py
diff --git a/tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py b/tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py
index dfadac3d31b596646c3dcf939306d4fa908e866f..5fadde7c401978e2fb21f6d7e71b785ae4133bac 100644
--- a/tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py
+++ b/tools/telemetry/telemetry/core/platform/linux_based_platform_backend_unittest.py
@@ -23,9 +23,33 @@ class TestBackend(linux_based_platform_backend.LinuxBasedPlatformBackend):
def GetFileContents(self, filename):
return self._mock_files[filename]
+ def GetClockTicks(self):
+ return 41
class LinuxBasedPlatformBackendTest(unittest.TestCase):
+ def testGetCpuStatsBasic(self):
+ if not linux_based_platform_backend.resource:
+ logging.warning('Test not supported')
+ return
+
+ backend = TestBackend()
+ with open(os.path.join(util.GetUnittestDataDir(), 'stat')) as f:
+ backend.SetMockFile('/proc/1/stat', f.read())
jeremy 2014/10/29 06:11:32 IMHO it might be a bit cleaner if you split these
Lei Zhang 2014/10/29 07:03:08 Done. Can you take a look again to make sure I did
+ result = backend.GetCpuStats(1)
+ self.assertEquals(result, {'CpuProcessTime': 22.0})
+
+ def testGetCpuTimestampBasic(self):
+ if not linux_based_platform_backend.resource:
+ logging.warning('Test not supported')
+ return
+
+ backend = TestBackend()
+ with open(os.path.join(util.GetUnittestDataDir(), 'timer_list')) as f:
+ backend.SetMockFile('/proc/timer_list', f.read())
+ result = backend.GetCpuTimestamp()
+ self.assertEquals(result, {'TotalTime': 105054633.0})
+
def testGetMemoryStatsBasic(self):
if not linux_based_platform_backend.resource:
logging.warning('Test not supported')
« no previous file with comments | « tools/telemetry/telemetry/core/platform/linux_based_platform_backend.py ('k') | tools/telemetry/unittest_data/timer_list » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698