Skip to content

Commit af6e6f2

Browse files
ekoopspoiana
authored andcommitted
ci: fix glibc check on unit-test-libsinsp binary
Fix glibc check to actually verify that the linked glibc symbol versions are not above the target one (2.17) instead of checking for exact equality of the highest one. Moreover, extract the check in a separate bash script. Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
1 parent b67a719 commit af6e6f2

3 files changed

Lines changed: 46 additions & 18 deletions

File tree

.github/check-glibc-version.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# Copyright (C) 2026 The Falco Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
# Check that the highest glibc symbol version the provided binary links against does not exceed the target ceiling.
20+
#
21+
# Usage: ./<script-name>.sh <binary>
22+
# <binary> path to the ELF binary to inspect
23+
24+
set -euo pipefail
25+
26+
if [ "$#" -ne 1 ]; then
27+
echo "usage: $0 <binary>" >&2
28+
exit 2
29+
fi
30+
31+
BINARY="$1"
32+
TARGET_GLIBC="GLIBC_2.17"
33+
34+
# Print all linked glibc symbol versions (sorted) for visibility in the CI logs.
35+
objdump -T "$BINARY" | grep -Eo 'GLIBC_\S+' | sort -u -t "." -k1,1n -k2,2n -k3,3n
36+
37+
# Get the highest glibc version actually required by the binary.
38+
LINKED_GLIBC=$(objdump -T "$BINARY" | grep -Eo 'GLIBC_\S+' | sort -u -t "." -k1,1n -k2,2n -k3,3n | tail -n1 | tr -d ')')
39+
40+
MAX_GLIBC=$(printf '%s\n%s\n' "$TARGET_GLIBC" "$LINKED_GLIBC" | sort -V | tail -1)
41+
if [ "$MAX_GLIBC" != "$TARGET_GLIBC" ]; then
42+
echo "Binary links $LINKED_GLIBC which exceeds ceiling $TARGET_GLIBC"
43+
exit 1
44+
fi

.github/workflows/ci.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,7 @@ jobs:
8080
# glibc version.
8181
- name: Test zig build glibc version
8282
if: matrix.name == 'zig'
83-
run: |
84-
cd build
85-
objdump -T libsinsp/test/unit-test-libsinsp | grep -Eo 'GLIBC_\S+' | sort -u -t "." -k1,1n -k2,2n -k3,3n
86-
linked_glibc=$(objdump -T libsinsp/test/unit-test-libsinsp | grep -Eo 'GLIBC_\S+' | sort -u -t "." -k1,1n -k2,2n -k3,3n | tail -n1 | tr -d ')')
87-
if [ "$linked_glibc" != "GLIBC_2.17" ]; then
88-
echo "Expected glibc 2.17; found $linked_glibc"
89-
exit 1
90-
fi
83+
run: .github/check-glibc-version.sh build/libsinsp/test/unit-test-libsinsp
9184

9285
build-libs-linux-amd64-cross-arm64:
9386
name: build-libs-linux-amd64-cross-arm64 (bundled_deps)

.github/workflows/drivers_ci.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,7 @@ jobs:
421421
# Check the glibc versions linked to scap-open to make sure we are actually using the correct glibc version.
422422
- name: Test zig build glibc version
423423
if: env.MUST_RUN == 'true'
424-
run: |
425-
TARGET_GLIBC="GLIBC_2.17"
426-
cd build
427-
objdump -T libscap/examples/01-open/scap-open | grep -Eo 'GLIBC_\S+' | sort -u -t "." -k1,1n -k2,2n -k3,3n
428-
LINKED_GLIBC=$(objdump -T libscap/examples/01-open/scap-open | grep -Eo 'GLIBC_\S+' | sort -u -t "." -k1,1n -k2,2n -k3,3n | tail -n1 | tr -d ')')
429-
MAX_GLIBC=$(printf '%s\n%s\n' "$TARGET_GLIBC" "$LINKED_GLIBC" | sort -V | tail -1)
430-
if [ "$MAX_GLIBC" != "$TARGET_GLIBC" ]; then
431-
echo "Binary links $LINKED_GLIBC which exceeds ceiling $TARGET_GLIBC"
432-
exit 1
433-
fi
424+
run: .github/check-glibc-version.sh build/libscap/examples/01-open/scap-open
434425

435426
# Only runs on pull request since on master branch it is already triggered by pages CI.
436427
kernel-tests-dev:

0 commit comments

Comments
 (0)