mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-09 07:51:59 -09:00
support/testing: add bpftrace test
This commit adds a simple bpftrace test that ensures that not only it
builds fine, but it also runs properly on a minimal test scenario.
Assisted-by: GPT-5.6
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
[Julien:
- reindent emulator.boot() options
- add a call to "bpftrace --version"
]
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit e06cfae9cb)
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
This commit is contained in:
committed by
Raphaël Mélotte
parent
7570d28d0b
commit
29b0486444
@@ -3187,6 +3187,8 @@ F: support/testing/tests/package/sample_python_flask.py
|
||||
F: support/testing/tests/package/sample_python_flask_expects_json.py
|
||||
F: support/testing/tests/package/sample_python_git.py
|
||||
F: support/testing/tests/package/sample_python_unittest_xml_reporting.py
|
||||
F: support/testing/tests/package/test_bpftrace.py
|
||||
F: support/testing/tests/package/test_bpftrace/linux-bpftrace.fragment
|
||||
F: support/testing/tests/package/test_nodejs.py
|
||||
F: support/testing/tests/package/test_python_augeas.py
|
||||
F: support/testing/tests/package/test_python_flask.py
|
||||
|
||||
65
support/testing/tests/package/test_bpftrace.py
Normal file
65
support/testing/tests/package/test_bpftrace.py
Normal file
@@ -0,0 +1,65 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
# gitlab-runner: 2xlarge
|
||||
class TestBpftrace(infra.basetest.BRTest):
|
||||
kern_fragment = infra.filepath(
|
||||
"tests/package/test_bpftrace/linux-bpftrace.fragment"
|
||||
)
|
||||
config = f"""
|
||||
BR2_aarch64=y
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.32"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
|
||||
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{kern_fragment}"
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
|
||||
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||
BR2_PACKAGE_BPFTRACE=y
|
||||
BR2_PACKAGE_TAR=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_ROOTFS_EXT2_4=y
|
||||
BR2_TARGET_ROOTFS_EXT2_SIZE="256M"
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
"""
|
||||
|
||||
def test_run(self):
|
||||
drive = os.path.join(self.builddir, "images", "rootfs.ext4")
|
||||
kern = os.path.join(self.builddir, "images", "Image")
|
||||
self.emulator.boot(
|
||||
arch="aarch64",
|
||||
kernel=kern,
|
||||
kernel_cmdline=["root=/dev/vda console=ttyAMA0"],
|
||||
options=[
|
||||
"-M", "virt",
|
||||
"-cpu", "cortex-a57",
|
||||
"-m", "256M",
|
||||
"-drive", f"file={drive},if=virtio,format=raw"
|
||||
]
|
||||
)
|
||||
self.emulator.login()
|
||||
|
||||
self.assertRunOk("mount -t debugfs none /sys/kernel/debug/")
|
||||
|
||||
# Check the program can run.
|
||||
self.assertRunOk("bpftrace --version")
|
||||
|
||||
# Check that bpftrace can find a syscall tracepoint.
|
||||
self.assertRunOk("bpftrace -l 'tracepoint:syscalls:sys_enter_execve'")
|
||||
|
||||
# Compile and attach a tracepoint program, then trigger it with the
|
||||
# command executed by bpftrace. The marker avoids matching volatile
|
||||
# fields such as PIDs or command names.
|
||||
cmd = (
|
||||
"bpftrace -e 'tracepoint:syscalls:sys_enter_execve "
|
||||
'{ printf("buildroot-bpftrace-test\\n"); exit(); }\' '
|
||||
"-c /bin/true"
|
||||
)
|
||||
output, ret = self.emulator.run(cmd)
|
||||
self.assertEqual(ret, 0)
|
||||
self.assertIn("buildroot-bpftrace-test", "\n".join(output))
|
||||
@@ -0,0 +1,4 @@
|
||||
CONFIG_FTRACE=y
|
||||
CONFIG_FTRACE_SYSCALLS=y
|
||||
CONFIG_FUNCTION_TRACER=y
|
||||
CONFIG_KPROBES=y
|
||||
Reference in New Issue
Block a user