From nobody Tue Sep 29 09:08:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFFBA29993F; Mon, 10 Aug 2026 09:33:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786354440; cv=none; b=K2urXPVHh0K99LHlFPxSLKfqTAvTeqsB4XmwhwZaxn3iOXVUfoW6mcOfvBL+S6HeGt5rQhdQcFP5NeAYqxYrPz1HPXFyzpIsTlNWg2bF2bIq/7COUhmKLjTwwvWI6C7YNoD0clv/zIruJyVY2AReNDlhKMFqngjXBawlkJkFkhg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786354440; c=relaxed/simple; bh=eW4yPk+rWH2EowfFx42tM/POPOErG4544DDWjuHLB0U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QStOXh8tOq0Q/mv+OE2PM8boq/jpfrJf3y77jD3B1mmk6j59qQuXYrIk8JzCtB1E4ItsVL5GJQvLw3jEFsRqdgOfN1qpM5Rgsnbj5fqrsXt4+6qFbQQuTQcOomK0tdSyQuCrI3JqbtA/Q5txxZm9Nf4e2hZLzOw9AUEyau5qkSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HAVm3ef5; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HAVm3ef5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 922F71F000E9; Mon, 10 Aug 2026 09:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786354438; bh=ymSt9ETFGvvWPMZYPgcyiS5XgIu6nNyGU1kd4eBvaqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HAVm3ef52eJieXHznjLdqRMBxjuUlopEQ2DlKUEb6DDPztmof9MibexX3y92YDfyJ JeYAsMMHuW7cs7m71kYkbMEIdLSYWn/jmpug8LqYxK6FQ6o9cJ7281qpnkU5HB92Hf 1OoyHpXUQFzYIni5TnY3Ec26IKwB+0zb+Ck4SBnFywXdKO6E1MkkjY6k97kw3oPC1i ocxk81lWVs9XOfRtDR+b15oAQURdINm28EBcBtQ2piV+LKHFgOprB0zi9hSFd+4jyF RBAa2OvmT/Mps8P71rDwLHWn6Qi57Q1VpVGYnG1ineAeAGYB20GcN+fUeK5DRAnfnh VcIfk1gT77N7w== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Masami Hiramatsu , Shuah Khan Cc: Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 1/4] selftests/ftrace: Add generic boot tracing test framework Date: Mon, 10 Aug 2026 18:33:54 +0900 Message-ID: <178635443424.380779.5002507769150817514.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <178635442508.380779.3709136256425432083.stgit@devnote2> References: <178635442508.380779.3709136256425432083.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Masami Hiramatsu (Google) Add a generic test framework under tools/testing/selftests/ftrace/boottime/ to verify kernel boot tracing configurations (bootconfig, kernel command-line tracing options, and persistent ring buffers) during early boot. The test runner (run_boottime_test.sh) sources ktap_helpers.sh to generate output in TAP version 13 format. It builds a minimal initramfs with busybox, dynamically resolves test specifications (.bconf for bootconfig, .cmdline for kernel boot parameters, .qemuopts for QEMU options, and # REBOOT: 1 for multi-boot crash/reboot tests with doubled timeout), boots QEMU, and runs corresponding tracefs checker scripts. Assisted-by: Antigravity:gemini-3.6-flash Signed-off-by: Masami Hiramatsu (Google) --- tools/testing/selftests/ftrace/Makefile | 2=20 tools/testing/selftests/ftrace/boottime/Makefile | 10 + tools/testing/selftests/ftrace/boottime/README | 71 ++++ .../selftests/ftrace/boottime/run_boottime_test.sh | 373 ++++++++++++++++= ++++ tools/testing/selftests/ftrace/config | 6=20 5 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/ftrace/boottime/Makefile create mode 100644 tools/testing/selftests/ftrace/boottime/README create mode 100755 tools/testing/selftests/ftrace/boottime/run_boottime_te= st.sh diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selfte= sts/ftrace/Makefile index 7c12263f8260..8d8881744149 100644 --- a/tools/testing/selftests/ftrace/Makefile +++ b/tools/testing/selftests/ftrace/Makefile @@ -3,7 +3,7 @@ all: =20 TEST_PROGS_EXTENDED :=3D ftracetest TEST_PROGS :=3D ftracetest-ktap -TEST_FILES :=3D test.d settings +TEST_FILES :=3D test.d settings boottime EXTRA_CLEAN :=3D $(OUTPUT)/logs/* =20 TEST_GEN_FILES :=3D poll diff --git a/tools/testing/selftests/ftrace/boottime/Makefile b/tools/testi= ng/selftests/ftrace/boottime/Makefile new file mode 100644 index 000000000000..fd0975350f10 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/Makefile @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0 + +all: + +run_tests: + @./run_boottime_test.sh + +clean: + +.PHONY: all run_tests clean diff --git a/tools/testing/selftests/ftrace/boottime/README b/tools/testing= /selftests/ftrace/boottime/README new file mode 100644 index 000000000000..85d7ec5c6670 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/README @@ -0,0 +1,71 @@ +Boot Tracing Test Suite +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +This directory contains an automated test framework to verify kernel boot +tracing configurations (bootconfig, kernel command-line tracing options, a= nd +persistent ring buffers) during early boot. + +Overview +-------- +The test runner (`run_boottime_test.sh`) constructs a lightweight initramf= s with +busybox and a tracefs checker script from `tests/`, attaches optional boot= configs +from `bootconfigs/` using the `bootconfig` tool, applies optional command-= line +parameters from `cmdlines/`, boots the target kernel image under QEMU, and= reports +results according to TAP version 13 format. + +Test Specification Format +------------------------- +For each test script `tests/.sh`, the harness dynamically detects: +- `bootconfigs/.bconf` or `.bconf`: Bootconfig configuration f= ile. +- `cmdlines/.cmdline` or `# CMDLINE: ` header in script: Kerne= l boot parameters. +- `qemuopts/.qemuopts` or `# QEMUOPTS: ` header in script: Add= itional QEMU CLI arguments. +- `# REBOOT: 1` header in script: Multi-boot reboot/crash test mode (omits= `-no-reboot` and doubles timeout). + +Required Tools +-------------- +- Host Architecture: x86 (x86_64/i686/i386/x86; tests skip on non-x86 host= s) +- `qemu-system-x86_64` (or custom QEMU executable) +- `busybox` (host binary at `/usr/bin/busybox` or custom path) +- `bootconfig` (compiled from `tools/bootconfig/bootconfig` or in PATH) +- `cpio` (standard archiver) + +Required Kernel Configurations +------------------------------ +The kernel binary under test must be compiled with: +- `CONFIG_BOOT_CONFIG=3Dy` +- `CONFIG_BOOTTIME_TRACING=3Dy` +- `CONFIG_MAGIC_SYSRQ=3Dy` (for guest reboot and poweroff) + +Additional feature-specific config options enable respective testcases: +- `CONFIG_KPROBE_EVENTS=3Dy` (for kprobe tests) +- `CONFIG_SYNTH_EVENTS=3Dy` (for synthetic event tests) +- `CONFIG_EPROBE_EVENTS=3Dy` (for eprobe tests) +- `CONFIG_FPROBE_EVENTS=3Dy` (for fprobe and tracepoint probe tests) +- `CONFIG_FUNCTION_TRACER=3Dy` (for tracer options) +- `CONFIG_RESERVE_MEM=3Dy` (for persistent ring buffer tests) + +Usage +----- +To run all test cases with a compiled kernel image: + + $ ./run_boottime_test.sh -k /path/to/bzImage + +To run a specific test case (e.g. `01-kprobe`): + + $ ./run_boottime_test.sh -k /path/to/bzImage -t 01-kprobe + +Customizing Tool Paths: + + $ ./run_boottime_test.sh -b /path/to/bootconfig \ + -k /path/to/bzImage \ + -q /path/to/qemu-system-x86_64 \ + -B /path/to/busybox + +Environment Variables +--------------------- +Tool locations and kernel paths can also be set via environment variables: +- `BOOTCONFIG`: Path to the `bootconfig` tool +- `KERNEL`: Path to the `bzImage` kernel binary +- `QEMU`: Path to the QEMU binary +- `BUSYBOX`: Path to the `busybox` binary +- `LOGDIR`: Directory path to preserve QEMU execution log files diff --git a/tools/testing/selftests/ftrace/boottime/run_boottime_test.sh b= /tools/testing/selftests/ftrace/boottime/run_boottime_test.sh new file mode 100755 index 000000000000..5e9c2b984808 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/run_boottime_test.sh @@ -0,0 +1,373 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# +# Generic Boot Tracing Test Harness +# Builds a lightweight initramfs, applies bootconfigs and kernel cmdline p= arameters, +# boots QEMU, and verifies tracefs configuration using test scripts. + +set -e + +SCRIPT_DIR=3D"$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +if [ -d "$SCRIPT_DIR/boottime" ]; then + SCRIPT_DIR=3D"$SCRIPT_DIR/boottime" +fi +KERNEL_SRC=3D"$(cd "$SCRIPT_DIR/../../../../.." && pwd)" + +# Source KTAP helpers +if [ -f "$SCRIPT_DIR/../../kselftest/ktap_helpers.sh" ]; then + KSELFTEST_DIR=3D"$(cd "$SCRIPT_DIR/../../kselftest" && pwd)" +elif [ -f "$SCRIPT_DIR/../kselftest/ktap_helpers.sh" ]; then + KSELFTEST_DIR=3D"$(cd "$SCRIPT_DIR/../kselftest" && pwd)" +else + echo "Error: ktap_helpers.sh not found relative to $SCRIPT_DIR" >&2 + exit 1 +fi +. "$KSELFTEST_DIR/ktap_helpers.sh" + +BOOTCONFIG=3D"${BOOTCONFIG:-"$KERNEL_SRC/tools/bootconfig/bootconfig"}" +KERNEL=3D"${KERNEL:-"$KERNEL_SRC/arch/x86/boot/bzImage"}" +QEMU=3D"${QEMU:-"qemu-system-x86_64"}" +BUSYBOX=3D"${BUSYBOX:-"$(which busybox 2>/dev/null || echo "/usr/bin/busyb= ox")"}" +TIMEOUT=3D"${TIMEOUT:-60s}" +LOGDIR=3D"${LOGDIR:-""}" +TARGET_TEST=3D"all" + +usage() { + echo "Usage: $0 [options]" + echo "Options:" + echo " -b, --bootconfig PATH Path to bootconfig tool (default: $BOOTCO= NFIG)" + echo " -k, --kernel PATH Path to kernel image (default: $KERNEL)" + echo " -q, --qemu PATH Path to QEMU executable (default: $QEMU)" + echo " -B, --busybox PATH Path to busybox binary (default: $BUSYBOX= )" + echo " -T, --timeout DURATION QEMU execution timeout (default: $TIMEOUT= )" + echo " -l, --logdir DIR Directory to save QEMU log files" + echo " -t, --test NAME Run specific test (e.g. 01-kprobe) or 'al= l'" + echo " -h, --help Show this help message" + exit 1 +} + +while [ $# -gt 0 ]; do + case "$1" in + -b|--bootconfig) + BOOTCONFIG=3D"$2" + shift 2 + ;; + -k|--kernel) + KERNEL=3D"$2" + shift 2 + ;; + -q|--qemu) + QEMU=3D"$2" + shift 2 + ;; + -B|--busybox) + BUSYBOX=3D"$2" + shift 2 + ;; + -T|--timeout) + TIMEOUT=3D"$2" + shift 2 + ;; + -l|--logdir) + LOGDIR=3D"$2" + shift 2 + ;; + -t|--test) + TARGET_TEST=3D"$2" + shift 2 + ;; + -h|--help) + usage + ;; + *) + echo "Unknown option: $1" + usage + ;; + esac +done + +# Check host architecture +HOST_ARCH=3D"$(uname -m)" +case "$HOST_ARCH" in + x86_64|i686|i386|x86) + ;; + *) + if [ "$KERNEL" =3D "$KERNEL_SRC/arch/x86/boot/bzImage" ]; then + ktap_print_header + ktap_skip_all \ + "Default boot tracing test is x86 only ($HOST_ARCH)" + exit 0 + fi + ;; +esac + +# Ensure bootconfig tool is built if Makefile exists +if [ ! -x "$BOOTCONFIG" ]; then + if [ -f "$KERNEL_SRC/tools/bootconfig/Makefile" ]; then + make -C "$KERNEL_SRC/tools/bootconfig" > /dev/null 2>&1 || true + fi + if [ ! -x "$BOOTCONFIG" ]; then + BOOTCONFIG=3D"$(which bootconfig 2>/dev/null || true)" + fi +fi + +if [ ! -x "$BOOTCONFIG" ]; then + ktap_print_header + ktap_skip_all "bootconfig tool not found at $BOOTCONFIG" + exit 0 +fi + +if [ ! -f "$KERNEL" ]; then + ktap_print_header + ktap_skip_all "Kernel image not found at $KERNEL" + exit 0 +fi + +if ! command -v "$QEMU" >/dev/null 2>&1; then + ktap_print_header + ktap_skip_all "QEMU binary not found: $QEMU" + exit 0 +fi + +if [ ! -x "$BUSYBOX" ]; then + ktap_print_header + ktap_skip_all "busybox binary not found at $BUSYBOX" + exit 0 +fi + +# Verify busybox architecture compatibility +if command -v file >/dev/null 2>&1; then + BUSYBOX_INFO=3D"$(file -b "$BUSYBOX" 2>/dev/null || true)" + case "$KERNEL" in + *x86*) + case "$BUSYBOX_INFO" in + *x86-64*|*x86_64*|*80386*|*i386*) + ;; + *) + ktap_print_header + ktap_skip_all \ + "busybox binary architecture is incompatible with x86 kernel ($BUSYB= OX_INFO)" + exit 0 + ;; + esac + ;; + esac +fi + +if ! command -v cpio >/dev/null 2>&1; then + ktap_print_header + ktap_skip_all "cpio tool not found" + exit 0 +fi + +HAS_TIMEOUT=3D0 +if command -v timeout >/dev/null 2>&1; then + HAS_TIMEOUT=3D1 +fi + +double_timeout() { + local val=3D"$1" + if [[ "$val" =3D~ ^([0-9]+)([a-z]*)$ ]]; then + local num=3D"${BASH_REMATCH[1]}" + local unit=3D"${BASH_REMATCH[2]}" + echo "$((num * 2))$unit" + else + echo "120s" + fi +} + +run_single_test() { + local test_script=3D"$1" + local name + local dir + name=3D"$(basename "$test_script" .sh)" + dir=3D"$(dirname "$test_script")" + + local bconf_file=3D"" + if [ -f "$SCRIPT_DIR/bootconfigs/$name.bconf" ]; then + bconf_file=3D"$SCRIPT_DIR/bootconfigs/$name.bconf" + elif [ -f "$dir/$name.bconf" ]; then + bconf_file=3D"$dir/$name.bconf" + fi + + local test_cmdline=3D"" + if [ -f "$SCRIPT_DIR/cmdlines/$name.cmdline" ]; then + test_cmdline=3D"$(cat "$SCRIPT_DIR/cmdlines/$name.cmdline")" + elif [ -f "$dir/$name.cmdline" ]; then + test_cmdline=3D"$(cat "$dir/$name.cmdline")" + fi + + local inline_cmdline + inline_cmdline=3D"$(grep -E '^# *CMDLINE:' "$test_script" | sed 's/^# *CM= DLINE://' | xargs || true)" + if [ -n "$inline_cmdline" ]; then + test_cmdline=3D"$test_cmdline $inline_cmdline" + fi + + local test_qemuopts=3D"" + if [ -f "$SCRIPT_DIR/qemuopts/$name.qemuopts" ]; then + test_qemuopts=3D"$(cat "$SCRIPT_DIR/qemuopts/$name.qemuopts")" + elif [ -f "$dir/$name.qemuopts" ]; then + test_qemuopts=3D"$(cat "$dir/$name.qemuopts")" + fi + + local inline_qemuopts + inline_qemuopts=3D"$(grep -E '^# *QEMUOPTS:' "$test_script" | sed 's/^# *= QEMUOPTS://' | xargs || true)" + if [ -n "$inline_qemuopts" ]; then + test_qemuopts=3D"$test_qemuopts $inline_qemuopts" + fi + + local test_timeout=3D"$TIMEOUT" + local inline_timeout + inline_timeout=3D"$(grep -E '^# *TIMEOUT:' "$test_script" | sed 's/^# *TI= MEOUT://' | xargs || true)" + if [ -n "$inline_timeout" ]; then + test_timeout=3D"$inline_timeout" + fi + + local is_reboot=3D0 + if grep -q -E '^# *REBOOT: *1' "$test_script" || [ -f "$dir/$name.reboot"= ]; then + is_reboot=3D1 + fi + + local effective_timeout=3D"$test_timeout" + if [ "$is_reboot" -eq 1 ]; then + effective_timeout=3D"$(double_timeout "$test_timeout")" + fi + + local workdir + workdir=3D"$(mktemp -d)" + if [ -z "$workdir" ] || [ ! -d "$workdir" ]; then + ktap_test_fail "$name (failed to create temporary directory)" + return 0 + fi + trap 'rm -rf "$workdir"' EXIT + + local rootfs=3D"$workdir/rootfs" + mkdir -p "$rootfs"/{bin,sbin,etc,proc,sys,dev,tmp} + + cp "$BUSYBOX" "$rootfs/bin/busybox" + chmod +x "$rootfs/bin/busybox" + (cd "$rootfs/bin" && for applet in sh cat mount umount echo sync reboot \ + poweroff cpio grep; do ln -s busybox $applet; done) + + if command -v ldd >/dev/null 2>&1; then + for lib in $(ldd "$BUSYBOX" 2>/dev/null | grep -o '/[^ ]*' || true); do + if [ -f "$lib" ]; then + mkdir -p "$rootfs$(dirname "$lib")" + cp -L "$lib" "$rootfs$lib" 2>/dev/null || true + fi + done + fi + + cat << 'EOF' > "$rootfs/init" +#!/bin/sh +mount -t proc proc /proc 2>/dev/null +mount -t sysfs sys /sys 2>/dev/null +mount -t tracefs nodev /sys/kernel/tracing 2>/dev/null + +/bin/check_test.sh +RET=3D$? + +if [ $RET -eq 0 ]; then + echo "TEST RESULT: PASS" +else + echo "TEST RESULT: FAIL" +fi +sync +echo o > /proc/sysrq-trigger 2>/dev/null || true +poweroff -f 2>/dev/null || reboot -f 2>/dev/null || true +while true; do sleep 100; done +EOF + chmod +x "$rootfs/init" + + cp "$test_script" "$rootfs/bin/check_test.sh" + chmod +x "$rootfs/bin/check_test.sh" + + local initramfs=3D"$workdir/initramfs.cpio" + (cd "$rootfs" && find . | cpio -o -H newc --quiet) > "$initramfs" + + if [ -n "$bconf_file" ] && [ -f "$bconf_file" ]; then + "$BOOTCONFIG" -a "$bconf_file" "$initramfs" > /dev/null + fi + + local timeout_cmd=3D"" + if [ "$HAS_TIMEOUT" -eq 1 ]; then + timeout_cmd=3D"timeout $effective_timeout" + fi + + local logfile + local base_cmdline=3D"bootconfig console=3Dtty0 console=3DttyS0 panic=3D-= 1" + if [ -n "$test_cmdline" ]; then + base_cmdline=3D"$base_cmdline $test_cmdline" + fi + + if [ -n "$LOGDIR" ]; then + mkdir -p "$LOGDIR" + logfile=3D"$LOGDIR/$name.log" + base_cmdline=3D"$base_cmdline dump_bconf" + else + logfile=3D"$workdir/qemu.log" + base_cmdline=3D"quiet $base_cmdline" + fi + + local qemu_args=3D() + if [ -n "$test_qemuopts" ]; then + read -r -a qemu_args <<< "$test_qemuopts" + fi + + if [ "$is_reboot" -ne 1 ]; then + qemu_args+=3D("-no-reboot") + fi + + $timeout_cmd "$QEMU" -kernel "$KERNEL" \ + -initrd "$initramfs" \ + -append "$base_cmdline" \ + -display none \ + -serial stdio \ + "${qemu_args[@]}" < /dev/null > "$logfile" 2>&1 || true + + if grep -q "TEST RESULT: PASS" "$logfile"; then + ktap_test_pass "$name" + else + ktap_test_fail "$name" + ktap_print_msg "QEMU Console Output for $name:" + while IFS=3D read -r line; do + ktap_print_msg "$line" + done < "$logfile" + fi + + rm -rf "$workdir" + trap - EXIT + return 0 +} + +TEST_SCRIPTS=3D() +if [ -d "$SCRIPT_DIR/tests" ]; then + while IFS=3D read -r f; do + [ -n "$f" ] && TEST_SCRIPTS+=3D("$f") + done < <(find "$SCRIPT_DIR/tests" -type f -name "*.sh" | sort) +fi + +TOTAL_TESTS=3D0 +for test_script in "${TEST_SCRIPTS[@]}"; do + name=3D"$(basename "$test_script" .sh)" + if [ "$TARGET_TEST" !=3D "all" ] && [ "$TARGET_TEST" !=3D "$name" ]; then + continue + fi + TOTAL_TESTS=3D$((TOTAL_TESTS + 1)) +done + +ktap_print_header +ktap_set_plan "$TOTAL_TESTS" + +for test_script in "${TEST_SCRIPTS[@]}"; do + name=3D"$(basename "$test_script" .sh)" + + if [ "$TARGET_TEST" !=3D "all" ] && [ "$TARGET_TEST" !=3D "$name" ]; then + continue + fi + + run_single_test "$test_script" +done + +ktap_finished diff --git a/tools/testing/selftests/ftrace/config b/tools/testing/selftest= s/ftrace/config index 544de0db5f58..29f05f7c6e2c 100644 --- a/tools/testing/selftests/ftrace/config +++ b/tools/testing/selftests/ftrace/config @@ -1,3 +1,5 @@ +CONFIG_BOOT_CONFIG=3Dy +CONFIG_BOOTTIME_TRACING=3Dy CONFIG_BPF_SYSCALL=3Dy CONFIG_DEBUG_INFO_BTF=3Dy CONFIG_DEBUG_INFO_DWARF4=3Dy @@ -8,22 +10,26 @@ CONFIG_FTRACE=3Dy CONFIG_FTRACE_SYSCALLS=3Dy CONFIG_FUNCTION_GRAPH_RETVAL=3Dy CONFIG_FUNCTION_PROFILER=3Dy +CONFIG_FUNCTION_TRACER=3Dy CONFIG_HIST_TRIGGERS=3Dy CONFIG_IRQSOFF_TRACER=3Dy CONFIG_KALLSYMS_ALL=3Dy CONFIG_KPROBES=3Dy CONFIG_KPROBE_EVENTS=3Dy +CONFIG_MAGIC_SYSRQ=3Dy CONFIG_MODULES=3Dy CONFIG_MODULE_UNLOAD=3Dy CONFIG_PREEMPTIRQ_DELAY_TEST=3Dm CONFIG_PREEMPT_TRACER=3Dy CONFIG_PROBE_EVENTS_BTF_ARGS=3Dy +CONFIG_RESERVE_MEM=3Dy CONFIG_SAMPLES=3Dy CONFIG_SAMPLE_FTRACE_DIRECT=3Dm CONFIG_SAMPLE_TRACE_EVENTS=3Dm CONFIG_SAMPLE_TRACE_PRINTK=3Dm CONFIG_SCHED_TRACER=3Dy CONFIG_STACK_TRACER=3Dy +CONFIG_SYNTH_EVENTS=3Dy CONFIG_TRACER_SNAPSHOT=3Dy CONFIG_UPROBES=3Dy CONFIG_UPROBE_EVENTS=3Dy From nobody Tue Sep 29 09:08:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 708873612E0; Mon, 10 Aug 2026 09:34:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786354449; cv=none; b=jF5tDBG3GOW17ogRu6pZ++uLrpIfC32F9lVp8Hu3LZUiDWWbnfAGLHIZuMcN4suyq2t4xczbJkFuK4r5AyrfzngduUwJo6nkyCukOhU+IBZEPTJnhiUmqQ2fD1JwlIoQrEze8fgz4NkPqlrsWH+zg0xrAMnoVyPzxam6OsbtLPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786354449; c=relaxed/simple; bh=s9W90EukrfC9rhIckxKAWYAjrTJKR308zNW6FQCO9KU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k+IRhMff5vkHyEOLAgVOq2G7jEOt+QKVRmwF0CwHxnV3E0MlsYk9J4NMxaJsKAK7WLoUgPV9BlfY7kJ45lFB+M47z6N7qlEht4Wma8EA/iVYsstkZ/vGrCLo1xTcbUQ/NMZwzAN1Sq7AjNM5zSQOZxJ7KVGksV+85nEUdcjy9yI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=izJ8MGdE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="izJ8MGdE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04DBA1F000E9; Mon, 10 Aug 2026 09:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786354447; bh=8rhLh4T/FGEzcoW4SaLoVPimMTJUUICBdRkRnALrYRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=izJ8MGdEeig/0/Z4UF1vvaMhvFr0GMp9k7EtougMQczt7wVJzKGzWFuQW3dh4t7x5 8ip4lUN5HQo3w/t6G909/WokTTsN4fw8V1g3vkgrCxp194gIcdPBJ6Pkm5ztSLltd3 nK8cq8nQXtr5o6iqk45TZZDI7TaAg31L2U17OQToakQoux5q37PWtoi3mFc9HRZRqU a4Q5nAoQHFpzPGsRNTrzBAMmJOHhPI7nz8jNeI4fU0uxWE2F/fOIVsA5rNOmLfyHZ9 4CvPSi6wOjg0hRkcMtIZf3fces5/Pk2KIHNADMRV4Stdxdnz+iYFF36E3QXqzQ/RE0 lhMNo02F/R9sQ== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Masami Hiramatsu , Shuah Khan Cc: Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 2/4] selftests/ftrace: Add boot-time tracing testcases Date: Mon, 10 Aug 2026 18:34:03 +0900 Message-ID: <178635444365.380779.6077913945595364034.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <178635442508.380779.3709136256425432083.stgit@devnote2> References: <178635442508.380779.3709136256425432083.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Masami Hiramatsu (Google) Add test cases for boot-time tracing configuration via bootconfig (see Documentation/trace/boottime-trace.rst). These test cases verify: - 01-kprobe: Dynamic kprobe events via bootconfig - 02-synth: Synthetic events via bootconfig - 03-eprobe: Event probes (eprobes) via bootconfig - 04-fprobe: Function probes (fprobes) via bootconfig - 05-tprobe: Tracepoint probes via bootconfig - 06-instance: Custom trace instances via bootconfig Assisted-by: Antigravity:gemini-3.6-flash Signed-off-by: Masami Hiramatsu (Google) --- .../ftrace/boottime/bootconfigs/01-kprobe.bconf | 4 +++ .../ftrace/boottime/bootconfigs/02-synth.bconf | 4 +++ .../ftrace/boottime/bootconfigs/03-eprobe.bconf | 4 +++ .../ftrace/boottime/bootconfigs/04-fprobe.bconf | 4 +++ .../ftrace/boottime/bootconfigs/05-tprobe.bconf | 4 +++ .../ftrace/boottime/bootconfigs/06-instance.bconf | 5 +++ .../selftests/ftrace/boottime/tests/01-kprobe.sh | 25 +++++++++++++++++ .../selftests/ftrace/boottime/tests/02-synth.sh | 25 +++++++++++++++++ .../selftests/ftrace/boottime/tests/03-eprobe.sh | 25 +++++++++++++++++ .../selftests/ftrace/boottime/tests/04-fprobe.sh | 25 +++++++++++++++++ .../selftests/ftrace/boottime/tests/05-tprobe.sh | 25 +++++++++++++++++ .../selftests/ftrace/boottime/tests/06-instance.sh | 30 ++++++++++++++++= ++++ 12 files changed, 180 insertions(+) create mode 100644 tools/testing/selftests/ftrace/boottime/bootconfigs/01-= kprobe.bconf create mode 100644 tools/testing/selftests/ftrace/boottime/bootconfigs/02-= synth.bconf create mode 100644 tools/testing/selftests/ftrace/boottime/bootconfigs/03-= eprobe.bconf create mode 100644 tools/testing/selftests/ftrace/boottime/bootconfigs/04-= fprobe.bconf create mode 100644 tools/testing/selftests/ftrace/boottime/bootconfigs/05-= tprobe.bconf create mode 100644 tools/testing/selftests/ftrace/boottime/bootconfigs/06-= instance.bconf create mode 100644 tools/testing/selftests/ftrace/boottime/tests/01-kprobe= .sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/02-synth.= sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/03-eprobe= .sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/04-fprobe= .sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/05-tprobe= .sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/06-instan= ce.sh diff --git a/tools/testing/selftests/ftrace/boottime/bootconfigs/01-kprobe.= bconf b/tools/testing/selftests/ftrace/boottime/bootconfigs/01-kprobe.bconf new file mode 100644 index 000000000000..13d30d1e51a6 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/bootconfigs/01-kprobe.bconf @@ -0,0 +1,4 @@ +ftrace.event.kprobes.vfs_read { + probes =3D "vfs_read $arg1" + enable +} diff --git a/tools/testing/selftests/ftrace/boottime/bootconfigs/02-synth.b= conf b/tools/testing/selftests/ftrace/boottime/bootconfigs/02-synth.bconf new file mode 100644 index 000000000000..b1f37713f33c --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/bootconfigs/02-synth.bconf @@ -0,0 +1,4 @@ +ftrace.event.synthetic.boot_lat { + fields =3D "unsigned long id", "u64 delta" + enable +} diff --git a/tools/testing/selftests/ftrace/boottime/bootconfigs/03-eprobe.= bconf b/tools/testing/selftests/ftrace/boottime/bootconfigs/03-eprobe.bconf new file mode 100644 index 000000000000..c1a8138e605d --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/bootconfigs/03-eprobe.bconf @@ -0,0 +1,4 @@ +ftrace.event.eprobes.ep_read { + probes =3D "sched/sched_switch" + enable +} diff --git a/tools/testing/selftests/ftrace/boottime/bootconfigs/04-fprobe.= bconf b/tools/testing/selftests/ftrace/boottime/bootconfigs/04-fprobe.bconf new file mode 100644 index 000000000000..82ae2ac0629f --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/bootconfigs/04-fprobe.bconf @@ -0,0 +1,4 @@ +ftrace.event.fprobes.fp_read { + probes =3D "vfs_read" + enable +} diff --git a/tools/testing/selftests/ftrace/boottime/bootconfigs/05-tprobe.= bconf b/tools/testing/selftests/ftrace/boottime/bootconfigs/05-tprobe.bconf new file mode 100644 index 000000000000..02a2803c770a --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/bootconfigs/05-tprobe.bconf @@ -0,0 +1,4 @@ +ftrace.event.tracepoints.tp_sched { + probes =3D "sched_switch" + enable +} diff --git a/tools/testing/selftests/ftrace/boottime/bootconfigs/06-instanc= e.bconf b/tools/testing/selftests/ftrace/boottime/bootconfigs/06-instance.b= conf new file mode 100644 index 000000000000..3fdb6717afe2 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/bootconfigs/06-instance.bconf @@ -0,0 +1,5 @@ +ftrace.instance.foo { + event.sched.sched_switch { + enable + } +} diff --git a/tools/testing/selftests/ftrace/boottime/tests/01-kprobe.sh b/t= ools/testing/selftests/ftrace/boottime/tests/01-kprobe.sh new file mode 100644 index 000000000000..6ed7caca4c5f --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/01-kprobe.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check kprobe bootconfig settings on tracefs +TRACEDIR=3D"/sys/kernel/tracing" + +if [ -f /proc/bootconfig ] && grep -q "dump_bconf" /proc/cmdline 2>/dev/nu= ll; then + echo "=3D=3D=3D /proc/bootconfig =3D=3D=3D" + cat /proc/bootconfig + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D" +fi + +if [ ! -d "$TRACEDIR/events/kprobes/vfs_read" ]; then + echo "FAIL: kprobe event kprobes/vfs_read does not exist" + exit 1 +fi + +ENABLE=3D$(cat "$TRACEDIR/events/kprobes/vfs_read/enable") +if [ "$ENABLE" !=3D "1" ]; then + echo "FAIL: kprobe event kprobes/vfs_read is not enabled ($ENABLE)" + exit 1 +fi + +echo "PASS: 01-kprobe" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/02-synth.sh b/to= ols/testing/selftests/ftrace/boottime/tests/02-synth.sh new file mode 100644 index 000000000000..745c328dde15 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/02-synth.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check synthetic event bootconfig settings on tracefs +TRACEDIR=3D"/sys/kernel/tracing" + +if [ -f /proc/bootconfig ] && grep -q "dump_bconf" /proc/cmdline 2>/dev/nu= ll; then + echo "=3D=3D=3D /proc/bootconfig =3D=3D=3D" + cat /proc/bootconfig + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D" +fi + +if [ ! -d "$TRACEDIR/events/synthetic/boot_lat" ]; then + echo "FAIL: synthetic event synthetic/boot_lat does not exist" + exit 1 +fi + +ENABLE=3D$(cat "$TRACEDIR/events/synthetic/boot_lat/enable") +if [ "$ENABLE" !=3D "1" ]; then + echo "FAIL: synthetic event synthetic/boot_lat is not enabled ($ENABLE)" + exit 1 +fi + +echo "PASS: 02-synth" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/03-eprobe.sh b/t= ools/testing/selftests/ftrace/boottime/tests/03-eprobe.sh new file mode 100644 index 000000000000..9b3b7ab23c69 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/03-eprobe.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check eprobe event bootconfig settings on tracefs +TRACEDIR=3D"/sys/kernel/tracing" + +if [ -f /proc/bootconfig ] && grep -q "dump_bconf" /proc/cmdline 2>/dev/nu= ll; then + echo "=3D=3D=3D /proc/bootconfig =3D=3D=3D" + cat /proc/bootconfig + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D" +fi + +if [ ! -d "$TRACEDIR/events/eprobes/ep_read" ]; then + echo "FAIL: eprobe event eprobes/ep_read does not exist" + exit 1 +fi + +ENABLE=3D$(cat "$TRACEDIR/events/eprobes/ep_read/enable") +if [ "$ENABLE" !=3D "1" ]; then + echo "FAIL: eprobe event eprobes/ep_read is not enabled ($ENABLE)" + exit 1 +fi + +echo "PASS: 03-eprobe" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/04-fprobe.sh b/t= ools/testing/selftests/ftrace/boottime/tests/04-fprobe.sh new file mode 100644 index 000000000000..27e090c28a4b --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/04-fprobe.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check fprobe event bootconfig settings on tracefs +TRACEDIR=3D"/sys/kernel/tracing" + +if [ -f /proc/bootconfig ] && grep -q "dump_bconf" /proc/cmdline 2>/dev/nu= ll; then + echo "=3D=3D=3D /proc/bootconfig =3D=3D=3D" + cat /proc/bootconfig + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D" +fi + +if [ ! -d "$TRACEDIR/events/fprobes/fp_read" ]; then + echo "FAIL: fprobe event fprobes/fp_read does not exist" + exit 1 +fi + +ENABLE=3D$(cat "$TRACEDIR/events/fprobes/fp_read/enable") +if [ "$ENABLE" !=3D "1" ]; then + echo "FAIL: fprobe event fprobes/fp_read is not enabled ($ENABLE)" + exit 1 +fi + +echo "PASS: 04-fprobe" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/05-tprobe.sh b/t= ools/testing/selftests/ftrace/boottime/tests/05-tprobe.sh new file mode 100644 index 000000000000..810d34055f94 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/05-tprobe.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check tracepoint probe event bootconfig settings on tracefs +TRACEDIR=3D"/sys/kernel/tracing" + +if [ -f /proc/bootconfig ] && grep -q "dump_bconf" /proc/cmdline 2>/dev/nu= ll; then + echo "=3D=3D=3D /proc/bootconfig =3D=3D=3D" + cat /proc/bootconfig + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D" +fi + +if [ ! -d "$TRACEDIR/events/tracepoints/tp_sched" ]; then + echo "FAIL: tracepoint probe event tracepoints/tp_sched does not exist" + exit 1 +fi + +ENABLE=3D$(cat "$TRACEDIR/events/tracepoints/tp_sched/enable") +if [ "$ENABLE" !=3D "1" ]; then + echo "FAIL: tracepoint probe event tracepoints/tp_sched is not enabled ($= ENABLE)" + exit 1 +fi + +echo "PASS: 05-tprobe" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/06-instance.sh b= /tools/testing/selftests/ftrace/boottime/tests/06-instance.sh new file mode 100644 index 000000000000..f6e8519912e4 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/06-instance.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check instance bootconfig settings on tracefs +TRACEDIR=3D"/sys/kernel/tracing" + +if [ -f /proc/bootconfig ] && grep -q "dump_bconf" /proc/cmdline 2>/dev/nu= ll; then + echo "=3D=3D=3D /proc/bootconfig =3D=3D=3D" + cat /proc/bootconfig + echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D" +fi + +if [ ! -d "$TRACEDIR/instances/foo" ]; then + echo "FAIL: trace instance foo does not exist" + exit 1 +fi + +if [ ! -d "$TRACEDIR/instances/foo/events/sched/sched_switch" ]; then + echo "FAIL: event sched_switch does not exist in instance foo" + exit 1 +fi + +ENABLE=3D$(cat "$TRACEDIR/instances/foo/events/sched/sched_switch/enable") +if [ "$ENABLE" !=3D "1" ]; then + echo "FAIL: event sched_switch is not enabled in instance foo ($ENABLE)" + exit 1 +fi + +echo "PASS: 06-instance" +exit 0 From nobody Tue Sep 29 09:08:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43E2B29993F; Mon, 10 Aug 2026 09:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786354458; cv=none; b=QSQnV+sbe4iR3naaAfWr4h4MBIED+y9zl54ekNL6086BvS1Ak6rcqMC5S5w4qVqia/WbHUzxw72IojMSXuTbP+eghxENUHxc4Syy6spU9OmnhGa9t35J+tO83FDKlnW3dBBZEFQMsdTSk6h4h7vfd53hZyiivLuuS7de8i+sQAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786354458; c=relaxed/simple; bh=bKmLfdu9nV38vi7SWsWQAzAnYK+q++UQcRlFl2A3Tt4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fri8qWDPK7LdlyeaSs9+QjXCJvHSkR8xCVvXChwkV/OX6zA4R6HbIRitP7e99LAAfMQ8sdAFZ5xVqDMSXNbSRqDSo9J1VcRczt9v2ZHZmZnO8bS7cwNFs8gTXaUaBBPW3vYkPXbd60sLguiitiAywaDEPsHV/aspCLg3SpUwisc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Gy7xMOAL; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Gy7xMOAL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 524FE1F000E9; Mon, 10 Aug 2026 09:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786354456; bh=GK9pyR6T2P4DM5Pb4s9UsojrvLjENMK3gDEyj5gtWDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Gy7xMOALUvLnJMVGW/AbLdNjxHGLndzZihA5awK7W40oaEOZfzBD9bisKSJK8QxWS A6YyT3ULnHHZaOFXsztXF5VJi5+wXSckegfFBYzZoKhjsMyAcrFx/ahbuhOHody6Jf 7C3sYwEkv3I1f/HO77YdTyO8MRVCG6xjsprt3BWlFc/jwVFqG/UIi90DwIXjlKBW58 xq+EaKuOn7PcO9Pas7ZAZupFpcoLSzWJsl+g+J5KumNpdn61Ti8EUI1KN1BrxEFz6T zU5q6iF72oWaI02HBdhTMcaE/XRbNUuwxFlpkkhEpM12ZNkrkmVO0WDdpbvmwA6BVI tl6owTF57751A== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Masami Hiramatsu , Shuah Khan Cc: Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 3/4] selftests/ftrace: Add kernel cmdline tracing testcases Date: Mon, 10 Aug 2026 18:34:13 +0900 Message-ID: <178635445318.380779.17618494362731257097.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <178635442508.380779.3709136256425432083.stgit@devnote2> References: <178635442508.380779.3709136256425432083.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Masami Hiramatsu (Google) Add test cases for kernel command-line tracing options (see Documentation/admin-guide/kernel-parameters.txt). These test cases verify: - cmdline-01-ftrace: ftrace=3D[tracer] parameter - cmdline-02-trace-event: trace_event=3D[event1,event2,...] parameter - cmdline-03-trace-buf-size: trace_buf_size=3DNNK parameter - cmdline-04-trace-options: trace_options=3D[option1,option2,...] parameter - cmdline-05-trace-clock: trace_clock=3D[clock] parameter - cmdline-06-trace-instance: trace_instance=3D[instance-info] parameter Assisted-by: Antigravity:gemini-3.6-flash Signed-off-by: Masami Hiramatsu (Google) --- .../boottime/cmdlines/cmdline-01-ftrace.cmdline | 1 + .../cmdlines/cmdline-02-trace-event.cmdline | 1 + .../cmdlines/cmdline-03-trace-buf-size.cmdline | 1 + .../cmdlines/cmdline-04-trace-options.cmdline | 1 + .../cmdlines/cmdline-05-trace-clock.cmdline | 1 + .../cmdlines/cmdline-06-trace-instance.cmdline | 1 + .../ftrace/boottime/tests/cmdline-01-ftrace.sh | 19 +++++++++++++++ .../boottime/tests/cmdline-02-trace-event.sh | 26 ++++++++++++++++= ++++ .../boottime/tests/cmdline-03-trace-buf-size.sh | 19 +++++++++++++++ .../boottime/tests/cmdline-04-trace-options.sh | 23 ++++++++++++++++= ++ .../boottime/tests/cmdline-05-trace-clock.sh | 19 +++++++++++++++ .../boottime/tests/cmdline-06-trace-instance.sh | 24 ++++++++++++++++= ++ 12 files changed, 136 insertions(+) create mode 100644 tools/testing/selftests/ftrace/boottime/cmdlines/cmdlin= e-01-ftrace.cmdline create mode 100644 tools/testing/selftests/ftrace/boottime/cmdlines/cmdlin= e-02-trace-event.cmdline create mode 100644 tools/testing/selftests/ftrace/boottime/cmdlines/cmdlin= e-03-trace-buf-size.cmdline create mode 100644 tools/testing/selftests/ftrace/boottime/cmdlines/cmdlin= e-04-trace-options.cmdline create mode 100644 tools/testing/selftests/ftrace/boottime/cmdlines/cmdlin= e-05-trace-clock.cmdline create mode 100644 tools/testing/selftests/ftrace/boottime/cmdlines/cmdlin= e-06-trace-instance.cmdline create mode 100644 tools/testing/selftests/ftrace/boottime/tests/cmdline-0= 1-ftrace.sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/cmdline-0= 2-trace-event.sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/cmdline-0= 3-trace-buf-size.sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/cmdline-0= 4-trace-options.sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/cmdline-0= 5-trace-clock.sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/cmdline-0= 6-trace-instance.sh diff --git a/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-01-ft= race.cmdline b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-01-= ftrace.cmdline new file mode 100644 index 000000000000..4f6fc54240c8 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-01-ftrace.cm= dline @@ -0,0 +1 @@ +ftrace=3Dfunction diff --git a/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-02-tr= ace-event.cmdline b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdlin= e-02-trace-event.cmdline new file mode 100644 index 000000000000..66bcd29b14cb --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-02-trace-eve= nt.cmdline @@ -0,0 +1 @@ +trace_event=3Dsched:sched_switch,kmem:kmalloc diff --git a/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-03-tr= ace-buf-size.cmdline b/tools/testing/selftests/ftrace/boottime/cmdlines/cmd= line-03-trace-buf-size.cmdline new file mode 100644 index 000000000000..e5d1c4a8ca89 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-03-trace-buf= -size.cmdline @@ -0,0 +1 @@ +trace_buf_size=3D2048K diff --git a/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-04-tr= ace-options.cmdline b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdl= ine-04-trace-options.cmdline new file mode 100644 index 000000000000..51d82f8e948d --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-04-trace-opt= ions.cmdline @@ -0,0 +1 @@ +trace_options=3Dsym-addr,verbose diff --git a/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-05-tr= ace-clock.cmdline b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdlin= e-05-trace-clock.cmdline new file mode 100644 index 000000000000..f72a4ac808a3 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-05-trace-clo= ck.cmdline @@ -0,0 +1 @@ +trace_clock=3Dglobal diff --git a/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-06-tr= ace-instance.cmdline b/tools/testing/selftests/ftrace/boottime/cmdlines/cmd= line-06-trace-instance.cmdline new file mode 100644 index 000000000000..9618e3e2b88b --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/cmdlines/cmdline-06-trace-ins= tance.cmdline @@ -0,0 +1 @@ +trace_instance=3Dbar,sched:sched_switch diff --git a/tools/testing/selftests/ftrace/boottime/tests/cmdline-01-ftrac= e.sh b/tools/testing/selftests/ftrace/boottime/tests/cmdline-01-ftrace.sh new file mode 100644 index 000000000000..23a0b15f2dd3 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/cmdline-01-ftrace.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check ftrace=3D kernel command-line tracer setting +TRACEDIR=3D"/sys/kernel/tracing" + +if [ ! -f "$TRACEDIR/current_tracer" ]; then + echo "FAIL: current_tracer does not exist" + exit 1 +fi + +read -r TRACER _ < "$TRACEDIR/current_tracer" +if [ "$TRACER" !=3D "function" ]; then + echo "FAIL: current_tracer is '$TRACER', expected 'function'" + exit 1 +fi + +echo "PASS: cmdline-01-ftrace" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/cmdline-02-trace= -event.sh b/tools/testing/selftests/ftrace/boottime/tests/cmdline-02-trace-= event.sh new file mode 100644 index 000000000000..b793907c48cd --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/cmdline-02-trace-event.= sh @@ -0,0 +1,26 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check trace_event=3D kernel command-line setting +TRACEDIR=3D"/sys/kernel/tracing" + +if [ ! -d "$TRACEDIR/events/sched/sched_switch" ]; then + echo "FAIL: event sched:sched_switch does not exist" + exit 1 +fi + +if [ ! -d "$TRACEDIR/events/kmem/kmalloc" ]; then + echo "FAIL: event kmem:kmalloc does not exist" + exit 1 +fi + +ENABLE1=3D$(cat "$TRACEDIR/events/sched/sched_switch/enable") +ENABLE2=3D$(cat "$TRACEDIR/events/kmem/kmalloc/enable") + +if [ "$ENABLE1" !=3D "1" ] || [ "$ENABLE2" !=3D "1" ]; then + echo "FAIL: events not enabled (sched_switch=3D$ENABLE1, kmalloc=3D$ENABL= E2)" + exit 1 +fi + +echo "PASS: cmdline-02-trace-event" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/cmdline-03-trace= -buf-size.sh b/tools/testing/selftests/ftrace/boottime/tests/cmdline-03-tra= ce-buf-size.sh new file mode 100644 index 000000000000..c4deb6dc2d9b --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/cmdline-03-trace-buf-si= ze.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check trace_buf_size=3D kernel command-line setting +TRACEDIR=3D"/sys/kernel/tracing" + +if [ ! -f "$TRACEDIR/buffer_size_kb" ]; then + echo "FAIL: buffer_size_kb does not exist" + exit 1 +fi + +BUFSIZE=3D$(cat "$TRACEDIR/buffer_size_kb") +if [ "$BUFSIZE" -lt 2048 ]; then + echo "FAIL: buffer_size_kb is $BUFSIZE, expected >=3D 2048" + exit 1 +fi + +echo "PASS: cmdline-03-trace-buf-size" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/cmdline-04-trace= -options.sh b/tools/testing/selftests/ftrace/boottime/tests/cmdline-04-trac= e-options.sh new file mode 100644 index 000000000000..98ada8d245da --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/cmdline-04-trace-option= s.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check trace_options=3D kernel command-line setting +TRACEDIR=3D"/sys/kernel/tracing" + +if [ ! -f "$TRACEDIR/trace_options" ]; then + echo "FAIL: trace_options file does not exist" + exit 1 +fi + +if ! grep -q "sym-addr" "$TRACEDIR/trace_options"; then + echo "FAIL: sym-addr option is not set in trace_options" + exit 1 +fi + +if ! grep -q "verbose" "$TRACEDIR/trace_options"; then + echo "FAIL: verbose option is not set in trace_options" + exit 1 +fi + +echo "PASS: cmdline-04-trace-options" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/cmdline-05-trace= -clock.sh b/tools/testing/selftests/ftrace/boottime/tests/cmdline-05-trace-= clock.sh new file mode 100644 index 000000000000..d6de9f6e2090 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/cmdline-05-trace-clock.= sh @@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check trace_clock=3D kernel command-line setting +TRACEDIR=3D"/sys/kernel/tracing" + +if [ ! -f "$TRACEDIR/trace_clock" ]; then + echo "FAIL: trace_clock file does not exist" + exit 1 +fi + +if ! grep -q '\[global\]' "$TRACEDIR/trace_clock"; then + CLOCK=3D$(cat "$TRACEDIR/trace_clock") + echo "FAIL: trace_clock is not set to global ($CLOCK)" + exit 1 +fi + +echo "PASS: cmdline-05-trace-clock" +exit 0 diff --git a/tools/testing/selftests/ftrace/boottime/tests/cmdline-06-trace= -instance.sh b/tools/testing/selftests/ftrace/boottime/tests/cmdline-06-tra= ce-instance.sh new file mode 100644 index 000000000000..aae7f0a86d81 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/cmdline-06-trace-instan= ce.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check trace_instance=3D kernel command-line setting +TRACEDIR=3D"/sys/kernel/tracing" + +if [ ! -d "$TRACEDIR/instances/bar" ]; then + echo "FAIL: trace instance bar does not exist" + exit 1 +fi + +if [ ! -d "$TRACEDIR/instances/bar/events/sched/sched_switch" ]; then + echo "FAIL: event sched_switch does not exist in instance bar" + exit 1 +fi + +ENABLE=3D$(cat "$TRACEDIR/instances/bar/events/sched/sched_switch/enable") +if [ "$ENABLE" !=3D "1" ]; then + echo "FAIL: event sched_switch is not enabled in instance bar ($ENABLE)" + exit 1 +fi + +echo "PASS: cmdline-06-trace-instance" +exit 0 From nobody Tue Sep 29 09:08:29 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A855C3B059B; Mon, 10 Aug 2026 09:34:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786354467; cv=none; b=UTwdZW6w9/nORagl1wnH3BVLt/BBOoFcDIfjhvQ8mG88v3LmipyRZbLw7rRulZurjG3p447nJ6zsJ9NvL7AuFAnHXdahg6yt/TJquq9ofDUERYJGvz7klDbnDe8DeoA4q5anIZV08m8zCgLw51veQl7Xs/9fXfxwZVIe1ye2D+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786354467; c=relaxed/simple; bh=4Td346V3shBa3kOWp1otXBoWThjpSdm7oxq/5NBr/NA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Gg5aZ/aQDXkU66PanhMAMVfyT15CjTHQn9XJcU3dDVEUdksE4HpXjaYoEYHTgo5wJ2Eg+y7E1yyevOXbtGmRNX/WD+1WW3nZ3597Hmcr6jyWiK67UXQoY2bO/xmOgozC8Roa7avlPinq/m7AHxIa0vTvu0kQMcXPXJzHUSGyda4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mm64ts59; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mm64ts59" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 873561F00A3F; Mon, 10 Aug 2026 09:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786354466; bh=HMP5x8PR0FQvUstRmPCUdayJeVK0ap+mE6zOOfJTCBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Mm64ts59q7wdRmyq+c3e44ucdSKy/IeXqwbj1Vk5w4NJu5hYonTqymFtyDabogY7K kJWB7pn4yhHlfSMByT49CGdmBv8OB2ldL/PCnNzTek4BtYM4UZm5/p4woKs0RSTsWO GO1j+wmITVGfz8KUDsw3SqkQ1wVOIfrbKsSlnkMWRpA6Gx+tRDVaIr+ajhU+b7lsSB w8isp8JbBec2R6pVcVT9Em/EMdx0kdIQNp7MunbiDiFzQZ6Dgt7FYQXCm0Zs7rfXto ElBFjyCKGbui2bkB9Tb9eW3bwmbo+W9IEsoU5xP7qQMXGc1OthbtQKwcJYahaVWttj aAXgYCgrlXcCQ== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Masami Hiramatsu , Shuah Khan Cc: Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 4/4] selftests/ftrace: Add persistent ring buffer testcases Date: Mon, 10 Aug 2026 18:34:22 +0900 Message-ID: <178635446219.380779.14935908214040944426.stgit@devnote2> X-Mailer: git-send-email 2.43.0 In-Reply-To: <178635442508.380779.3709136256425432083.stgit@devnote2> References: <178635442508.380779.3709136256425432083.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Masami Hiramatsu (Google) Add test cases for persistent ring buffer (reserve_mem=3D combined with trace_instance=3D) and backup instance (trace_instance=3Dbackup=3Dboot= _map). These test cases verify: - persistent-01-reserve-mem: Memory reservation via reserve_mem=3D and trace_instance=3Dboot_map@trace. Verifies trace data retention in the boot_map instance across guest crash/reboot via sysrq-trigger. - persistent-02-backup-instance: Backup instance creation via trace_instance=3Dbackup=3Dboot_map. Verifies that previous boot trace log is preserved in the backup instance on the subsequent boot. These test cases specify '# REBOOT: 1' to enable multi-boot guest crash/reboot testing with doubled QEMU timeout. Assisted-by: Antigravity:gemini-3.6-flash Signed-off-by: Masami Hiramatsu (Google) --- .../cmdlines/persistent-01-reserve-mem.cmdline | 1 + .../cmdlines/persistent-02-backup-instance.cmdline | 1 + .../boottime/tests/persistent-01-reserve-mem.sh | 28 ++++++++++++++ .../tests/persistent-02-backup-instance.sh | 40 ++++++++++++++++= ++++ 4 files changed, 70 insertions(+) create mode 100644 tools/testing/selftests/ftrace/boottime/cmdlines/persis= tent-01-reserve-mem.cmdline create mode 100644 tools/testing/selftests/ftrace/boottime/cmdlines/persis= tent-02-backup-instance.cmdline create mode 100644 tools/testing/selftests/ftrace/boottime/tests/persisten= t-01-reserve-mem.sh create mode 100644 tools/testing/selftests/ftrace/boottime/tests/persisten= t-02-backup-instance.sh diff --git a/tools/testing/selftests/ftrace/boottime/cmdlines/persistent-01= -reserve-mem.cmdline b/tools/testing/selftests/ftrace/boottime/cmdlines/per= sistent-01-reserve-mem.cmdline new file mode 100644 index 000000000000..58e53f7edcd4 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/cmdlines/persistent-01-reserv= e-mem.cmdline @@ -0,0 +1 @@ +reserve_mem=3D12M:4096:trace trace_instance=3Dboot_map@trace diff --git a/tools/testing/selftests/ftrace/boottime/cmdlines/persistent-02= -backup-instance.cmdline b/tools/testing/selftests/ftrace/boottime/cmdlines= /persistent-02-backup-instance.cmdline new file mode 100644 index 000000000000..7b0713f550f8 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/cmdlines/persistent-02-backup= -instance.cmdline @@ -0,0 +1 @@ +reserve_mem=3D12M:4096:trace trace_instance=3Dboot_map@trace trace_instanc= e=3Dbackup=3Dboot_map diff --git a/tools/testing/selftests/ftrace/boottime/tests/persistent-01-re= serve-mem.sh b/tools/testing/selftests/ftrace/boottime/tests/persistent-01-= reserve-mem.sh new file mode 100644 index 000000000000..49abaf518481 --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/persistent-01-reserve-m= em.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check persistent ring buffer across guest crash/reboot +# REBOOT: 1 +TRACEDIR=3D"/sys/kernel/tracing" + +if [ ! -f "$TRACEDIR/instances/boot_map/trace" ]; then + echo "FAIL: persistent trace instance boot_map/trace file missing" + exit 1 +fi + +# Check if Boot 1 marker was already written +if grep -q "BOOT1_MARKER" "$TRACEDIR/instances/boot_map/trace" 2>/dev/null= ; then + # Second boot: verify persistent ring buffer content from first boot + echo "PASS: persistent-01-reserve-mem" + exit 0 +fi + +# First boot: write marker to persistent buffer and trigger kernel crash/r= eboot +echo "BOOT1_MARKER" > "$TRACEDIR/instances/boot_map/trace_marker" +sync + +# Trigger reboot to restart into second boot +echo b > /proc/sysrq-trigger 2>/dev/null || echo c > /proc/sysrq-trigger 2= >/dev/null || true +sleep 5 +echo "FAIL: reboot trigger failed on first boot" +exit 1 diff --git a/tools/testing/selftests/ftrace/boottime/tests/persistent-02-ba= ckup-instance.sh b/tools/testing/selftests/ftrace/boottime/tests/persistent= -02-backup-instance.sh new file mode 100644 index 000000000000..0b2a2f03ce4f --- /dev/null +++ b/tools/testing/selftests/ftrace/boottime/tests/persistent-02-backup-in= stance.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2026, Google LLC. +# Check persistent backup instance across guest crash/reboot +# REBOOT: 1 +TRACEDIR=3D"/sys/kernel/tracing" + +# Ensure both boot_map/trace and backup/trace files exist +if [ ! -f "$TRACEDIR/instances/boot_map/trace" ]; then + echo "FAIL: boot_map/trace file missing" + exit 1 +fi + +if [ ! -f "$TRACEDIR/instances/backup/trace" ]; then + echo "FAIL: backup/trace file missing" + exit 1 +fi + +# Check if BOOT1_MARKER is in boot_map/trace (indicates second boot) +if grep -q "BOOT1_MARKER" "$TRACEDIR/instances/boot_map/trace" 2>/dev/null= ; then + # Second boot: verify BOOT1_MARKER was copied into backup/trace from Boot= 1 + if grep -q "BOOT1_MARKER" "$TRACEDIR/instances/backup/trace" 2>/dev/null;= then + echo "PASS: persistent-02-backup-instance" + exit 0 + else + echo "FAIL: BOOT1_MARKER found in boot_map/trace" \ + "but missing from backup/trace on second boot" + exit 1 + fi +fi + +# First boot: write BOOT1_MARKER to boot_map and reboot via sysrq-trigger +echo "BOOT1_MARKER" > "$TRACEDIR/instances/boot_map/trace_marker" +sync + +# Trigger reboot to restart into second boot +echo b > /proc/sysrq-trigger 2>/dev/null || echo c > /proc/sysrq-trigger 2= >/dev/null || true +sleep 5 +echo "FAIL: reboot trigger failed on first boot" +exit 1