diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..b2aa3f4e --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +# Today, this repository only uses Rust for tests. This +# toplevel Cargo.toml helps tools like rust-analyzer understand +# that this project contains Rust code. We don't otherwise currently +# use `cargo` for any part of the core build. +[workspace] +members = ["tests/inst"] diff --git a/Makefile-tests.am b/Makefile-tests.am index 23dba331..c99a7ede 100644 --- a/Makefile-tests.am +++ b/Makefile-tests.am @@ -431,8 +431,11 @@ if ENABLE_INSTALLED_TESTS_EXCLUSIVE dist_installed_test_scripts = $(_installed_or_uninstalled_test_scripts) installed_test_programs = $(_installed_or_uninstalled_test_programs) check-local: + echo "NOTE: Run the Rust installed tests (uninstalled) with ./tests/run-installed" echo "NOTE: Exclusive installed tests are enabled; to run them, make install, then: gnome-desktop-testing-runner -p 0 libostree/" else +check-local: + echo "NOTE: Run the Rust installed tests (uninstalled) with ./tests/run-installed" dist_test_scripts += $(_installed_or_uninstalled_test_scripts) test_programs += $(_installed_or_uninstalled_test_programs) endif diff --git a/Makefile.am b/Makefile.am index b2588ad7..2f3cb53f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,6 +46,9 @@ GITIGNOREFILES = aclocal.m4 build-aux/ buildutil/*.m4 config.h.in gtk-doc.make # Generated by coreos-assembler build-fast and kola GITIGNOREFILES += fastbuild-*.qcow2 _kola_temp/ +# Rust stuff +GITIGNOREFILES += target/ Cargo.lock + SUBDIRS += . if ENABLE_GTK_DOC diff --git a/tests/inst/.gitignore b/tests/inst/.gitignore deleted file mode 100644 index 2c96eb1b..00000000 --- a/tests/inst/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target/ -Cargo.lock diff --git a/tests/inst/src/sysroot.rs b/tests/inst/src/sysroot.rs index a8ff3eb3..ce0378eb 100644 --- a/tests/inst/src/sysroot.rs +++ b/tests/inst/src/sysroot.rs @@ -6,10 +6,14 @@ use ostree::prelude::*; use crate::test::*; +fn skip_non_ostree_host() -> bool { + !std::path::Path::new("/run/ostree-booted").exists() +} + #[itest] fn test_sysroot_ro() -> Result<()> { // TODO add a skipped identifier - if !std::path::Path::new("/run/ostree-booted").exists() { + if skip_non_ostree_host() { return Ok(()); } let cancellable = Some(gio::Cancellable::new()); @@ -34,6 +38,9 @@ fn test_sysroot_ro() -> Result<()> { #[itest] fn test_immutable_bit() -> Result<()> { + if skip_non_ostree_host() { + return Ok(()); + } // https://bugzilla.redhat.com/show_bug.cgi?id=1867601 cmd_has_output(sh_inline::bash_command!("lsattr -d /").unwrap(), "-i-")?; Ok(()) diff --git a/tests/kolainst/Makefile b/tests/kolainst/Makefile index acfdc3b7..5dc18281 100644 --- a/tests/kolainst/Makefile +++ b/tests/kolainst/Makefile @@ -12,6 +12,6 @@ all: install: install -D -m 0644 -t $(KOLA_TESTDIR) $(LIBSCRIPTS) for x in $(TESTDIRS); do rsync -rlv ./$${x} $(KOLA_TESTDIR)/; done - install -D -m 0755 -t $(KOLA_TESTDIR)/nondestructive-rs ../inst/target/release/ostree-test + install -D -m 0755 -t $(KOLA_TESTDIR)/nondestructive-rs ../../target/release/ostree-test install -D -m 0644 destructive-stamp.ign $(KOLA_TESTDIR)/destructive-rs/config.ign ./install-wrappers.sh destructive-list.txt $(KOLA_TESTDIR)/destructive-rs diff --git a/tests/run-installed b/tests/run-installed new file mode 100755 index 00000000..e9f9842b --- /dev/null +++ b/tests/run-installed @@ -0,0 +1,6 @@ +#!/bin/bash +# Run this script after e.g. `sudo make install` in a development container/host +# to run tests which operate on the installed binaries. +set -xeuo pipefail +dn=$(dirname $0) +(cd ${dn}/../tests/inst && cargo run --release)