diff --git a/CMakeLists.txt b/CMakeLists.txt index 183100a0..9135ec8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,4 +138,5 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libmosquittopp.pc" DESTINATION "${PKG # ======================================== # Testing # ======================================== -add_custom_target(Tests COMMAND make -C ${mosquitto_SOURCE_DIR}/test test) +enable_testing() +add_test("test" make -C ${mosquitto_SOURCE_DIR}/test test) diff --git a/ChangeLog.txt b/ChangeLog.txt index 2ddcb2b1..f9713364 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,9 @@ Broker: Clients: - Fix compilation on non glibc systems due to missing sys/time.h header. +Build: +- Add `make check` target and document testing procedure. Closes #1230. + 1.6 - 20190417 ============== diff --git a/Makefile b/Makefile index ab67ae0b..8e7e4bce 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ DIRS=lib client src DOCDIRS=man DISTDIRS=man -.PHONY : all mosquitto api docs binary clean reallyclean test install uninstall dist sign copy +.PHONY : all mosquitto api docs binary check clean reallyclean test install uninstall dist sign copy all : $(MAKE_ALL) @@ -36,6 +36,8 @@ reallyclean : $(MAKE) -C test reallyclean -rm -f *.orig +check : test + test : mosquitto $(MAKE) -C test test diff --git a/readme-tests.md b/readme-tests.md new file mode 100644 index 00000000..e2947579 --- /dev/null +++ b/readme-tests.md @@ -0,0 +1,30 @@ +# Tests + +## Running + +The Mosquitto test suite can be invoked using either of + +``` +make test +make check +``` + +The tests run in series and due to the nature of some of the tests being made +can take a while. + +## Parallel Tests + +To run the tests with some parallelism, use + +``` +make ptest +``` + +This runs up to 20 tests in parallel at once, yielding much faster overall run +time at the expense of having up to 20 instances of Python running at once. +This is not a particularly CPU intensive option, but does require more memory +and may be unsuitable on e.g. a Raspberry Pi. + +## Dependencies + +The tests require Python 3 and CUnit to be installed. diff --git a/test/Makefile b/test/Makefile index 571ea3e4..119d61e1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,9 +1,11 @@ include ../config.mk -.PHONY: all test ptest clean +.PHONY: all check test ptest clean all : +check : test + test : utest $(MAKE) -C broker test $(MAKE) -C lib test diff --git a/test/broker/Makefile b/test/broker/Makefile index e5b3fbd4..eace92da 100644 --- a/test/broker/Makefile +++ b/test/broker/Makefile @@ -1,10 +1,12 @@ include ../../config.mk -.PHONY: all clean test ptest +.PHONY: all check clean test ptest .NOTPARALLEL: all : +check : test + clean : -rm -f *.vglog *.db $(MAKE) -C c clean diff --git a/test/lib/Makefile b/test/lib/Makefile index b2bfa9a8..180e660d 100644 --- a/test/lib/Makefile +++ b/test/lib/Makefile @@ -1,12 +1,14 @@ include ../../config.mk -.PHONY: all test test-compile test-compile-c test-compile-cpp c cpp +.PHONY: all check test test-compile test-compile-c test-compile-cpp c cpp .NOTPARALLEL: LD_LIBRARY_PATH=../../lib all : +check : test + ptest : test-compile ./test.py diff --git a/test/unit/Makefile b/test/unit/Makefile index db25ccba..c0758fa7 100644 --- a/test/unit/Makefile +++ b/test/unit/Makefile @@ -1,6 +1,6 @@ include ../../config.mk -.PHONY: all test test-broker test-lib clean coverage +.PHONY: all check test test-broker test-lib clean coverage CFLAGS=-I../.. -I../../lib -I../../src -I../../src/deps -coverage -Wall -ggdb TEST_LDFLAGS=-lcunit -coverage @@ -56,6 +56,7 @@ PERSIST_WRITE_OBJS = \ all : test +check : test mosq_test : ${TEST_OBJS} ${LIB_OBJS} $(CROSS_COMPILE)$(CC) -o $@ $^ ${TEST_LDFLAGS}