`test_query_trace_info.py`: adapt regex to NT path style
[babeltrace.git] / tests / plugins / src.ctf.fs / query / test_query_trace_info.py
index a026a68ecebb4b7c9057309738f891bd2784fb2f..a63fe04f1f86ca14eb374157b1ba42617be24747 100644 (file)
@@ -18,9 +18,10 @@ import unittest
 import bt2
 import os
 import re
+from pathlib import PureWindowsPath, PurePosixPath
 
 
-test_ctf_traces_path = os.environ['TEST_CTF_TRACES_PATH']
+test_ctf_traces_path = os.environ['BT_CTF_TRACES_PATH']
 
 
 # Key to sort streams in a predictable order.
@@ -32,19 +33,24 @@ def sort_predictably(stream):
 
 
 class QueryTraceInfoClockOffsetTestCase(unittest.TestCase):
-
     def setUp(self):
         ctf = bt2.find_plugin('ctf')
         self._fs = ctf.source_component_classes['fs']
 
-        self._paths = [os.path.join(test_ctf_traces_path, 'intersection', '3eventsintersect')]
+        self._paths = [
+            os.path.join(test_ctf_traces_path, 'intersection', '3eventsintersect')
+        ]
         self._executor = bt2.QueryExecutor()
 
     def _check(self, trace, offset):
         self.assertEqual(trace['range-ns']['begin'], 13515309000000000 + offset)
         self.assertEqual(trace['range-ns']['end'], 13515309000000120 + offset)
-        self.assertEqual(trace['intersection-range-ns']['begin'], 13515309000000070 + offset)
-        self.assertEqual(trace['intersection-range-ns']['end'], 13515309000000100 + offset)
+        self.assertEqual(
+            trace['intersection-range-ns']['begin'], 13515309000000070 + offset
+        )
+        self.assertEqual(
+            trace['intersection-range-ns']['end'], 13515309000000100 + offset
+        )
 
         streams = sorted(trace['streams'], key=sort_predictably)
         self.assertEqual(streams[0]['range-ns']['begin'], 13515309000000000 + offset)
@@ -58,70 +64,74 @@ class QueryTraceInfoClockOffsetTestCase(unittest.TestCase):
     # Without clock class offset
 
     def test_no_clock_class_offset(self):
-        res = self._executor.query(self._fs, 'trace-info', {
-            'paths': self._paths,
-        })
+        res = self._executor.query(self._fs, 'trace-info', {'paths': self._paths})
         trace = res[0]
         self._check(trace, 0)
 
     # With clock-class-offset-s
 
     def test_clock_class_offset_s(self):
-        res = self._executor.query(self._fs, 'trace-info', {
-            'paths': self._paths,
-            'clock-class-offset-s': 2,
-        })
+        res = self._executor.query(
+            self._fs, 'trace-info', {'paths': self._paths, 'clock-class-offset-s': 2}
+        )
         trace = res[0]
         self._check(trace, 2000000000)
 
     # With clock-class-offset-ns
 
     def test_clock_class_offset_ns(self):
-        res = self._executor.query(self._fs, 'trace-info', {
-            'paths': self._paths,
-            'clock-class-offset-ns': 2,
-        })
+        res = self._executor.query(
+            self._fs, 'trace-info', {'paths': self._paths, 'clock-class-offset-ns': 2}
+        )
         trace = res[0]
         self._check(trace, 2)
 
     # With both, negative
 
     def test_clock_class_offset_both(self):
-        res = self._executor.query(self._fs, 'trace-info', {
-            'paths': self._paths,
-            'clock-class-offset-s': -2,
-            'clock-class-offset-ns': -2,
-        })
+        res = self._executor.query(
+            self._fs,
+            'trace-info',
+            {
+                'paths': self._paths,
+                'clock-class-offset-s': -2,
+                'clock-class-offset-ns': -2,
+            },
+        )
         trace = res[0]
         self._check(trace, -2000000002)
 
     def test_clock_class_offset_s_wrong_type(self):
