Tage Johansson
2023-Aug-04 11:34 UTC
[Libguestfs] [libnbd PATCH v6 04/13] rust: Make it possible to run tests with Valgrind
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 | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rust/Makefile.am b/rust/Makefile.am index 1e63724..bb2e6f0 100644 --- a/rust/Makefile.am +++ b/rust/Makefile.am @@ -89,6 +89,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 d45b1bf..f7db344 100755 --- a/rust/run-tests.sh.in +++ b/rust/run-tests.sh.in @@ -23,4 +23,8 @@ set -x requires nbdkit --version - at CARGO@ test -- --nocapture +if [ -z "$VG" ]; then + @CARGO@ test -- --nocapture +else + @CARGO@ test --config "target.'cfg(all())'.runner = \"$VG\"" -- --nocapture +fi -- 2.41.0
Richard W.M. Jones
2023-Aug-04 13:04 UTC
[Libguestfs] [libnbd PATCH v6 04/13] rust: Make it possible to run tests with Valgrind
On Fri, Aug 04, 2023 at 11:34:07AM +0000, Tage Johansson wrote:> 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 | 6 +++++- > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/rust/Makefile.am b/rust/Makefile.am > index 1e63724..bb2e6f0 100644 > --- a/rust/Makefile.am > +++ b/rust/Makefile.am > @@ -89,6 +89,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 d45b1bf..f7db344 100755 > --- a/rust/run-tests.sh.in > +++ b/rust/run-tests.sh.in > @@ -23,4 +23,8 @@ set -x > > requires nbdkit --version > > - at CARGO@ test -- --nocapture > +if [ -z "$VG" ]; then > + @CARGO@ test -- --nocapture > +else > + @CARGO@ test --config "target.'cfg(all())'.runner = \"$VG\"" -- --nocapture > +fiSo the tests don't actually pass, with unfortunately quite a lot of errors. Do they pass for you? You may need to add a valgrind/rust.suppressions file. Does rust require a runtime mode where it is forced to free up allocations on exit (as not all languages will bother with that, since it is not necessary ordinarily). Rich. -- Richard Jones, Virtualization Group, Red Hat people.redhat.com/~rjones Read my programming and virtualization blog: rwmj.wordpress.com virt-builder quickly builds VMs from scratch libguestfs.org/virt-builder.1.html