ostree/tests/runkola
Colin Walters 1f637bf341 Add new Rust-based tests
There's a lot going on here.  First, this is intended to run
nicely as part of the new [cosa/kola ext-tests](https://github.com/coreos/coreos-assembler/pull/1252).

With Rust we can get one big static binary that we can upload,
and include a webserver as part of the binary.  This way we don't
need to do the hack of running a container with Python or whatever.

Now, what's even better about Rust for this is that it has macros,
and specifically we are using [commandspec](https://github.com/tcr/commandspec/)
which allows us to "inline" shell script.  I think the macros
could be even better, but this shows how we can intermix
pure Rust code along with using shell safely enough.

We're using my fork of commandspec because the upstream hasn't
merged [a few PRs](https://github.com/tcr/commandspec/pulls?q=is%3Apr+author%3Acgwalters+).

This model is intended to replace *both* some of our
`make check` tests as well.

Oh, and this takes the obvious step of using the Rust OSTree bindings
as part of our tests.  Currently the "commandspec tests" and "API tests"
are separate, but nothing stops us from intermixing them if we wanted.

I haven't yet tried to write destructive tests with this but
I think it will go well.
2020-05-27 21:59:23 +00:00

19 lines
438 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Generate a new qemu image and run tests
top=$(git rev-parse --show-toplevel)
cd ${top}
make
cosa build-fast
image=$(ls fastbuild-*-qemu.qcow2 | head -1)
if [ -z "${image}" ]; then
echo "failed to find image"; exit 1
fi
if [ -z "$@" ]; then
set -- 'ext.ostree.*' "$@"
fi
set -x
make -C tests/kolainst
sudo make -C tests/kolainst install
exec kola run -p qemu --qemu-image "${image}" -E ${top} "$@"