2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 21:45:37 +00:00

[#2788] make all commandLineArgs tests more strict

This commit is contained in:
Andrei Pavel
2023-12-15 10:53:19 +02:00
parent a264e33224
commit f6bf9f925b
3 changed files with 14 additions and 8 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.