...
1#!/usr/bin/env bats
2
3load helpers
4
5function setup() {
6 setup_busybox
7 update_config '.process.args = ["/bin/echo", "Hello World"]'
8}
9
10function teardown() {
11 teardown_bundle
12}
13
14@test "spec generation cwd" {
15 runc run test_hello
16 [ "$status" -eq 0 ]
17}
18
19@test "spec generation --bundle" {
20 runc run --bundle "$(pwd)" test_hello
21 [ "$status" -eq 0 ]
22}
23
24@test "spec validator" {
25 requires rootless_no_features
26
27 SPEC_VERSION=$(awk '$1 == "github.com/opencontainers/runtime-spec" {print $2}' "$BATS_TEST_DIRNAME"/../../go.mod)
28 # Will look like this when not pinned to specific tag: "v0.0.0-20190207185410-29686dbc5559", otherwise "v1.0.0"
29 SPEC_COMMIT=$(cut -d "-" -f 3 <<<"$SPEC_VERSION")
30 SPEC_REF=$([[ -z "$SPEC_COMMIT" ]] && echo "$SPEC_VERSION" || echo "$SPEC_COMMIT")
31
32 git clone https://github.com/opencontainers/runtime-spec.git
33 (cd runtime-spec && git reset --hard "$SPEC_REF")
34 SCHEMA='runtime-spec/schema/config-schema.json'
35 [ -e "$SCHEMA" ]
36
37 GO111MODULE=auto go get github.com/xeipuuv/gojsonschema
38 GO111MODULE=auto go build runtime-spec/schema/validate.go
39
40 ./validate "$SCHEMA" config.json
41}
View as plain text