Merge pull request #2703 from NorbertHeusser/makefile-improvements

Makefile improvements
pull/2709/head
Roger Light 3 years ago committed by GitHub
commit ac5dfca52a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -81,11 +81,13 @@ reallyclean :
check : test check : test
test-compile: test-compile: mosquitto lib
$(MAKE) -C test test-compile $(MAKE) -C test test-compile
$(MAKE) -C plugins test-compile
test : mosquitto test : mosquitto lib apps
$(MAKE) -C test test $(MAKE) -C test test
$(MAKE) -C plugins test
ptest : mosquitto ptest : mosquitto
$(MAKE) -C test ptest $(MAKE) -C test ptest

@ -41,7 +41,7 @@ stubs.o : stubs.c
reallyclean: clean reallyclean: clean
clean : clean :
-rm -f *.o mosquitto_db_dump *.gcda *.gcno -rm -f $(OBJS) $(BROKER_OBJS) mosquitto_db_dump *.gcda *.gcno
install: install:

@ -101,7 +101,7 @@ uninstall :
reallyclean : clean reallyclean : clean
clean : clean :
-rm -f *.o libmosquitto.so.${SOVERSION} libmosquitto.so libmosquitto.a *.gcno *.gcda -rm -f ${MOSQ_OBJS} libmosquitto.so.${SOVERSION} libmosquitto.so libmosquitto.a *.gcno *.gcda
$(MAKE) -C cpp clean $(MAKE) -C cpp clean
libmosquitto.so.${SOVERSION} : ${MOSQ_OBJS} libmosquitto.so.${SOVERSION} : ${MOSQ_OBJS}

@ -3,7 +3,7 @@ DIRS= \
examples \ examples \
persist-sqlite persist-sqlite
.PHONY : all binary check clean reallyclean test install uninstall .PHONY : all binary check clean reallyclean test test-compile install uninstall
all : all :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d}; done set -e; for d in ${DIRS}; do $(MAKE) -C $${d}; done
@ -17,6 +17,9 @@ clean :
reallyclean : reallyclean :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
test-compile :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
check : test check : test
test : test :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done

@ -1,7 +1,7 @@
R=../.. R=../..
include ${R}/config.mk include ${R}/config.mk
.PHONY : all binary check clean reallyclean test install uninstall .PHONY : all binary check clean reallyclean test test-compile install uninstall
PLUGIN_NAME=mosquitto_dynamic_security PLUGIN_NAME=mosquitto_dynamic_security
LOCAL_CPPFLAGS=-I${R}/lib/ -I${R}/src/ -I${R}/plugins/common -DWITH_CJSON -DWITH_TLS LOCAL_CPPFLAGS=-I${R}/lib/ -I${R}/src/ -I${R}/plugins/common -DWITH_CJSON -DWITH_TLS
@ -115,8 +115,10 @@ reallyclean : clean
clean: clean:
-rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno
test-compile:
check: test check: test
test: test: test-compile
install: all install: all
ifeq ($(WITH_CJSON),yes) ifeq ($(WITH_CJSON),yes)

@ -16,7 +16,7 @@ DIRS= \
topic-modification \ topic-modification \
wildcard-temp wildcard-temp
.PHONY : all binary check clean reallyclean test install uninstall .PHONY : all binary check clean reallyclean test test-compile install uninstall
all : all :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d}; done set -e; for d in ${DIRS}; do $(MAKE) -C $${d}; done
@ -30,8 +30,10 @@ clean :
reallyclean : reallyclean :
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
test-compile:
check : test check : test
test : test: test-compile
set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done set -e; for d in ${DIRS}; do $(MAKE) -C $${d} $@; done
install : install :

