From 7f3986e787da234ebd241585f5671c3142d3cef1 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sun, 31 Mar 2019 19:58:29 +0200 Subject: [PATCH] rename villas-config-check to villas-test-config --- src/CMakeLists.txt | 4 +- ...onfig-check.cpp => villas-test-config.cpp} | 43 +++++++++++++++---- .../{config-check.sh => test-config.sh} | 2 +- 3 files changed, 38 insertions(+), 11 deletions(-) rename src/{villas-config-check.cpp => villas-test-config.cpp} (68%) rename tests/integration/{config-check.sh => test-config.sh} (97%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 12ed8b465..5d9431de7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,8 +23,8 @@ add_executable(villas-node villas-node.cpp) target_link_libraries(villas-node PUBLIC villas) -add_executable(villas-config-check villas-config-check.cpp) -target_link_libraries(villas-config-check PUBLIC villas) +add_executable(villas-test-config villas-test-config.cpp) +target_link_libraries(villas-test-config PUBLIC villas) add_executable(villas-test-rtt villas-test-rtt.cpp) target_link_libraries(villas-test-rtt PUBLIC villas) diff --git a/src/villas-config-check.cpp b/src/villas-test-config.cpp similarity index 68% rename from src/villas-config-check.cpp rename to src/villas-test-config.cpp index 2ec1bbe7e..ce6daf886 100644 --- a/src/villas-config-check.cpp +++ b/src/villas-test-config.cpp @@ -35,12 +35,14 @@ using namespace villas::node; static void usage() { - std::cout << "Usage: villas-config-check CONFIG" << std::endl - << " CONFIG is the path to an optional configuration file" << std::endl << std::endl; + std::cout << "Usage: villas-test-config [OPTIONS] CONFIG" << std::endl + << " CONFIG is the path to an optional configuration file" << std::endl + << " OPTIONS is one or more of the following options:" << std::endl + << " -d LVL set debug level" << std::endl + << " -V show version and exit" << std::endl + << " -h show usage and exit" << std::endl << std::endl; print_copyright(); - - exit(EXIT_FAILURE); } int main(int argc, char *argv[]) @@ -48,11 +50,36 @@ int main(int argc, char *argv[]) SuperNode sn; Logger logger = logging.get("config-test"); - try { - if (argc != 2) - usage(); + bool check = false; - sn.parse(argv[1]); + int c; + while ((c = getopt (argc, argv, "hcV")) != -1) { + switch (c) { + case 'c': + check = true; + break; + + case 'V': + print_version(); + exit(EXIT_SUCCESS); + + case 'h': + case '?': + usage(); + exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS); + } + } + + if (argc - optind < 2) { + usage(); + exit(EXIT_FAILURE); + } + + try { + sn.parse(argv[argc - optind]); + + if (check) + sn.check(); return 0; } diff --git a/tests/integration/config-check.sh b/tests/integration/test-config.sh similarity index 97% rename from tests/integration/config-check.sh rename to tests/integration/test-config.sh index 27301144b..9604771d3 100755 --- a/tests/integration/config-check.sh +++ b/tests/integration/test-config.sh @@ -38,5 +38,5 @@ for CONFIG in ${CONFIGS}; do fi echo "=== Testing config: ${CONFIG}" - villas-config-check ${CONFIG} + villas-test-config ${CONFIG} done