Skip to content

Commit

Permalink
Add make check and document testing procedure.
Browse files Browse the repository at this point in the history
Also support test target in cmake.
  • Loading branch information
ralight committed Sep 17, 2019
1 parent d413801 commit b3ba0a7
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 3 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
==============
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -36,6 +36,8 @@ reallyclean :
$(MAKE) -C test reallyclean
-rm -f *.orig

check : test

test : mosquitto
$(MAKE) -C test test

Expand Down
30 changes: 30 additions & 0 deletions readme-tests.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 3 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/broker/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/lib/Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion test/unit/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -56,6 +56,7 @@ PERSIST_WRITE_OBJS = \

all : test

check : test

mosq_test : ${TEST_OBJS} ${LIB_OBJS}
$(CROSS_COMPILE)$(CC) -o $@ $^ ${TEST_LDFLAGS}
Expand Down

0 comments on commit b3ba0a7

Please sign in to comment.