@ -22,8 +22,8 @@ test:
install: ${PLUGIN_NAME}.so install: ${PLUGIN_NAME}.so
# Don't install, these are examples only. # Don't install, these are examples only.
$(INSTALL) -d "${DESTDIR}$(libdir)" #$(INSTALL) -d "${DESTDIR}$(libdir)"
$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" #$(INSTALL) ${STRIP_OPTS} ${PLUGIN_NAME}.so "${DESTDIR}${libdir}/${PLUGIN_NAME}.so"
uninstall : uninstall :
-rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so" -rm -f "${DESTDIR}${libdir}/${PLUGIN_NAME}.so"

@ -1,7 +1,7 @@
R=../.. R=../..
include ${R}/config.mk include ${R}/config.mk
.PHONY : all binary check clean reallyclean test install uninstall .PHONY : all binary check clean reallyclean test test-compile install uninstall
PLUGIN_NAME=mosquitto_persist_sqlite PLUGIN_NAME=mosquitto_persist_sqlite
LOCAL_CPPFLAGS=-I${R}/src/ LOCAL_CPPFLAGS=-I${R}/src/
@ -60,8 +60,10 @@ reallyclean : clean
clean: clean:
-rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno -rm -f *.o ${PLUGIN_NAME}.so *.gcda *.gcno
check: test test-compile:
test:
check : test
test: test-compile
install: all install: all
ifeq ($(WITH_SQLITE),yes) ifeq ($(WITH_SQLITE),yes)

@ -10,20 +10,21 @@ test-compile:
$(MAKE) -C client test-compile $(MAKE) -C client test-compile
$(MAKE) -C lib test-compile $(MAKE) -C lib test-compile
$(MAKE) -C unit test-compile $(MAKE) -C unit test-compile
$(MAKE) -C apps test-compile
check : test check : test
test : utest test : utest
$(MAKE) -C apps test
$(MAKE) -C broker test $(MAKE) -C broker test
$(MAKE) -C lib test $(MAKE) -C lib test
$(MAKE) -C client test $(MAKE) -C client test
$(MAKE) -C apps test
ptest : utest ptest : utest
$(MAKE) -C apps ptest
$(MAKE) -C broker ptest $(MAKE) -C broker ptest
$(MAKE) -C lib ptest $(MAKE) -C lib ptest
$(MAKE) -C client ptest $(MAKE) -C client ptest
$(MAKE) -C apps ptest
utest : utest :
$(MAKE) -C unit test $(MAKE) -C unit test
@ -32,4 +33,6 @@ reallyclean : clean
clean : clean :
$(MAKE) -C lib clean $(MAKE) -C lib clean
$(MAKE) -C broker clean $(MAKE) -C broker clean
$(MAKE) -C client clean
$(MAKE) -C unit clean $(MAKE) -C unit clean
$(MAKE) -C apps clean

@ -1,19 +1,3 @@
file(GLOB PY_TEST_FILES [0-9][0-9]-*.py) add_subdirectory(ctrl)
add_subdirectory(db_dump)
set(EXCLUDE_LIST add_subdirectory(passwd)
# none
)
foreach(PY_TEST_FILE ${PY_TEST_FILES})
get_filename_component(PY_TEST_NAME ${PY_TEST_FILE} NAME_WE)
if(${PY_TEST_NAME} IN_LIST EXCLUDE_LIST)
continue()
endif()
add_test(NAME apps-${PY_TEST_NAME}
COMMAND ${PY_TEST_FILE}
)
set_tests_properties(apps-${PY_TEST_NAME}
PROPERTIES
ENVIRONMENT "BUILD_ROOT=${CMAKE_BINARY_DIR}"
)
endforeach()

