summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2023-12-15 09:53:19 +0100
committerAndrei Pavel <andrei@isc.org>2024-01-26 18:47:41 +0100
commitf6bf9f925bf76bc016163bf07a37f132b4be4a56 (patch)
treee240800701fcb3bf1261e1e6668658732d33ec39
parent[#3235] bump up library versions for 2.5.5 release (diff)
downloadkea-f6bf9f925bf76bc016163bf07a37f132b4be4a56.tar.xz
kea-f6bf9f925bf76bc016163bf07a37f132b4be4a56.zip
[#2788] make all commandLineArgs tests more strict
-rw-r--r--src/bin/agent/tests/ca_controller_unittests.cc8
-rw-r--r--src/bin/d2/tests/d2_controller_unittests.cc5
-rw-r--r--src/lib/process/tests/d_controller_unittests.cc9
3 files changed, 14 insertions, 8 deletions
diff --git a/src/bin/agent/tests/ca_controller_unittests.cc b/src/bin/agent/tests/ca_controller_unittests.cc
index f7b2c8bbe6..dc63e01a39 100644
--- a/src/bin/agent/tests/ca_controller_unittests.cc
+++ b/src/bin/agent/tests/ca_controller_unittests.cc
@@ -13,8 +13,12 @@
#include <cc/data.h>
#include <cc/command_interpreter.h>
#include <process/testutils/d_test_stubs.h>
+#include <testutils/gtest_utils.h>
+
#include <boost/pointer_cast.hpp>
+
#include <sstream>
+
#include <unistd.h>
using namespace isc::asiolink::test;
@@ -200,7 +204,7 @@ TEST_F(CtrlAgentControllerTest, commandLineArgs) {
EXPECT_TRUE(checkVerbose(false));
// Verify that standard options can be parsed without error.
- EXPECT_NO_THROW(parseArgs(argc, argv));
+ EXPECT_NO_THROW_LOG(parseArgs(argc, argv));
// Verify that verbose flag is true.
EXPECT_TRUE(checkVerbose(true));
@@ -212,7 +216,7 @@ TEST_F(CtrlAgentControllerTest, commandLineArgs) {
char* argv2[] = { const_cast<char*>("progName"),
const_cast<char*>("-x") };
argc = 2;
- EXPECT_THROW(parseArgs(argc, argv2), InvalidUsage);
+ EXPECT_THROW_MSG(parseArgs(argc, argv2), InvalidUsage, "unsupported option: [x] ");
}
// Tests application process creation and initialization.
diff --git a/src/bin/d2/tests/d2_controller_unittests.cc b/src/bin/d2/tests/d2_controller_unittests.cc
index 0c6e5ecf90..8bac486ba6 100644
--- a/src/bin/d2/tests/d2_controller_unittests.cc
+++ b/src/bin/d2/tests/d2_controller_unittests.cc
@@ -12,6 +12,7 @@
#include <d2/d2_controller.h>
#include <d2/d2_process.h>
#include <process/testutils/d_test_stubs.h>
+#include <testutils/gtest_utils.h>
#include <boost/pointer_cast.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
@@ -119,7 +120,7 @@ TEST_F(D2ControllerTest, commandLineArgs) {
EXPECT_TRUE(checkVerbose(false));
// Verify that standard options can be parsed without error.
- EXPECT_NO_THROW(parseArgs(argc, argv));
+ EXPECT_NO_THROW_LOG(parseArgs(argc, argv));
// Verify that verbose flag is true.
EXPECT_TRUE(checkVerbose(true));
@@ -131,7 +132,7 @@ TEST_F(D2ControllerTest, commandLineArgs) {
char* argv2[] = { const_cast<char*>("progName"),
const_cast<char*>("-x") };
argc = 2;
- EXPECT_THROW(parseArgs(argc, argv2), InvalidUsage);
+ EXPECT_THROW_MSG(parseArgs(argc, argv2), InvalidUsage, "unsupported option: [x] ");
}
/// @brief Tests application process creation and initialization.
diff --git a/src/lib/process/tests/d_controller_unittests.cc b/src/lib/process/tests/d_controller_unittests.cc
index 4d7b73c433..1063e162aa 100644
--- a/src/lib/process/tests/d_controller_unittests.cc
+++ b/src/lib/process/tests/d_controller_unittests.cc
@@ -10,6 +10,7 @@
#include <asiolink/testutils/timed_signal.h>
#include <cc/command_interpreter.h>
#include <process/testutils/d_test_stubs.h>
+#include <testutils/gtest_utils.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <gtest/gtest.h>
@@ -79,7 +80,7 @@ TEST_F(DStubControllerTest, commandLineArgs) {
const_cast<char*>("cfgName"),
const_cast<char*>("-d") };
int argc = 4;
- EXPECT_NO_THROW(parseArgs(argc, argv));
+ EXPECT_NO_THROW_LOG(parseArgs(argc, argv));
// Verify that verbose is true.
EXPECT_TRUE(checkVerbose(true));
@@ -92,20 +93,20 @@ TEST_F(DStubControllerTest, commandLineArgs) {
xopt[1] = *DStubController::stub_option_x_;
char* argv1[] = { const_cast<char*>("progName"), xopt};
argc = 2;
- EXPECT_NO_THROW (parseArgs(argc, argv1));
+ EXPECT_NO_THROW_LOG(parseArgs(argc, argv1));
// Verify that an unknown option is detected.
char* argv2[] = { const_cast<char*>("progName"),
const_cast<char*>("-bs") };
argc = 2;
- EXPECT_THROW (parseArgs(argc, argv2), InvalidUsage);
+ EXPECT_THROW_MSG(parseArgs(argc, argv2), InvalidUsage, "unsupported option: [b] ");
// Verify that extraneous information is detected.
char* argv3[] = { const_cast<char*>("progName"),
const_cast<char*>("extra"),
const_cast<char*>("information") };
argc = 3;
- EXPECT_THROW (parseArgs(argc, argv3), InvalidUsage);
+ EXPECT_THROW_MSG(parseArgs(argc, argv3), InvalidUsage, "unsupported option: [s] ");
}
/// @brief Tests application process creation and initialization.