Files
Kir Kolyshkin 5ff8136ed9 tests/int: call runc via bats' run helper
Now that runc is a real binary (a wrapper script in PATH), tests can
call it the way any other command is called, using bats' run helper
directly:

	run -0 runc start ctr

instead of the old

	runc start ctr
	[ "$status" -eq 0 ]

where runc was a bash function hiding a call to run. The exit code check
is now part of the call: -N for an expected exit code, ! for "any
failure", and no argument where the exit code is checked later or not at
all.

This has to be done in one go: while the runc function exists, "run runc"
would call it, resulting in a nested run.

Other changes made necessary or possible by this:

  - The runc and sane_run functions are gone. The output of a failed
    command is now printed by bats itself, see the previous commit.

  - __runc (a raw runc call, not using run) is now simply runc.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-10-02 14:47:43 -07:00

40 lines
995 B
Bash

#!/usr/bin/env bats
load helpers
function setup() {
setup_busybox
update_config '.process.args = ["/bin/echo", "Hello World"]'
}
function teardown() {
teardown_bundle
}
@test "spec generation cwd" {
run -0 runc run test_hello
}
@test "spec generation --bundle" {
run -0 runc run --bundle "$(pwd)" test_hello
}
@test "spec validator" {
requires rootless_no_features
SPEC_VERSION=$(awk '$1 == "github.com/opencontainers/runtime-spec" {print $2}' "$BATS_TEST_DIRNAME"/../../go.mod)
# Will look like this when not pinned to specific tag: "v0.0.0-20190207185410-29686dbc5559", otherwise "v1.0.0"
SPEC_COMMIT=$(cut -d "-" -f 3 <<<"$SPEC_VERSION")
SPEC_REF=$([[ -z "$SPEC_COMMIT" ]] && echo "$SPEC_VERSION" || echo "$SPEC_COMMIT")
git clone https://github.com/opencontainers/runtime-spec.git
(cd runtime-spec && git reset --hard "$SPEC_REF")
cd runtime-spec/schema
go mod init runtime-spec
go mod tidy
go build ./validate.go
./validate config-schema.json ../../config.json
}