[sw, rom_ext_signer] Add testing option to invoke_cargo.sh
Without this change there is no way of triggering rust unittests from
the build - and instead it had to be done manually by `cd` into the
directory with the `Cargo.toml` and calling `cargo test --workspace`.
- This solution is by no means ideal, but should be enough for now.
- We SHOULD eventually come back to it and completely reassess how
cargo builds are triggered.
To trigger a test build additionally to a production build, set
`CARGO_TEST=1` environment variable:
`CARGO_TEST=1 ninja -C build-out`
Signed-off-by: Silvestrs Timofejevs <silvestrst@lowrisc.org>
diff --git a/util/invoke_cargo.sh b/util/invoke_cargo.sh
index 376dc78..0f87787 100755
--- a/util/invoke_cargo.sh
+++ b/util/invoke_cargo.sh
@@ -21,4 +21,10 @@
export MESON_SOURCE_ROOT="${5}"
export MESON_BUILD_ROOT="${6}"
-"${CARGO}" +"${TOOLCHAIN}" build ${CARGO_FLAGS}
+if [ "${CARGO_TEST}" == 1 ]; then
+ echo "CARGO TEST BUILD!"
+ "${CARGO}" +"${TOOLCHAIN}" test ${CARGO_FLAGS} --workspace
+ "${CARGO}" +"${TOOLCHAIN}" build ${CARGO_FLAGS}
+else
+ "${CARGO}" +"${TOOLCHAIN}" build ${CARGO_FLAGS}
+fi