From e9463c57b26cc0edb654e2844d8f55212335400b Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Sat, 4 Jul 2020 13:03:50 +0200 Subject: [PATCH] Add an executable wrapper for test_oneliner Signed-off-by: Erik Boasson --- src/core/ddsc/tests/CMakeLists.txt | 16 +++++++++++- src/core/ddsc/tests/oneliner.c | 25 +++++++++++++++++++ src/core/ddsc/tests/test_common.h | 5 ++-- src/core/ddsc/tests/test_oneliner.c | 6 ++++- .../ddsc/tests/{test_common.c => test_util.c} | 2 +- src/core/ddsc/tests/test_util.h | 21 ++++++++++++++++ 6 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 src/core/ddsc/tests/oneliner.c rename src/core/ddsc/tests/{test_common.c => test_util.c} (97%) create mode 100644 src/core/ddsc/tests/test_util.h diff --git a/src/core/ddsc/tests/CMakeLists.txt b/src/core/ddsc/tests/CMakeLists.txt index bde5eae..eb372bb 100644 --- a/src/core/ddsc/tests/CMakeLists.txt +++ b/src/core/ddsc/tests/CMakeLists.txt @@ -58,7 +58,8 @@ set(ddsc_test_sources "write.c" "write_various_types.c" "writer.c" - "test_common.c" + "test_util.c" + "test_util.h" "test_common.h" "test_oneliner.c" "test_oneliner.h") @@ -92,3 +93,16 @@ set_tests_properties( ENVIRONMENT "${CUnit_ddsc_config_simple_udp_env}") configure_file("config_env.h.in" "config_env.h" @ONLY) + +add_executable(oneliner + "oneliner.c" + "test_oneliner.c" + "test_oneliner.h" + "test_util.c" + "test_util.h") +target_include_directories( + oneliner PRIVATE + "$" + "$" + "$") +target_link_libraries(oneliner PRIVATE RoundTrip Space ddsc) diff --git a/src/core/ddsc/tests/oneliner.c b/src/core/ddsc/tests/oneliner.c new file mode 100644 index 0000000..d6e32a9 --- /dev/null +++ b/src/core/ddsc/tests/oneliner.c @@ -0,0 +1,25 @@ +/* + * Copyright(c) 2020 ADLINK Technology Limited and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License + * v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +#include +#include + +#include "test_oneliner.h" + +int main (int argc, char **argv) +{ + for (int i = 1; i < argc; i++) + { + if (test_oneliner (argv[i]) <= 0) + return 1; + } + return 0; +} diff --git a/src/core/ddsc/tests/test_common.h b/src/core/ddsc/tests/test_common.h index 6672d93..824263d 100644 --- a/src/core/ddsc/tests/test_common.h +++ b/src/core/ddsc/tests/test_common.h @@ -18,10 +18,9 @@ #include "CUnit/Test.h" #include "CUnit/Theory.h" +#include "test_util.h" + #include "Space.h" #include "RoundTrip.h" -/* Get unique g_topic name on each invocation. */ -char *create_unique_topic_name (const char *prefix, char *name, size_t size); - #endif /* _TEST_COMMON_H_ */ diff --git a/src/core/ddsc/tests/test_oneliner.c b/src/core/ddsc/tests/test_oneliner.c index 83684b5..8c19b65 100644 --- a/src/core/ddsc/tests/test_oneliner.c +++ b/src/core/ddsc/tests/test_oneliner.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "dds/dds.h" @@ -31,9 +32,12 @@ #include "dds/ddsi/q_xevent.h" #include "dds/ddsi/ddsi_entity_index.h" -#include "test_common.h" +#include "test_util.h" #include "test_oneliner.h" +#include "Space.h" +#include "RoundTrip.h" + #define MAXDOMS (sizeof (((struct oneliner_ctx){.result=0}).doms) / sizeof (((struct oneliner_ctx){.result=0}).doms[0])) static const char knownentities[] = "PRWrstwxy"; diff --git a/src/core/ddsc/tests/test_common.c b/src/core/ddsc/tests/test_util.c similarity index 97% rename from src/core/ddsc/tests/test_common.c rename to src/core/ddsc/tests/test_util.c index 531322b..7a5f5c0 100644 --- a/src/core/ddsc/tests/test_common.c +++ b/src/core/ddsc/tests/test_util.c @@ -13,7 +13,7 @@ #include "dds/ddsrt/atomics.h" #include "dds/ddsrt/process.h" #include "dds/ddsrt/threads.h" -#include "test_common.h" +#include "test_util.h" char *create_unique_topic_name (const char *prefix, char *name, size_t size) { diff --git a/src/core/ddsc/tests/test_util.h b/src/core/ddsc/tests/test_util.h new file mode 100644 index 0000000..639a72a --- /dev/null +++ b/src/core/ddsc/tests/test_util.h @@ -0,0 +1,21 @@ +/* + * Copyright(c) 2020 ADLINK Technology Limited and others + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License + * v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ +#ifndef _TEST_UTIL_H_ +#define _TEST_UTIL_H_ + +#include +#include + +/* Get unique g_topic name on each invocation. */ +char *create_unique_topic_name (const char *prefix, char *name, size_t size); + +#endif /* _TEST_UTIL_H_ */