mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-02-06 11:12:09 +08:00
include_dir test.
This commit is contained in:
52
test/broker/16-config-includedir.py
Executable file
52
test/broker/16-config-includedir.py
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Test whether include_dir works properly
|
||||
|
||||
from mosq_test_helper import *
|
||||
|
||||
def write_config(filename, port):
|
||||
with open(filename, 'w') as f:
|
||||
f.write(f"include_dir {port}\n")
|
||||
os.mkdir(str(port))
|
||||
with open(f"{port}/1.conf", 'w') as f:
|
||||
f.write(f"listener {port}\n")
|
||||
with open(f"{port}/2.conf", 'w') as f:
|
||||
f.write(f"allow_anonymous true\n")
|
||||
|
||||
|
||||
def do_test():
|
||||
port = mosq_test.get_port()
|
||||
|
||||
conf_file = os.path.basename(__file__).replace('.py', '.conf')
|
||||
write_config(conf_file, port)
|
||||
|
||||
broker = mosq_test.start_broker(filename=os.path.basename(__file__), use_conf=True, port=port)
|
||||
|
||||
try:
|
||||
rc = 1
|
||||
connect_packet = mosq_test.gen_connect("connect-include-dir")
|
||||
connack_packet = mosq_test.gen_connack(rc=0)
|
||||
|
||||
sock = mosq_test.do_client_connect(connect_packet, connack_packet, port=port)
|
||||
sock.close()
|
||||
rc = 0
|
||||
except mosq_test.TestError:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(e)
|
||||
finally:
|
||||
os.remove(conf_file)
|
||||
os.remove(f"{port}/1.conf")
|
||||
os.remove(f"{port}/2.conf")
|
||||
os.rmdir(f"{port}")
|
||||
broker.terminate()
|
||||
broker.wait()
|
||||
(stdo, stde) = broker.communicate()
|
||||
if rc:
|
||||
print(stde.decode('utf-8'))
|
||||
exit(rc)
|
||||
|
||||
|
||||
do_test()
|
||||
|
||||
exit(0)
|
||||
@@ -17,7 +17,7 @@ test-compile :
|
||||
ptest : test-compile msg_sequence_test
|
||||
./test.py
|
||||
|
||||
test : test-compile msg_sequence_test 01 02 03 04 05 06 07 08 09 10 11 12 13 14
|
||||
test : test-compile msg_sequence_test 01 02 03 04 05 06 07 08 09 10 11 12 13 14 16
|
||||
|
||||
msg_sequence_test:
|
||||
./msg_sequence_test.py
|
||||
@@ -256,4 +256,7 @@ endif
|
||||
./15-persist-subscription-v3-1-1.py
|
||||
./15-persist-retain-v3-1-1.py
|
||||
./15-persist-client-msg-in-v3-1-1.py
|
||||
./15-persist-client-msg-out-v3-1-1.py
|
||||
./15-persist-client-msg-out-v3-1-1.py
|
||||
|
||||
16 :
|
||||
./16-config-includedir.py
|
||||
|
||||
@@ -217,6 +217,8 @@ tests = [
|
||||
#(1, './15-persist-client-v3-1-1.py'),
|
||||
#(1, './15-persist-retain-v3-1-1.py'),
|
||||
#(1, './15-persist-subscription-v3-1-1.py'),
|
||||
|
||||
(1, './16-config-includedir.py'),
|
||||
]
|
||||
|
||||
ptest.run_tests(tests)
|
||||
|
||||
Reference in New Issue
Block a user