mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-23 00:24:47 +08:00
Test fixes.
This commit is contained in:
@@ -4,12 +4,17 @@
|
||||
|
||||
from mosq_test_helper import *
|
||||
|
||||
def do_test(proto_ver):
|
||||
def do_test(proto_ver, ipver):
|
||||
rc = 1
|
||||
|
||||
(port1, port2) = mosq_test.get_port(2)
|
||||
|
||||
cmd = ['microsocks', '-1', '-b', '-i', '127.0.0.1', '-u', 'user', '-P', 'password', '-p', str(port1)]
|
||||
if ipver == 4:
|
||||
host = "localhost"
|
||||
else:
|
||||
host = "ip6-localhost"
|
||||
|
||||
cmd = ['microsocks', '-1', '-b', '-i', host, '-u', 'user', '-P', 'password', '-p', str(port1)]
|
||||
try:
|
||||
proxy = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
except FileNotFoundError:
|
||||
@@ -28,15 +33,14 @@ def do_test(proto_ver):
|
||||
'XDG_CONFIG_HOME':'/tmp/missing'
|
||||
}
|
||||
cmd = [
|
||||
'/snap/bin/valgrind', '--log-file=vglog',
|
||||
'../../client/mosquitto_pub',
|
||||
'-h', '127.0.0.1',
|
||||
'-h', host,
|
||||
'-p', str(port2),
|
||||
'-q', '1',
|
||||
'-t', '03/pub/proxy/test',
|
||||
'-m', 'message',
|
||||
'-V', V,
|
||||
'--proxy', f'socks5h://user:password@localhost:{port1}'
|
||||
'--proxy', f'socks5h://user:password@{host}:{port1}'
|
||||
]
|
||||
|
||||
mid = 1
|
||||
@@ -46,7 +50,7 @@ def do_test(proto_ver):
|
||||
else:
|
||||
puback_packet = mosq_test.gen_puback(mid, proto_ver=proto_ver)
|
||||
|
||||
broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port2)
|
||||
broker = mosq_test.start_broker(filename=os.path.basename(__file__), port=port2, checkhost=host)
|
||||
|
||||
try:
|
||||
sock = mosq_test.sub_helper(port=port2, topic="#", qos=1, proto_ver=proto_ver)
|
||||
@@ -73,6 +77,7 @@ def do_test(proto_ver):
|
||||
exit(rc)
|
||||
|
||||
|
||||
do_test(proto_ver=3)
|
||||
do_test(proto_ver=4)
|
||||
do_test(proto_ver=5)
|
||||
do_test(proto_ver=3, ipver=4)
|
||||
do_test(proto_ver=4, ipver=4)
|
||||
do_test(proto_ver=5, ipver=4)
|
||||
do_test(proto_ver=5, ipver=6)
|
||||
|
||||
@@ -26,6 +26,7 @@ int main(int argc, char *argv[])
|
||||
struct mosquittopp_test *mosq;
|
||||
|
||||
int port = atoi(argv[1]);
|
||||
int rc;
|
||||
|
||||
mosqpp::lib_init();
|
||||
|
||||
@@ -34,7 +35,8 @@ int main(int argc, char *argv[])
|
||||
mosq->connect("localhost", port, 5);
|
||||
|
||||
while(run == -1){
|
||||
mosq->loop();
|
||||
rc = mosq->loop();
|
||||
if(rc) break;
|
||||
}
|
||||
delete mosq;
|
||||
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ class TestError(Exception):
|
||||
def __init__(self, message="Mismatched packets"):
|
||||
self.message = message
|
||||
|
||||
def start_broker(filename, cmd=None, port=0, use_conf=False, expect_fail=False, nolog=False):
|
||||
def start_broker(filename, cmd=None, port=0, use_conf=False, expect_fail=False, nolog=False, checkhost="localhost"):
|
||||
global vg_index
|
||||
global vg_logfiles
|
||||
|
||||
@@ -63,7 +63,7 @@ def start_broker(filename, cmd=None, port=0, use_conf=False, expect_fail=False,
|
||||
time.sleep(delay)
|
||||
c = None
|
||||
try:
|
||||
c = socket.create_connection(("localhost", port))
|
||||
c = socket.create_connection((checkhost, port))
|
||||
except socket.error as err:
|
||||
if err.errno != errno.ECONNREFUSED:
|
||||
raise
|
||||
|
||||
@@ -30,7 +30,7 @@ static void map_valid_helper(const char *topic, const char *local_prefix, const
|
||||
rc = bridge__remap_topic_in(&mosq, &map_topic);
|
||||
CU_ASSERT_EQUAL(rc, 0);
|
||||
CU_ASSERT_PTR_NOT_NULL(map_topic);
|
||||
if(topic){
|
||||
if(map_topic){
|
||||
CU_ASSERT_STRING_EQUAL(map_topic, expected);
|
||||
free(map_topic);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user