Skip to content

Commit

Permalink
clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anotra committed Mar 17, 2024
1 parent 811d9ea commit e671017
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
11 changes: 6 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
project(anotest)
add_executable(${PROJECT_NAME} main.c
locks-pthread.c
ordering.c
)
add_executable(${PROJECT_NAME} main.c)
target_link_libraries(${PROJECT_NAME} PRIVATE anomap)


if (WITH_LOCKS)
if (CMAKE_USE_PTHREADS_INIT)
target_sources(${PROJECT_NAME} PRIVATE locks-pthread.c)
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_LOCKS)
add_test(locks ${PROJECT_NAME} locks)
endif()

target_sources(${PROJECT_NAME} PRIVATE ordering.c)
add_test(ordering ${PROJECT_NAME} ordering)
30 changes: 17 additions & 13 deletions test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@
#include <stdio.h>
#include <string.h>

#define TEST_FUNC(name) \
int test_ ## name(void)


TEST_FUNC(locks);
TEST_FUNC(ordering);


#define TEST_FEATURE(name)\
do {\
if (0 == strcmp(#name, argv[1])) {\
return test_ ## name();\
}\
#define TEST_FEATURE(name) \
do { \
int test_ ## name(void); \
if (0 == strcmp(#name, argv[1])) \
return test_ ## name(); \
} while (0)

static int _run_test(int argc, char *argv[]);

int main(int argc, char *argv[]) {
if (argc != 2)
return 1;
return _run_test(argc, argv);
}

int
_run_test(int argc, char *argv[]) {

#ifdef WITH_LOCKS
TEST_FEATURE(locks);
#endif

TEST_FEATURE(ordering);

return -1;
}

0 comments on commit e671017

Please sign in to comment.