class GetCmdPerfCpuclockTestCase(LepvTestCase): def setUp(self): self.profiler = PerfProfiler('') def validate(self, expected, actual, expectedMatchType): print("Actual:") pprint(actual) compare_result = DictUtil.compare(actual, expected) if expectedMatchType == 'equals': self.assertEqual(compare_result, 0, "Expected and Actual does not match") elif expectedMatchType == 'contains': self.assertIn(compare_result, [0, 1], "Actual does not contain the expected") else: print("") @file_data("unittests.json") def test(self, kernel, os, cpu, note, lepdResult, expected, expectedMatchType): self.describe(kernel, os, cpu, note, expectedMatchType, expected) actual = self.profiler.get_perf_cpu_clock(lepdResult) self.validate(expected, actual, expectedMatchType)
def getPerfCpuClockData(server): profiler = PerfProfiler(server) data = profiler.get_perf_cpu_clock() if 'request_id' in request.args: data['response_id'] = request.args['request_id'] return jsonify(data)