aboutsummaryrefslogtreecommitdiff
path: root/tests/test_idle.py
diff options
context:
space:
mode:
authorBrendan Jackman <brendan.jackman@arm.com>2016-10-18 14:48:04 +0100
committerJavi Merino <merino.jav@gmail.com>2016-10-25 12:46:49 +0100
commita3e1a485ea32966885fa1ad1b0c5c2a8f8358038 (patch)
tree32acacaab21c52b57684fb11a2dc9d0f54def2ae /tests/test_idle.py
parent5e97a10f18e26d77c131e0454bf807427d02dfe9 (diff)
downloadtrappy-a3e1a485ea32966885fa1ad1b0c5c2a8f8358038.tar.gz
idle: Add parser for cpu_idle events
This requires removing cpu_idle events from the trace_empty.txt, so that the FTrace tests that use it are not broken.
Diffstat (limited to 'tests/test_idle.py')
-rw-r--r--tests/test_idle.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/test_idle.py b/tests/test_idle.py
new file mode 100644
index 0000000..dec1b43
--- /dev/null
+++ b/tests/test_idle.py
@@ -0,0 +1,68 @@
+# Copyright 2016 ARM Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+import os
+import sys
+import unittest
+
+import pandas as pd
+from pandas.util.testing import assert_series_equal
+
+import utils_tests
+import trappy
+
+@unittest.skipUnless(utils_tests.trace_cmd_installed(),
+ "trace-cmd not installed")
+class TestCpuIdle(utils_tests.SetupDirectory):
+ def __init__(self, *args, **kwargs):
+ super(TestCpuIdle, self).__init__(
+ [("trace_idle.dat", "trace.dat")],
+ *args,
+ **kwargs)
+
+ def test_get_dataframe(self):
+ """Test that CpuIdle creates a proper data_frame"""
+
+ df = trappy.FTrace(normalize_time=False).cpu_idle.data_frame
+
+ exp_index = pd.Float64Index([
+ 162534.215764,
+ 162534.216001,
+ 162534.216552,
+ 162534.216568,
+ 162534.217401,
+ 162534.217521,
+ 162534.217655,
+ 162534.219077,
+ 162534.219252,
+ 162534.219268,
+ 162534.219329,
+ 162534.219336,
+ 162534.219587,
+ 162534.219763,
+ 162534.219853,
+ 162534.220947,
+ 162534.220947
+ ], name="Time")
+
+ exp_states = pd.Series([
+ 2, -1, 2, -1, -1, -1, 2, -1, 2, -1, 0, 0, 2, -1, 2, -1, -1
+ ], index=exp_index, name="state")
+ exp_cpus = pd.Series([
+ 5, 2, 2, 1, 3, 0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 3, 1
+ ], index=exp_index, name="cpu_id")
+
+ assert_series_equal(df["state"], exp_states, check_exact=True)
+ assert_series_equal(df["cpu_id"], exp_cpus, check_exact=True)