[gnome-bluetooth/wip/hadess/more-tests: 3/4] tests: Run tests under Valgrind if requested
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth/wip/hadess/more-tests: 3/4] tests: Run tests under Valgrind if requested
- Date: Tue, 16 Feb 2021 16:38:20 +0000 (UTC)
commit e4a0471ad9a35820126ef2d836f117d58b949e58
Author: Bastien Nocera <hadess hadess net>
Date: Tue Feb 16 17:33:09 2021 +0100
tests: Run tests under Valgrind if requested
VALGRIND=1 meson test
will run the tests under Valgrind and print out all the output from the
memory leak detection tool.
tests/integration-test | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/tests/integration-test b/tests/integration-test
index d0eaa188..ea7e8368 100755
--- a/tests/integration-test
+++ b/tests/integration-test
@@ -143,6 +143,10 @@ class Tests(dbusmock.DBusTestCase):
(cls.p_mock, cls.obj_bluez) = cls.spawn_server_template(
'bluez5', {}, stdout=subprocess.PIPE)
+ cls.exec_path = [sys.argv[0]]
+ if os.getenv('VALGRIND') != None:
+ cls.exec_path = ['valgrind'] + cls.exec_path
+
@classmethod
def tearDownClass(cls):
cls.p_mock.stdout.close()
@@ -158,8 +162,10 @@ class Tests(dbusmock.DBusTestCase):
# Get the calling function's name
test_name = inspect.stack()[1][3]
# And run the test with the same name in the OopTests class in a separate process
- out = subprocess.run([sys.argv[0], 'OopTests.' + test_name], capture_output=True)
+ out = subprocess.run(self.exec_path + ['OopTests.' + test_name], capture_output=True)
self.assertEqual(out.returncode, 0, "Running test " + test_name + " failed:" +
out.stderr.decode('UTF-8'))
+ if os.getenv('VALGRIND') != None:
+ print(out.stderr.decode('UTF-8'))
def test_no_adapters(self):
self.run_test_process()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]