diff options
-rw-r--r-- | tests/test_run.py | 25 | ||||
-rw-r--r-- | tests/trace.dat | bin | 0 -> 2523136 bytes | |||
-rw-r--r-- | tests/utils_tests.py | 14 |
3 files changed, 38 insertions, 1 deletions
diff --git a/tests/test_run.py b/tests/test_run.py index 49839c3..545ea26 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -5,6 +5,7 @@ import os import re import shutil import tempfile +import unittest from test_thermal import BaseTestThermal import cr2 @@ -194,3 +195,27 @@ class TestRunSched(utils_tests.SetupDirectory): run = cr2.Run() self.assertEqual(run.thermal.data_frame.index[0], 0) + +@unittest.skipUnless(utils_tests.trace_cmd_installed(), + "trace-cmd not installed") +class TestTraceDat(utils_tests.SetupDirectory): + """Test that trace.dat handling work""" + def __init__(self, *args, **kwargs): + super(TestTraceDat, self).__init__( + [("trace.dat", "trace.dat")], + *args, **kwargs) + + def test_do_txt_if_not_there(self): + """Create trace.txt if it's not there""" + self.assertFalse(os.path.isfile("trace.txt")) + + cr2.Run() + + found = False + with open("trace.txt") as fin: + for line in fin: + if re.search("thermal", line): + found = True + break + + self.assertTrue(found) diff --git a/tests/trace.dat b/tests/trace.dat Binary files differnew file mode 100644 index 0000000..c54b5e2 --- /dev/null +++ b/tests/trace.dat diff --git a/tests/utils_tests.py b/tests/utils_tests.py index c0aa33f..a7ac216 100644 --- a/tests/utils_tests.py +++ b/tests/utils_tests.py @@ -2,10 +2,22 @@ import unittest import os -import shutil, tempfile +import shutil +import subprocess +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): self.files_to_copy = files_to_copy |