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<std::string> 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<count; i++) {
+ m_params.push_back(argv[i+start]);
+ }
}
#include "config.h"
#include <string>
+#include <vector>
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<std::string> m_params;
};
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)
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);
};
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);
}
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);
#!/bin/sh
-exec "$2" "$1"
+exec "$3" "$1" "$2"