Moved python tests inside test/apps to subfolder per app

Signed-off-by: Norbert Heusser <norbert.heusser@cedalo.com>
pull/2703/head
Norbert Heusser 3 years ago
parent e4c252b781
commit 8a07110cef

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

@ -1,19 +1,3 @@
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()
add_subdirectory(ctrl)
add_subdirectory(db_dump)
add_subdirectory(passwd)

@ -7,25 +7,17 @@ include ${R}/config.mk
all :
check : test
ptest : test
test : 01 02 03
01 :
./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
test :
$(MAKE) -C db_dump test
$(MAKE) -C ctrl test
$(MAKE) -C passwd test
02 :
./02-ctrl-args.py
./02-ctrl-broker.py
./02-ctrl-dynsec.py
ptest :
$(MAKE) -C db_dump ptest
$(MAKE) -C ctrl ptest
$(MAKE) -C passwd ptest
03 :
./03-passwd-args.py
./03-passwd-changes.py
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,9 +9,10 @@ def do_test(file, counts):
f"MS: {counts[3]} " + \
f" {counts[4]}\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',
'--client-stats',
f'db_dump/{file}'
f'./{file}'
]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')

@ -4,8 +4,9 @@ from mosq_test_helper import *
def do_test(file, stderr, rc_expected):
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
f'db_dump/{file}'
cmd = [
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')
@ -17,7 +18,7 @@ def do_test(file, stderr, rc_expected):
print(res.returncode)
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('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)

@ -4,8 +4,9 @@ from mosq_test_helper import *
def do_test(file, stdout):
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
f'db_dump/{file}'
cmd = [
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')

@ -4,13 +4,22 @@ from mosq_test_helper import *
def do_test(file, stdout):
cmd = [mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
f'db_dump/{file}'
cmd = [
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')
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
stdout = """Mosquitto DB dump

@ -4,8 +4,9 @@ from mosq_test_helper import *
def do_test(file, stdout):
cmd = [mosq_test.get_build_root() + '/apps/db_dump/mosquitto_db_dump',
f'db_dump/{file}'
cmd = [
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')

@ -20,7 +20,8 @@ def check_db(port, counts):
f"DB_CHUNK_SUB: {counts[4]}\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',
f'{port}/mosquitto.db'
]
@ -51,7 +52,8 @@ def do_test(counts):
}
# 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',
'-i', 'client-id',
'-p', str(port),
@ -62,7 +64,8 @@ def do_test(counts):
subprocess.run(cmd, timeout=1, env=env)
# 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),
'-q', '1',
'-t', 'sub-topic',

@ -10,9 +10,10 @@ def do_test(file, counts):
f"DB_CHUNK_SUB: {counts[4]}\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',
f'db_dump/{file}'
f'./{file}'
]
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')

@ -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)
Loading…
Cancel
Save