Reorganize repository
* Move the project top-level CMakeLists.txt to the root of the project; this allows building Cyclone as part of ROS2 without any special tricks; * Clean up the build options: ENABLE_SSL: whether to check for and include OpenSSL support if a library can be found (default = ON); this used to be called DDSC_ENABLE_OPENSSL, the old name is deprecated but still works BUILD_DOCS: whether to build docs (default = OFF) BUILD_TESTING: whether to build test (default = OFF) * Collect all documentation into top-level "docs" directory; * Move the examples to the top-level directory; * Remove the unused and somewhat misleading pseudo-default cyclonedds.xml; * Remove unused cmake files Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
4e80559763
commit
9cf4b97f1a
102 changed files with 627 additions and 1925 deletions
96
cmake/Modules/CUnit/include/CUnit/Test.h
Normal file
96
cmake/Modules/CUnit/include/CUnit/Test.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
#ifndef CUNIT_TEST_H
|
||||
#define CUNIT_TEST_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <CUnit/CUnit.h>
|
||||
#include <CUnit/CUError.h>
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void(*cu_test_init_func_t)(void);
|
||||
typedef void(*cu_test_fini_func_t)(void);
|
||||
|
||||
typedef struct {
|
||||
cu_test_init_func_t init;
|
||||
cu_test_fini_func_t fini;
|
||||
int disabled; /* Parsed by CMake, used at test registration in main. */
|
||||
int timeout; /* Parsed by CMake, used at test registration in CMake. */
|
||||
} cu_data_t;
|
||||
|
||||
#define CU_InitName(suite) \
|
||||
CU_Init_ ## suite
|
||||
#define CU_CleanName(suite) \
|
||||
CU_Fini_ ## suite
|
||||
#define CU_TestName(suite, test) \
|
||||
CU_Test_ ## suite ## _ ## test
|
||||
#define CU_TestProxyName(suite, test) \
|
||||
CU_TestProxy_ ## suite ## _ ## test
|
||||
|
||||
#define CU_InitDecl(suite) \
|
||||
extern int CU_InitName(suite)(void)
|
||||
#define CU_Init(suite) \
|
||||
CU_InitDecl(suite); \
|
||||
int CU_InitName(suite)(void)
|
||||
|
||||
#define CU_CleanDecl(suite) \
|
||||
extern int CU_CleanName(suite)(void)
|
||||
#define CU_Clean(suite) \
|
||||
CU_CleanDecl(suite); \
|
||||
int CU_CleanName(suite)(void)
|
||||
|
||||
/* CU_Test generates a wrapper function that takes care of per-test
|
||||
initialization and deinitialization, if provided in the CU_Test
|
||||
signature. */
|
||||
#define CU_Test(suite, test, ...) \
|
||||
static void CU_TestName(suite, test)(void); \
|
||||
void CU_TestProxyName(suite, test)(void); \
|
||||
\
|
||||
void CU_TestProxyName(suite, test)(void) { \
|
||||
cu_data_t data = CU_Fixture(__VA_ARGS__); \
|
||||
\
|
||||
if (data.init != NULL) { \
|
||||
data.init(); \
|
||||
} \
|
||||
\
|
||||
CU_TestName(suite, test)(); \
|
||||
\
|
||||
if (data.fini != NULL) { \
|
||||
data.fini(); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void CU_TestName(suite, test)(void)
|
||||
|
||||
#define CU_TestDecl(suite, test) \
|
||||
extern void CU_TestProxyName(suite, test)(void)
|
||||
|
||||
/* Microsoft Visual Studio does not like empty struct initializers, i.e.
|
||||
no fixtures are specified. To work around that issue CU_Fixture inserts a
|
||||
NULL initializer as fall back. */
|
||||
#define CU_Comma() ,
|
||||
#define CU_Reduce(one, ...) one
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Microsoft Visual Studio does not expand __VA_ARGS__ correctly. */
|
||||
#define CU_Fixture__(...) CU_Fixture____((__VA_ARGS__))
|
||||
#define CU_Fixture____(tuple) CU_Fixture___ tuple
|
||||
#else
|
||||
#define CU_Fixture__(...) CU_Fixture___(__VA_ARGS__)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#define CU_Fixture___(throw, away, value, ...) value
|
||||
|
||||
#define CU_Fixture(...) \
|
||||
CU_Fixture_( CU_Comma CU_Reduce(__VA_ARGS__,) (), __VA_ARGS__ )
|
||||
|
||||
#define CU_Fixture_(throwaway, ...) \
|
||||
CU_Fixture__(throwaway, ((cu_data_t){ 0 }), ((cu_data_t){ __VA_ARGS__ }))
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CUNIT_TEST_H */
|
||||
|
73
cmake/Modules/CUnit/include/CUnit/Theory.h
Normal file
73
cmake/Modules/CUnit/include/CUnit/Theory.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
#ifndef CUNIT_THEORY_H
|
||||
#define CUNIT_THEORY_H
|
||||
|
||||
/* Function-style macros cannot be defined on the command line. */
|
||||
#ifdef CU_THEORY_INCLUDE_FILE
|
||||
#include CU_THEORY_INCLUDE_FILE
|
||||
#endif
|
||||
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CU_TheoryDataPointsName(suite, test) \
|
||||
CU_TheoryDataPoints_ ## suite ## _ ## test
|
||||
|
||||
#define CU_TheoryDataPointsTypeName(suite, test) \
|
||||
CU_TheoryDataPointsType_ ## suite ## _ ## test
|
||||
|
||||
#define CU_TheoryDataPointsSize(suite, test) \
|
||||
CU_TheoryDataPointsSize_ ## suite ## _ ## test ( \
|
||||
CU_TheoryDataPointsName(suite, test))
|
||||
|
||||
#define CU_TheoryDataPointsSlice(suite, test, index) \
|
||||
CU_TheoryDataPointsSlice_ ## suite ## _ ## test ( \
|
||||
CU_TheoryDataPointsName(suite, test), index)
|
||||
|
||||
#define CU_TheoryDataPointsTypedef(suite, test) \
|
||||
CU_TheoryDataPointsTypedef_ ## suite ## _ ## test()
|
||||
|
||||
#define CU_TheoryDataPoints(suite, test) \
|
||||
struct CU_TheoryDataPointsTypeName(suite, test) \
|
||||
CU_TheoryDataPointsTypedef(suite, test) ; \
|
||||
\
|
||||
static struct CU_TheoryDataPointsTypeName(suite, test) \
|
||||
CU_TheoryDataPointsName(suite, test)
|
||||
|
||||
#define CU_DataPoints(type, ...) { \
|
||||
.p = (type[]) { __VA_ARGS__ }, \
|
||||
.n = (sizeof((type[]) { __VA_ARGS__ }) / sizeof(type)) \
|
||||
}
|
||||
|
||||
#define CU_Theory(signature, suite, test, ...) \
|
||||
static void CU_TestName(suite, test) signature; \
|
||||
void CU_TestProxyName(suite, test)(void); \
|
||||
\
|
||||
void CU_TestProxyName(suite, test)(void) { \
|
||||
cu_data_t data = CU_Fixture(__VA_ARGS__); \
|
||||
size_t i, n; \
|
||||
\
|
||||
if (data.init != NULL) { \
|
||||
data.init(); \
|
||||
} \
|
||||
\
|
||||
for (i = 0, n = CU_TheoryDataPointsSize(suite, test); i < n; i++) { \
|
||||
CU_TestName(suite, test) CU_TheoryDataPointsSlice(suite, test, i) ; \
|
||||
} \
|
||||
\
|
||||
if (data.fini != NULL) { \
|
||||
data.fini(); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
static void CU_TestName(suite, test) signature
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CUNIT_THEORY_H */
|
||||
|
239
cmake/Modules/CUnit/src/main.c.in
Normal file
239
cmake/Modules/CUnit/src/main.c.in
Normal file
|
@ -0,0 +1,239 @@
|
|||
/*
|
||||
* Copyright(c) 2006 to 2018 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define EX_USAGE (64)
|
||||
#define EX_SOFTWARE (70)
|
||||
|
||||
#include <CUnit/Basic.h>
|
||||
#include <CUnit/Automated.h>
|
||||
#include "CUnit/Test.h"
|
||||
|
||||
static struct {
|
||||
bool print_help;
|
||||
bool automated;
|
||||
bool junit;
|
||||
const char *results;
|
||||
CU_BasicRunMode mode;
|
||||
CU_ErrorAction error_action;
|
||||
const char *suite;
|
||||
const char *test;
|
||||
} opts = {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NULL,
|
||||
CU_BRM_NORMAL,
|
||||
CUEA_IGNORE,
|
||||
"*",
|
||||
"*"
|
||||
};
|
||||
|
||||
static int patmatch(const char *pat, const char *str)
|
||||
{
|
||||
while (*pat) {
|
||||
if (*pat == '?') {
|
||||
/* any character will do */
|
||||
if (*str++ == 0) {
|
||||
return 0;
|
||||
}
|
||||
pat++;
|
||||
} else if (*pat == '*') {
|
||||
/* collapse a sequence of wildcards, requiring as many
|
||||
characters in str as there are ?s in the sequence */
|
||||
while (*pat == '*' || *pat == '?') {
|
||||
if (*pat == '?' && *str++ == 0) {
|
||||
return 0;
|
||||
}
|
||||
pat++;
|
||||
}
|
||||
/* try matching on all positions where str matches pat */
|
||||
while (*str) {
|
||||
if (*str == *pat && patmatch(pat+1, str+1)) {
|
||||
return 1;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
return *pat == 0;
|
||||
} else {
|
||||
/* only an exact match */
|
||||
if (*str++ != *pat++) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *str == 0;
|
||||
}
|
||||
|
||||
static void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s OPTIONS\n", name);
|
||||
fprintf(stderr, "Try '%s -h' for more information\n", name);
|
||||
}
|
||||
|
||||
static void help(const char *name)
|
||||
{
|
||||
printf("Usage: %s [OPTIONS]\n", name);
|
||||
printf("\n");
|
||||
printf("Possible options:\n");
|
||||
printf(" -a run in automated mode\n");
|
||||
printf(" -f fail fast\n");
|
||||
printf(" -h display this help and exit\n");
|
||||
printf(" -j junit format results \n");
|
||||
printf(" -r FILENAME results file for automated run\n");
|
||||
printf(" -s PATTERN run only tests in suites matching pattern\n");
|
||||
printf(" -t PATTERN run only test matching pattern\n");
|
||||
printf("\n");
|
||||
printf("Exit codes:\n");
|
||||
printf(" %-2d Successful termination\n", EXIT_SUCCESS);
|
||||
printf(" %-2d One or more failing test cases\n", EXIT_FAILURE);
|
||||
printf(" %-2d Command line usage error\n", EX_USAGE);
|
||||
printf(" %-2d Internal software error\n", EX_SOFTWARE);
|
||||
}
|
||||
|
||||
static int parse_options(int argc, char *argv[])
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
for (int i = 1; err == 0 && i < argc; i++) {
|
||||
switch ((argv[i][0] == '-') ? argv[i][1] : 0) {
|
||||
case 'a':
|
||||
opts.automated = true;
|
||||
break;
|
||||
case 'f':
|
||||
opts.error_action = CUEA_FAIL;
|
||||
break;
|
||||
case 'h':
|
||||
opts.print_help = true;
|
||||
break;
|
||||
case 'j':
|
||||
opts.junit = true;
|
||||
break;
|
||||
case 'r':
|
||||
if((i+1) < argc){
|
||||
opts.results = argv[++i];
|
||||
break;
|
||||
}
|
||||
/* FALLS THROUGH */
|
||||
case 's':
|
||||
if ((i+1) < argc) {
|
||||
opts.suite = argv[++i];
|
||||
break;
|
||||
}
|
||||
/* FALLS THROUGH */
|
||||
case 't':
|
||||
if ((i+1) < argc) {
|
||||
opts.test = argv[++i];
|
||||
break;
|
||||
}
|
||||
/* FALLS THROUGH */
|
||||
default:
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void
|
||||
add_suite(
|
||||
const char *suite,
|
||||
CU_InitializeFunc pInitFunc,
|
||||
CU_CleanupFunc pCleanFunc)
|
||||
{
|
||||
CU_pSuite pSuite;
|
||||
|
||||
pSuite = CU_get_suite(suite);
|
||||
if (pSuite == NULL) {
|
||||
pSuite = CU_add_suite(suite, pInitFunc, pCleanFunc);
|
||||
CU_set_suite_active(pSuite, patmatch(opts.suite, suite));
|
||||
}
|
||||
}
|
||||
|
||||
#define ADD_SUITE(suite, init, clean) \
|
||||
add_suite(#suite, init, clean)
|
||||
|
||||
static void
|
||||
add_test(
|
||||
const char *suite,
|
||||
const char *test,
|
||||
CU_TestFunc pTestFunc,
|
||||
bool enable)
|
||||
{
|
||||
CU_pSuite pSuite;
|
||||
CU_pTest pTest;
|
||||
|
||||
pSuite = CU_get_suite(suite);
|
||||
pTest = CU_add_test(pSuite, test, pTestFunc);
|
||||
CU_set_test_active(pTest, enable && patmatch(opts.test, test));
|
||||
}
|
||||
|
||||
#define ADD_TEST(suite, test, enable) \
|
||||
add_test(#suite, #test, CU_TestProxyName(suite, test), enable)
|
||||
|
||||
/* CMake will expand the macro below to declare generated functions. */
|
||||
@decls@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
if (parse_options(argc, argv) != 0) {
|
||||
usage(argv[0]);
|
||||
return EX_USAGE;
|
||||
} else if (opts.print_help) {
|
||||
help(argv[0]);
|
||||
return ret;
|
||||
} else if (CU_initialize_registry() != CUE_SUCCESS) {
|
||||
fprintf(stderr, "CU_initialize_registry: %s\n", CU_get_error_msg());
|
||||
return EX_SOFTWARE;
|
||||
}
|
||||
|
||||
/* CMake will expand the macro below to register all suites and tests. */
|
||||
@defns@
|
||||
|
||||
CU_set_error_action(opts.error_action);
|
||||
|
||||
if (opts.automated) {
|
||||
if (opts.results != NULL) {
|
||||
CU_set_output_filename(opts.results);
|
||||
}
|
||||
|
||||
#if defined(HAVE_ENABLE_JUNIT_XML)
|
||||
if (opts.junit) {
|
||||
CU_automated_enable_junit_xml(CU_TRUE);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
CU_list_tests_to_file();
|
||||
}
|
||||
CU_automated_run_tests();
|
||||
} else {
|
||||
CU_basic_set_mode(opts.mode);
|
||||
CU_basic_run_tests();
|
||||
}
|
||||
|
||||
if (CU_get_error() != CUE_SUCCESS) {
|
||||
ret = EX_SOFTWARE;
|
||||
} else if (CU_get_number_of_failures() != 0) {
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
CU_cleanup_registry();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue