Skip to contentSkip to conversation

test: ensure expected output works for older and newer kernels

PATCH In review Kris Van Hees 2 participants 2 messages Oct 30 – Nov 6

lore
Share & tools
lore
#0 lore raw

PATCH 20/20 test: ensure expected output works for older and newer kernels

Older kernel BPF verifiers report -EFAULT whereras newer ones report -E2BIG. Support both, and also make the tests more robust if code generation might result in a less predictable jump count.

---
 test/unittest/options/tst.bpflogsize-cmdline.sh | 9 ++++-----
 test/unittest/options/tst.bpflogsize-pragma.sh  | 9 ++++-----
 2 files changed, 8 insertions(+), 10 deletions(-)
test/unittest/options/tst.bpflogsize-cmdline.sh +4 -5
index c67dd280..994acb9a 100755
@@ -39,7 +39,6 @@ cat > D.out << EOF
 BPF verifier log is incomplete and is not reported.
 Set DTrace option 'bpflogsize' to some greater size for more output.
 (Current size is nnnn.)
-dtrace: could not enable tracing: BPF program load for 'dtrace:::BEGIN' failed: Bad address
 EOF
 
 # dump files
@@ -77,7 +76,7 @@ while [ $cursiz -lt $((1024 * 1024 * 1024)) ]; do
 	# Usually (at least in the default case),
 	# dtrace should fail because the BPF log size is too small.
 	# Output should match D.out.
-	if [ `sed s/$cursiz/nnnn/ tmp.out | diff - D.out | wc -l` -eq 0 ]; then
+	if [ `sed -e s/$cursiz/nnnn/ -e '/^dtrace: /d' tmp.out | diff - D.out | wc -l` -eq 0 ]; then
 		echo okay: $cursiz is too small
 
 		# bump the size up and try again
@@ -88,7 +87,7 @@ while [ $cursiz -lt $((1024 * 1024 * 1024)) ]; do
 		echo "The default case is expected to have bpflogsize too small"
 		echo "and fail with the expected error."
 		echo "========== output (expected)"
-		sed 's/nnnn/'$cursiz'/' D.out
+		sed -e 's/nnnn/'$cursiz'/' D.out
 		dump_files
 		exit 1
 	fi
@@ -111,11 +110,11 @@ while [ $cursiz -lt $((1024 * 1024 * 1024)) ]; do
 		echo ERROR: expected only one non-\"BPF:\" output line
 		status=1
 	fi
-	if ! grep -q '^BPF: The sequence of 8193 jumps is too complex.' tmp.out; then
+	if ! grep -q '^BPF: The sequence of [1-9][0-9]* jumps is too complex.' tmp.out; then
 		echo ERROR: BPF error message is missing
 		status=1
 	fi
-	if ! grep -q '^dtrace: could not enable tracing: BPF program load for '\''dtrace:::BEGIN'\'' failed: Bad address' tmp.out; then
+	if ! grep -q '^dtrace: ' tmp.out; then
 		echo ERROR: dtrace error message is missing
 		status=1
 	fi
test/unittest/options/tst.bpflogsize-pragma.sh +4 -5
index 25cda675..342bb3b9 100755
@@ -40,7 +40,6 @@ cat > D.out << EOF
 BPF verifier log is incomplete and is not reported.
 Set DTrace option 'bpflogsize' to some greater size for more output.
 (Current size is nnnn.)
-dtrace: could not enable tracing: BPF program load for 'dtrace:::BEGIN' failed: Bad address
 EOF
 
 # dump files
@@ -77,7 +76,7 @@ while [ $cursiz -lt $((1024 * 1024 * 1024)) ]; do
 	# Usually (at least in the default case),
 	# dtrace should fail because the BPF log size is too small.
 	# Output should match D.out.
-	if [ `sed s/$cursiz/nnnn/ tmp.out | diff - D.out | wc -l` -eq 0 ]; then
+	if [ `sed -e s/$cursiz/nnnn/ -e '/^dtrace: /d' tmp.out | diff - D.out | wc -l` -eq 0 ]; then
 		echo okay: $cursiz is too small
 
 		# bump the size up and try again
@@ -88,7 +87,7 @@ while [ $cursiz -lt $((1024 * 1024 * 1024)) ]; do
 		echo "The default case is expected to have bpflogsize too small"
 		echo "and fail with the expected error."
 		echo "========== output (expected)"
-		sed 's/nnnn/'$cursiz'/' D.out
+		sed -e s/nnnn/$cursiz/ -e '/^dtrace: /d' D.out
 		dump_files
 		exit 1
 	fi
@@ -111,11 +110,11 @@ while [ $cursiz -lt $((1024 * 1024 * 1024)) ]; do
 		echo ERROR: expected only one non-\"BPF:\" output line
 		status=1
 	fi
-	if ! grep -q '^BPF: The sequence of 8193 jumps is too complex.' tmp.out; then
+	if ! grep -q '^BPF: The sequence of [1-9][0-9]* jumps is too complex.' tmp.out; then
 		echo ERROR: BPF error message is missing
 		status=1
 	fi
-	if ! grep -q '^dtrace: could not enable tracing: BPF program load for '\''dtrace:::BEGIN'\'' failed: Bad address' tmp.out; then
+	if ! grep -q '^dtrace: ' tmp.out; then
 		echo ERROR: dtrace error message is missing
 		status=1
 	fi
Signature · 1 line
2.52.0
Reviewed-by on v1 20/20
#1 lore raw

On 30 Oct 2026, Kris Van Hees told this:

Quoted 5 lines

Older kernel BPF verifiers report -EFAULT whereras newer ones report -E2BIG. Support both, and also make the tests more robust if code generation might result in a less predictable jump count.

Hm, this only seems to be loking for *some* error now, without concern for what it was. In particulary it's not looking for -E2BIG at all, But I suppose as long as we're looking for the bpflogsize error message it's OK.

Signature · 1 line
NULL && (void)