Skip to content

Commit 08d3474

Browse files
committed
test: add TestExpectedSeccompVersion
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 bc352fa commit 08d3474

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
@@ -60,6 +60,27 @@ func execInSubprocess(t *testing.T, f func(t *testing.T)) {
6060
t.Logf("\n%s", b.String())
6161
}
6262

63+
func TestExpectedSeccompVersion(t *testing.T) {
64+
execInSubprocess(t, subprocessExpectedSeccompVersion)
65+
}
66+
67+
func subprocessExpectedSeccompVersion(t *testing.T) {
68+
// This environment variable can be set by CI.
69+
const name = "_EXPECTED_LIBSECCOMP_VERSION"
70+
71+
expVer := os.Getenv(name)
72+
if expVer == "" {
73+
t.Skip(name, "not set")
74+
}
75+
expVer = strings.TrimPrefix(expVer, "v")
76+
77+
curVer := fmt.Sprintf("%d.%d.%d", verMajor, verMinor, verMicro)
78+
t.Logf("testing against libseccomp %s", curVer)
79+
if curVer != expVer {
80+
t.Fatalf("libseccomp version mismatch: must be %s, got %s", expVer, curVer)
81+
}
82+
}
83+
6384
// Type Function Tests
6485

6586
func APILevelIsSupported() bool {

0 commit comments

Comments
 (0)