From c0b7f54ac110ed4e51fea65636e32a62ee33eebb Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sat, 4 Feb 2023 23:35:22 +0000 Subject: [PATCH] Fuzzing: db_dump file loading --- .gitignore | 5 ++ apps/db_dump/Makefile | 11 +++- apps/db_dump/db_dump.c | 4 ++ apps/mosquitto_passwd/Makefile | 11 +++- client/Makefile | 16 +++-- config.mk | 12 ++-- fuzzing/Makefile | 7 +- fuzzing/db_dump/Makefile | 20 ++++++ fuzzing/db_dump/db_dump_fuzz_load.cpp | 62 ++++++++++++++++++ src/Makefile | 4 ++ .../apps/db_dump/{ => data}/bad-chunk.test-db | Bin .../db_dump/{ => data}/bad-dbid-size.test-db | Bin .../apps/db_dump/{ => data}/bad-magic.test-db | 0 test/apps/db_dump/{ => data}/short.test-db | Bin .../db_dump/{ => data}/v3-corrupt.test-db | Bin test/apps/db_dump/{ => data}/v3-empty.test-db | Bin .../db_dump/{ => data}/v4-corrupt.test-db | Bin test/apps/db_dump/{ => data}/v4-empty.test-db | Bin .../{ => data}/v4-single-client.test-db | Bin .../db_dump/{ => data}/v4-single-cmsg.test-db | Bin .../{ => data}/v4-single-retain.test-db | Bin .../db_dump/{ => data}/v4-single-sub.test-db | Bin .../db_dump/{ => data}/v5-corrupt.test-db | Bin test/apps/db_dump/{ => data}/v5-empty.test-db | Bin .../{ => data}/v6-corrupt-client.test-db | Bin .../{ => data}/v6-corrupt-cmsg.test-db | Bin .../{ => data}/v6-corrupt-retain.test-db | Bin .../db_dump/{ => data}/v6-corrupt-sub.test-db | Bin .../db_dump/{ => data}/v6-corrupt.test-db | Bin test/apps/db_dump/{ => data}/v6-empty.test-db | Bin .../{ => data}/v6-mqtt-v5-props.test-db | Bin .../db_dump/{ => data}/v6-single-all.test-db | Bin .../{ => data}/v6-single-client.test-db | Bin .../db_dump/{ => data}/v6-single-cmsg.test-db | Bin .../{ => data}/v6-single-retain.test-db | Bin .../db_dump/{ => data}/v6-single-sub.test-db | Bin test/apps/db_dump/db-dump-client-stats.py | 2 +- test/apps/db_dump/db-dump-corrupt.py | 4 +- test/apps/db_dump/db-dump-print-empty.py | 2 +- test/apps/db_dump/db-dump-print-v6-all.py | 2 +- .../db_dump/db-dump-print-v6-mqtt-v5-props.py | 2 +- test/apps/db_dump/db-dump-stats.py | 2 +- 42 files changed, 144 insertions(+), 22 deletions(-) create mode 100644 fuzzing/db_dump/Makefile create mode 100644 fuzzing/db_dump/db_dump_fuzz_load.cpp rename test/apps/db_dump/{ => data}/bad-chunk.test-db (100%) rename test/apps/db_dump/{ => data}/bad-dbid-size.test-db (100%) rename test/apps/db_dump/{ => data}/bad-magic.test-db (100%) rename test/apps/db_dump/{ => data}/short.test-db (100%) rename test/apps/db_dump/{ => data}/v3-corrupt.test-db (100%) rename test/apps/db_dump/{ => data}/v3-empty.test-db (100%) rename test/apps/db_dump/{ => data}/v4-corrupt.test-db (100%) rename test/apps/db_dump/{ => data}/v4-empty.test-db (100%) rename test/apps/db_dump/{ => data}/v4-single-client.test-db (100%) rename test/apps/db_dump/{ => data}/v4-single-cmsg.test-db (100%) rename test/apps/db_dump/{ => data}/v4-single-retain.test-db (100%) rename test/apps/db_dump/{ => data}/v4-single-sub.test-db (100%) rename test/apps/db_dump/{ => data}/v5-corrupt.test-db (100%) rename test/apps/db_dump/{ => data}/v5-empty.test-db (100%) rename test/apps/db_dump/{ => data}/v6-corrupt-client.test-db (100%) rename test/apps/db_dump/{ => data}/v6-corrupt-cmsg.test-db (100%) rename test/apps/db_dump/{ => data}/v6-corrupt-retain.test-db (100%) rename test/apps/db_dump/{ => data}/v6-corrupt-sub.test-db (100%) rename test/apps/db_dump/{ => data}/v6-corrupt.test-db (100%) rename test/apps/db_dump/{ => data}/v6-empty.test-db (100%) rename test/apps/db_dump/{ => data}/v6-mqtt-v5-props.test-db (100%) rename test/apps/db_dump/{ => data}/v6-single-all.test-db (100%) rename test/apps/db_dump/{ => data}/v6-single-client.test-db (100%) rename test/apps/db_dump/{ => data}/v6-single-cmsg.test-db (100%) rename test/apps/db_dump/{ => data}/v6-single-retain.test-db (100%) rename test/apps/db_dump/{ => data}/v6-single-sub.test-db (100%) diff --git a/.gitignore b/.gitignore index b6808e3d..12c8f647 100644 --- a/.gitignore +++ b/.gitignore @@ -17,15 +17,20 @@ c/*.test cpp/*.test apps/db_dump/mosquitto_db_dump +apps/db_dump/mosquitto_db_dump.a apps/mosquitto_ctrl/mosquitto_ctrl apps/mosquitto_passwd/mosquitto_passwd +apps/mosquitto_passwd/mosquitto_passwd.a build/ build64/ client/mosquitto_pub +client/mosquitto_pub.a client/mosquitto_rr +client/mosquitto_rr.a client/mosquitto_sub +client/mosquitto_sub.a client/testing client/testing.c diff --git a/apps/db_dump/Makefile b/apps/db_dump/Makefile index 7b9bee0f..c38a990a 100644 --- a/apps/db_dump/Makefile +++ b/apps/db_dump/Makefile @@ -1,7 +1,7 @@ R=../.. include ${R}/config.mk -CFLAGS_FINAL=${CFLAGS} ${BROKER_CFLAGS} ${BROKER_CPPFLAGS} -I${R}/include -I${R}/ -I${R}/lib -I${R}/src -I${R}/deps -I${R}/common +CFLAGS_FINAL=${CFLAGS} ${CPPFLAGS} ${BROKER_CFLAGS} ${BROKER_CPPFLAGS} -I${R}/include -I${R}/ -I${R}/lib -I${R}/src -I${R}/deps -I${R}/common OBJS = \ db_dump.o \ @@ -21,11 +21,18 @@ BROKER_OBJS = \ .PHONY: all clean reallyclean +ifeq ($(WITH_FUZZING),yes) +all : mosquitto_db_dump.a +else all : mosquitto_db_dump +endif mosquitto_db_dump : ${OBJS} ${BROKER_OBJS} ${CROSS_COMPILE}${CC} $^ -o $@ ${LDFLAGS} ${LIBS} ${APP_LDFLAGS} +mosquitto_db_dump.a : ${OBJS} ${BROKER_OBJS} + ${CROSS_COMPILE}$(AR) cr $@ $^ + db_dump.o : db_dump.c db_dump.h ${R}/src/persist.h ${CROSS_COMPILE}${CC} $(CFLAGS_FINAL) -c $< -o $@ @@ -41,7 +48,7 @@ stubs.o : stubs.c reallyclean: clean clean : - -rm -f $(OBJS) $(BROKER_OBJS) mosquitto_db_dump *.gcda *.gcno + -rm -f $(OBJS) $(BROKER_OBJS) mosquitto_db_dump mosquitto_db_dump.a *.gcda *.gcno install: diff --git a/apps/db_dump/db_dump.c b/apps/db_dump/db_dump.c index 072b9ad9..946d143c 100644 --- a/apps/db_dump/db_dump.c +++ b/apps/db_dump/db_dump.c @@ -387,7 +387,11 @@ static void cleanup_msg_store() } +#ifdef WITH_FUZZING +int db_dump_fuzz_main(int argc, char *argv[]) +#else int main(int argc, char *argv[]) +#endif { FILE *fd; char header[15]; diff --git a/apps/mosquitto_passwd/Makefile b/apps/mosquitto_passwd/Makefile index 11b1150c..635eb11e 100644 --- a/apps/mosquitto_passwd/Makefile +++ b/apps/mosquitto_passwd/Makefile @@ -12,7 +12,11 @@ OBJS= mosquitto_passwd.o \ password_mosq.o ifeq ($(WITH_TLS),yes) -all: mosquitto_passwd +ifeq ($(WITH_FUZZING),yes) +all : mosquitto_passwd.a +else +all : mosquitto_passwd +endif else all: endif @@ -20,6 +24,9 @@ endif mosquitto_passwd : ${OBJS} ${CROSS_COMPILE}${CC} ${LDFLAGS} ${APP_LDFLAGS} $^ -o $@ $(PASSWD_LDADD) +mosquitto_passwd.a : ${OBJS} + ${CROSS_COMPILE}$(AR) cr $@ $^ + mosquitto_passwd.o : mosquitto_passwd.c ${CROSS_COMPILE}${CC} $(APP_CPPFLAGS) $(APP_CFLAGS) -c $< -o $@ @@ -51,7 +58,7 @@ uninstall : -rm -f "${DESTDIR}${prefix}/bin/mosquitto_passwd" clean : - -rm -f *.o mosquitto_passwd *.gcda *.gcno + -rm -f *.o *.a mosquitto_passwd *.gcda *.gcno reallyclean : clean -rm -rf *.orig *.db diff --git a/client/Makefile b/client/Makefile index 9f69d2c8..5099f4ed 100644 --- a/client/Makefile +++ b/client/Makefile @@ -3,6 +3,10 @@ include ${R}/config.mk .PHONY: all install uninstall reallyclean clean static static_pub static_sub static_rr +CLIENT_CFLAGS:=$(CLIENT_CFLAGS) $(CFLAGS) +CLIENT_CPPFLAGS:=$(CLIENT_CPPFLAGS) $(CPPFLAGS) +CLIENT_LDFLAGS:=$(CLIENT_LDFLAGS) $(LDFLAGS) + ifeq ($(WITH_SHARED_LIBRARIES),yes) SHARED_DEP:=${R}/lib/libmosquitto.so.${SOVERSION} endif @@ -22,22 +26,22 @@ static : static_pub static_sub static_rr # libmosquitto only. static_pub : pub_client.o pub_shared.o client_props.o client_shared.o ${R}/lib/libmosquitto.a - ${CROSS_COMPILE}${CC} $^ -o mosquitto_pub ${LDFLAGS} ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS} ${CLIENT_STATIC_LDADD} + ${CROSS_COMPILE}${CC} $^ -o mosquitto_pub ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS} ${CLIENT_STATIC_LDADD} static_sub : sub_client.o sub_client_output.o client_props.o client_shared.o ${R}/lib/libmosquitto.a - ${CROSS_COMPILE}${CC} $^ -o mosquitto_sub ${LDFLAGS} ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS} ${CLIENT_STATIC_LDADD} + ${CROSS_COMPILE}${CC} $^ -o mosquitto_sub ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS} ${CLIENT_STATIC_LDADD} static_rr : rr_client.o client_props.o client_shared.o pub_shared.o sub_client_output.o ${R}/lib/libmosquitto.a - ${CROSS_COMPILE}${CC} $^ -o mosquitto_rr ${LDFLAGS} ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS} ${CLIENT_STATIC_LDADD} + ${CROSS_COMPILE}${CC} $^ -o mosquitto_rr ${CLIENT_LDFLAGS} ${STATIC_LIB_DEPS} ${CLIENT_STATIC_LDADD} mosquitto_pub : pub_client.o pub_shared.o client_shared.o client_props.o - ${CROSS_COMPILE}${CC} ${LDFLAGS} $(CLIENT_LDFLAGS) $^ -o $@ $(CLIENT_LDADD) + ${CROSS_COMPILE}${CC} $(CLIENT_LDFLAGS) $^ -o $@ $(CLIENT_LDADD) mosquitto_sub : sub_client.o sub_client_output.o client_shared.o client_props.o - ${CROSS_COMPILE}${CC} ${LDFLAGS} $(CLIENT_LDFLAGS) $^ -o $@ $(CLIENT_LDADD) + ${CROSS_COMPILE}${CC} $(CLIENT_LDFLAGS) $^ -o $@ $(CLIENT_LDADD) mosquitto_rr : rr_client.o client_shared.o client_props.o pub_shared.o sub_client_output.o - ${CROSS_COMPILE}${CC} ${LDFLAGS} $(CLIENT_LDFLAGS) $^ -o $@ $(CLIENT_LDADD) + ${CROSS_COMPILE}${CC} $(CLIENT_LDFLAGS) $^ -o $@ $(CLIENT_LDADD) pub_client.o : pub_client.c ${SHARED_DEP} ${CROSS_COMPILE}${CC} $(CLIENT_CPPFLAGS) $(CLIENT_CFLAGS) -c $< -o $@ diff --git a/config.mk b/config.mk index 1ac885fb..bd1c2258 100644 --- a/config.mk +++ b/config.mk @@ -215,6 +215,11 @@ ifeq ($(UNAME),Linux) LIB_LIBADD:=$(LIB_LIBADD) -lrt endif +ifeq ($(WITH_FUZZING),yes) + WITH_SHARED_LIBRARIES:=no + WITH_STATIC_LIBRARIES:=yes +endif + ifeq ($(WITH_SHARED_LIBRARIES),yes) CLIENT_LDADD:=${CLIENT_LDADD} ${R}/lib/libmosquitto.so.${SOVERSION} endif @@ -430,10 +435,9 @@ endif ifeq ($(WITH_FUZZING),yes) MAKE_ALL:=$(MAKE_ALL) fuzzing - BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) -DWITH_FUZZING - BROKER_CFLAGS:=$(BROKER_CFLAGS) -fPIC - BROKER_LDFLAGS:=$(BROKER_LDFLAGS) -shared - LDFLAGS:=$(LDFLAGS) $(CFLAGS) + CPPFLAGS:=$(CPPFLAGS) -DWITH_FUZZING + CFLAGS:=$(CFLAGS) -fPIC + LDFLAGS:=$(LDFLAGS) -shared $(CFLAGS) endif BROKER_LDADD:=${BROKER_LDADD} ${LDADD} diff --git a/fuzzing/Makefile b/fuzzing/Makefile index 0bd8077d..1428e670 100644 --- a/fuzzing/Makefile +++ b/fuzzing/Makefile @@ -2,8 +2,13 @@ all: ./generate_packet_corpora.py + zip -r corpora/db_dump_seed_corpus.zip ../test/apps/db_dump/data/ $(MAKE) -C broker $@ + $(MAKE) -C db_dump $@ clean: - -rm -rf corpora/broker corpora/client corpora/broker_packet_seed_corpus.zip corpora/client_packet_seed_corpus.zip + -rm -rf corpora/broker corpora/client + -rm -f corpora/broker_packet_seed_corpus.zip corpora/client_packet_seed_corpus.zip + -rm -f corpora/db_dump_seed_corpus.zip $(MAKE) -C broker $@ + $(MAKE) -C db_dump $@ diff --git a/fuzzing/db_dump/Makefile b/fuzzing/db_dump/Makefile new file mode 100644 index 00000000..753f5a96 --- /dev/null +++ b/fuzzing/db_dump/Makefile @@ -0,0 +1,20 @@ +R=../.. +.PHONY: all clean + +FUZZERS:= \ + db_dump_fuzz_load + +LOCAL_CPPFLAGS:=$(CPPFLAGS) +LOCAL_CXXFLAGS:=$(CXXFLAGS) -g -Wall -Werror -pthread +LOCAL_LDFLAGS:=$(LDFLAGS) +LOCAL_LIBADD:=$(LIBADD) $(LIB_FUZZING_ENGINE) ${R}/apps/db_dump/mosquitto_db_dump.a + +all: $(FUZZERS) + +db_dump_fuzz_load : db_dump_fuzz_load.cpp + $(CXX) $(LOCAL_CXXFLAGS) $(LOCAL_CPPFLAGS) $(LOCAL_LDFLAGS) -o $@ $^ $(LOCAL_LIBADD) + install $@ ${OUT}/$@ + cp ${R}/fuzzing/corpora/db_dump_seed_corpus.zip ${OUT}/ + +clean: + rm -f *.o $(FUZZERS) diff --git a/fuzzing/db_dump/db_dump_fuzz_load.cpp b/fuzzing/db_dump/db_dump_fuzz_load.cpp new file mode 100644 index 00000000..dd62fc53 --- /dev/null +++ b/fuzzing/db_dump/db_dump_fuzz_load.cpp @@ -0,0 +1,62 @@ +/* +Copyright (c) 2023 Cedalo GmbH + +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License 2.0 +and Eclipse Distribution License v1.0 which accompany this distribution. + +The Eclipse Public License is available at + https://www.eclipse.org/legal/epl-2.0/ +and the Eclipse Distribution License is available at + http://www.eclipse.org/org/documents/edl-v10.php. + +SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + +Contributors: + Roger Light - initial implementation and documentation. +*/ + +#include +#include +#include +#include +#include + +/* + * Test loading a file + */ + + +/* The fuzz-only main function. */ +extern "C" int db_dump_fuzz_main(int argc, char *argv[]); + +void run_db_dump(char *filename) +{ + char *argv[2]; + int argc = 2; + + argv[0] = strdup("mosquitto_db_dump"); + argv[1] = filename; + + db_dump_fuzz_main(argc, argv); + + free(argv[0]); +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + char filename[100]; + FILE *fptr; + + snprintf(filename, sizeof(filename), "/tmp/db_dump_%d.db", getpid()); + fptr = fopen(filename, "wb"); + if(!fptr) return 1; + fwrite(data, 1, size, fptr); + fclose(fptr); + + run_db_dump(filename); + + unlink(filename); + + return 0; +} diff --git a/src/Makefile b/src/Makefile index 8f4776c4..62cedd13 100644 --- a/src/Makefile +++ b/src/Makefile @@ -3,6 +3,10 @@ include ${R}/config.mk .PHONY: all install uninstall clean reallyclean +BROKER_CFLAGS:=$(BROKER_CFLAGS) $(CFLAGS) +BROKER_CPPFLAGS:=$(BROKER_CPPFLAGS) $(CPPFLAGS) +BROKER_LDFLAGS:=$(BROKER_LDFLAGS) $(LDFLAGS) + ifeq ($(WITH_FUZZING),yes) all : mosquitto_broker.a else diff --git a/test/apps/db_dump/bad-chunk.test-db b/test/apps/db_dump/data/bad-chunk.test-db similarity index 100% rename from test/apps/db_dump/bad-chunk.test-db rename to test/apps/db_dump/data/bad-chunk.test-db diff --git a/test/apps/db_dump/bad-dbid-size.test-db b/test/apps/db_dump/data/bad-dbid-size.test-db similarity index 100% rename from test/apps/db_dump/bad-dbid-size.test-db rename to test/apps/db_dump/data/bad-dbid-size.test-db diff --git a/test/apps/db_dump/bad-magic.test-db b/test/apps/db_dump/data/bad-magic.test-db similarity index 100% rename from test/apps/db_dump/bad-magic.test-db rename to test/apps/db_dump/data/bad-magic.test-db diff --git a/test/apps/db_dump/short.test-db b/test/apps/db_dump/data/short.test-db similarity index 100% rename from test/apps/db_dump/short.test-db rename to test/apps/db_dump/data/short.test-db diff --git a/test/apps/db_dump/v3-corrupt.test-db b/test/apps/db_dump/data/v3-corrupt.test-db similarity index 100% rename from test/apps/db_dump/v3-corrupt.test-db rename to test/apps/db_dump/data/v3-corrupt.test-db diff --git a/test/apps/db_dump/v3-empty.test-db b/test/apps/db_dump/data/v3-empty.test-db similarity index 100% rename from test/apps/db_dump/v3-empty.test-db rename to test/apps/db_dump/data/v3-empty.test-db diff --git a/test/apps/db_dump/v4-corrupt.test-db b/test/apps/db_dump/data/v4-corrupt.test-db similarity index 100% rename from test/apps/db_dump/v4-corrupt.test-db rename to test/apps/db_dump/data/v4-corrupt.test-db diff --git a/test/apps/db_dump/v4-empty.test-db b/test/apps/db_dump/data/v4-empty.test-db similarity index 100% rename from test/apps/db_dump/v4-empty.test-db rename to test/apps/db_dump/data/v4-empty.test-db diff --git a/test/apps/db_dump/v4-single-client.test-db b/test/apps/db_dump/data/v4-single-client.test-db similarity index 100% rename from test/apps/db_dump/v4-single-client.test-db rename to test/apps/db_dump/data/v4-single-client.test-db diff --git a/test/apps/db_dump/v4-single-cmsg.test-db b/test/apps/db_dump/data/v4-single-cmsg.test-db similarity index 100% rename from test/apps/db_dump/v4-single-cmsg.test-db rename to test/apps/db_dump/data/v4-single-cmsg.test-db diff --git a/test/apps/db_dump/v4-single-retain.test-db b/test/apps/db_dump/data/v4-single-retain.test-db similarity index 100% rename from test/apps/db_dump/v4-single-retain.test-db rename to test/apps/db_dump/data/v4-single-retain.test-db diff --git a/test/apps/db_dump/v4-single-sub.test-db b/test/apps/db_dump/data/v4-single-sub.test-db similarity index 100% rename from test/apps/db_dump/v4-single-sub.test-db rename to test/apps/db_dump/data/v4-single-sub.test-db diff --git a/test/apps/db_dump/v5-corrupt.test-db b/test/apps/db_dump/data/v5-corrupt.test-db similarity index 100% rename from test/apps/db_dump/v5-corrupt.test-db rename to test/apps/db_dump/data/v5-corrupt.test-db diff --git a/test/apps/db_dump/v5-empty.test-db b/test/apps/db_dump/data/v5-empty.test-db similarity index 100% rename from test/apps/db_dump/v5-empty.test-db rename to test/apps/db_dump/data/v5-empty.test-db diff --git a/test/apps/db_dump/v6-corrupt-client.test-db b/test/apps/db_dump/data/v6-corrupt-client.test-db similarity index 100% rename from test/apps/db_dump/v6-corrupt-client.test-db rename to test/apps/db_dump/data/v6-corrupt-client.test-db diff --git a/test/apps/db_dump/v6-corrupt-cmsg.test-db b/test/apps/db_dump/data/v6-corrupt-cmsg.test-db similarity index 100% rename from test/apps/db_dump/v6-corrupt-cmsg.test-db rename to test/apps/db_dump/data/v6-corrupt-cmsg.test-db diff --git a/test/apps/db_dump/v6-corrupt-retain.test-db b/test/apps/db_dump/data/v6-corrupt-retain.test-db similarity index 100% rename from test/apps/db_dump/v6-corrupt-retain.test-db rename to test/apps/db_dump/data/v6-corrupt-retain.test-db diff --git a/test/apps/db_dump/v6-corrupt-sub.test-db b/test/apps/db_dump/data/v6-corrupt-sub.test-db similarity index 100% rename from test/apps/db_dump/v6-corrupt-sub.test-db rename to test/apps/db_dump/data/v6-corrupt-sub.test-db diff --git a/test/apps/db_dump/v6-corrupt.test-db b/test/apps/db_dump/data/v6-corrupt.test-db similarity index 100% rename from test/apps/db_dump/v6-corrupt.test-db rename to test/apps/db_dump/data/v6-corrupt.test-db diff --git a/test/apps/db_dump/v6-empty.test-db b/test/apps/db_dump/data/v6-empty.test-db similarity index 100% rename from test/apps/db_dump/v6-empty.test-db rename to test/apps/db_dump/data/v6-empty.test-db diff --git a/test/apps/db_dump/v6-mqtt-v5-props.test-db b/test/apps/db_dump/data/v6-mqtt-v5-props.test-db similarity index 100% rename from test/apps/db_dump/v6-mqtt-v5-props.test-db rename to test/apps/db_dump/data/v6-mqtt-v5-props.test-db diff --git a/test/apps/db_dump/v6-single-all.test-db b/test/apps/db_dump/data/v6-single-all.test-db similarity index 100% rename from test/apps/db_dump/v6-single-all.test-db rename to test/apps/db_dump/data/v6-single-all.test-db diff --git a/test/apps/db_dump/v6-single-client.test-db b/test/apps/db_dump/data/v6-single-client.test-db similarity index 100% rename from test/apps/db_dump/v6-single-client.test-db rename to test/apps/db_dump/data/v6-single-client.test-db diff --git a/test/apps/db_dump/v6-single-cmsg.test-db b/test/apps/db_dump/data/v6-single-cmsg.test-db similarity index 100% rename from test/apps/db_dump/v6-single-cmsg.test-db rename to test/apps/db_dump/data/v6-single-cmsg.test-db diff --git a/test/apps/db_dump/v6-single-retain.test-db b/test/apps/db_dump/data/v6-single-retain.test-db similarity index 100% rename from test/apps/db_dump/v6-single-retain.test-db rename to test/apps/db_dump/data/v6-single-retain.test-db diff --git a/test/apps/db_dump/v6-single-sub.test-db b/test/apps/db_dump/data/v6-single-sub.test-db similarity index 100% rename from test/apps/db_dump/v6-single-sub.test-db rename to test/apps/db_dump/data/v6-single-sub.test-db diff --git a/test/apps/db_dump/db-dump-client-stats.py b/test/apps/db_dump/db-dump-client-stats.py index 00d05ca2..a394a5c7 100755 --- a/test/apps/db_dump/db-dump-client-stats.py +++ b/test/apps/db_dump/db-dump-client-stats.py @@ -12,7 +12,7 @@ def do_test(file, counts): cmd = [ mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', '--client-stats', - f'{test_dir}/apps/db_dump/{file}' + f'{test_dir}/apps/db_dump/data/{file}' ] res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') diff --git a/test/apps/db_dump/db-dump-corrupt.py b/test/apps/db_dump/db-dump-corrupt.py index 3362d32a..a3c52406 100755 --- a/test/apps/db_dump/db-dump-corrupt.py +++ b/test/apps/db_dump/db-dump-corrupt.py @@ -6,7 +6,7 @@ def do_test(file, stderr, rc_expected): cmd = [ mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', - f'{test_dir}/apps/db_dump/{file}' + f'{test_dir}/apps/db_dump/data/{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', f"Error: Unable to open {test_dir}/apps/db_dump/missing.test-db\n", 0) +do_test('missing.test-db', f"Error: Unable to open {test_dir}/apps/db_dump/data/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) diff --git a/test/apps/db_dump/db-dump-print-empty.py b/test/apps/db_dump/db-dump-print-empty.py index 2c85bacc..1a1738e0 100755 --- a/test/apps/db_dump/db-dump-print-empty.py +++ b/test/apps/db_dump/db-dump-print-empty.py @@ -6,7 +6,7 @@ def do_test(file, stdout): cmd = [ mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', - f'{test_dir}/apps/db_dump/{file}' + f'{test_dir}/apps/db_dump/data/{file}' ] res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') diff --git a/test/apps/db_dump/db-dump-print-v6-all.py b/test/apps/db_dump/db-dump-print-v6-all.py index caf50b5c..fe2432e6 100755 --- a/test/apps/db_dump/db-dump-print-v6-all.py +++ b/test/apps/db_dump/db-dump-print-v6-all.py @@ -6,7 +6,7 @@ def do_test(file, stdout): cmd = [ mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', - f'{test_dir}/apps/db_dump/{file}' + f'{test_dir}/apps/db_dump/data/{file}' ] res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8') diff --git a/test/apps/db_dump/db-dump-print-v6-mqtt-v5-props.py b/test/apps/db_dump/db-dump-print-v6-mqtt-v5-props.py index e043db8f..bbfed8d0 100755 --- a/test/apps/db_dump/db-dump-print-v6-mqtt-v5-props.py +++ b/test/apps/db_dump/db-dump-print-v6-mqtt-v5-props.py @@ -6,7 +6,7 @@ def do_test(file, stdout): cmd = [ mosq_test.get_build_root() + '/apps/db_dump/mosquitto_db_dump', - f'{test_dir}/apps/db_dump/{file}' + f'{test_dir}/apps/db_dump/data/{file}' ] res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3, encoding='utf-8') diff --git a/test/apps/db_dump/db-dump-stats.py b/test/apps/db_dump/db-dump-stats.py index 72169848..3c632603 100755 --- a/test/apps/db_dump/db-dump-stats.py +++ b/test/apps/db_dump/db-dump-stats.py @@ -13,7 +13,7 @@ def do_test(file, counts): cmd = [ mosq_test.get_build_root()+'/apps/db_dump/mosquitto_db_dump', '--stats', - f'{test_dir}/apps/db_dump/{file}' + f'{test_dir}/apps/db_dump/data/{file}' ] res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=1, encoding='utf-8')