X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=tests%2Fplugins%2Fsrc.ctf.fs%2Fquery%2Ftest_query_trace_info.py;h=eb8fd25ce8e63638386bed9f6f9cbd96bcd89f54;hb=a0baab4a979e830f7dc4698c20b71e84dea6ff9d;hp=41b2b83121206ef8938451174d65c4e88519ecd9;hpb=5f2a1585bf407f3f3aa7e63d9041b75390cf8563;p=babeltrace.git diff --git a/tests/plugins/src.ctf.fs/query/test_query_trace_info.py b/tests/plugins/src.ctf.fs/query/test_query_trace_info.py index 41b2b831..eb8fd25c 100644 --- a/tests/plugins/src.ctf.fs/query/test_query_trace_info.py +++ b/tests/plugins/src.ctf.fs/query/test_query_trace_info.py @@ -1,24 +1,12 @@ -# Copyright (C) 2019 Simon Marchi -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; only version 2 -# of the License. +# SPDX-License-Identifier: GPL-2.0-only # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# Copyright (C) 2019 Simon Marchi # -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import unittest import bt2 import os import re -from pathlib import PureWindowsPath, PurePosixPath test_ctf_traces_path = os.environ['BT_CTF_TRACES_PATH'] @@ -145,26 +133,27 @@ class QueryTraceInfoPortNameTestCase(unittest.TestCase): }, ).query() - os_stream_path = PurePosixPath( - '/tests/data/ctf-traces/intersection/3eventsintersect/' - ) - if os.environ['BT_OS_TYPE'] == 'mingw': - os_stream_path = PureWindowsPath(os_stream_path) + if os.environ['BT_TESTS_OS_TYPE'] == 'mingw': + os_stream_path = ( + '\\tests\\data\\ctf-traces\\intersection\\3eventsintersect\\' + ) + else: + os_stream_path = '/tests/data/ctf-traces/intersection/3eventsintersect/' self.assertEqual(len(res), 1) trace = res[0] streams = sorted(trace["stream-infos"], key=sort_predictably) self.assertEqual(len(streams), 2) - self.assertRegexpMatches( + self.assertRegex( str(streams[0]["port-name"]), r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*" - + re.escape(str(os_stream_path / "test_stream_0")) + + re.escape(os_stream_path + "test_stream_0") + r"$", ) - self.assertRegexpMatches( + self.assertRegex( str(streams[1]["port-name"]), r"^7afe8fbe-79b8-4f6a-bbc7-d0c782e7ddaf \| 0 \| .*" - + re.escape(str(os_stream_path / "test_stream_1")) + + re.escape(os_stream_path + "test_stream_1") + r"$", ) @@ -175,20 +164,19 @@ class QueryTraceInfoPortNameTestCase(unittest.TestCase): {"inputs": [os.path.join(test_ctf_traces_path, "succeed", "succeed1")]}, ).query() - 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) + if os.environ['BT_TESTS_OS_TYPE'] == 'mingw': + os_stream_path = '\\tests\\data\\ctf-traces\\succeed\\succeed1\\dummystream' + else: + os_stream_path = '/tests/data/ctf-traces/succeed/succeed1/dummystream' self.assertEqual(len(res), 1) trace = res[0] streams = sorted(trace["stream-infos"], key=sort_predictably) self.assertEqual(len(streams), 1) - self.assertRegexpMatches( + self.assertRegex( str(streams[0]["port-name"]), r"^2a6422d0-6cee-11e0-8c08-cb07d7b3a564 \| .*" - + re.escape(str(os_stream_path)) + + re.escape(os_stream_path) + r"$", ) @@ -218,6 +206,43 @@ class QueryTraceInfoRangeTestCase(unittest.TestCase): self.assertRaises(KeyError, lambda: trace['range-ns']) self.assertRaises(KeyError, lambda: streams[0]['range-ns']) + def test_trace_with_tracefile_rotation(self): + res = bt2.QueryExecutor( + self._fs, + "babeltrace.trace-infos", + { + "inputs": [ + os.path.join( + test_ctf_traces_path, + "succeed", + "lttng-tracefile-rotation", + "kernel", + ) + ] + }, + ).query() + + self.assertEqual(len(res), 1) + trace = res[0] + streams = trace["stream-infos"] + self.assertEqual(len(streams), 4) + + # Note: the end timestamps are not the end timestamps found in the + # index files, because fix_index_lttng_event_after_packet_bug changes + # them based on the time of the last event in the stream. + + self.assertEqual(streams[0]['range-ns']['begin'], 1571261795455986789) + self.assertEqual(streams[0]['range-ns']['end'], 1571261797582611840) + + self.assertEqual(streams[1]['range-ns']['begin'], 1571261795456368232) + self.assertEqual(streams[1]['range-ns']['end'], 1571261797577754111) + + self.assertEqual(streams[2]['range-ns']['begin'], 1571261795456748255) + self.assertEqual(streams[2]['range-ns']['end'], 1571261797577727795) + + self.assertEqual(streams[3]['range-ns']['begin'], 1571261795457285142) + self.assertEqual(streams[3]['range-ns']['end'], 1571261797582522088) + class QueryTraceInfoPacketTimestampQuirksTestCase(unittest.TestCase): def setUp(self):