[Libguestfs] [libnbd PATCH v7 1/9] rust: Make it possible to run tests with Valgrind

Tage Johansson tage.j.lists at posteo.net
Thu Aug 10 11:24:28 UTC 2023


Make it possible to run Rust tests with Valgrind with
`make check-valgrind` in the rust directory.
---
 rust/Makefile.am     |  3 +++
 rust/run-tests.sh.in | 16 ++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/rust/Makefile.am b/rust/Makefile.am
index 6609eec..295254d 100644
--- a/rust/Makefile.am
+++ b/rust/Makefile.am
@@ -92,6 +92,9 @@ TESTS_ENVIRONMENT = \
 LOG_COMPILER = $(top_builddir)/run
 TESTS = run-tests.sh
 
+check-valgrind:
+	LIBNBD_VALGRIND=1 $(MAKE) check
+
 clean-local:
 	$(CARGO) clean
 	$(CARGO) clean --manifest-path cargo_test/Cargo.toml
diff --git a/rust/run-tests.sh.in b/rust/run-tests.sh.in
index afa83dc..3ebf9a1 100755
--- a/rust/run-tests.sh.in
+++ b/rust/run-tests.sh.in
@@ -25,9 +25,13 @@ requires @NBDKIT@ --version
 requires @NBDKIT@ floppy --version
 requires @NBDKIT@ memory --version
 
- at CARGO@ test -- --nocapture
- at CARGO@ run --example connect-command
- at NBDKIT@ -U - memory 1M \
-         --run '@CARGO@ run --example get-size -- $unixsocket'
- at NBDKIT@ -U - floppy . \
-         --run '@CARGO@ run --example fetch-first-sector -- $unixsocket'
+if [ -z "$VG" ]; then
+    @CARGO@ test -- --nocapture
+    @CARGO@ run --example connect-command
+    @NBDKIT@ -U - memory 1M \
+             --run '@CARGO@ run --example get-size -- $unixsocket'
+    @NBDKIT@ -U - floppy . \
+             --run '@CARGO@ run --example fetch-first-sector -- $unixsocket'
+else
+    @CARGO@ test --config "target.'cfg(all())'.runner = \"$VG\"" -- --nocapture
+fi
-- 
2.41.0



More information about the Libguestfs mailing list