@ -7,25 +7,19 @@ include ${R}/config.mk
all : all :
check : test check : test
ptest : test
test : 01 02 03
01 : test-compile:
./01-db-dump-client-stats.py
./01-db-dump-corrupt.py
./01-db-dump-print-empty.py
./01-db-dump-print-v6-all.py
./01-db-dump-print-v6-mqtt-v5-props.py
./01-db-dump-stats-current.py
./01-db-dump-stats.py
02 : test :
./02-ctrl-args.py $(MAKE) -C db_dump test
./02-ctrl-broker.py $(MAKE) -C ctrl test
./02-ctrl-dynsec.py $(MAKE) -C passwd test
03 : ptest :
./03-passwd-args.py $(MAKE) -C db_dump ptest
./03-passwd-changes.py $(MAKE) -C ctrl ptest
$(MAKE) -C passwd ptest
clean: reallyclean : clean
clean :
$(MAKE) -C db_dump clean

@ -0,0 +1,19 @@
file(GLOB PY_TEST_FILES [0-9][0-9]-*.py)
set(EXCLUDE_LIST
# none
)
foreach(PY_TEST_FILE ${PY_TEST_FILES})
get_filename_component(PY_TEST_NAME ${PY_TEST_FILE} NAME_WE)
if(${PY_TEST_NAME} IN_LIST EXCLUDE_LIST)
continue()
endif()
add_test(NAME apps-${PY_TEST_NAME}
COMMAND ${PY_TEST_FILE}
)
set_tests_properties(apps-${PY_TEST_NAME}
PROPERTIES
ENVIRONMENT "BUILD_ROOT=${CMAKE_BINARY_DIR}"
)
endforeach()

@ -0,0 +1,19 @@
R=../../..
include ${R}/config.mk
.PHONY: all check test ptest clean
.NOTPARALLEL:
all :
check : test
test :
./ctrl-args.py
./ctrl-broker.py
./ctrl-dynsec.py
ptest:
./test.py
clean:

@ -0,0 +1,19 @@
import logging
import sys
from pathlib import Path
logging.basicConfig(
level=logging.INFO,
format="%(levelname)s %(asctime)s.%(msecs)03d %(module)s: %(message)s",
datefmt="%H:%M:%S",
)
current_source_dir = Path(__file__).resolve().parent
test_dir = current_source_dir.parents[1]
if test_dir not in sys.path:
sys.path.insert(0, str(test_dir))
import mosq_test
import subprocess
import os

@ -0,0 +1,13 @@
#!/usr/bin/env python3
import mosq_test_helper
import pathlib
import ptest
tests = [
(0, './ctrl-args.py'),
(2, './ctrl-broker.py'),
(2, './ctrl-dynsec.py')
]
ptest.run_tests(tests)

@ -0,0 +1,19 @@
file(GLOB PY_TEST_FILES [0-9][0-9]-*.py)
set(EXCLUDE_LIST
# none
)
foreach(PY_TEST_FILE ${PY_TEST_FILES})
get_filename_component(PY_TEST_NAME ${PY_TEST_FILE} NAME_WE)
if(${PY_TEST_NAME} IN_LIST EXCLUDE_LIST)
continue()
endif()
add_test(NAME apps-${PY_TEST_NAME}
COMMAND ${PY_TEST_FILE}
)
set_tests_properties(apps-${PY_TEST_NAME}
PROPERTIES
ENVIRONMENT "BUILD_ROOT=${CMAKE_BINARY_DIR}"
)
endforeach()

@ -0,0 +1,21 @@
.PHONY: all check test test-compile ptest clean
all :
check : test
test-compile:
test:
./db-dump-client-stats.py
./db-dump-corrupt.py
./db-dump-print-empty.py
./db-dump-print-v6-all.py
./db-dump-print-v6-mqtt-v5-props.py
./db-dump-stats.py
./db-dump-stats-current.py
ptest:
./test.py
clean :

@ -9,10 +9,11 @@ def do_test(file, counts):
f"MS: {counts[3]} " + \ f"MS: {counts[3]} " + \
f" {counts[4]}\n" f" {counts[4]}\n"
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', cmd = [
'--client-stats', mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
f'db_dump/{file}' '--client-stats',
] f'./{file}'
]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
if res.stdout != stdout: if res.stdout != stdout:

