From: Linux Karlsson Date: Tue, 27 Jul 2010 16:08:05 +0000 (+0200) Subject: Modified test code to accept multiple parameters. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce01839b3b94bbca820d089115cf44202cc81e41;p=thirdparty%2Fntp.git Modified test code to accept multiple parameters. bk: 4c4f0465hT-B3qCQ5YNeprd8ICx6OQ --- diff --git a/tests/main.cpp b/tests/main.cpp index 7409c9bb87..98395ccb52 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -3,18 +3,20 @@ int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - // Some tests makes use of an extra parameter passed to the tests - // executable. Save this param as a static member of the base class. + // Some tests makes use of extra parameters passed to the tests + // executable. Save these params as static members of the base class. if (argc > 1) { - ntptest::SetExtraParam(argv[1]); + ntptest::SetExtraParams(1, argc-1, argv); } return RUN_ALL_TESTS(); } -std::string ntptest::m_param = ""; +std::vector ntptest::m_params; -void ntptest::SetExtraParam(const char* param) +void ntptest::SetExtraParams(int start, int count, char** argv) { - m_param = param; + for (int i=0; i +#include class ntptest : public ::testing::Test { public: - static void SetExtraParam(const char* param); + static void SetExtraParams(int start, int count, char** argv); protected: - static std::string m_param; + static std::vector m_params; }; diff --git a/tests/sntp/Makefile.am b/tests/sntp/Makefile.am index a7eddc4d04..d823e44a4f 100644 --- a/tests/sntp/Makefile.am +++ b/tests/sntp/Makefile.am @@ -25,7 +25,7 @@ INCLUDES = $(LIBOPTS_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/inc TESTS = -TESTS_ENVIRONMENT = $(top_srcdir)/tests/sntp/test-driver $(abs_srcdir)/data +TESTS_ENVIRONMENT = $(top_srcdir)/tests/sntp/test-driver $(abs_srcdir)/data $(abs_builddir)/data if !NTP_CROSSCOMPILE TESTS += $(check_PROGRAMS) diff --git a/tests/sntp/kodFile.cpp b/tests/sntp/kodFile.cpp index dde4a2c98a..b3791158ca 100644 --- a/tests/sntp/kodFile.cpp +++ b/tests/sntp/kodFile.cpp @@ -16,8 +16,12 @@ extern char* kod_db_file; class kodFileTest : public sntptest { protected: - std::string CreatePath(const char* filename) { - std::string path = m_param; + std::string CreatePath(const char* filename, int argument) { + std::string path; + + if (m_params.size() >= argument + 1) { + path = m_params[argument]; + } if (path[path.size()-1] != DIR_SEP && !path.empty()) { path.append(1, DIR_SEP); @@ -45,13 +49,13 @@ protected: }; TEST_F(kodFileTest, ReadEmptyFile) { - kod_init_kod_db(CreatePath("kod-test-empty").c_str()); + kod_init_kod_db(CreatePath("kod-test-empty", 0).c_str()); EXPECT_EQ(0, kod_db_cnt); } TEST_F(kodFileTest, ReadCorrectFile) { - kod_init_kod_db(CreatePath("kod-test-correct").c_str()); + kod_init_kod_db(CreatePath("kod-test-correct", 0).c_str()); EXPECT_EQ(2, kod_db_cnt); @@ -69,7 +73,7 @@ TEST_F(kodFileTest, ReadCorrectFile) { } TEST_F(kodFileTest, ReadFileWithBlankLines) { - kod_init_kod_db(CreatePath("kod-test-blanks").c_str()); + kod_init_kod_db(CreatePath("kod-test-blanks", 0).c_str()); EXPECT_EQ(3, kod_db_cnt); diff --git a/tests/sntp/test-driver b/tests/sntp/test-driver index 44b0aeb72e..d6c5ced9af 100755 --- a/tests/sntp/test-driver +++ b/tests/sntp/test-driver @@ -1,3 +1,3 @@ #!/bin/sh -exec "$2" "$1" +exec "$3" "$1" "$2"