diff options
| -rw-r--r-- | CMakeLists.txt | 8 | ||||
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | test/CMakeLists.txt | 17 | ||||
| -rw-r--r-- | test/Makefile | 4 | ||||
| -rw-r--r-- | test/src/Makefile | 7 |
5 files changed, 36 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b696f5e..a13030d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 2.8.11) project(ecgen C) set(CMAKE_LIBRARY_PATH ${CMAKE_SOURCE_DIR}/lib) -SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -g -Wall -Werror -pedantic") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG -O3 -Wall") +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -g -Wall -Werror -pedantic") +set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG -O3 -Wall") include_directories(src) include_directories(lib) @@ -19,4 +19,6 @@ add_executable(ecgen ${ECGEN_SRC}) add_executable(econvert ${ECONVERT_SRC}) target_link_libraries(ecgen pthread rt pari ${parson} ${sha1}) -target_link_libraries(econvert pthread rt pari ${parson} ${sha1})
\ No newline at end of file +target_link_libraries(econvert pthread rt pari ${parson} ${sha1}) + +add_subdirectory(test)
\ No newline at end of file @@ -24,6 +24,9 @@ docs: test: all +$(MAKE) -C test test +unittest: all + +$(MAKE) -C test unittest + help: @echo "ecgen, tool for generating Elliptic curve domain parameters" @echo @@ -33,14 +36,15 @@ help: @echo " - econvert : build the format conversion binary" @echo " - docs : generate doxygen docs" @echo " - test : test the main binary" + @echo " - unittest : " @echo " - clean : cleans up after a build" @echo " - clean-all : cleans all" @echo " - format : run clang-format on source files" @echo " - help : print this help" -.PHONY: all clean clean-all docs test help +.PHONY: all clean clean-all docs test unittest help -ifeq (, $(filter all clean clean-all docs test help, $(MAKECMDGOALS))) +ifeq (, $(filter all clean clean-all docs test unittest help, $(MAKECMDGOALS))) # Just pass all targets to a Makefile in src $(MAKECMDGOALS): +$(MAKE) -C src $@ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..3def321 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 2.8.11) +project(test_ecgen C) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/criterion/include) + +message("${CMAKE_LIBRARY_PATH}") + +find_library(criterion NAMES criterion PATHS ${CMAKE_CURRENT_SOURCE_DIR}/lib/criterion/build) + +file(GLOB TEST_SRC "src/math/*.c" "src/gen/*.c" "src/cm/*.c" "src/invalid/*.c" "src/io/*.c" "src/exhaustive/*.c" "src/util/*.c") +add_executable(test_ecgen ${TEST_SRC} ${SRC}) + +target_link_libraries(test_ecgen pthread rt pari ${parson} ${sha1} ${criterion}) + +enable_testing() +add_test(NAME test_ecgen COMMAND test_ecgen)
\ No newline at end of file diff --git a/test/Makefile b/test/Makefile index abb836f..8c5fd8b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,7 +5,9 @@ # #### -test: unit ecgen econvert +test: ecgen econvert + +unittest: unit ecgen econvert unit: cd lib/criterion && mkdir -p build && cd build && cmake .. && cmake --build . diff --git a/test/src/Makefile b/test/src/Makefile index e22dcd3..e9d3d8e 100644 --- a/test/src/Makefile +++ b/test/src/Makefile @@ -9,17 +9,20 @@ CC ?= gcc CFLAGS = -Wall -g -O0 LDFLAGS = -L../../lib/parson -L../../lib/sha1 -L../../lib/pari -L../lib/criterion/build -INCLUDES = -I. -I../../lib -I../lib/criterion/include +INCLUDES = -I. -I../../src -I../../lib -I../lib/criterion/include LIBS = -lrt -lpari -lpthread -lparson -lsha1 -lcriterion TEST_SRC = $(wildcard *.c) $(wildcard */*.c) TEST_OBJ = $(patsubst %.c,%.o, $(TEST_SRC)) TESTS = $(patsubst %.c,%, $(TEST_SRC)) +ECGEN_SRC = $(wildcard ../../src/*/*.c) +ECGEN_OBJ = $(patsubst %.c,%.o, $(ECGEN_SRC)) + all: test_ecgen LD_LIBRARY_PATH=../lib/criterion/build ./test_ecgen -test_ecgen: $(TEST_OBJ) +test_ecgen: $(TEST_OBJ) $(ECGEN_OBJ) $(CC) $(CFLAGS) $(INCLUDES) -o $@ $^ $(LDFLAGS) $(LIBS) %.o: %.c |
