From fd9496433c112418b3ac830b376d702dd8086be0 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 1 Jul 2014 22:02:06 +0100 Subject: [PATCH] Configure client tests for valgrind. --- test/lib/01-con-discon-success.py | 4 ++-- test/lib/01-keepalive-pingreq.py | 2 +- test/lib/01-no-clean-session.py | 2 +- test/lib/01-unpwd-set.py | 2 +- test/lib/01-will-set.py | 2 +- test/lib/01-will-unpwd-set.py | 2 +- test/lib/02-subscribe-qos0.py | 2 +- test/lib/02-subscribe-qos1.py | 2 +- test/lib/02-subscribe-qos2.py | 2 +- test/lib/02-unsubscribe.py | 2 +- test/lib/03-publish-b2c-qos1.py | 2 +- test/lib/03-publish-b2c-qos2.py | 2 +- test/lib/03-publish-c2b-qos1-disconnect.py | 2 +- test/lib/03-publish-c2b-qos1-timeout.py | 2 +- test/lib/03-publish-c2b-qos2-disconnect.py | 2 +- test/lib/03-publish-c2b-qos2-timeout.py | 2 +- test/lib/03-publish-c2b-qos2.py | 2 +- test/lib/03-publish-qos0-no-payload.py | 2 +- test/lib/03-publish-qos0.py | 2 +- test/lib/04-retain-qos0.py | 2 +- test/lib/08-ssl-bad-cacert.py | 2 +- test/lib/08-ssl-connect-cert-auth-enc.py | 2 +- test/lib/08-ssl-connect-cert-auth.py | 2 +- test/lib/08-ssl-connect-no-auth.py | 2 +- test/lib/08-ssl-fake-cacert.py | 2 +- test/lib/09-util-topic-matching.py | 2 +- test/lib/09-util-topic-tokenise.py | 2 +- test/mosq_test.py | 8 ++++++++ 28 files changed, 36 insertions(+), 28 deletions(-) diff --git a/test/lib/01-con-discon-success.py b/test/lib/01-con-discon-success.py index f3c0835d..1ebe6c97 100755 --- a/test/lib/01-con-discon-success.py +++ b/test/lib/01-con-discon-success.py @@ -43,7 +43,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() @@ -57,7 +57,7 @@ try: conn.close() finally: - client.terminate() + #client.terminate() client.wait() sock.close() diff --git a/test/lib/01-keepalive-pingreq.py b/test/lib/01-keepalive-pingreq.py index 60483166..f0dbceaa 100755 --- a/test/lib/01-keepalive-pingreq.py +++ b/test/lib/01-keepalive-pingreq.py @@ -43,7 +43,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/01-no-clean-session.py b/test/lib/01-no-clean-session.py index af9ce202..9ae2a7c8 100755 --- a/test/lib/01-no-clean-session.py +++ b/test/lib/01-no-clean-session.py @@ -37,7 +37,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/01-unpwd-set.py b/test/lib/01-unpwd-set.py index 2b05458c..67cf4f7b 100755 --- a/test/lib/01-unpwd-set.py +++ b/test/lib/01-unpwd-set.py @@ -37,7 +37,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/01-will-set.py b/test/lib/01-will-set.py index 5d2ce23e..a54f849a 100755 --- a/test/lib/01-will-set.py +++ b/test/lib/01-will-set.py @@ -39,7 +39,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/01-will-unpwd-set.py b/test/lib/01-will-unpwd-set.py index 3edb4a31..b27820da 100755 --- a/test/lib/01-will-unpwd-set.py +++ b/test/lib/01-will-unpwd-set.py @@ -41,7 +41,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/02-subscribe-qos0.py b/test/lib/02-subscribe-qos0.py index d671b4ef..42b9874e 100755 --- a/test/lib/02-subscribe-qos0.py +++ b/test/lib/02-subscribe-qos0.py @@ -51,7 +51,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/02-subscribe-qos1.py b/test/lib/02-subscribe-qos1.py index f96b813f..6190431a 100755 --- a/test/lib/02-subscribe-qos1.py +++ b/test/lib/02-subscribe-qos1.py @@ -51,7 +51,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/02-subscribe-qos2.py b/test/lib/02-subscribe-qos2.py index f9c42c8b..411de65b 100755 --- a/test/lib/02-subscribe-qos2.py +++ b/test/lib/02-subscribe-qos2.py @@ -51,7 +51,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/02-unsubscribe.py b/test/lib/02-unsubscribe.py index 1485bf96..257f95a6 100755 --- a/test/lib/02-unsubscribe.py +++ b/test/lib/02-unsubscribe.py @@ -41,7 +41,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-b2c-qos1.py b/test/lib/03-publish-b2c-qos1.py index 993f077d..edfbb40f 100755 --- a/test/lib/03-publish-b2c-qos1.py +++ b/test/lib/03-publish-b2c-qos1.py @@ -50,7 +50,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-b2c-qos2.py b/test/lib/03-publish-b2c-qos2.py index 658103b6..83545421 100755 --- a/test/lib/03-publish-b2c-qos2.py +++ b/test/lib/03-publish-b2c-qos2.py @@ -57,7 +57,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-c2b-qos1-disconnect.py b/test/lib/03-publish-c2b-qos1-disconnect.py index 6ce0a8e9..41316862 100755 --- a/test/lib/03-publish-c2b-qos1-disconnect.py +++ b/test/lib/03-publish-c2b-qos1-disconnect.py @@ -43,7 +43,7 @@ except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-c2b-qos1-timeout.py b/test/lib/03-publish-c2b-qos1-timeout.py index de59699f..344ca957 100755 --- a/test/lib/03-publish-c2b-qos1-timeout.py +++ b/test/lib/03-publish-c2b-qos1-timeout.py @@ -56,7 +56,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-c2b-qos2-disconnect.py b/test/lib/03-publish-c2b-qos2-disconnect.py index ce638bff..704f1807 100755 --- a/test/lib/03-publish-c2b-qos2-disconnect.py +++ b/test/lib/03-publish-c2b-qos2-disconnect.py @@ -45,7 +45,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-c2b-qos2-timeout.py b/test/lib/03-publish-c2b-qos2-timeout.py index 3a78af7c..f04368e7 100755 --- a/test/lib/03-publish-c2b-qos2-timeout.py +++ b/test/lib/03-publish-c2b-qos2-timeout.py @@ -63,7 +63,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-c2b-qos2.py b/test/lib/03-publish-c2b-qos2.py index e486ea11..0954ed84 100755 --- a/test/lib/03-publish-c2b-qos2.py +++ b/test/lib/03-publish-c2b-qos2.py @@ -62,7 +62,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-qos0-no-payload.py b/test/lib/03-publish-qos0-no-payload.py index 58cf1bf5..c74aa4d6 100755 --- a/test/lib/03-publish-qos0-no-payload.py +++ b/test/lib/03-publish-qos0-no-payload.py @@ -47,7 +47,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/03-publish-qos0.py b/test/lib/03-publish-qos0.py index 5a6b5e58..d58f3f51 100755 --- a/test/lib/03-publish-qos0.py +++ b/test/lib/03-publish-qos0.py @@ -47,7 +47,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/04-retain-qos0.py b/test/lib/04-retain-qos0.py index 70d7882b..8860c036 100755 --- a/test/lib/04-retain-qos0.py +++ b/test/lib/04-retain-qos0.py @@ -38,7 +38,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = sock.accept() diff --git a/test/lib/08-ssl-bad-cacert.py b/test/lib/08-ssl-bad-cacert.py index cf2861f8..8509ff99 100755 --- a/test/lib/08-ssl-bad-cacert.py +++ b/test/lib/08-ssl-bad-cacert.py @@ -30,7 +30,7 @@ except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) client.wait() rc = client.returncode diff --git a/test/lib/08-ssl-connect-cert-auth-enc.py b/test/lib/08-ssl-connect-cert-auth-enc.py index 0c7f20a5..a4f81138 100644 --- a/test/lib/08-ssl-connect-cert-auth-enc.py +++ b/test/lib/08-ssl-connect-cert-auth-enc.py @@ -52,7 +52,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = ssock.accept() diff --git a/test/lib/08-ssl-connect-cert-auth.py b/test/lib/08-ssl-connect-cert-auth.py index bab07927..71ebdeaf 100755 --- a/test/lib/08-ssl-connect-cert-auth.py +++ b/test/lib/08-ssl-connect-cert-auth.py @@ -52,7 +52,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = ssock.accept() diff --git a/test/lib/08-ssl-connect-no-auth.py b/test/lib/08-ssl-connect-no-auth.py index b05c61ca..d0c531b9 100755 --- a/test/lib/08-ssl-connect-no-auth.py +++ b/test/lib/08-ssl-connect-no-auth.py @@ -49,7 +49,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = ssock.accept() diff --git a/test/lib/08-ssl-fake-cacert.py b/test/lib/08-ssl-fake-cacert.py index 275b57e6..0e6c29cd 100755 --- a/test/lib/08-ssl-fake-cacert.py +++ b/test/lib/08-ssl-fake-cacert.py @@ -36,7 +36,7 @@ try: except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) try: (conn, address) = ssock.accept() diff --git a/test/lib/09-util-topic-matching.py b/test/lib/09-util-topic-matching.py index b678bc6c..d531ea3e 100755 --- a/test/lib/09-util-topic-matching.py +++ b/test/lib/09-util-topic-matching.py @@ -22,7 +22,7 @@ except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) client.wait() if client.returncode: (stdo, stde) = client.communicate() diff --git a/test/lib/09-util-topic-tokenise.py b/test/lib/09-util-topic-tokenise.py index 0625e028..3a6741b0 100755 --- a/test/lib/09-util-topic-tokenise.py +++ b/test/lib/09-util-topic-tokenise.py @@ -22,6 +22,6 @@ except KeyError: pp = '' env['PYTHONPATH'] = '../../lib/python:'+pp -client = subprocess.Popen(client_args, env=env) +client = mosq_test.start_client(filename=sys.argv[1].replace('/', '-'), cmd=client_args, env=env) client.wait() exit(client.returncode) diff --git a/test/mosq_test.py b/test/mosq_test.py index c50eee06..ec6183d6 100644 --- a/test/mosq_test.py +++ b/test/mosq_test.py @@ -28,6 +28,14 @@ def start_broker(filename, cmd=None, port=1888): return broker raise IOError +def start_client(filename, cmd, env): + if cmd is None: + raise ValueError + if os.environ.get('MOSQ_USE_VALGRIND') is not None: + cmd = ['valgrind', '-q', '--log-file='+filename+'.vglog'] + cmd + + return subprocess.Popen(cmd, env=env) + def expect_packet(sock, name, expected): if len(expected) > 0: rlen = len(expected)