@ -4,9 +4,10 @@ from mosq_test_helper import *
def do_test(file, stderr, rc_expected): def do_test(file, stderr, rc_expected):
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', cmd = [
f'db_dump/{file}' mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
] f'./{file}'
]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
if res.stderr != stderr: if res.stderr != stderr:
@ -17,7 +18,7 @@ def do_test(file, stderr, rc_expected):
print(res.returncode) print(res.returncode)
raise mosq_test.TestError raise mosq_test.TestError
do_test('missing.test-db', "Error: Unable to open db_dump/missing.test-db\n", 0) do_test('missing.test-db', "Error: Unable to open ./missing.test-db\n", 0)
do_test('bad-magic.test-db', "Error: Unrecognised file format.\n", 1) do_test('bad-magic.test-db', "Error: Unrecognised file format.\n", 1)
do_test('short.test-db', "Error: Corrupt persistent database.\n", 1) do_test('short.test-db', "Error: Corrupt persistent database.\n", 1)
do_test('bad-dbid-size.test-db', "Error: Incompatible database configuration (dbid size is 5 bytes, expected 8)", 1) do_test('bad-dbid-size.test-db', "Error: Incompatible database configuration (dbid size is 5 bytes, expected 8)", 1)

@ -4,9 +4,10 @@ from mosq_test_helper import *
def do_test(file, stdout): def do_test(file, stdout):
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', cmd = [
f'db_dump/{file}' mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
] f'./{file}'
]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
if res.stdout != stdout: if res.stdout != stdout:

@ -4,13 +4,22 @@ from mosq_test_helper import *
def do_test(file, stdout): def do_test(file, stdout):
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', cmd = [
f'db_dump/{file}' mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
f'./{file}'
] ]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
if res.stdout != stdout: if res.stdout != stdout:
print(res.stdout) read_lines = res.stdout.splitlines()
expected_lines = stdout.splitlines()
for (read,expected) in zip(read_lines,expected_lines):
if read != expected:
print(f"- {expected}")
print(f"+ {read}")
else:
print(f" {read}")
raise mosq_test.TestError raise mosq_test.TestError
stdout = """Mosquitto DB dump stdout = """Mosquitto DB dump

@ -4,9 +4,10 @@ from mosq_test_helper import *
def do_test(file, stdout): def do_test(file, stdout):
cmd = [mosq_test.get_build_root() + '/apps/db_dump/mosquitto_db_dump', cmd = [
f'db_dump/{file}' mosq_test.get_build_root() + '/apps/db_dump/mosquitto_db_dump',
] f'./{file}'
]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3, encoding='utf-8') res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3, encoding='utf-8')
if res.stdout != stdout: if res.stdout != stdout:

@ -20,10 +20,11 @@ def check_db(port, counts):
f"DB_CHUNK_SUB: {counts[4]}\n" + \ f"DB_CHUNK_SUB: {counts[4]}\n" + \
f"DB_CHUNK_CLIENT: {counts[5]}\n" f"DB_CHUNK_CLIENT: {counts[5]}\n"
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', cmd = [
'--stats', mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
f'{port}/mosquitto.db' '--stats',
] f'{port}/mosquitto.db'
]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
if res.stdout != stdout: if res.stdout != stdout:
print(res.stdout) print(res.stdout)
@ -51,24 +52,26 @@ def do_test(counts):
} }
# Set up persistent client session, including a subscription # Set up persistent client session, including a subscription
cmd = [mosq_test.get_build_root()+'/client/mosquitto_sub', cmd = [
mosq_test.get_build_root()+'/client/mosquitto_sub',
'-c', '-c',
'-i', 'client-id', '-i', 'client-id',
'-p', str(port), '-p', str(port),
'-q', '1', '-q', '1',
'-t', 'sub-topic', '-t', 'sub-topic',
'-E' '-E'
] ]
subprocess.run(cmd, timeout=1, env=env) subprocess.run(cmd, timeout=1, env=env)
# Publish a retained message which is also queued for the subscriber # Publish a retained message which is also queued for the subscriber
cmd = [mosq_test.get_build_root()+'/client/mosquitto_pub', cmd = [
mosq_test.get_build_root()+'/client/mosquitto_pub',
'-p', str(port), '-p', str(port),
'-q', '1', '-q', '1',
'-t', 'sub-topic', '-t', 'sub-topic',
'-m', 'message', '-m', 'message',
'-r' '-r'
] ]
subprocess.run(cmd, timeout=1, env=env) subprocess.run(cmd, timeout=1, env=env)
broker.terminate() broker.terminate()

