Skip to content

Commit 591efe2

Browse files
committed
TestExpectedSeccompVersion: add
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 <[email protected]>
1 parent d84e824 commit 591efe2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ jobs:
5151
# - chances are good such version won't ever exist;
5252
# - it is easy to spot in tests output;
5353
# - the LIBFILE pattern below expects single digits.
54-
sed -i '/^AC_INIT(/s/0\.0\.0/9.9.9/' configure.ac
54+
VER="${{ matrix.libseccomp }}"
55+
if [ "$VER" == "HEAD" ]; then
56+
VER=9.9.9
57+
sed -i "/^AC_INIT(/s/0\.0\.0/$VER/" configure.ac
58+
fi
5559
./autogen.sh
5660
./configure --prefix="$PREFIX" --libdir="$LIBDIR"
5761
make
@@ -63,6 +67,8 @@ jobs:
6367
echo "PKG_CONFIG_LIBDIR=$LIBDIR/pkgconfig" >> $GITHUB_ENV
6468
LIBFILE="$(echo $LIBDIR/libseccomp.so.?.?.?)"
6569
echo "LD_PRELOAD=$LIBFILE" >> $GITHUB_ENV
70+
# For TestExpectedSeccompVersion.
71+
echo "_EXPECTED_LIBSECCOMP_VERSION=$VER" >> $GITHUB_ENV
6672
6773
- name: build
6874
run: make check-build

seccomp_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,27 @@ func execInSubprocess(t *testing.T, f func(t *testing.T)) {
4242
}
4343
}
4444

45+
func TestExpectedSeccompVersion(t *testing.T) {
46+
execInSubprocess(t, subprocessExpectedSeccompVersion)
47+
}
48+
49+
func subprocessExpectedSeccompVersion(t *testing.T) {
50+
// This environment variable can be set by CI.
51+
const name = "_EXPECTED_LIBSECCOMP_VERSION"
52+
53+
expVer := os.Getenv(name)
54+
if expVer == "" {
55+
t.Skip(name, "not set")
56+
}
57+
expVer = strings.TrimPrefix(expVer, "v")
58+
59+
curVer := fmt.Sprintf("%d.%d.%d", verMajor, verMinor, verMicro)
60+
t.Logf("testing against libseccomp %s", curVer)
61+
if curVer != expVer {
62+
t.Fatalf("libseccomp version mismatch: must be %s, got %s", expVer, curVer)
63+
}
64+
}
65+
4566
// Type Function Tests
4667

4768
func APILevelIsSupported() bool {

0 commit comments

Comments
 (0)