class Test(unittest.TestCase): def setUp(self): pass def tearDown(self): pass def test_cpu(self): assert 1 == 2 - 1 def test_case(self): Relative_map_info = reaily.TopicInfo(config.AllTopics())['/apollo/relative_map'] Exp_Relative_map_info = output['/apollo/relative_map'] assert Relative_map_info == Exp_Relative_map_info if __name__ == '__main__': # 检测被测对象,停掉对应模块,放对应导航线线 # if detect_Node.name == 'GUARDIAN': # os.system('bash /apollo/scripts/ultanalyse.sh stop') # os.system('bash /apollo/scripts/guardian.sh stop') reaily = Bag_Read_message(config.bagpath()) print(reaily) rosbag_play(config.bagpath(),config.AllTopics()[1:]) output = listener(config) suite = unittest.TestSuite() suite.addTest(Test('test_cpu')) suite.addTest(Test('test_case')) runner = unittest.TextTestRunner() runner.run(suite) # 测试完成后,重新启动所有模块 # os.system('bash /apollo/start_apollo_sys.sh')
#coding:utf-8 import sys sys.path.append('/apollo/data/autotest/apotest') from config.Case_Config import rosbag_play, listener from Command.tools.topic2dict import writetopic path_prefix = sys.argv[1] bagpath = sys.argv[2] output_topic = sys.argv[3] rosbag_play(bagpath, sys.argv[4:]) output = listener(bagpath, sys.argv[3:]) # 指定观察的话题 output_topic_info = output[output_topic] # 指定生成话题信息的文件 with open(path_prefix + 'real.txt', "w") as f: f.write(str(output_topic_info)) f.close() with open(path_prefix + 'output.txt', "w") as f: f.write(str(output)) f.close() # 指定读取bag包中的话题 writetopic(bag=bagpath, topic=output_topic, path=path_prefix)