24 #include "cheetah/pipeline/test/CheetahConfigTest.h" 25 #include "cheetah/pipeline/CheetahConfig.h" 27 #include "panda/test/TestFile.h" 35 CheetahConfigTest::CheetahConfigTest()
40 CheetahConfigTest::~CheetahConfigTest()
44 void CheetahConfigTest::SetUp()
48 void CheetahConfigTest::TearDown()
52 TEST_F(CheetahConfigTest, test_pipeline_handlers_unset)
54 pipeline::CheetahConfig<uint8_t> config;
55 ASSERT_EQ(
"", config.pipeline_name());
58 char cmd[] =
"cheetah_test";
59 char pipeline_option[] =
"--pipeline";
60 char option[]=
"test_a";
61 char* argv[3] = { cmd, pipeline_option, option };
62 ASSERT_EQ(0, config.parse(3, argv));
63 config.parse(3, argv);
67 TEST_F(CheetahConfigTest, test_pipeline_handlers_set)
69 pipeline::CheetahConfig<uint8_t> config;
70 std::vector<std::string> handlers( {
"test_a",
"test_b",
"test_c" } );
71 config.set_pipeline_handlers(handlers);
74 char cmd[] =
"cheetah_test";
75 char pipeline_option[] =
"--pipeline";
77 char* argv[3] = { cmd, pipeline_option, option };
78 for(
auto const& handler : handlers ) {
79 strcpy(option, handler.c_str());
80 ASSERT_EQ(0, config.parse(3, argv));
81 ASSERT_EQ(handler, config.pipeline_name());
85 TEST_F(CheetahConfigTest, test_parse_no_arguments)
87 char** argv =
nullptr;
88 pipeline::CheetahConfig<uint8_t> config;
89 ASSERT_NO_THROW(config.parse(0, argv));
91 ASSERT_NE(
"", config.version());
92 ASSERT_FALSE(config.time_handler_invocation());
93 ASSERT_EQ(
"", config.pipeline_name());
94 ASSERT_NE(
"", config.stream_name());
97 TEST_F(CheetahConfigTest, test_specify_non_existing_config_file)
99 char cmd[] =
"cheetah_test";
100 char config_option[] =
"--config";
101 char empty_config[10] =
"./rubbish";
102 char* argv[3] = { cmd, config_option, empty_config };
103 pipeline::CheetahConfig<uint8_t> config;
104 ASSERT_THROW(config.parse(3, argv), panda::Error);
107 TEST_F(CheetahConfigTest, test_specify_existing_config_file)
109 char cmd[] =
"cheetah_test";
110 char config_option[] =
"--config";
111 panda::test::TestFile config_file(
"%%%%-%%%%-%%%%-%%%%.xml");
113 char config_filename[32];
114 strcpy(config_filename, config_file.filename().c_str());
115 char* argv[3] = { cmd, config_option, config_filename };
116 pipeline::CheetahConfig<uint8_t> config;
117 std::vector<std::string> handlers( {
"test_a",
"test_b",
"test_c" } );
118 config.set_pipeline_handlers(handlers);
119 ASSERT_THROW(config.parse(3, argv), panda::Error);
122 config_file <<
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
123 config_file <<
"<cheetah>\n";
124 config_file <<
"<pipeline>" <<
"test_b" <<
"</pipeline>\n";
125 config_file <<
"</cheetah>\n";
127 ASSERT_EQ(
"", config.pipeline_name());
128 config.parse(3, argv);
129 ASSERT_EQ(
"test_b", config.pipeline_name());
132 char pipeline_option[] =
"--pipeline";
133 char option[]=
"test_a";
134 char* argv_2[5] = { cmd, pipeline_option, option, config_option, config_filename };
135 config.parse(3, argv_2);
136 ASSERT_EQ(
"test_a", config.pipeline_name());
Some limits and constants for FLDO.