-        with self.assertRaises(bt2.InvalidQueryParams):
-            self._executor.query(self._fs, 'trace-info', {
-                'paths': self._paths,
-                'clock-class-offset-s': "2",
-            })
+        with self.assertRaises(bt2.InvalidParams):
+            self._executor.query(
+                self._fs,
+                'trace-info',
+                {'paths': self._paths, 'clock-class-offset-s': "2"},
+            )
 
     def test_clock_class_offset_s_wrong_type_none(self):
-        with self.assertRaises(bt2.InvalidQueryParams):
-            self._executor.query(self._fs, 'trace-info', {
-                'paths': self._paths,
-                'clock-class-offset-s': None,
-            })
+        with self.assertRaises(bt2.InvalidParams):
+            self._executor.query(
+                self._fs,
+                'trace-info',
+                {'paths': self._paths, 'clock-class-offset-s': None},
+            )
 
     def test_clock_class_offset_ns_wrong_type(self):
-        with self.assertRaises(bt2.InvalidQueryParams):
-            self._executor.query(self._fs, 'trace-info', {
-                'paths': self._paths,
-                'clock-class-offset-ns': "2",
-            })
+        with self.assertRaises(bt2.InvalidParams):
+            self._executor.query(
+                self._fs,
+                'trace-info',
+                {'paths': self._paths, 'clock-class-offset-ns': "2"},
+            )
 
     def test_clock_class_offset_ns_wrong_type_none(self):
-        with self.assertRaises(bt2.InvalidQueryParams):
-            self._executor.query(self._fs, 'trace-info', {
-                'paths': self._paths,
-                'clock-class-offset-ns': None,
-            })
+        with self.assertRaises(bt2.InvalidParams):
+            self._executor.query(
+                self._fs,
+                'trace-info',
+                {'paths': self._paths, 'clock-class-offset-ns': None},
+            )
 
 
 class QueryTraceInfoPortNameTestCase(unittest.TestCase):
@@ -143,17 +153,28 @@ class QueryTraceInfoPortNameTestCase(unittest.TestCase):
                 ]
             },
         )
+
+        os_stream_path = PurePosixPath(
+            '/tests/data/ctf-traces/intersection/3eventsintersect/'
+        )
+        if os.environ['BT_OS_TYPE'] == 'mingw':
+            os_stream_path = PureWindowsPath(os_stream_path)
+
         self.assertEqual(len(res), 1)
         trace = res[0]
         streams = sorted(trace["streams"], key=sort_predictably)
         self.assertEqual(len(streams), 2)
         self.assertRegexpMatches(
             str(streams[0]["port-name"]),
-            r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*/tests/ctf-traces/intersection/3eventsintersect/test_stream_0$",
+            r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*"
+            + re.escape(str(os_stream_path / "test_stream_0"))
+            + r"$",
         )
         self.assertRegexpMatches(
             str(streams[1]["port-name"]),
-            r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*/tests/ctf-traces/intersection/3eventsintersect/test_stream_1$",
+            r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*"
+            + re.escape(str(os_stream_path / "test_stream_1"))
+            + r"$",
         )
 
     def test_trace_uuid_no_stream_class_id_no_stream_id(self):
@@ -162,13 +183,22 @@ class QueryTraceInfoPortNameTestCase(unittest.TestCase):
             "trace-info",
             {"paths": [os.path.join(test_ctf_traces_path, "succeed", "succeed1")]},
         )
+
+        os_stream_path = PurePosixPath(
+            '/tests/data/ctf-traces/succeed/succeed1/dummystream'
+        )
+        if os.environ['BT_OS_TYPE'] == 'mingw':
+            os_stream_path = PureWindowsPath(os_stream_path)
+
         self.assertEqual(len(res), 1)
         trace = res[0]
         streams = sorted(trace["streams"], key=sort_predictably)
         self.assertEqual(len(streams), 1)
         self.assertRegexpMatches(
             str(streams[0]["port-name"]),
-            r"^2a6422d0-6cee-11e0-8c08-cb07d7b3a564 \| .*/tests/ctf-traces/succeed/succeed1/dummystream$",
+            r"^2a6422d0-6cee-11e0-8c08-cb07d7b3a564 \| .*"
+            + re.escape(str(os_stream_path))
+            + r"$",
         )
 
 
This page took 0.041666 seconds and 4 git commands to generate.