mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-02-06 02:52:07 +08:00
Fix cmake tests
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
add_subdirectory(db_dump)
|
||||
add_subdirectory(mosquitto_ctrl)
|
||||
add_subdirectory(mosquitto_passwd)
|
||||
|
||||
33
apps/db_dump/CMakeLists.txt
Normal file
33
apps/db_dump/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
add_executable(mosquitto_db_dump
|
||||
db_dump.c
|
||||
print.c
|
||||
stubs.c
|
||||
|
||||
../../lib/memory_mosq.c
|
||||
../../lib/packet_datatypes.c
|
||||
../../lib/property_mosq.c
|
||||
../../lib/utf8_mosq.c
|
||||
|
||||
../../src/memory_public.c
|
||||
../../src/persist_read.c
|
||||
../../src/persist_read_v234.c
|
||||
../../src/persist_read_v5.c
|
||||
../../src/topic_tok.c
|
||||
)
|
||||
|
||||
target_compile_definitions(mosquitto_db_dump PRIVATE
|
||||
WITH_BROKER
|
||||
WITH_PERSISTENCE
|
||||
)
|
||||
|
||||
target_include_directories(mosquitto_db_dump PRIVATE
|
||||
"${mosquitto_SOURCE_DIR}"
|
||||
"${mosquitto_SOURCE_DIR}/common"
|
||||
"${mosquitto_SOURCE_DIR}/include"
|
||||
"${mosquitto_SOURCE_DIR}/lib"
|
||||
"${mosquitto_SOURCE_DIR}/src"
|
||||
)
|
||||
|
||||
install(TARGETS mosquitto_db_dump
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
)
|
||||
@@ -1,3 +1,4 @@
|
||||
add_subdirectory(apps)
|
||||
add_subdirectory(broker)
|
||||
add_subdirectory(client)
|
||||
add_subdirectory(lib)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
file(GLOB PY_TEST_FILES [0-9][0-9]-*.py)
|
||||
file(GLOB PY_TEST_FILES ctrl-*.py)
|
||||
|
||||
set(EXCLUDE_LIST
|
||||
# none
|
||||
|
||||
@@ -26,18 +26,18 @@ do_test(["broker"], 1)
|
||||
do_test(["-A"], 1, response="Error: -A argument given but no address specified.\n\n")
|
||||
do_test(["-A", "127.0.0.1"], 1) # Gives generic help
|
||||
do_test(["--cafile"], 1, response="Error: --cafile argument given but no file specified.\n\n")
|
||||
do_test(["--cafile", mosq_test.get_build_root()+"/test/ssl/all-ca.crt"], 1) # Gives generic help
|
||||
do_test(["--cafile", ssl_dir / "all-ca.crt"], 1) # Gives generic help
|
||||
do_test(["--capath"], 1, response="Error: --capath argument given but no directory specified.\n\n")
|
||||
do_test(["--capath", mosq_test.get_build_root()+"/test/ssl"], 1) # Gives generic help
|
||||
do_test(["--capath", ssl_dir], 1) # Gives generic help
|
||||
do_test(["--cert"], 1, response="Error: --cert argument given but no file specified.\n\n")
|
||||
do_test(["--cert", mosq_test.get_build_root()+"/test/ssl/client.crt"], 1, response="Error: Both certfile and keyfile must be provided if one of them is set.\n")
|
||||
do_test(["--cert", ssl_dir / "client.crt"], 1, response="Error: Both certfile and keyfile must be provided if one of them is set.\n")
|
||||
do_test(["--key"], 1, response="Error: --key argument given but no file specified.\n\n")
|
||||
do_test(["--key", mosq_test.get_build_root()+"/test/ssl/client.key"], 1, response="Error: Both certfile and keyfile must be provided if one of them is set.\n")
|
||||
do_test(["--key", ssl_dir / "client.key"], 1, response="Error: Both certfile and keyfile must be provided if one of them is set.\n")
|
||||
do_test(["--ciphers"], 1, response="Error: --ciphers argument given but no ciphers specified.\n\n")
|
||||
do_test(["--ciphers", "DEFAULT"], 1) # Gives generic help
|
||||
do_test(["--debug"], 1) # Gives generic help
|
||||
do_test(["-f"], 1, response="Error: -f argument given but no data file specified.\n\n")
|
||||
do_test(["-f", mosq_test.get_build_root()+"/test/ssl/test"], 1) # Gives generic help
|
||||
do_test(["-f", ssl_dir / "test"], 1) # Gives generic help
|
||||
do_test(["--help"], 1) # Gives generic help
|
||||
do_test(["--host"], 1, response="Error: -h argument given but no host specified.\n\n")
|
||||
do_test(["--host", "127.0.0.1"], 1) # Gives generic help
|
||||
|
||||
@@ -14,8 +14,8 @@ def write_config(filename, ports):
|
||||
f.write("allow_anonymous false\n")
|
||||
f.write(f"listener {ports[0]}\n")
|
||||
f.write(f"listener {ports[1]}\n")
|
||||
f.write(f"certfile {mosq_test.get_build_root()}/test/ssl/server.crt\n")
|
||||
f.write(f"keyfile {mosq_test.get_build_root()}/test/ssl/server.key\n")
|
||||
f.write(f"certfile {ssl_dir}/server.crt\n")
|
||||
f.write(f"keyfile {ssl_dir}/server.key\n")
|
||||
|
||||
def ctrl_cmd(cmd, args, ports, response=None):
|
||||
opts = ["-u", "admin",
|
||||
@@ -30,7 +30,7 @@ def ctrl_cmd(cmd, args, ports, response=None):
|
||||
capture_output = False
|
||||
else:
|
||||
opts += ["-p", str(ports[1])]
|
||||
opts += ["--cafile", f"{mosq_test.get_build_root()}/test/ssl/all-ca.crt"]
|
||||
opts += ["--cafile", f"{ssl_dir}/all-ca.crt"]
|
||||
capture_output = True
|
||||
|
||||
proc = subprocess.run([mosq_test.get_build_root()+"/apps/mosquitto_ctrl/mosquitto_ctrl"]
|
||||
|
||||
@@ -11,8 +11,8 @@ def write_config(filename, ports):
|
||||
f.write("allow_anonymous false\n")
|
||||
f.write(f"listener {ports[0]}\n")
|
||||
f.write(f"listener {ports[1]}\n")
|
||||
f.write(f"certfile {mosq_test.get_build_root()}/test/ssl/server.crt\n")
|
||||
f.write(f"keyfile {mosq_test.get_build_root()}/test/ssl/server.key\n")
|
||||
f.write(f"certfile {ssl_dir}/server.crt\n")
|
||||
f.write(f"keyfile {ssl_dir}/server.key\n")
|
||||
|
||||
def ctrl_dynsec_cmd(args, ports, response=None, input=None):
|
||||
opts = ["-u", "admin",
|
||||
@@ -25,7 +25,7 @@ def ctrl_dynsec_cmd(args, ports, response=None, input=None):
|
||||
]
|
||||
else:
|
||||
opts += ["-p", str(ports[1])]
|
||||
opts += ["--cafile", f"{mosq_test.get_build_root()}/test/ssl/all-ca.crt"]
|
||||
opts += ["--cafile", f"{ssl_dir}/all-ca.crt"]
|
||||
|
||||
proc = subprocess.run([mosq_test.get_build_root()+"/apps/mosquitto_ctrl/mosquitto_ctrl"]
|
||||
+ opts + ["dynsec"] + args,
|
||||
|
||||
@@ -14,6 +14,8 @@ test_dir = current_source_dir.parents[1]
|
||||
if test_dir not in sys.path:
|
||||
sys.path.insert(0, str(test_dir))
|
||||
|
||||
ssl_dir = test_dir / "ssl"
|
||||
|
||||
import mosq_test
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
file(GLOB PY_TEST_FILES [0-9][0-9]-*.py)
|
||||
file(GLOB PY_TEST_FILES db-dump-*.py)
|
||||
|
||||
set(EXCLUDE_LIST
|
||||
# none
|
||||
|
||||
@@ -12,7 +12,7 @@ def do_test(file, counts):
|
||||
cmd = [
|
||||
mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
|
||||
'--client-stats',
|
||||
f'./{file}'
|
||||
f'{test_dir}/apps/db_dump/{file}'
|
||||
]
|
||||
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
|
||||
|
||||
@@ -6,7 +6,7 @@ def do_test(file, stderr, rc_expected):
|
||||
|
||||
cmd = [
|
||||
mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
|
||||
f'./{file}'
|
||||
f'{test_dir}/apps/db_dump/{file}'
|
||||
]
|
||||
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
|
||||
@@ -18,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 ./missing.test-db\n", 0)
|
||||
do_test('missing.test-db', f"Error: Unable to open {test_dir}/apps/db_dump/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)
|
||||
|
||||
@@ -6,7 +6,7 @@ def do_test(file, stdout):
|
||||
|
||||
cmd = [
|
||||
mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
|
||||
f'./{file}'
|
||||
f'{test_dir}/apps/db_dump/{file}'
|
||||
]
|
||||
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
|
||||
|
||||
@@ -6,11 +6,11 @@ def do_test(file, stdout):
|
||||
|
||||
cmd = [
|
||||
mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
|
||||
f'./{file}'
|
||||
f'{test_dir}/apps/db_dump/{file}'
|
||||
]
|
||||
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
|
||||
|
||||
|
||||
if res.stdout != stdout:
|
||||
read_lines = res.stdout.splitlines()
|
||||
expected_lines = stdout.splitlines()
|
||||
|
||||
@@ -6,7 +6,7 @@ def do_test(file, stdout):
|
||||
|
||||
cmd = [
|
||||
mosq_test.get_build_root() + '/apps/db_dump/mosquitto_db_dump',
|
||||
f'./{file}'
|
||||
f'{test_dir}/apps/db_dump/{file}'
|
||||
]
|
||||
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3, encoding='utf-8')
|
||||
|
||||
@@ -13,7 +13,7 @@ def do_test(file, counts):
|
||||
cmd = [
|
||||
mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump',
|
||||
'--stats',
|
||||
f'./{file}'
|
||||
f'{test_dir}/apps/db_dump/{file}'
|
||||
]
|
||||
|
||||
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')
|
||||
|
||||
@@ -13,6 +13,8 @@ test_dir = current_source_dir.parents[1]
|
||||
if test_dir not in sys.path:
|
||||
sys.path.insert(0, str(test_dir))
|
||||
|
||||
ssl_dir = test_dir / "ssl"
|
||||
|
||||
import mosq_test
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
file(GLOB PY_TEST_FILES [0-9][0-9]-*.py)
|
||||
file(GLOB PY_TEST_FILES passwd-*.py)
|
||||
|
||||
set(EXCLUDE_LIST
|
||||
# none
|
||||
|
||||
@@ -13,6 +13,8 @@ test_dir = current_source_dir.parents[1]
|
||||
if test_dir not in sys.path:
|
||||
sys.path.insert(0, str(test_dir))
|
||||
|
||||
ssl_dir = test_dir / "ssl"
|
||||
|
||||
import mosq_test
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
Reference in New Issue
Block a user