[PATCH] test: account for member name change in mm_struct
Kris Van Hees <[email protected]> Tue, 03 Feb 2026 11:23:30 -0500
| Newsgroups | dev.linux.lists.dtrace |
|---|---|
| Message-ID | <DS0PR10MB7522C34E1C6FA098104E192CC29BA@DS0PR10MB7522.namprd10.prod.outlook.com> |
mm_struct->cpu_bitmap has been renamed mm_struct->flexible_array Add support for both variants. Signed-off-by: Kris Van Hees <[email protected]> --- ....d => tst.ctf-dynsized-bounds-runtime-1.d} | 0 .../tst.ctf-dynsized-bounds-runtime-1.x | 17 +++++++++++++ .../tst.ctf-dynsized-bounds-runtime-2.d | 25 +++++++++++++++++++ .../tst.ctf-dynsized-bounds-runtime-2.x | 17 +++++++++++++ 4 files changed, 59 insertions(+) rename test/unittest/arrays/{tst.ctf-dynsized-bounds-runtime.d => tst.ctf-dynsized-bounds-runtime-1.d} (100%) create mode 100755 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-1.x create mode 100644 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-2.d create mode 100755 test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-2.x diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-1.d similarity index 100% rename from test/unittest/arrays/tst.ctf-dynsized-bounds-runtime.d rename to test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-1.d diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-1.x b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-1.x new file mode 100755 index 00000000..264fa150 --- /dev/null +++ b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-1.x @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. + +# Skip this test if mm_struct does not have a cpu_bitmap member. + +type_id=`bpftool btf dump id 1 | \ + awk '/\047mm_struct\047/ { print int(substr($1, 2)); }'` + +if bpftool btf dump id 1 root_id ${type_id} | grep "'cpu_bitmap'" &>/dev/null; then + exit 0 +fi + +exit 2 diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-2.d b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-2.d new file mode 100644 index 00000000..5e296d60 --- /dev/null +++ b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-2.d @@ -0,0 +1,25 @@ +/* + * Oracle Linux DTrace. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * Licensed under the Universal Permissive License v 1.0 as shown at + * http://oss.oracle.com/licenses/upl. + */ + +/* + * ASSERTION: Array accesses work for CTF-declared arrays of dynamic size + * (ensuring the bounds checking is also bypassed at runtime). + * + * SECTION: Pointers and Arrays/Array Declarations and Storage + */ + +BEGIN +{ + i = pid - pid; /* Non-constant 0 value. */ + trace(curthread->mm->flexible_array[i]); + exit(0); +} + +ERROR +{ + exit(1); +} diff --git a/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-2.x b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-2.x new file mode 100755 index 00000000..17aa06df --- /dev/null +++ b/test/unittest/arrays/tst.ctf-dynsized-bounds-runtime-2.x @@ -0,0 +1,17 @@ +#!/bin/bash +# +# Oracle Linux DTrace. +# Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved. +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. + +# Skip this test if mm_struct does not have a flexible_array member. + +type_id=`bpftool btf dump id 1 | \ + awk '/\047mm_struct\047/ { print int(substr($1, 2)); }'` + +if bpftool btf dump id 1 root_id ${type_id} | grep "'flexible_array'" &>/dev/null; then + exit 0 +fi + +exit 2 -- 2.51.0