Skip to content

Commit

Permalink
test: add TestExpectedSeccompVersion
Browse files Browse the repository at this point in the history
This is to ensure we're testing against the expected libseccomp version
(as prepared by CI, which sets the _EXPECTED_LIBSECCOMP_VERSION var).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Sep 29, 2021
1 parent 70107f6 commit 6f6ba25
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ jobs:
# - chances are good such version won't ever exist;
# - it is easy to spot in tests output;
# - the LIBFILE pattern below expects single digits.
sed -i '/^AC_INIT(/s/0\.0\.0/9.9.9/' configure.ac
VER="${{ matrix.libseccomp }}"
if [ "$VER" == "HEAD" ]; then
VER=9.9.9
sed -i "/^AC_INIT(/s/0\.0\.0/$VER/" configure.ac
fi
./autogen.sh
./configure --prefix="$PREFIX" --libdir="$LIBDIR"
make
Expand All @@ -63,6 +67,8 @@ jobs:
echo "PKG_CONFIG_LIBDIR=$LIBDIR/pkgconfig" >> $GITHUB_ENV
LIBFILE="$(echo $LIBDIR/libseccomp.so.?.?.?)"
echo "LD_PRELOAD=$LIBFILE" >> $GITHUB_ENV
# For TestExpectedSeccompVersion.
echo "_EXPECTED_LIBSECCOMP_VERSION=$VER" >> $GITHUB_ENV
- name: build
run: make check-build
Expand Down
21 changes: 21 additions & 0 deletions seccomp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ func execInSubprocess(t *testing.T, f func(t *testing.T)) {
}
}

func TestExpectedSeccompVersion(t *testing.T) {
execInSubprocess(t, subprocessExpectedSeccompVersion)
}

func subprocessExpectedSeccompVersion(t *testing.T) {
// This environment variable can be set by CI.
const name = "_EXPECTED_LIBSECCOMP_VERSION"

expVer := os.Getenv(name)
if expVer == "" {
t.Skip(name, "not set")
}
expVer = strings.TrimPrefix(expVer, "v")

curVer := fmt.Sprintf("%d.%d.%d", verMajor, verMinor, verMicro)
t.Logf("testing against libseccomp %s", curVer)
if curVer != expVer {
t.Fatalf("libseccomp version mismatch: must be %s, got %s", expVer, curVer)
}
}

// Type Function Tests

func APILevelIsSupported() bool {
Expand Down

0 comments on commit 6f6ba25

Please sign in to comment.