From e4a1f696ef6d2ca842d21ac72a3e2e049c4e171c Mon Sep 17 00:00:00 2001 From: dhood Date: Thu, 24 Mar 2016 15:01:03 -0700 Subject: [PATCH] Regression test for issue #736 --- test/test_rosbag/test/test_bag.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) mode change 100644 => 100755 test/test_rosbag/test/test_bag.py diff --git a/test/test_rosbag/test/test_bag.py b/test/test_rosbag/test/test_bag.py old mode 100644 new mode 100755 index 048f652331..4d8e0746d8 --- a/test/test_rosbag/test/test_bag.py +++ b/test/test_rosbag/test/test_bag.py @@ -33,10 +33,12 @@ # # test_bag.py +import hashlib import heapq import os import shutil import sys +import tempfile import time import unittest @@ -188,6 +190,34 @@ def test_rosbag_filter(self): self.assertEquals(len(msgs), 5) + def test_trivial_rosbag_filter(self): + # regression test for issue #736 + + tempdir = tempfile.mkdtemp() + try: + inbag_filename = os.path.join(tempdir, 'test_rosbag_filter__1.bag') + outbag1_filename = os.path.join(tempdir, 'test_rosbag_filter__2.bag') + outbag2_filename = os.path.join(tempdir, 'test_rosbag_filter__3.bag') + + with rosbag.Bag(inbag_filename, 'w') as b: + for i in range(30): + msg = ColorRGBA() + t = genpy.Time.from_sec(i) + b.write('/ints' + str(i), msg, t) + + # filtering multiple times should not affect the filtered rosbag + cmd = 'rosbag filter %s %s "True"' + os.system(cmd % (inbag_filename, outbag1_filename)) + os.system(cmd % (outbag1_filename, outbag2_filename)) + + with open(outbag1_filename, 'r') as h: + outbag1_md5 = hashlib.md5(h.read()).hexdigest() + with open(outbag2_filename, 'r') as h: + outbag2_md5 = hashlib.md5(h.read()).hexdigest() + self.assertEquals(outbag1_md5, outbag2_md5) + finally: + shutil.rmtree(tempdir) + def test_reindex_works(self): fn = '/tmp/test_reindex_works.bag'