@ -10,10 +10,11 @@ def do_test(file, counts):
f"DB_CHUNK_SUB: {counts[4]}\n" + \ f"DB_CHUNK_SUB: {counts[4]}\n" + \
f"DB_CHUNK_CLIENT: {counts[5]}\n" f"DB_CHUNK_CLIENT: {counts[5]}\n"
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', cmd = [
mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
'--stats', '--stats',
f'db_dump/{file}' f'./{file}'
] ]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
if res.stdout != stdout: if res.stdout != stdout:

@ -0,0 +1,18 @@
import logging
import sys
from pathlib import Path
logging.basicConfig(
level=logging.INFO,
format="%(levelname)s %(asctime)s.%(msecs)03d %(module)s: %(message)s",
datefmt="%H:%M:%S",
)
current_source_dir = Path(__file__).resolve().parent
test_dir = current_source_dir.parents[1]
if test_dir not in sys.path:
sys.path.insert(0, str(test_dir))
import mosq_test
import subprocess
import os

@ -0,0 +1,12 @@
#!/usr/bin/env python3
import mosq_test_helper
import pathlib
import ptest
tests = []
for test_file in pathlib.Path('.').glob('db-dump-*.py'):
tests.append((1, test_file.resolve()))
ptest.run_tests(tests)

@ -0,0 +1,19 @@
file(GLOB PY_TEST_FILES [0-9][0-9]-*.py)
set(EXCLUDE_LIST
# none
)
foreach(PY_TEST_FILE ${PY_TEST_FILES})
get_filename_component(PY_TEST_NAME ${PY_TEST_FILE} NAME_WE)
if(${PY_TEST_NAME} IN_LIST EXCLUDE_LIST)
continue()
endif()
add_test(NAME apps-${PY_TEST_NAME}
COMMAND ${PY_TEST_FILE}
)
set_tests_properties(apps-${PY_TEST_NAME}
PROPERTIES
ENVIRONMENT "BUILD_ROOT=${CMAKE_BINARY_DIR}"
)
endforeach()

@ -0,0 +1,18 @@
R=../../..
include ${R}/config.mk
.PHONY: all check test ptest clean
.NOTPARALLEL:
all :
check : test
test :
./passwd-args.py
./passwd-changes.py
ptest :
./test.py
clean:

@ -0,0 +1,18 @@
import logging
import sys
from pathlib import Path
logging.basicConfig(
level=logging.INFO,
format="%(levelname)s %(asctime)s.%(msecs)03d %(module)s: %(message)s",
datefmt="%H:%M:%S",
)
current_source_dir = Path(__file__).resolve().parent
test_dir = current_source_dir.parents[1]
if test_dir not in sys.path:
sys.path.insert(0, str(test_dir))
import mosq_test
import subprocess
import os

@ -0,0 +1,12 @@
#!/usr/bin/env python3
import mosq_test_helper
import pathlib
import ptest
tests = []
for test_file in pathlib.Path('.').glob('passwd-*.py'):
tests.append((1, test_file.resolve()))
ptest.run_tests(tests)

@ -76,7 +76,7 @@ endif
ptest : ptest :
./test.sh ./test.sh
#./test-ws.sh ./test-ws.sh
./test.py ./test.py
clean: clean:

Loading…
Cancel
Save