aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKapileshwar Singh <kapileshwarsingh@gmail.com>2015-12-02 11:59:52 +0000
committerKapileshwar Singh <kapileshwarsingh@gmail.com>2015-12-02 11:59:52 +0000
commit37c6e2167e9480abb452d02f1cbda39434330478 (patch)
treea34c71dc4fe5a1cc87e883e26cef264a998bebda
parentbabf744f1437577aab8ad58f8dc6f36db8b70a70 (diff)
parent261b7e50b33d19f1cdd0bad71b9a32ff782f2f44 (diff)
downloadbart-37c6e2167e9480abb452d02f1cbda39434330478.tar.gz
Merge pull request #38 from JaviMerino/sched_assert_tests
tests: import test_sched_assert from trappy
-rw-r--r--tests/raw_trace.datbin0 -> 2437120 bytes
-rw-r--r--tests/test_sched_assert.py70
-rw-r--r--tests/utils_tests.py10
3 files changed, 80 insertions, 0 deletions
diff --git a/tests/raw_trace.dat b/tests/raw_trace.dat
new file mode 100644
index 0000000..adfb449
--- /dev/null
+++ b/tests/raw_trace.dat
Binary files differ
diff --git a/tests/test_sched_assert.py b/tests/test_sched_assert.py
new file mode 100644
index 0000000..e65a94b
--- /dev/null
+++ b/tests/test_sched_assert.py
@@ -0,0 +1,70 @@
+# Copyright 2015-2015 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 trappy
+from trappy.stats.Topology import Topology
+import unittest
+
+import utils_tests
+
+from bart.sched.SchedAssert import SchedAssert
+
+@unittest.skipUnless(utils_tests.trace_cmd_installed(),
+ "trace-cmd not installed")
+class TestSchedAssert(utils_tests.SetupDirectory):
+
+ def __init__(self, *args, **kwargs):
+
+ self.BIG = [1,2]
+ self.LITTLE = [0, 3, 4, 5]
+ self.clusters = [self.BIG, self.LITTLE]
+ self.topology = Topology(clusters=self.clusters)
+ super(TestSchedAssert, self).__init__(
+ [("raw_trace.dat", "trace.dat")],
+ *args,
+ **kwargs)
+
+ def test_get_runtime(self):
+
+ r = trappy.Run()
+ # The ls process is process we are
+ # testing against with pre calculated
+ # values
+ process = "ls"
+
+ # Complete duration
+ expected_time = 0.0034740000264719129
+ s = SchedAssert(r, self.topology, execname=process)
+ self.assertAlmostEqual(s.getRuntime(), expected_time, places=9)
+ self.assertAlmostEqual(s.getRuntime(), expected_time, places=9)
+
+ # Non Interrupted Window
+ window = (0.0034, 0.003525)
+ expected_time = 0.000125
+ self.assertAlmostEqual(s.getRuntime(window=window), expected_time,
+ places=9)
+
+ # Interrupted Window
+ window = (0.0030, 0.0032)
+ expected_time = 0.000166
+ self.assertAlmostEqual(s.getRuntime(window=window), expected_time,
+ places=9)
+
+ # A window with multiple interruptions
+ window = (0.0027, 0.0036)
+ expected_time = 0.000817
+ self.assertAlmostEqual(s.getRuntime(window=window), expected_time,
+ places=9)
diff --git a/tests/utils_tests.py b/tests/utils_tests.py
index 63a050e..8216ea5 100644
--- a/tests/utils_tests.py
+++ b/tests/utils_tests.py
@@ -23,6 +23,16 @@ import tempfile
TESTS_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
+def trace_cmd_installed():
+ """Return true if trace-cmd is installed, false otherwise"""
+ with open(os.devnull) as devnull:
+ try:
+ subprocess.check_call(["trace-cmd", "options"], stdout=devnull)
+ except OSError:
+ return False
+
+ return True
+
class SetupDirectory(unittest.TestCase):
def __init__(self, files_to_copy, *args, **kwargs):