All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [LTP PATCH v4 0/5] ftrace: Convert shell tests to C
@ 2026-06-08  5:49 Praveen K Pandey
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 1/5] ftrace: Add common library for C implementation Praveen K Pandey
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Praveen K Pandey @ 2026-06-08  5:49 UTC (permalink / raw)
  To: ltp

This patch series converts the ftrace shell-based tests to C
implementation using LTP's new API, addressing GitHub issue #1282.

The conversion provides:
- Better integration with LTP framework
- Improved error handling and reporting
- More maintainable code structure
- Consistent test behavior across platforms

Changes in v4:
- Fixed all trailing whitespace on blank lines in ftrace_lib.c (20+ locations)
- Corrected ftrace_regression01 commit message to accurately describe test behavior
  (tests userstacktrace with page fault events, not general function tracing)
- Corrected ftrace_regression02 commit message to describe actual test
  (verifies signal:signal_generate tracepoint fields, not function_graph tracer)
- Replaced inline tst_kvercmp() check with .min_kver = "3.2" in ftrace_regression02
- Removed incorrect LTP_TIMEOUT_MUL parsing in ftrace_stress_test setup()
- All whitespace issues verified with checkpatch.pl

Changes in v3:
- Fixed tst_tmpdir_path() usage by adding .needs_tmpdir = 1 to all tests
- Removed incorrect CVE-2015-8550 tag from ftrace_regression01
- Fixed memory leak in TST_RETRY_FUNC usage by assigning to variable and freeing
- Changed [Algorithm] sections from numbered lists to bullet points (using '-')
- Added root requirement documentation to all test doc comments
- Fixed Makefile LDLIBS placement (moved before generic_leaf_target.mk include)
- Created .gitignore for new test binaries
- Removed deprecated [Description] header from ftrace_stress_test
- Deleted orphaned shell files that were replaced by C implementations

Changes in v2:
- Fixed TST_NO_DEFAULT_MAIN placement in ftrace_lib.c (before includes)
- Removed tst_test.h include from ftrace_lib.h (libraries shouldn't include it)
- Fixed include order in test files (tst_test.h before ftrace_lib.h)
- Added proper cleanup of allocated memory in tests
- Improved error messages and test documentation
- Fixed Makefile dependencies and library filtering

Testing:
All tests have been compiled and verified to work correctly on x86_64
and ppc64le systems with various kernel versions. All whitespace issues
have been verified with checkpatch.pl.

Praveen K Pandey (5):
  ftrace: Add common library for C implementation
  ftrace: Convert ftrace_regression01.sh to C
  ftrace: Convert ftrace_regression02.sh to C
  ftrace: Convert ftrace_stress_test.sh to C
  ftrace: Remove obsolete shell test files

 runtest/tracing                               |   6 +-
 .../kernel/tracing/ftrace_test/.gitignore     |   4 +
 testcases/kernel/tracing/ftrace_test/Makefile |  19 +-
 .../kernel/tracing/ftrace_test/ftrace_lib.c   | 358 ++++++++++++++++++
 .../kernel/tracing/ftrace_test/ftrace_lib.h   | 139 +++++++
 .../kernel/tracing/ftrace_test/ftrace_lib.sh  | 180 ---------
 .../tracing/ftrace_test/ftrace_regression01.c | 128 +++++++
 .../ftrace_test/ftrace_regression01.sh        |  83 ----
 .../tracing/ftrace_test/ftrace_regression02.c | 103 +++++
 .../ftrace_test/ftrace_regression02.sh        |  63 ----
 .../ftrace_stress/ftrace_buffer_size_kb.sh    |  45 ---
 .../ftrace_stress/ftrace_current_tracer.sh    |  32 --
 .../ftrace_stress/ftrace_ftrace_enabled.sh    |  38 --
 .../ftrace_function_profile_enabled.sh        |  38 --
 .../ftrace_stress/ftrace_set_event.sh         |  46 ---
 .../ftrace_stress/ftrace_set_ftrace_filter.sh | 119 ------
 .../ftrace_stress/ftrace_set_ftrace_pid.sh    |  37 --
 .../ftrace_stress/ftrace_stack_max_size.sh    |  27 --
 .../ftrace_stress/ftrace_stack_trace.sh       |  35 --
 .../ftrace_test/ftrace_stress/ftrace_trace.sh |  25 --
 .../ftrace_stress/ftrace_trace_clock.sh       |  27 --
 .../ftrace_stress/ftrace_trace_options.sh     |  58 ---
 .../ftrace_stress/ftrace_trace_pipe.sh        |  45 ---
 .../ftrace_stress/ftrace_trace_stat.sh        |  38 --
 .../ftrace_stress/ftrace_tracing_cpumask.sh   |  91 -----
 .../ftrace_stress/ftrace_tracing_enabled.sh   |  38 --
 .../ftrace_tracing_max_latency.sh             |  27 --
 .../ftrace_stress/ftrace_tracing_on.sh        |  38 --
 .../tracing/ftrace_test/ftrace_stress_test.c  | 322 ++++++++++++++++
 .../tracing/ftrace_test/ftrace_stress_test.sh | 121 ------
 30 files changed, 1072 insertions(+), 1258 deletions(-)
 create mode 100644 testcases/kernel/tracing/ftrace_test/.gitignore
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_lib.c
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_lib.h
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_regression01.c
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_regression02.c
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_stress_test.c
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh

-- 
2.50.1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [LTP PATCH v4 1/5] ftrace: Add common library for C implementation
  2026-06-08  5:49 [LTP] [LTP PATCH v4 0/5] ftrace: Convert shell tests to C Praveen K Pandey
@ 2026-06-08  5:49 ` Praveen K Pandey
  2026-06-08  9:01   ` [LTP] " linuxtestproject.agent
  2026-06-08  9:41   ` [LTP] [LTP PATCH v4 1/5] " Cyril Hrubis
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 2/5] ftrace: Convert ftrace_regression01.sh to C Praveen K Pandey
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 8+ messages in thread
From: Praveen K Pandey @ 2026-06-08  5:49 UTC (permalink / raw)
  To: ltp

Add ftrace_lib.c and ftrace_lib.h to provide common functionality for
ftrace C test implementations. This library handles:

- Debugfs mounting and tracing path management
- Reading and writing ftrace files
- Saving and restoring ftrace settings
- Tracer enumeration and management

The library uses TST_NO_DEFAULT_MAIN to allow linking with LTP test
framework without defining multiple main() functions.

Signed-off-by: Praveen K Pandey <praveen@linux.ibm.com>
---
 .../kernel/tracing/ftrace_test/ftrace_lib.c   | 358 ++++++++++++++++++
 .../kernel/tracing/ftrace_test/ftrace_lib.h   | 139 +++++++
 2 files changed, 497 insertions(+)
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_lib.c
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_lib.h

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.c b/testcases/kernel/tracing/ftrace_test/ftrace_lib.c
new file mode 100644
index 000000000..8b93b9849
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.c
@@ -0,0 +1,358 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2010 FUJITSU LIMITED
+ * Copyright (c) 2024 Linux Test Project
+ * Copyright (c) IBM, 2026
+ *
+ * Author: Li Zefan <lizf@cn.fujitsu.com>
+ * Converted to C by: Praveen K Pandey <praveen@linux.ibm.com>
+ */
+
+#define TST_NO_DEFAULT_MAIN
+#include "ftrace_lib.h"
+#include "tst_test.h"
+#include "tst_safe_macros.h"
+#include "tst_safe_stdio.h"
+
+char *tracing_path = NULL;
+char *debugfs_path = NULL;
+static int debugfs_mounted_by_us = 0;
+
+struct ftrace_saved_state saved_state = {0};
+
+void ftrace_initialize(void)
+{
+	FILE *fp;
+	char line[PATH_MAX];
+	int found = 0;
+
+	/* Check if debugfs is already mounted */
+	fp = SAFE_FOPEN("/proc/mounts", "r");
+	while (fgets(line, sizeof(line), fp)) {
+		if (strstr(line, "debugfs")) {
+			debugfs_path = strdup("/sys/kernel/debug");
+			found = 1;
+			break;
+		}
+	}
+	SAFE_FCLOSE(fp);
+
+	/* Mount debugfs if not already mounted */
+	if (!found) {
+		char *tmpdir = tst_tmpdir_path();
+		debugfs_path = malloc(PATH_MAX);
+		if (!debugfs_path)
+			tst_brk(TBROK | TERRNO, "malloc failed");
+		snprintf(debugfs_path, PATH_MAX, "%s/debugfs", tmpdir);
+		SAFE_MKDIR(debugfs_path, 0755);
+		SAFE_MOUNT("debugfs", debugfs_path, "debugfs", 0, NULL);
+		debugfs_mounted_by_us = 1;
+	}
+
+	/* Set tracing path */
+	tracing_path = malloc(PATH_MAX);
+	if (!tracing_path)
+		tst_brk(TBROK | TERRNO, "malloc failed");
+
+	snprintf(tracing_path, PATH_MAX, "%s/tracing", debugfs_path);
+
+	/* Check if tracing is supported */
+	if (access(tracing_path, F_OK) != 0)
+		tst_brk(TCONF, "Tracing is not supported");
+
+	/* Save current settings */
+	ftrace_save_settings();
+}
+
+void ftrace_cleanup(void)
+{
+	ftrace_restore_settings();
+
+	if (debugfs_mounted_by_us && debugfs_path) {
+		tst_umount(debugfs_path);
+		rmdir(debugfs_path);
+	}
+
+	free(tracing_path);
+	free(debugfs_path);
+
+	/* Free saved state */
+	free(saved_state.trace_options);
+	free(saved_state.tracing_on);
+	free(saved_state.buffer_size);
+	free(saved_state.tracing_cpumask);
+	free(saved_state.tracing_enabled);
+	free(saved_state.stack_tracer_enabled);
+	free(saved_state.ftrace_enabled);
+	free(saved_state.function_profile_enabled);
+}
+
+char *ftrace_get_path(const char *filename)
+{
+	char *path;
+
+	path = malloc(PATH_MAX);
+	if (!path)
+		return NULL;
+
+	snprintf(path, PATH_MAX, "%s/%s", tracing_path, filename);
+	return path;
+}
+
+char *ftrace_read_file(const char *filename)
+{
+	char *path;
+	FILE *fp;
+	char *content = NULL;
+	size_t len = 0;
+	ssize_t read;
+	char *line = NULL;
+	size_t total_size = 0;
+
+	path = ftrace_get_path(filename);
+	if (!path)
+		return NULL;
+
+	fp = fopen(path, "r");
+	free(path);
+
+	if (!fp)
+		return NULL;
+
+	/* Read entire file */
+	while ((read = getline(&line, &len, fp)) != -1) {
+		char *new_content = realloc(content, total_size + read + 1);
+		if (!new_content) {
+			free(content);
+			free(line);
+			fclose(fp);
+			return NULL;
+		}
+		content = new_content;
+		memcpy(content + total_size, line, read);
+		total_size += read;
+	}
+
+	if (content)
+		content[total_size] = '\0';
+
+	free(line);
+	fclose(fp);
+
+	return content;
+}
+
+int ftrace_write_file(const char *filename, const char *content)
+{
+	char *path;
+	FILE *fp;
+	int ret;
+
+	path = ftrace_get_path(filename);
+	if (!path)
+		return -1;
+
+	fp = fopen(path, "w");
+	free(path);
+
+	if (!fp)
+		return -1;
+
+	ret = fprintf(fp, "%s", content);
+	fclose(fp);
+
+	return (ret > 0) ? 0 : -1;
+}
+
+int ftrace_file_exists(const char *filename)
+{
+	char *path;
+	int ret;
+
+	path = ftrace_get_path(filename);
+	if (!path)
+		return 0;
+
+	ret = (access(path, F_OK) == 0);
+	free(path);
+
+	return ret;
+}
+
+void ftrace_save_settings(void)
+{
+	if (saved_state.saved)
+		return;
+
+	saved_state.trace_options = ftrace_read_file("trace_options");
+	saved_state.tracing_on = ftrace_read_file("tracing_on");
+	saved_state.buffer_size = ftrace_read_file("buffer_size_kb");
+
+	if (ftrace_file_exists("tracing_cpumask"))
+		saved_state.tracing_cpumask = ftrace_read_file("tracing_cpumask");
+
+	if (ftrace_file_exists("tracing_enabled"))
+		saved_state.tracing_enabled = ftrace_read_file("tracing_enabled");
+
+	if (ftrace_file_exists("stack_max_size")) {
+		char *path = strdup("/proc/sys/kernel/stack_tracer_enabled");
+		FILE *fp = fopen(path, "r");
+
+		if (fp) {
+			saved_state.stack_tracer_enabled = malloc(32);
+			if (saved_state.stack_tracer_enabled)
+				fgets(saved_state.stack_tracer_enabled, 32, fp);
+			fclose(fp);
+		}
+		free(path);
+	}
+
+	if (access("/proc/sys/kernel/ftrace_enabled", F_OK) == 0) {
+		FILE *fp = fopen("/proc/sys/kernel/ftrace_enabled", "r");
+
+		if (fp) {
+			saved_state.ftrace_enabled = malloc(32);
+			if (saved_state.ftrace_enabled)
+				fgets(saved_state.ftrace_enabled, 32, fp);
+			fclose(fp);
+		}
+	}
+
+	if (ftrace_file_exists("function_profile_enabled"))
+		saved_state.function_profile_enabled = ftrace_read_file("function_profile_enabled");
+
+	saved_state.saved = 1;
+}
+
+void ftrace_restore_settings(void)
+{
+	if (!saved_state.saved)
+		return;
+
+	/* Reset tracer and events */
+	ftrace_write_file("current_tracer", "nop\n");
+	ftrace_write_file("events/enable", "0\n");
+
+	if (ftrace_file_exists("tracing_max_latency"))
+		ftrace_write_file("tracing_max_latency", "0\n");
+
+	if (saved_state.tracing_cpumask)
+		ftrace_write_file("tracing_cpumask", saved_state.tracing_cpumask);
+
+	if (ftrace_file_exists("trace_clock"))
+		ftrace_write_file("trace_clock", "local\n");
+
+	if (saved_state.function_profile_enabled)
+		ftrace_write_file("function_profile_enabled", saved_state.function_profile_enabled);
+
+	if (saved_state.ftrace_enabled) {
+		FILE *fp = fopen("/proc/sys/kernel/ftrace_enabled", "w");
+		if (fp) {
+			fprintf(fp, "%s", saved_state.ftrace_enabled);
+			fclose(fp);
+		}
+	}
+
+	if (saved_state.stack_tracer_enabled && ftrace_file_exists("stack_max_size")) {
+		FILE *fp = fopen("/proc/sys/kernel/stack_tracer_enabled", "w");
+		if (fp) {
+			fprintf(fp, "%s", saved_state.stack_tracer_enabled);
+			fclose(fp);
+		}
+		ftrace_write_file("stack_max_size", "0\n");
+	}
+
+	if (saved_state.buffer_size)
+		ftrace_write_file("buffer_size_kb", saved_state.buffer_size);
+
+	if (saved_state.tracing_on)
+		ftrace_write_file("tracing_on", saved_state.tracing_on);
+
+	if (saved_state.tracing_enabled)
+		ftrace_write_file("tracing_enabled", saved_state.tracing_enabled);
+
+	/* Restore trace options */
+	if (saved_state.trace_options) {
+		char *options = strdup(saved_state.trace_options);
+		char *token = strtok(options, "\n");
+		while (token) {
+			ftrace_write_file("trace_options", token);
+			token = strtok(NULL, "\n");
+		}
+		free(options);
+	}
+
+	/* Clear trace */
+	ftrace_clear_trace();
+
+	/* Clear filter */
+	if (ftrace_file_exists("set_ftrace_filter"))
+		ftrace_write_file("set_ftrace_filter", "\n");
+}
+
+char **ftrace_get_available_tracers(int *count)
+{
+	char *content;
+	char **tracers = NULL;
+	int n = 0;
+	char *token;
+	char *saveptr;
+
+	content = ftrace_read_file("available_tracers");
+	if (!content) {
+		*count = 0;
+		return NULL;
+	}
+
+	/* Count tracers */
+	char *tmp = strdup(content);
+	token = strtok_r(tmp, " \n", &saveptr);
+	while (token) {
+		n++;
+		token = strtok_r(NULL, " \n", &saveptr);
+	}
+	free(tmp);
+
+	/* Allocate array */
+	tracers = malloc(sizeof(char *) * n);
+	if (!tracers) {
+		free(content);
+		*count = 0;
+		return NULL;
+	}
+
+	/* Fill array */
+	n = 0;
+	token = strtok_r(content, " \n", &saveptr);
+	while (token) {
+		tracers[n++] = strdup(token);
+		token = strtok_r(NULL, " \n", &saveptr);
+	}
+
+	free(content);
+	*count = n;
+	return tracers;
+}
+
+int ftrace_set_tracer(const char *tracer)
+{
+	char buf[256];
+	snprintf(buf, sizeof(buf), "%s\n", tracer);
+	return ftrace_write_file("current_tracer", buf);
+}
+
+void ftrace_clear_trace(void)
+{
+	ftrace_write_file("trace", "\n");
+}
+
+void ftrace_enable_tracing(void)
+{
+	ftrace_write_file("tracing_on", "1\n");
+}
+
+void ftrace_disable_tracing(void)
+{
+	ftrace_write_file("tracing_on", "0\n");
+}
+
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.h b/testcases/kernel/tracing/ftrace_test/ftrace_lib.h
new file mode 100644
index 000000000..b40877ed1
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.h
@@ -0,0 +1,139 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2010 FUJITSU LIMITED
+ * Copyright (c) 2024 Linux Test Project
+ * Copyright (c) IBM, 2026
+ *
+ * Author: Li Zefan <lizf@cn.fujitsu.com>
+ * Converted to C by: Praveen K Pandey <praveen@linux.ibm.com>
+ */
+
+#ifndef FTRACE_LIB_H
+#define FTRACE_LIB_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <limits.h>
+
+/* Global paths */
+extern char *tracing_path;
+extern char *debugfs_path;
+
+/* Saved settings for cleanup */
+struct ftrace_saved_state {
+	char *trace_options;
+	char *tracing_on;
+	char *buffer_size;
+	char *tracing_cpumask;
+	char *tracing_enabled;
+	char *stack_tracer_enabled;
+	char *ftrace_enabled;
+	char *function_profile_enabled;
+	int saved;
+};
+
+extern struct ftrace_saved_state saved_state;
+
+/**
+ * ftrace_initialize() - Initialize ftrace test environment
+ *
+ * This function:
+ * - Checks if debugfs is mounted, mounts it if needed
+ * - Verifies tracing support
+ * - Saves current ftrace settings
+ */
+void ftrace_initialize(void);
+
+/**
+ * ftrace_cleanup() - Cleanup and restore ftrace settings
+ *
+ * Restores all saved ftrace settings and unmounts debugfs if needed
+ */
+void ftrace_cleanup(void);
+
+/**
+ * ftrace_save_settings() - Save current ftrace settings
+ *
+ * Saves all ftrace configuration to restore later
+ */
+void ftrace_save_settings(void);
+
+/**
+ * ftrace_restore_settings() - Restore saved ftrace settings
+ *
+ * Restores ftrace configuration saved by ftrace_save_settings()
+ */
+void ftrace_restore_settings(void);
+
+/**
+ * ftrace_get_path() - Get full path to a tracing file
+ * @filename: Name of the file in tracing directory
+ *
+ * Returns: Allocated string with full path (caller must free)
+ */
+char *ftrace_get_path(const char *filename);
+
+/**
+ * ftrace_read_file() - Read content from a tracing file
+ * @filename: Name of the file in tracing directory
+ *
+ * Returns: Allocated string with file content (caller must free)
+ */
+char *ftrace_read_file(const char *filename);
+
+/**
+ * ftrace_write_file() - Write content to a tracing file
+ * @filename: Name of the file in tracing directory
+ * @content: Content to write
+ *
+ * Returns: 0 on success, -1 on failure
+ */
+int ftrace_write_file(const char *filename, const char *content);
+
+/**
+ * ftrace_file_exists() - Check if a tracing file exists
+ * @filename: Name of the file in tracing directory
+ *
+ * Returns: 1 if exists, 0 otherwise
+ */
+int ftrace_file_exists(const char *filename);
+
+/**
+ * ftrace_get_available_tracers() - Get list of available tracers
+ * @count: Pointer to store number of tracers
+ *
+ * Returns: Array of tracer names (caller must free)
+ */
+char **ftrace_get_available_tracers(int *count);
+
+/**
+ * ftrace_set_tracer() - Set current tracer
+ * @tracer: Name of the tracer to set
+ *
+ * Returns: 0 on success, -1 on failure
+ */
+int ftrace_set_tracer(const char *tracer);
+
+/**
+ * ftrace_clear_trace() - Clear the trace buffer
+ */
+void ftrace_clear_trace(void);
+
+/**
+ * ftrace_enable_tracing() - Enable tracing
+ */
+void ftrace_enable_tracing(void);
+
+/**
+ * ftrace_disable_tracing() - Disable tracing
+ */
+void ftrace_disable_tracing(void);
+
+#endif /* FTRACE_LIB_H */
-- 
2.50.1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [LTP PATCH v4 2/5] ftrace: Convert ftrace_regression01.sh to C
  2026-06-08  5:49 [LTP] [LTP PATCH v4 0/5] ftrace: Convert shell tests to C Praveen K Pandey
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 1/5] ftrace: Add common library for C implementation Praveen K Pandey
@ 2026-06-08  5:49 ` Praveen K Pandey
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 3/5] ftrace: Convert ftrace_regression02.sh " Praveen K Pandey
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Praveen K Pandey @ 2026-06-08  5:49 UTC (permalink / raw)
  To: ltp

Convert ftrace_regression01.sh to C implementation using LTP new API.

This is a regression test for commit 1dbd195 (tracing: Fix preempt count leak).
The bug caused kernel panics when enabling userstacktrace option together with
page fault events. The test enables these features and repeats the loop multiple
times to trigger potential race conditions, verifying the system remains stable.

The test requires root to access and configure the ftrace subsystem via debugfs.

Signed-off-by: Praveen K Pandey <praveen@linux.ibm.com>
---
 .../tracing/ftrace_test/ftrace_regression01.c | 128 ++++++++++++++++++
 1 file changed, 128 insertions(+)
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_regression01.c

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_regression01.c b/testcases/kernel/tracing/ftrace_test/ftrace_regression01.c
new file mode 100644
index 000000000..cc92fb0fd
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_regression01.c
@@ -0,0 +1,128 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2015 Red Hat Inc.
+ * Copyright (c) 2024 Linux Test Project
+ * Copyright (c) IBM, 2026
+ *
+ * Author: Li Wang <liwang@redhat.com>
+ * Converted to C by: Praveen K Pandey <praveen@linux.ibm.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Test for kernel panic while using userstacktrace with page fault events.
+ *
+ * This is a regression test for commit 1dbd195 (tracing: Fix preempt count leak).
+ * The bug caused kernel panics when enabling userstacktrace option together with
+ * page fault events:
+ *
+ * - BUG: unable to handle kernel paging request
+ * - Thread overran stack, or stack corrupted
+ *
+ * Requires root to access and configure the ftrace subsystem via debugfs.
+ *
+ * [Algorithm]
+ *
+ * - Enable stack tracer
+ * - Enable userstacktrace option
+ * - Enable page fault events (either exceptions:page_fault_kernel or
+ *   kmem:mm_kernel_pagefault depending on kernel version)
+ * - Repeat the loop multiple times to trigger potential race conditions
+ * - Verify system remains stable without kernel panic
+ */
+
+#include "tst_test.h"
+#include "ftrace_lib.h"
+
+#define LOOP_COUNT 10
+
+static void run_test(void)
+{
+	int i;
+	char *exc_page_fault_enable = NULL;
+	char *mm_page_fault_enable = NULL;
+	int use_exc_event = 0;
+
+	/* Check if stack tracer is available */
+	if (access("/proc/sys/kernel/stack_tracer_enabled", F_OK) != 0)
+		tst_brk(TCONF, "Stack tracer is not configured in this kernel");
+
+	/* Determine which page fault event is available */
+	if (ftrace_file_exists("events/exceptions/page_fault_kernel/enable")) {
+		use_exc_event = 1;
+		exc_page_fault_enable = ftrace_read_file("events/exceptions/page_fault_kernel/enable");
+	} else if (ftrace_file_exists("events/kmem/mm_kernel_pagefault/enable")) {
+		use_exc_event = 0;
+		mm_page_fault_enable = ftrace_read_file("events/kmem/mm_kernel_pagefault/enable");
+	} else {
+		tst_brk(TCONF, "Neither page_fault_kernel nor mm_kernel_pagefault event is available");
+	}
+
+	/* Run the test loop */
+	for (i = 0; i < LOOP_COUNT; i++) {
+		char *options;
+
+		/* Enable stack tracer */
+		SAFE_FILE_PRINTF("/proc/sys/kernel/stack_tracer_enabled", "1");
+
+		/* Enable userstacktrace option */
+		if (ftrace_write_file("trace_options", "userstacktrace\n") != 0)
+			tst_brk(TBROK, "Failed to set userstacktrace option");
+
+		/* Verify userstacktrace is enabled */
+		options = ftrace_read_file("trace_options");
+		if (!options || !strstr(options, "userstacktrace")) {
+			free(options);
+			tst_brk(TBROK, "Failed to enable userstacktrace");
+		}
+		free(options);
+
+		/* Enable page fault event */
+		if (use_exc_event) {
+			if (ftrace_write_file("events/exceptions/page_fault_kernel/enable", "1\n") != 0)
+				tst_res(TINFO, "Failed to enable page_fault_kernel event");
+		} else {
+			if (ftrace_write_file("events/kmem/mm_kernel_pagefault/enable", "1\n") != 0)
+				tst_res(TINFO, "Failed to enable mm_kernel_pagefault event");
+		}
+
+		/* Wait for trace events to be written */
+		char *trace_content = TST_RETRY_FUNC(ftrace_read_file("trace"), TST_RETVAL_NOTNULL);
+		free(trace_content);
+	}
+
+	/* Restore page fault event state */
+	if (use_exc_event && exc_page_fault_enable) {
+		ftrace_write_file("events/exceptions/page_fault_kernel/enable", exc_page_fault_enable);
+		free(exc_page_fault_enable);
+	} else if (!use_exc_event && mm_page_fault_enable) {
+		ftrace_write_file("events/kmem/mm_kernel_pagefault/enable", mm_page_fault_enable);
+		free(mm_page_fault_enable);
+	}
+
+	tst_res(TPASS, "System did not panic with userstacktrace enabled");
+}
+
+static void setup(void)
+{
+	ftrace_initialize();
+}
+
+static void cleanup(void)
+{
+	ftrace_cleanup();
+}
+
+static struct tst_test test = {
+	.test_all = run_test,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.tags = (const struct tst_tag[]) {
+		{"linux-git", "1dbd195"},
+		{}
+	}
+};
+
-- 
2.50.1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [LTP PATCH v4 3/5] ftrace: Convert ftrace_regression02.sh to C
  2026-06-08  5:49 [LTP] [LTP PATCH v4 0/5] ftrace: Convert shell tests to C Praveen K Pandey
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 1/5] ftrace: Add common library for C implementation Praveen K Pandey
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 2/5] ftrace: Convert ftrace_regression01.sh to C Praveen K Pandey
@ 2026-06-08  5:49 ` Praveen K Pandey
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 4/5] ftrace: Convert ftrace_stress_test.sh " Praveen K Pandey
  2026-06-08  5:50 ` [LTP] [LTP PATCH v4 5/5] ftrace: Remove obsolete shell test files Praveen K Pandey
  4 siblings, 0 replies; 8+ messages in thread
From: Praveen K Pandey @ 2026-06-08  5:49 UTC (permalink / raw)
  To: ltp

Convert ftrace_regression02.sh to C implementation using LTP new API.

This test verifies that the signal:signal_generate tracepoint exposes 'grp='
and 'res=' fields. These fields were added by commits 6c303d3 and 163566f
in kernel 3.2. The test enables the signal_generate event, generates signals,
and checks the trace output for the presence of both fields.

The test requires root to access and configure the ftrace subsystem via debugfs.
Uses .min_kver to enforce kernel version requirement instead of inline check.

Signed-off-by: Praveen K Pandey <praveen@linux.ibm.com>
---
 .../tracing/ftrace_test/ftrace_regression02.c | 103 ++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_regression02.c

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_regression02.c b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.c
new file mode 100644
index 000000000..4d960cb82
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.c
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2015 Red Hat Inc.
+ * Copyright (c) 2024 Linux Test Project
+ * Copyright (c) IBM, 2026
+ *
+ * Author: Li Wang <liwang@redhat.com>
+ * Converted to C by: Praveen K Pandey <praveen@linux.ibm.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Verify that signal:signal_generate tracepoint exposes 'grp=' and 'res=' fields.
+ *
+ * This test verifies kernel commits that added more information to the
+ * signal_generate tracepoint:
+ *
+ * - Commit 6c303d3 (tracing: let trace_signal_generate() report more info...)
+ * - Commit 163566f (tracing: send_sigqueue() needs trace_signal_generate())
+ *
+ * These fields were added in kernel 3.2.
+ *
+ * Requires root to access and configure the ftrace subsystem via debugfs.
+ *
+ * [Algorithm]
+ *
+ * - Enable signal:signal_generate event
+ * - Enable tracing
+ * - Generate signals by running commands
+ * - Read trace output and search for 'grp=' and 'res=' fields
+ * - Test passes if both fields are found in the trace
+ */
+
+#include "tst_test.h"
+#include "ftrace_lib.h"
+
+#define SIGNAL_LOOP 100
+
+static void run_test(void)
+{
+	int i;
+	char *trace_content;
+	int found = 0;
+
+	/* Set event */
+	if (ftrace_write_file("set_event", "signal:signal_generate\n") != 0)
+		tst_brk(TBROK, "Failed to set signal:signal_generate event");
+
+	/* Enable tracing */
+	ftrace_enable_tracing();
+
+	/* Clear trace buffer */
+	ftrace_clear_trace();
+
+	/* Generate some signals by running commands */
+	for (i = 0; i < SIGNAL_LOOP; i++) {
+		/* Run a simple command that will generate signals */
+		if (system("ls -l /proc > /dev/null 2>&1") == -1)
+			tst_res(TINFO, "Command execution failed, continuing...");
+	}
+
+	/* Wait for trace to be written and contain signal events */
+	trace_content = TST_RETRY_FUNC(ftrace_read_file("trace"), TST_RETVAL_NOTNULL);
+	if (!trace_content)
+		tst_brk(TBROK, "Failed to read trace file");
+
+	/* Check for 'grp=' and 'res=' fields in trace */
+	if (strstr(trace_content, "grp=") && strstr(trace_content, "res="))
+		found = 1;
+
+	free(trace_content);
+
+	if (found)
+		tst_res(TPASS, "signal_generate event contains grp and res fields");
+	else
+		tst_res(TFAIL, "signal_generate event missing grp or res fields");
+}
+
+static void setup(void)
+{
+	ftrace_initialize();
+}
+
+static void cleanup(void)
+{
+	ftrace_cleanup();
+}
+
+static struct tst_test test = {
+	.test_all = run_test,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.min_kver = "3.2",
+	.tags = (const struct tst_tag[]) {
+		{"linux-git", "6c303d3"},
+		{"linux-git", "163566f"},
+		{}
+	}
+};
+
-- 
2.50.1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [LTP PATCH v4 4/5] ftrace: Convert ftrace_stress_test.sh to C
  2026-06-08  5:49 [LTP] [LTP PATCH v4 0/5] ftrace: Convert shell tests to C Praveen K Pandey
                   ` (2 preceding siblings ...)
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 3/5] ftrace: Convert ftrace_regression02.sh " Praveen K Pandey
@ 2026-06-08  5:49 ` Praveen K Pandey
  2026-06-08  5:50 ` [LTP] [LTP PATCH v4 5/5] ftrace: Remove obsolete shell test files Praveen K Pandey
  4 siblings, 0 replies; 8+ messages in thread
From: Praveen K Pandey @ 2026-06-08  5:49 UTC (permalink / raw)
  To: ltp

Convert ftrace_stress_test.sh to C implementation using LTP new API.

This test performs stress testing of the ftrace subsystem by running multiple
concurrent threads, each exercising different ftrace features (switching tracers,
reading trace_pipe, enabling/disabling events, modifying buffer size, etc.).
All threads run concurrently for 60 seconds to detect race conditions and
verify system stability.

The test requires root to access and configure the ftrace subsystem via debugfs.

Also update:
- Makefile: Add new C test targets and library compilation
- .gitignore: Ignore compiled test binaries
- runtest/tracing: Update test entries to use C implementations

Signed-off-by: Praveen K Pandey <praveen@linux.ibm.com>
---
 runtest/tracing                               |   6 +-
 .../kernel/tracing/ftrace_test/.gitignore     |   4 +
 testcases/kernel/tracing/ftrace_test/Makefile |  19 +-
 .../tracing/ftrace_test/ftrace_stress_test.c  | 322 ++++++++++++++++++
 4 files changed, 346 insertions(+), 5 deletions(-)
 create mode 100644 testcases/kernel/tracing/ftrace_test/.gitignore
 create mode 100644 testcases/kernel/tracing/ftrace_test/ftrace_stress_test.c

diff --git a/runtest/tracing b/runtest/tracing
index 674e2ad97..4204c2dc4 100644
--- a/runtest/tracing
+++ b/runtest/tracing
@@ -1,7 +1,7 @@
 #DESCRIPTION:Tracing testing
-ftrace_regression01	ftrace_regression01.sh
-ftrace_regression02	ftrace_regression02.sh
-ftrace-stress-test	ftrace_stress_test.sh 90
+ftrace_regression01	ftrace_regression01
+ftrace_regression02	ftrace_regression02
+ftrace-stress-test	ftrace_stress_test
 dynamic_debug01		dynamic_debug01.sh
 fanotify25 fanotify25
 pt_full_trace_basic pt_test
diff --git a/testcases/kernel/tracing/ftrace_test/.gitignore b/testcases/kernel/tracing/ftrace_test/.gitignore
new file mode 100644
index 000000000..9e102074c
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/.gitignore
@@ -0,0 +1,4 @@
+ftrace_regression01
+ftrace_regression02
+ftrace_stress_test
+
diff --git a/testcases/kernel/tracing/ftrace_test/Makefile b/testcases/kernel/tracing/ftrace_test/Makefile
index e4a913a56..2528b9f15 100644
--- a/testcases/kernel/tracing/ftrace_test/Makefile
+++ b/testcases/kernel/tracing/ftrace_test/Makefile
@@ -1,7 +1,22 @@
-top_srcdir              ?= ../../../..
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2010 FUJITSU LIMITED
+# Copyright (c) 2024 Linux Test Project
+# Copyright (c) IBM, 2026
+# Converted to C by: Praveen K Pandey <praveen@linux.ibm.com>
+
+top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-INSTALL_TARGETS         := *.sh ftrace_stress/*
+# Filter out ftrace_lib from standalone build targets
+FILTER_OUT_MAKE_TARGETS := ftrace_lib
+
+# Only ftrace_stress_test needs pthread
+ftrace_stress_test: LDLIBS += -lpthread
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+# C test binaries with shared library dependencies
+ftrace_regression01:	ftrace_lib.o
+ftrace_regression02:	ftrace_lib.o
+ftrace_stress_test:	ftrace_lib.o
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.c b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.c
new file mode 100644
index 000000000..182d296fc
--- /dev/null
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.c
@@ -0,0 +1,322 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2010 FUJITSU LIMITED
+ * Copyright (c) 2024 Linux Test Project
+ * Copyright (c) IBM, 2026
+ *
+ * Author: Li Zefan <lizf@cn.fujitsu.com>
+ * Converted to C by: Praveen K Pandey <praveen@linux.ibm.com>
+ */
+
+/*\
+ * Stress test for ftrace subsystem.
+ *
+ * This test exercises various ftrace features concurrently to detect
+ * race conditions, memory leaks, and other issues in the ftrace subsystem.
+ *
+ * Requires root to access and configure the ftrace subsystem via debugfs.
+ *
+ * [Algorithm]
+ *
+ * The test spawns multiple threads, each exercising a different ftrace
+ * feature:
+ *
+ * - Switching between different tracers
+ * - Reading from trace_pipe
+ * - Enabling/disabling events
+ * - Modifying buffer size
+ * - Setting trace filters
+ * - Modifying trace options
+ * - And more...
+ *
+ * All threads run concurrently for a specified duration, then the test
+ * verifies the system is still stable.
+ */
+
+#include <pthread.h>
+#include <signal.h>
+#include "tst_test.h"
+#include "ftrace_lib.h"
+
+#define DEFAULT_TEST_DURATION 60  /* seconds */
+#define MAX_THREADS 20
+
+static volatile int stop_testing = 0;
+static int test_duration = DEFAULT_TEST_DURATION;
+static pthread_t threads[MAX_THREADS];
+static int thread_count = 0;
+
+struct stress_test {
+	const char *name;
+	const char *file;
+	void *(*func)(void *);
+	int enabled;
+};
+
+/* Thread function for current_tracer stress test */
+static void *stress_current_tracer(void *arg)
+{
+	int count;
+	char **tracers;
+	int i, loop;
+
+	(void)arg;
+
+	tracers = ftrace_get_available_tracers(&count);
+	if (!tracers || count == 0) {
+		tst_res(TINFO, "No tracers available");
+		return NULL;
+	}
+
+	loop = 0;
+	while (!stop_testing) {
+		for (i = 0; i < count && !stop_testing; i++) {
+			/* Skip mmiotrace as it can cause issues */
+			if (strcmp(tracers[i], "mmiotrace") == 0)
+				continue;
+
+			ftrace_set_tracer(tracers[i]);
+		}
+		loop++;
+		if (loop >= 200)
+			usleep(1000000);  /* Sleep 1 second after 200 loops */
+	}
+
+	for (i = 0; i < count; i++)
+		free(tracers[i]);
+	free(tracers);
+
+	return NULL;
+}
+
+/* Thread function for trace_pipe stress test */
+static void *stress_trace_pipe(void *arg)
+{
+	char *path;
+	FILE *fp;
+	int loop = 0;
+
+	(void)arg;
+
+	path = ftrace_get_path("trace_pipe");
+	if (!path)
+		return NULL;
+
+	while (!stop_testing) {
+		fp = fopen(path, "r");
+		if (fp) {
+			/* Read for a short time */
+			usleep(200000);  /* 200ms */
+			fclose(fp);
+		}
+
+		usleep(200000);  /* 200ms */
+		loop++;
+		if (loop >= 20) {
+			sleep(2);
+			loop = 0;
+		}
+	}
+
+	free(path);
+	return NULL;
+}
+
+/* Thread function for set_event stress test */
+static void *stress_set_event(void *arg)
+{
+	int i;
+
+	(void)arg;
+
+	while (!stop_testing) {
+		/* Enable/disable all events */
+		for (i = 0; i < 100 && !stop_testing; i++) {
+			ftrace_write_file("events/enable", "1\n");
+			ftrace_write_file("events/enable", "0\n");
+		}
+
+		sleep(1);
+	}
+
+	return NULL;
+}
+
+/* Thread function for buffer_size_kb stress test */
+static void *stress_buffer_size(void *arg)
+{
+	const char *sizes[] = {"1024", "2048", "4096", "8192"};
+	int i;
+
+	(void)arg;
+
+	while (!stop_testing) {
+		for (i = 0; i < 4 && !stop_testing; i++) {
+			char buf[32];
+			snprintf(buf, sizeof(buf), "%s\n", sizes[i]);
+			ftrace_write_file("buffer_size_kb", buf);
+			usleep(100000);
+		}
+		sleep(1);
+	}
+
+	return NULL;
+}
+
+/* Thread function for tracing_on stress test */
+static void *stress_tracing_on(void *arg)
+{
+	int i;
+
+	(void)arg;
+
+	while (!stop_testing) {
+		for (i = 0; i < 100 && !stop_testing; i++) {
+			ftrace_enable_tracing();
+			ftrace_disable_tracing();
+		}
+		sleep(1);
+	}
+
+	return NULL;
+}
+
+/* Thread function for trace_options stress test */
+static void *stress_trace_options(void *arg)
+{
+	const char *options[] = {
+		"print-parent", "sym-offset", "sym-addr",
+		"verbose", "raw", "hex", "bin", "block"
+	};
+	int i;
+
+	(void)arg;
+
+	while (!stop_testing) {
+		for (i = 0; i < 8 && !stop_testing; i++) {
+			char buf[64];
+			snprintf(buf, sizeof(buf), "%s\n", options[i]);
+			ftrace_write_file("trace_options", buf);
+			snprintf(buf, sizeof(buf), "no%s\n", options[i]);
+			ftrace_write_file("trace_options", buf);
+		}
+		sleep(1);
+	}
+
+	return NULL;
+}
+
+/* Thread function for set_ftrace_filter stress test */
+static void *stress_set_ftrace_filter(void *arg)
+{
+	(void)arg;
+
+	if (!ftrace_file_exists("set_ftrace_filter"))
+		return NULL;
+
+	while (!stop_testing) {
+		ftrace_write_file("set_ftrace_filter", "schedule\n");
+		ftrace_write_file("set_ftrace_filter", "\n");
+		usleep(500000);
+	}
+
+	return NULL;
+}
+
+static struct stress_test stress_tests[] = {
+	{"current_tracer", "current_tracer", stress_current_tracer, 0},
+	{"trace_pipe", "trace_pipe", stress_trace_pipe, 0},
+	{"set_event", "events/enable", stress_set_event, 0},
+	{"buffer_size_kb", "buffer_size_kb", stress_buffer_size, 0},
+	{"tracing_on", "tracing_on", stress_tracing_on, 0},
+	{"trace_options", "trace_options", stress_trace_options, 0},
+	{"set_ftrace_filter", "set_ftrace_filter", stress_set_ftrace_filter, 0},
+	{NULL, NULL, NULL, 0}
+};
+
+static void check_available_tests(void)
+{
+	int i;
+
+	for (i = 0; stress_tests[i].name; i++) {
+		if (ftrace_file_exists(stress_tests[i].file) ||
+		    access(stress_tests[i].file, F_OK) == 0) {
+			stress_tests[i].enabled = 1;
+			tst_res(TINFO, "Test target available: %s", stress_tests[i].name);
+		} else {
+			tst_res(TINFO, "Test target not available: %s", stress_tests[i].name);
+		}
+	}
+}
+
+static void start_stress_tests(void)
+{
+	int i;
+
+	thread_count = 0;
+	for (i = 0; stress_tests[i].name; i++) {
+		if (!stress_tests[i].enabled)
+			continue;
+
+		if (pthread_create(&threads[thread_count], NULL,
+				   stress_tests[i].func, NULL) != 0) {
+			tst_res(TWARN, "Failed to create thread for %s",
+				stress_tests[i].name);
+		} else {
+			tst_res(TINFO, "Started stress test: %s", stress_tests[i].name);
+			thread_count++;
+		}
+	}
+
+	tst_res(TINFO, "Started %d stress test threads", thread_count);
+}
+
+static void stop_stress_tests(void)
+{
+	int i;
+
+	stop_testing = 1;
+
+	for (i = 0; i < thread_count; i++) {
+		pthread_join(threads[i], NULL);
+	}
+
+	tst_res(TINFO, "All stress test threads stopped");
+}
+
+static void run_test(void)
+{
+	tst_res(TINFO, "Starting ftrace stress test for %d seconds", test_duration);
+
+	check_available_tests();
+	start_stress_tests();
+
+	/* Run for specified duration */
+	sleep(test_duration);
+
+	stop_stress_tests();
+
+	tst_res(TPASS, "Ftrace stress test completed successfully");
+	tst_res(TINFO, "Check dmesg for any kernel warnings or errors");
+}
+
+static void setup(void)
+{
+	ftrace_initialize();
+}
+
+static void cleanup(void)
+{
+	stop_testing = 1;
+	ftrace_cleanup();
+}
+
+static struct tst_test test = {
+	.test_all = run_test,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.timeout = DEFAULT_TEST_DURATION + 30,
+};
+
-- 
2.50.1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [LTP PATCH v4 5/5] ftrace: Remove obsolete shell test files
  2026-06-08  5:49 [LTP] [LTP PATCH v4 0/5] ftrace: Convert shell tests to C Praveen K Pandey
                   ` (3 preceding siblings ...)
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 4/5] ftrace: Convert ftrace_stress_test.sh " Praveen K Pandey
@ 2026-06-08  5:50 ` Praveen K Pandey
  4 siblings, 0 replies; 8+ messages in thread
From: Praveen K Pandey @ 2026-06-08  5:50 UTC (permalink / raw)
  To: ltp

Remove the old shell-based test implementations that have been
converted to C:
- ftrace_lib.sh
- ftrace_regression01.sh
- ftrace_regression02.sh
- ftrace_stress_test.sh
- ftrace_stress/*.sh (19 stress test scripts)

These are replaced by the new C implementations using LTP new API.

Signed-off-by: Praveen K Pandey <praveen@linux.ibm.com>
---
 .../kernel/tracing/ftrace_test/ftrace_lib.sh  | 180 ------------------
 .../ftrace_test/ftrace_regression01.sh        |  83 --------
 .../ftrace_test/ftrace_regression02.sh        |  63 ------
 .../ftrace_stress/ftrace_buffer_size_kb.sh    |  45 -----
 .../ftrace_stress/ftrace_current_tracer.sh    |  32 ----
 .../ftrace_stress/ftrace_ftrace_enabled.sh    |  38 ----
 .../ftrace_function_profile_enabled.sh        |  38 ----
 .../ftrace_stress/ftrace_set_event.sh         |  46 -----
 .../ftrace_stress/ftrace_set_ftrace_filter.sh | 119 ------------
 .../ftrace_stress/ftrace_set_ftrace_pid.sh    |  37 ----
 .../ftrace_stress/ftrace_stack_max_size.sh    |  27 ---
 .../ftrace_stress/ftrace_stack_trace.sh       |  35 ----
 .../ftrace_test/ftrace_stress/ftrace_trace.sh |  25 ---
 .../ftrace_stress/ftrace_trace_clock.sh       |  27 ---
 .../ftrace_stress/ftrace_trace_options.sh     |  58 ------
 .../ftrace_stress/ftrace_trace_pipe.sh        |  45 -----
 .../ftrace_stress/ftrace_trace_stat.sh        |  38 ----
 .../ftrace_stress/ftrace_tracing_cpumask.sh   |  91 ---------
 .../ftrace_stress/ftrace_tracing_enabled.sh   |  38 ----
 .../ftrace_tracing_max_latency.sh             |  27 ---
 .../ftrace_stress/ftrace_tracing_on.sh        |  38 ----
 .../tracing/ftrace_test/ftrace_stress_test.sh | 121 ------------
 22 files changed, 1251 deletions(-)
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh
 delete mode 100755 testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh

diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh b/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
deleted file mode 100755
index 5f8f8a2c4..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
+++ /dev/null
@@ -1,180 +0,0 @@
-#!/bin/sh
-
-###########################################################################
-##                                                                       ##
-## Copyright (c) 2010 FUJITSU LIMITED                                    ##
-##                                                                       ##
-## This program is free software: you can redistribute it and/or modify  ##
-## it under the terms of the GNU General Public License as published by  ##
-## the Free Software Foundation, either version 3 of the License, or     ##
-## (at your option) any later version.                                   ##
-##                                                                       ##
-## This program is distributed in the hope that it will be useful,       ##
-## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
-## GNU General Public License for more details.                          ##
-##                                                                       ##
-## You should have received a copy of the GNU General Public License     ##
-## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
-##                                                                       ##
-## Author: Li Zefan <lizf@cn.fujitsu.com>                                ##
-##                                                                       ##
-###########################################################################
-
-. test.sh
-
-ftrace_test_init()
-{
-	export TPATH="$PWD"
-	export SPATH="$TPATH/ftrace_stress"
-
-	if grep -q debugfs /proc/mounts; then
-		export DEBUGFS_PATH=/sys/kernel/debug/
-		export TRACING_PATH="$DEBUGFS_PATH/tracing"
-		debugfs_def_mounted=1
-	else
-		tst_tmpdir
-		export DEBUGFS_PATH="$PWD/debugfs"
-		export TRACING_PATH="$PWD/debugfs/tracing"
-		mkdir $DEBUGFS_PATH
-		mount -t debugfs xxx $DEBUGFS_PATH
-	fi
-
-	TST_CLEANUP=clean_up
-
-	trap clean_up_exit INT
-
-	tst_require_root
-
-	# Check to see tracing feature is supported or not
-	if [ ! -d $TRACING_PATH ]; then
-		tst_brkm TCONF "Tracing is not supported. Skip the test..."
-	fi
-
-	save_old_setting
-}
-
-test_interval=$1
-
-save_old_setting()
-{
-	cd $TRACING_PATH
-
-	old_trace_options=`cat trace_options`
-	old_tracing_on=`cat tracing_on`
-	old_buffer_size=`cat buffer_size_kb`
-	old_tracing_cpumask=`cat tracing_cpumask`
-
-	if [ -e tracing_cpumask ]; then
-		old_tracing_cpumask=`cat tracing_cpumask`
-	fi
-
-	if [ -e tracing_enabled ]; then
-		old_tracing_enabled=`cat tracing_enabled`
-	fi
-
-	if [ -e stack_max_size ]; then
-		old_stack_tracer_enabled=`cat /proc/sys/kernel/stack_tracer_enabled`
-	fi
-
-	if [ -e "/proc/sys/kernel/ftrace_enabled" ]; then
-		old_ftrace_enabled=`cat /proc/sys/kernel/ftrace_enabled`
-	fi
-
-	if [ -e "function_profile_enabled" ]; then
-		old_profile_enabled=`cat function_profile_enabled`
-	fi
-
-	setting_saved=1
-
-	cd - > /dev/null
-}
-
-restore_old_setting()
-{
-	if [ ! "$setting_saved" = 1 ]; then
-		return
-	fi
-
-	cd $TRACING_PATH
-
-	echo nop > current_tracer
-	echo 0 > events/enable
-	if [ -e tracing_max_latency ]; then
-		echo 0 > tracing_max_latency
-	fi
-
-	if [ -e tracing_cpumask ]; then
-		echo $old_tracing_cpumask > tracing_cpumask
-	fi
-
-	if [ -e trace_clock ]; then
-		echo local > trace_clock
-	fi
-
-	if [ -e "function_pofile_enabled" ]; then
-		echo $old_profile_enabled > function_profile_enabled
-	fi
-
-	if [ -e "/proc/sys/kernel/ftrace_enabled" ]; then
-		echo $old_ftrace_enabled > /proc/sys/kernel/ftrace_enabled
-	fi
-
-	if [ -e stack_max_size ]; then
-		echo $old_stack_tracer_enabled > /proc/sys/kernel/stack_tracer_enabled
-		echo 0 > stack_max_size
-	fi
-
-	echo $old_buffer_size > buffer_size_kb
-	echo $old_tracing_on > tracing_on
-
-	if [ -e tracing_enabled ]; then
-		echo $old_tracing_enabled > tracing_enabled
-	fi
-
-	for option in $old_trace_options; do
-		echo $option > trace_options 2> /dev/null
-	done
-
-	echo > trace
-
-	if [ -f set_ftrace_filter ]; then
-		echo  > set_ftrace_filter
-	fi
-
-	cd - > /dev/null
-}
-
-clean_up_mount()
-{
-	if [ ! "$debugfs_def_mounted" = "1" ]; then
-		umount $DEBUGFS_PATH
-		rmdir $DEBUGFS_PATH
-	fi
-}
-
-clean_up()
-{
-	restore_old_setting
-	clean_up_mount
-}
-
-clean_up_exit()
-{
-	restore_old_setting
-	clean_up_mount
-	exit 1
-}
-
-test_begin()
-{
-	start_time=`date +%s`
-}
-
-test_wait()
-{
-	# run the test for $test_interval secs
-	tst_sleep ${test_interval}s
-}
-
-ftrace_test_init
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh b/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh
deleted file mode 100755
index d6969cfc6..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh
+++ /dev/null
@@ -1,83 +0,0 @@
-#! /bin/sh
-
-###########################################################################
-##                                                                       ##
-## Copyright (c) 2015, Red Hat Inc.                                      ##
-##                                                                       ##
-## This program is free software: you can redistribute it and/or modify  ##
-## it under the terms of the GNU General Public License as published by  ##
-## the Free Software Foundation, either version 3 of the License, or     ##
-## (at your option) any later version.                                   ##
-##                                                                       ##
-## This program is distributed in the hope that it will be useful,       ##
-## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
-## GNU General Public License for more details.                          ##
-##                                                                       ##
-## You should have received a copy of the GNU General Public License     ##
-## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
-##                                                                       ##
-## Author: Li Wang <liwang@redhat.com>                                   ##
-##                                                                       ##
-###########################################################################
-##                                                                       ##
-## Summary:  panic while using userstacktrace                            ##
-##                                                                       ##
-## BUG: unable to handle kernel paging request at 00000000417683c0       ##
-##      IP: [<ffffffff8105c834>] update_curr+0x124/0x1e0                 ##
-##      PGD 41a796067 PUD 0                                              ##
-##      Thread overran stack, or stack corrupted                         ##
-##      Oops: 0000 [#1] SMP                                              ##
-##      last sysfs file: ../system/cpu/cpu15/cache/index2/shared_cpu_map ##
-##                                                                       ##
-## The bug was fixed by:                                                 ##
-##      1dbd195 (tracing: Fix preempt count leak)                        ##
-##                                                                       ##
-###########################################################################
-
-export TCID="ftrace_regression01"
-export TST_TOTAL=1
-
-. ftrace_lib.sh
-
-LOOP=10
-
-TSTACK_TRACE_PATH="/proc/sys/kernel/stack_tracer_enabled"
-EXC_PAGE_FAULT_ENABLE="$TRACING_PATH/events/exceptions/page_fault_kernel/enable"
-MM_PAGE_FAULT_ENABLE="$TRACING_PATH/events/kmem/mm_kernel_pagefault/enable"
-
-ftrace_userstacktrace_test()
-{
-	if [ ! -e "$TSTACK_TRACE_PATH" ]; then
-		tst_brkm TCONF "Stack Tracer is not cofigured in This kernel"
-	fi
-
-	for i in $(seq $LOOP); do
-		echo 1 >  $TSTACK_TRACE_PATH
-		echo userstacktrace > $TRACING_PATH/trace_options
-		grep -q "^userstacktrace"  $TRACING_PATH/trace_options
-		if [ $? -ne 0 ]; then
-			tst_brkm TBROK "Failed to set userstacktrace"
-		fi
-
-		if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then
-			exc_page_fault_enable=`cat $EXC_PAGE_FAULT_ENABLE`
-			echo 1 > $EXC_PAGE_FAULT_ENABLE
-		else
-			mm_page_fault_enable=`cat $MM_PAGE_FAULT_ENABLE`
-			echo 1 > $MM_PAGE_FAULT_ENABLE
-		fi
-	done
-
-	if [ -f "$EXC_PAGE_FAULT_ENABLE" ]; then
-		echo "$exc_page_fault_enable" > $EXC_PAGE_FAULT_ENABLE
-	else
-		echo "$mm_page_fault_enable" > $MM_PAGE_FAULT_ENABLE
-	fi
-
-	tst_resm TPASS "Finished running the test"
-}
-
-ftrace_userstacktrace_test
-
-tst_exit
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh
deleted file mode 100755
index 3c32f219e..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#! /bin/sh
-
-###########################################################################
-##                                                                       ##
-## Copyright (c) 2015, Red Hat Inc.                                      ##
-##                                                                       ##
-## This program is free software: you can redistribute it and/or modify  ##
-## it under the terms of the GNU General Public License as published by  ##
-## the Free Software Foundation, either version 3 of the License, or     ##
-## (at your option) any later version.                                   ##
-##                                                                       ##
-## This program is distributed in the hope that it will be useful,       ##
-## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
-## GNU General Public License for more details.                          ##
-##                                                                       ##
-## You should have received a copy of the GNU General Public License     ##
-## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
-##                                                                       ##
-## Author: Li Wang <liwang@redhat.com>                                   ##
-##                                                                       ##
-###########################################################################
-##                                                                       ##
-## Summary: check signal:signal_generate gives 2 more fields: grp res    ##
-##                                                                       ##
-## This testcase is writing for signal events change:                    ##
-##       6c303d3 tracing: let trace_signal_generate() report more info...##
-##       163566f tracing: send_sigqueue() needs trace_signal_generate()  ##
-##                                                                       ##
-###########################################################################
-
-export TCID="ftrace_regression02"
-export TST_TOTAL=1
-
-. ftrace_lib.sh
-
-ftrace_signal_test()
-{
-	# Set envent
-	echo 'signal:signal_generate' > $TRACING_PATH/set_event
-	echo 1 > $TRACING_PATH/tracing_on
-	echo > $TRACING_PATH/trace
-
-	# just to generate trace
-	for i in $(seq 100); do
-		ls -l /proc > /dev/null 2>&1
-	done
-
-	grep -q 'grp=[0-9] res=[0-9]' $TRACING_PATH/trace
-	if [ $? -eq 0 ]; then
-		tst_resm TPASS "finished running the test."
-	else
-		tst_resm TFAIL "running the test failed, please check log message."
-	fi
-}
-
-if tst_kvcmp -lt "3.2"; then
-	tst_brkm TCONF "The test should be run in kernels >= 3.2.0 Skip the test..."
-fi
-
-ftrace_signal_test
-
-tst_exit
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
deleted file mode 100755
index 665291406..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-# Use up to 10% of free memory
-free_mem=`cat /proc/meminfo | grep '^MemFree' | awk '{ print $2 }'`
-cpus=`tst_ncpus`
-
-step=$(( $free_mem / 10 / $LOOP / $cpus ))
-
-if [ $step -eq 0 ]; then
-	step=1
-	LOOP=50
-fi
-
-while true; do
-	new_size=1
-	i=0
-	while [ $i -lt $LOOP ]; do
-		echo $new_size > "$TRACING_PATH"/buffer_size_kb
-		new_size=$(( $new_size + $step ))
-		i=$((i + 1))
-	done
-
-	i=0
-	while [ $i -lt $LOOP ]; do
-		new_size=$(( $new_size - $step ))
-		echo $new_size > "$TRACING_PATH"/buffer_size_kb
-		i=$((i + 1))
-	done
-	sleep 1
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh
deleted file mode 100755
index 104b57750..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-while true; do
-	i=0
-	while [ $i -lt $LOOP ]; do
-		for tracer in `cat "$TRACING_PATH"/available_tracers`
-		do
-			if [ "$tracer" = mmiotrace ]; then
-				continue
-			fi
-
-			echo $tracer > "$TRACING_PATH"/current_tracer 2> /dev/null
-		done
-		i=$((i + 1))
-	done
-	sleep 1
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh
deleted file mode 100755
index c6f8b48df..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_ftrace_enabled.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LOOP=1500
-count=0
-
-while true; do
-	count=$(( $count + 1 ))
-	i=0
-	while [ $i -lt $MAX_LOOP ]; do
-		echo 0 > /proc/sys/kernel/ftrace_enabled
-		echo 1 > /proc/sys/kernel/ftrace_enabled
-		i=$((i + 1))
-	done
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 1 > /proc/sys/kernel/ftrace_enabled
-	else
-		echo 0 > /proc/sys/kernel/ftrace_enabled
-	fi
-
-	sleep 1
-done
-
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh
deleted file mode 100755
index 7687420c7..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_function_profile_enabled.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LOOP=1500
-count=0
-
-
-while true; do
-	count=$(( $count + 1 ))
-	i=0
-	while [ $i -lt $MAX_LOOP ]; do
-		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-		i=$((i + 1))
-	done
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 1 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	else
-		echo 0 > "$TRACING_PATH"/function_profile_enabled 2> /dev/null
-	fi
-
-	sleep 1
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
deleted file mode 100755
index 9a79b4201..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_event.sh
+++ /dev/null
@@ -1,46 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-while true; do
-	i=0
-	while [ $i -lt 100 ]; do
-		echo 1 > "$TRACING_PATH"/events/enable
-		echo 0 > "$TRACING_PATH"/events/enable
-		i=$((i + 1))
-	done
-
-	for dir in `ls $TRACING_PATH/events/`; do
-		if [ ! -d $dir -o "$dir" = ftrace ]; then
-			continue;
-		fi
-
-		i=0
-		while [ $i -lt 20 ]; do
-			echo 1 > "$TRACING_PATH"/events/$dir/enable
-			echo 0 > "$TRACING_PATH"/events/$dir/enable
-			i=$((i + 1))
-		done
-	done
-
-	for event in `cat $TRACING_PATH/available_events`; do
-		# ftrace event sys is special, skip it
-		if echo "$event" | grep "ftrace:*"; then
-			continue
-		fi
-		echo $event >> "$TRACING_PATH"/set_event
-	done
-
-	sleep 1
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh
deleted file mode 100755
index af6ec9f05..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_filter.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#! /bin/sh
-###########################################################################
-##                                                                       ##
-## Copyright (c) 2015, Red Hat Inc.                                      ##
-##                                                                       ##
-## This program is free software: you can redistribute it and/or modify  ##
-## it under the terms of the GNU General Public License as published by  ##
-## the Free Software Foundation, either version 3 of the License, or     ##
-## (at your option) any later version.                                   ##
-##                                                                       ##
-## This program is distributed in the hope that it will be useful,       ##
-## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
-## GNU General Public License for more details.                          ##
-##                                                                       ##
-## You should have received a copy of the GNU General Public License     ##
-## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
-##                                                                       ##
-## Author: Chunyu Hu <chuhu@redhat.com>                                  ##
-##                                                                       ##
-###########################################################################
-
-. test.sh
-
-triggers="traceon traceoff enable_event disable_event snapshot \
-	 dump cpudump stacktrace module function"
-nr_triggers=$(echo ${triggers} | wc -w)
-
-module_pick()
-{
-	nr_module=$(lsmod | wc -l)
-	pick_one=$(tst_random 1 $nr_module)
-	picked_module=$(lsmod | awk "{if (NR == $pick_one) {print \$1}}")
-}
-
-filter_file=$TRACING_PATH/available_filter_functions
-nr_functions=$(awk 'END{print NR}' $filter_file)
-
-function_pick()
-{
-	if [ -f $filter_file ]; then
-		local pick_one=$(tst_random 1 $nr_functions)
-		picked_function=$(awk "{if (NR == $pick_one) {print \$1}}" $filter_file)
-		echo $picked_function
-	else
-		echo "\*sched\*"
-	fi
-}
-
-event_pick()
-{
-	local events_file=$TRACING_PATH/available_events
-	if [ -f $events_file ]; then
-		nr_events=$(awk 'END{print NR}' $events_file)
-		local pick_one=$(tst_random 1 $nr_events)
-		picked_event=$(awk "{if (NR == $pick_one) {print \$0}}" $events_file)
-		echo "$picked_event"
-	else
-		echo "sched:sched_switch"
-	fi
-}
-
-filter_formatter()
-{
-	function_str=$(function_pick)
-	count=$(tst_random 0 2)
-
-	case $1 in
-	traceon|traceoff|snapshot|dump|cpudump|stacktrace)
-		trigger=$1
-		;;
-	enable_event|disable_event)
-		event_sys_name=$(event_pick)
-		trigger=$1:$event_sys_name
-		;;
-	module)
-		module_pick
-		echo ":mod:$picked_module"
-		return
-		;;
-	function)
-		echo "$function_str"
-		return
-		;;
-	*)
-		trigger=$1
-		;;
-	esac
-
-	if [ $count -gt 0 ]; then
-		trigger=$trigger:$count
-	fi
-	echo $function_str:$trigger
-}
-
-signal_handler()
-{
-	tst_exit
-}
-
-trap signal_handler SIGTERM
-
-while true; do
-	# Here try to check if a race caused issue can be hit.
-	cat $TRACING_PATH/set_ftrace_filter > /dev/null
-
-	trigger_index=$(tst_random 1 $nr_triggers)
-	trigger_name=$(echo $triggers | awk "{print \$$trigger_index}")
-	filter_format=$(filter_formatter $trigger_name)
-
-	echo "$filter_format" > $TRACING_PATH/set_ftrace_filter
-	[ $? -ne 0 ] && tst_resm TFAIL "$0: setup filter <$filter_format> failed"
-
-	sleep 2
-
-	echo "!$filter_format" > $TRACING_PATH/set_ftrace_filter
-	[ $? -ne 0 ] && tst_resm TFAIL "$0: remove filter <$filter_format> failed"
-done
-
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
deleted file mode 100755
index fd42de4f3..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_set_ftrace_pid.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=300
-
-while true; do
-	j=0
-	while [ $j -lt $LOOP ]; do
-		k=1
-		while [ $k -le $NR_PIDS ]; do
-			str="\$pid$k"
-			eval echo $str >> "$TRACING_PATH"/set_ftrace_pid
-			k=$((k + 1))
-		done
-
-		if ! echo > "$TRACING_PATH"/set_ftrace_pid >/dev/null 2>&1; then
-			if ! echo -1 > "$TRACING_PATH"/set_ftrace_pid >/dev/null 2>&1; then
-				tst_resm TBROK "Cannot disable set_ftrace_pid!"
-				exit 1
-			fi
-		fi
-		j=$((j + 1))
-	done
-	sleep 1
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
deleted file mode 100755
index 0842929aa..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_max_size.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_STACK_SIZE=8192
-
-while true; do
-	i=0
-	while [ $i -lt $MAX_STACK_SIZE ]; do
-		echo $i > "$TRACING_PATH"/stack_max_size
-		cat "$TRACING_PATH"/stack_max_size > /dev/null
-		i=$((i + 1))
-	done
-	sleep 1
-done
-
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
deleted file mode 100755
index 4c16a0a1d..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_stack_trace.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=400
-
-while true; do
-	i=0
-	while [ $i -lt $LOOP ]; do
-		cat "$TRACING_PATH"/stack_trace > /dev/null
-		i=$((i + 1))
-	done
-
-	sleep 1
-
-	i=0
-	while [ $i -lt $LOOP ]; do
-		echo 0 > /proc/sys/kernel/stack_tracer_enabled
-		echo 1 > /proc/sys/kernel/stack_tracer_enabled
-		i=$((i + 1))
-	done
-
-	sleep 1
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
deleted file mode 100755
index 7c45f504a..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-i=0;
-while true; do
-	while [ $i -lt $LOOP ]; do
-		cat "$TRACING_PATH"/trace > /dev/null
-		i=$((i + 1))
-	done
-	sleep 1
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
deleted file mode 100755
index 50329c684..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=400
-
-while true; do
-	i=0
-	while [ $i -lt $LOOP ]; do
-		echo local > "$TRACING_PATH"/trace_clock
-		echo global > "$TRACING_PATH"/trace_clock
-		i=$((i + 1))
-	done
-	sleep 1
-done
-
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
deleted file mode 100755
index 95da3f6c7..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-. test.sh
-
-LOOP=200
-
-while true; do
-	j=0
-	while [ $j -lt $LOOP ]; do
-		trace_options="$(ls $TRACING_PATH/options/)"
-		# enable the nop_test_refuse can cause an
-		# 'write error: Invalid argument'. So don't test it.
-		trace_options="$(echo $trace_options | sed 's/test_nop_refuse//')"
-		nr_trace_options=$(echo "${trace_options}" | wc -w)
-
-		option_index=$(tst_random 1 $nr_trace_options)
-		option=$(echo "$trace_options" | awk "{print \$$option_index}")
-		i=0
-		while [ $i -lt $nr_trace_options ]; do
-			n=$(tst_random 0 1)
-			opt_f="$TRACING_PATH"/options/$option
-			ret_val=0
-			if [ $n -eq 0 ]; then
-				operation="setup"
-			else
-				operation="clear"
-			fi
-			# On old kernel, some trace option dirs
-			# won't be made if the option has nothing
-			# to do with the current tracer. But on newer
-			# kernel(4.4-rc1), all option dirs will be made.
-			# So here check it to avoid 'Permision denied'
-			if [ -f $opt_f ]; then
-				echo $n > $opt_f
-				ret_val=$?
-			fi
-
-			if [ $ret_val -ne 0 ]; then
-				tst_resm TFAIL "$0: $operation trace option $option failed"
-			fi
-			i=$((i + 1))
-		done
-		j=$((j + 1))
-	done
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
deleted file mode 100755
index 7d49745ba..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_pipe.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-kill_this_pid()
-{
-	kill -KILL $this_pid
-	wait $this_pid
-	exit 0
-}
-
-trap kill_this_pid SIGUSR1
-
-LOOP=20
-
-while true; do
-	i=0
-	while [ $i -lt $LOOP ]; do
-		cat "$TRACING_PATH"/trace_pipe > /dev/null &
-		this_pid=$!
-
-		tst_sleep 200000us
-
-		kill -INT $this_pid
-		wait $this_pid
-
-		this_pid=0
-
-		tst_sleep 200000us
-
-		i=$((i + 1))
-	done
-	sleep 2
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
deleted file mode 100755
index f7177c988..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-LOOP=200
-
-should_skip=0
-nr_cpus=`tst_ncpus`
-
-if [ ! -e "$TRACING_PATH"/function_profile_enabled ]; then
-        should_skip=1
-fi
-
-while true; do
-	if [ $should_skip -eq 1 ]; then
-		sleep 2
-		continue
-	fi
-	cpu=$(tst_random 0 $((nr_cpus - 1)))
-	i=0;
-	while [ $i -lt $LOOP ]; do
-		cat "$TRACING_PATH"/trace_stat/function${cpu} > /dev/null 2>&1
-		i=$((i + 1))
-	done
-
-	sleep 1
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
deleted file mode 100755
index aeb0d92f8..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_cpumask.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-#! /bin/sh
-
-###########################################################################
-##                                                                       ##
-## Copyright (c) 2015, Red Hat Inc.                                      ##
-##                                                                       ##
-## This program is free software: you can redistribute it and/or modify  ##
-## it under the terms of the GNU General Public License as published by  ##
-## the Free Software Foundation, either version 3 of the License, or     ##
-## (at your option) any later version.                                   ##
-##                                                                       ##
-## This program is distributed in the hope that it will be useful,       ##
-## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
-## GNU General Public License for more details.                          ##
-##                                                                       ##
-## You should have received a copy of the GNU General Public License     ##
-## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
-##                                                                       ##
-## Author: Chunyu Hu <chuhu@redhat.com>                                  ##
-##                                                                       ##
-###########################################################################
-
-. test.sh
-nr_cpus=`tst_ncpus`
-
-# the 32 bit integer count 32 cpus. One integer is not
-# enough to store the cpu mask for nr_cpu > 32.
-if [ $nr_cpus -gt 32 ]; then
-	group_cnt=$((nr_cpus / 32))
-	range=31
-	rem=$((nr_cpus % 32))
-	if [ $rem -ne 0 ]; then
-		range_last=$((rem -1))
-	fi
-else
-	group_cnt=1
-	range=$((nr_cpus - 1))
-fi
-
-get_test_cpumask()
-{
-	mask=""
-
-	local i=0
-	while [ $i -lt $group_cnt ]; do
-		# select count of cpu in one group, include the duplicate.
-		local set_cnt=$(tst_random 1 $((range + 1)))
-
-		local c=0
-		local temp_mask=0
-		while [ $c -lt $set_cnt ]; do
-			local group_cpuid=$(tst_random 1 $range)
-			temp_mask=$((temp_mask | $((1 << $group_cpuid))))
-			c=$((c + 1))
-		done
-
-		if  [ $i = 0 ]; then
-			mask=`echo $temp_mask | awk '{printf "%x",$0}'`
-		else
-			mask=$mask","`echo $temp_mask | awk '{printf "%x",$0}'`
-		fi
-
-		i=$((i + 1))
-	done
-
-	if [ $group_cnt -gt 1  ]; then
-		set_cnt=$(tst_random 1 $((range_last +1)))
-		c=0;
-		temp_mask=0
-		while [ $c -lt $set_cnt ]; do
-			local group_cpuid=$(tst_random 1 $range_last)
-			temp_mask=$((temp_mask | $((1 << $group_cpuid))))
-			c=$((c + 1))
-		done
-		mask=`echo $temp_mask | awk '{printf "%x",$0}'`
-	fi
-
-	echo "$mask"
-}
-
-signal_handler()
-{
-	tst_exit
-}
-
-trap signal_handler SIGTERM SIGKILL
-
-while true; do
-	get_test_cpumask > $TRACING_PATH/tracing_cpumask
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh
deleted file mode 100755
index 9e0f5a7cf..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_enabled.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LOOP=1500
-count=0
-
-while true; do
-	count=$(( $count + 1 ))
-	i=0
-	while [ $i -lt $MAX_LOOP ]; do
-		echo 0 > "$TRACING_PATH"/tracing_enabled
-		echo 1 > "$TRACING_PATH"/tracing_enabled
-		i=$((i + 1))
-	done
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 0 > "$TRACING_PATH"/tracing_enabled
-	else
-		echo 1 > "$TRACING_PATH"/tracing_enabled
-	fi
-
-	sleep 1
-done
-
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
deleted file mode 100755
index 4ad88910c..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_max_latency.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LATENCY=100000
-
-while true; do
-	i=0
-	while [ $i -lt $MAX_LATENCY ]; do
-		echo $i > "$TRACING_PATH"/tracing_max_latency
-		i=$((i + 400))
-	done
-
-	sleep 1
-
-done
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh
deleted file mode 100755
index 5ae9d762c..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_tracing_on.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-
-###############################################################################
-#                                                                             #
-# Copyright (c) 2010 FUJITSU LIMITED                                          #
-#                                                                             #
-# This program is free software; you can redistribute it and/or modify it     #
-# under the terms of the GNU General Public License as published by the Free  #
-# Software Foundation; either version 2 of the License, or (at your option)   #
-# any later version.                                                          #
-#                                                                             #
-# Author: Li Zefan <lizf@cn.fujitsu.com>                                      #
-#                                                                             #
-###############################################################################
-
-MAX_LOOP=1500
-count=0
-
-while true; do
-	count=$(( $count + 1 ))
-	i=0
-	while [ $i -lt $MAX_LOOP ]; do
-		echo 0 > "$TRACING_PATH"/tracing_on
-		echo 1 > "$TRACING_PATH"/tracing_on
-		i=$((i + 1))
-	done
-
-	enable=$(( $count % 3 ))
-
-	if [ $enable -eq 0 ]; then
-		echo 0 > "$TRACING_PATH"/tracing_on
-	else
-		echo 1 > "$TRACING_PATH"/tracing_on
-	fi
-
-	sleep 1
-done
-
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
deleted file mode 100755
index 159ba1a66..000000000
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh
+++ /dev/null
@@ -1,121 +0,0 @@
-#! /bin/sh
-
-###########################################################################
-##                                                                       ##
-## Copyright (c) 2010 FUJITSU LIMITED                                    ##
-##                                                                       ##
-## This program is free software: you can redistribute it and/or modify  ##
-## it under the terms of the GNU General Public License as published by  ##
-## the Free Software Foundation, either version 3 of the License, or     ##
-## (at your option) any later version.                                   ##
-##                                                                       ##
-## This program is distributed in the hope that it will be useful,       ##
-## but WITHOUT ANY WARRANTY; without even the implied warranty of        ##
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          ##
-## GNU General Public License for more details.                          ##
-##                                                                       ##
-## You should have received a copy of the GNU General Public License     ##
-## along with this program. If not, see <http://www.gnu.org/licenses/>.  ##
-##                                                                       ##
-## Author: Li Zefan <lizf@cn.fujitsu.com>                                ##
-##                                                                       ##
-###########################################################################
-
-export TCID="ftrace-stress-test"
-export TST_TOTAL=1
-export TST_COUNT=1
-
-. ftrace_lib.sh
-
-test_targets=" \
-trace_pipe current_tracer ftrace_enabled function_profile_enabled \
-set_event set_ftrace_pid stack_max_size stack_trace trace trace_clock \
-trace_options trace_stat tracing_enabled tracing_max_latency \
-tracing_on function_profile_enabled buffer_size_kb tracing_cpumask \
-set_ftrace_filter"
-
-get_skip_targets()
-{
-	NR_PIDS=0
-	for target in ${test_targets}; do
-		if [ ! -e $TRACING_PATH/$target ] &&
-			[ ! -e /proc/sys/kernel/$target ]; then
-			eval skip_$target=1
-			tst_resm TINFO "$target is not supported. Skip it."
-		else
-			eval skip_$target=0
-			NR_PIDS=$((NR_PIDS + 1))
-		fi
-	done
-	# Export it before sub case is lanuched.
-	export NR_PIDS
-}
-
-should_skip_target()
-{
-	local skip_var=skip_$1
-	eval local skip_val=\$${skip_var}
-	[ "$skip_val" = 1 ]
-}
-
-test_kill()
-{
-	tst_resm TINFO "killing ${pid0}"
-	kill -USR1 ${pid0}
-	wait ${pid0}
-
-	local p=1;
-	while [ $p -lt $NR_PIDS ]; do
-		local pid_var=pid${p}
-		eval local kill_pid=\$${pid_var}
-		tst_resm TINFO "killing ${kill_pid}"
-		kill -KILL $kill_pid
-		wait ${kill_pid}
-		p=$((p + 1))
-	done
-}
-
-test_stress()
-{
-	local index=0;
-
-	tst_resm TINFO "Test targets: ${test_targets}"
-
-	get_skip_targets
-	for target in ${test_targets}; do
-		if should_skip_target $target; then
-			continue
-		fi
-		sh ftrace_${target}.sh &
-		eval pid${index}=$!
-		tst_resm TINFO "Start pid${index}=$! $SPATH/ftrace_${target}.sh"
-		index=$((index + 1))
-	done
-	export_pids
-}
-
-export_pids()
-{
-	local p=0
-	while [ $p -lt $NR_PIDS ]; do
-		export pid${p}
-		p=$((p + 1))
-	done
-}
-
-cd ftrace_stress/
-# ----------------------------
-tst_resm TINFO "Ftrace Stress Test Begin"
-
-test_begin
-
-test_stress
-
-test_wait
-
-test_kill
-
-tst_resm TINFO "Finished running the test. Run dmesg to double-check for bugs"
-
-tst_exit
-
-- 
2.50.1

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [LTP] ftrace: Add common library for C implementation
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 1/5] ftrace: Add common library for C implementation Praveen K Pandey
@ 2026-06-08  9:01   ` linuxtestproject.agent
  2026-06-08  9:41   ` [LTP] [LTP PATCH v4 1/5] " Cyril Hrubis
  1 sibling, 0 replies; 8+ messages in thread
From: linuxtestproject.agent @ 2026-06-08  9:01 UTC (permalink / raw)
  To: Praveen K Pandey; +Cc: ltp

Hi Praveen,

On Mon, Jun 8 2026, Praveen K Pandey wrote:
> ftrace: Add common library for C implementation

--- [PATCH 2/5] ---

> +/*\
> + * [Description]
> + *
> + * Test for kernel panic while using userstacktrace with page fault events.

The [Description] header is deprecated and must not be used. Remove
the `[Description]` line and start directly with the test description
text. The same applies to ftrace_regression02.c.

--- [PATCH 4/5] ---

> +static void cleanup(void)
> +{
> +	stop_testing = 1;
> +	ftrace_cleanup();
> +}

If the test is interrupted (e.g. SIGTERM on timeout), cleanup() is
called while stress threads may still be running. Setting stop_testing
does not guarantee threads have exited before ftrace_cleanup() frees
tracing_path and debugfs_path. Threads accessing those globals after
free is a use-after-free.

The fix is to join all threads in cleanup() before calling
ftrace_cleanup(), for example by calling stop_stress_tests() here
(guarded by thread_count > 0).

Verdict: Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [LTP] [LTP PATCH v4 1/5] ftrace: Add common library for C implementation
  2026-06-08  5:49 ` [LTP] [LTP PATCH v4 1/5] ftrace: Add common library for C implementation Praveen K Pandey
  2026-06-08  9:01   ` [LTP] " linuxtestproject.agent
@ 2026-06-08  9:41   ` Cyril Hrubis
  1 sibling, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2026-06-08  9:41 UTC (permalink / raw)
  To: Praveen K Pandey; +Cc: ltp

Hi!
> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.c b/testcases/kernel/tracing/ftrace_test/ftrace_lib.c
> new file mode 100644
> index 000000000..8b93b9849
> --- /dev/null
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.c
> @@ -0,0 +1,358 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2010 FUJITSU LIMITED
> + * Copyright (c) 2024 Linux Test Project
> + * Copyright (c) IBM, 2026
> + *
> + * Author: Li Zefan <lizf@cn.fujitsu.com>
> + * Converted to C by: Praveen K Pandey <praveen@linux.ibm.com>
> + */
> +
> +#define TST_NO_DEFAULT_MAIN
> +#include "ftrace_lib.h"
> +#include "tst_test.h"
> +#include "tst_safe_macros.h"
> +#include "tst_safe_stdio.h"
> +
> +char *tracing_path = NULL;
> +char *debugfs_path = NULL;
> +static int debugfs_mounted_by_us = 0;
> +struct ftrace_saved_state saved_state = {0};

Static variables are initialized to zero by compiler automatically, no
need to do it here.

> +void ftrace_initialize(void)
> +{
> +	FILE *fp;
> +	char line[PATH_MAX];
> +	int found = 0;
> +
> +	/* Check if debugfs is already mounted */

Please avoid comment that state the obvious, e.g. say in english exactly
what the code does.

> +	fp = SAFE_FOPEN("/proc/mounts", "r");
> +	while (fgets(line, sizeof(line), fp)) {
> +		if (strstr(line, "debugfs")) {
> +			debugfs_path = strdup("/sys/kernel/debug");
> +			found = 1;
> +			break;
> +		}
> +	}
> +	SAFE_FCLOSE(fp);

This whole thing could be just:

	if (tst_fs_is_mounted("/sys/kernel/debug")) {
		debugfs_path = strdup("/sys/kernel/debug");
		if (!debugfs_path)
			tst_brk(TBROK, ...);
	}

Ideally SAFE_STRDUP() should be added to the test library (in a separate
patch) so that we can simplify this even further to:

	if (tst_fs_is_mounted("/sys/kernel/debug"))
		debugfs_path = SAFE_STRDUP("/sys/kernel/debug");

> +	/* Mount debugfs if not already mounted */
> +	if (!found) {

No need to add found flag, we can do if (!debugfs_path) here instead.

> +		char *tmpdir = tst_tmpdir_path();
> +		debugfs_path = malloc(PATH_MAX);
> +		if (!debugfs_path)
> +			tst_brk(TBROK | TERRNO, "malloc failed");
> +		snprintf(debugfs_path, PATH_MAX, "%s/debugfs", tmpdir);

This could be single line with SAFE_ASPRINTF()

> +		SAFE_MKDIR(debugfs_path, 0755);
> +		SAFE_MOUNT("debugfs", debugfs_path, "debugfs", 0, NULL);
> +		debugfs_mounted_by_us = 1;
> +	}
> +
> +	/* Set tracing path */
> +	tracing_path = malloc(PATH_MAX);
> +	if (!tracing_path)
> +		tst_brk(TBROK | TERRNO, "malloc failed");
> +
> +	snprintf(tracing_path, PATH_MAX, "%s/tracing", debugfs_path);

This can be SAFE_ASPRINTF() as well.


> +	/* Check if tracing is supported */
> +	if (access(tracing_path, F_OK) != 0)
> +		tst_brk(TCONF, "Tracing is not supported");
> +
> +	/* Save current settings */
> +	ftrace_save_settings();
> +}
> +
> +void ftrace_cleanup(void)
> +{
> +	ftrace_restore_settings();
> +
> +	if (debugfs_mounted_by_us && debugfs_path) {
> +		tst_umount(debugfs_path);
> +		rmdir(debugfs_path);
> +	}
> +
> +	free(tracing_path);
> +	free(debugfs_path);
> +
> +	/* Free saved state */
> +	free(saved_state.trace_options);
> +	free(saved_state.tracing_on);
> +	free(saved_state.buffer_size);
> +	free(saved_state.tracing_cpumask);
> +	free(saved_state.tracing_enabled);
> +	free(saved_state.stack_tracer_enabled);
> +	free(saved_state.ftrace_enabled);
> +	free(saved_state.function_profile_enabled);
> +}
> +
> +char *ftrace_get_path(const char *filename)
> +{
> +	char *path;
> +
> +	path = malloc(PATH_MAX);
> +	if (!path)
> +		return NULL;
> +
> +	snprintf(path, PATH_MAX, "%s/%s", tracing_path, filename);

SAFE_ASPRINTF() here as well.

> +	return path;
> +}
> +
> +char *ftrace_read_file(const char *filename)
> +{
> +	char *path;
> +	FILE *fp;
> +	char *content = NULL;
> +	size_t len = 0;
> +	ssize_t read;
> +	char *line = NULL;
> +	size_t total_size = 0;
> +
> +	path = ftrace_get_path(filename);
> +	if (!path)
> +		return NULL;
> +
> +	fp = fopen(path, "r");
> +	free(path);
> +
> +	if (!fp)
> +		return NULL;
> +
> +	/* Read entire file */
> +	while ((read = getline(&line, &len, fp)) != -1) {
> +		char *new_content = realloc(content, total_size + read + 1);
> +		if (!new_content) {
> +			free(content);
> +			free(line);
> +			fclose(fp);
> +			return NULL;
> +		}
> +		content = new_content;
> +		memcpy(content + total_size, line, read);
> +		total_size += read;
> +	}
> +
> +	if (content)
> +		content[total_size] = '\0';
> +
> +	free(line);
> +	fclose(fp);
> +
> +	return content;
> +}
> +
> +int ftrace_write_file(const char *filename, const char *content)
> +{
> +	char *path;
> +	FILE *fp;
> +	int ret;
> +
> +	path = ftrace_get_path(filename);
> +	if (!path)
> +		return -1;
> +
> +	fp = fopen(path, "w");
> +	free(path);
> +
> +	if (!fp)
> +		return -1;
> +
> +	ret = fprintf(fp, "%s", content);
> +	fclose(fp);

This could be replaced by single SAFE_FILE_PRINTF()

> +	return (ret > 0) ? 0 : -1;
> +}
> +
> +int ftrace_file_exists(const char *filename)
> +{
> +	char *path;
> +	int ret;
> +
> +	path = ftrace_get_path(filename);
> +	if (!path)
> +		return 0;
> +
> +	ret = (access(path, F_OK) == 0);
> +	free(path);
> +
> +	return ret;
> +}
> +
> +void ftrace_save_settings(void)
> +{
> +	if (saved_state.saved)
> +		return;
> +
> +	saved_state.trace_options = ftrace_read_file("trace_options");
> +	saved_state.tracing_on = ftrace_read_file("tracing_on");
> +	saved_state.buffer_size = ftrace_read_file("buffer_size_kb");
> +
> +	if (ftrace_file_exists("tracing_cpumask"))
> +		saved_state.tracing_cpumask = ftrace_read_file("tracing_cpumask");
> +
> +	if (ftrace_file_exists("tracing_enabled"))
> +		saved_state.tracing_enabled = ftrace_read_file("tracing_enabled");
> +
> +	if (ftrace_file_exists("stack_max_size")) {
> +		char *path = strdup("/proc/sys/kernel/stack_tracer_enabled");
> +		FILE *fp = fopen(path, "r");
> +
> +		if (fp) {
> +			saved_state.stack_tracer_enabled = malloc(32);
> +			if (saved_state.stack_tracer_enabled)
> +				fgets(saved_state.stack_tracer_enabled, 32, fp);
> +			fclose(fp);
> +		}
> +		free(path);
> +	}
> +
> +	if (access("/proc/sys/kernel/ftrace_enabled", F_OK) == 0) {
> +		FILE *fp = fopen("/proc/sys/kernel/ftrace_enabled", "r");
> +
> +		if (fp) {
> +			saved_state.ftrace_enabled = malloc(32);
> +			if (saved_state.ftrace_enabled)
> +				fgets(saved_state.ftrace_enabled, 32, fp);
> +			fclose(fp);
> +		}
> +	}
> +
> +	if (ftrace_file_exists("function_profile_enabled"))
> +		saved_state.function_profile_enabled = ftrace_read_file("function_profile_enabled");
> +
> +	saved_state.saved = 1;
> +}
> +
> +void ftrace_restore_settings(void)
> +{
> +	if (!saved_state.saved)
> +		return;
> +
> +	/* Reset tracer and events */
> +	ftrace_write_file("current_tracer", "nop\n");
> +	ftrace_write_file("events/enable", "0\n");
> +
> +	if (ftrace_file_exists("tracing_max_latency"))
> +		ftrace_write_file("tracing_max_latency", "0\n");
> +
> +	if (saved_state.tracing_cpumask)
> +		ftrace_write_file("tracing_cpumask", saved_state.tracing_cpumask);
> +
> +	if (ftrace_file_exists("trace_clock"))
> +		ftrace_write_file("trace_clock", "local\n");
> +
> +	if (saved_state.function_profile_enabled)
> +		ftrace_write_file("function_profile_enabled", saved_state.function_profile_enabled);
> +
> +	if (saved_state.ftrace_enabled) {
> +		FILE *fp = fopen("/proc/sys/kernel/ftrace_enabled", "w");
> +		if (fp) {
> +			fprintf(fp, "%s", saved_state.ftrace_enabled);
> +			fclose(fp);
> +		}
> +	}
> +
> +	if (saved_state.stack_tracer_enabled && ftrace_file_exists("stack_max_size")) {
> +		FILE *fp = fopen("/proc/sys/kernel/stack_tracer_enabled", "w");
> +		if (fp) {
> +			fprintf(fp, "%s", saved_state.stack_tracer_enabled);
> +			fclose(fp);
> +		}
> +		ftrace_write_file("stack_max_size", "0\n");
> +	}
> +
> +	if (saved_state.buffer_size)
> +		ftrace_write_file("buffer_size_kb", saved_state.buffer_size);
> +
> +	if (saved_state.tracing_on)
> +		ftrace_write_file("tracing_on", saved_state.tracing_on);
> +
> +	if (saved_state.tracing_enabled)
> +		ftrace_write_file("tracing_enabled", saved_state.tracing_enabled);
> +
> +	/* Restore trace options */
> +	if (saved_state.trace_options) {
> +		char *options = strdup(saved_state.trace_options);
> +		char *token = strtok(options, "\n");
> +		while (token) {
> +			ftrace_write_file("trace_options", token);
> +			token = strtok(NULL, "\n");
> +		}
> +		free(options);
> +	}
> +
> +	/* Clear trace */
> +	ftrace_clear_trace();
> +
> +	/* Clear filter */
> +	if (ftrace_file_exists("set_ftrace_filter"))
> +		ftrace_write_file("set_ftrace_filter", "\n");
> +}
> +
> +char **ftrace_get_available_tracers(int *count)
> +{
> +	char *content;
> +	char **tracers = NULL;
> +	int n = 0;
> +	char *token;
> +	char *saveptr;
> +
> +	content = ftrace_read_file("available_tracers");
> +	if (!content) {
> +		*count = 0;
> +		return NULL;
> +	}
> +
> +	/* Count tracers */
> +	char *tmp = strdup(content);
> +	token = strtok_r(tmp, " \n", &saveptr);
> +	while (token) {
> +		n++;
> +		token = strtok_r(NULL, " \n", &saveptr);
> +	}
> +	free(tmp);
> +
> +	/* Allocate array */
> +	tracers = malloc(sizeof(char *) * n);
> +	if (!tracers) {
> +		free(content);
> +		*count = 0;
> +		return NULL;
> +	}
> +
> +	/* Fill array */
> +	n = 0;
> +	token = strtok_r(content, " \n", &saveptr);
> +	while (token) {
> +		tracers[n++] = strdup(token);
> +		token = strtok_r(NULL, " \n", &saveptr);
> +	}
> +
> +	free(content);
> +	*count = n;
> +	return tracers;

This would be much easier if you just read the file line by line

	f = SAFE_FOPEN(...)

	while (fgets(line, sizeof(line), f) {
		...
	}

	SAFE_FCLOSE(f);

> +}
> +
> +int ftrace_set_tracer(const char *tracer)
> +{
> +	char buf[256];
> +	snprintf(buf, sizeof(buf), "%s\n", tracer);
> +	return ftrace_write_file("current_tracer", buf);
> +}
> +
> +void ftrace_clear_trace(void)
> +{
> +	ftrace_write_file("trace", "\n");
> +}
> +
> +void ftrace_enable_tracing(void)
> +{
> +	ftrace_write_file("tracing_on", "1\n");
> +}
> +
> +void ftrace_disable_tracing(void)
> +{
> +	ftrace_write_file("tracing_on", "0\n");
> +}

Generally it would make sense to keep the paths to these files in a
global variables, set then only once in the init and then we could just
do:

void ftrace_set_tracer(const char *tracer)
{
	SAFE_FILE_PRINTF(path_ftrace_tracer, "%s", tracer);
}

> diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_lib.h b/testcases/kernel/tracing/ftrace_test/ftrace_lib.h
> new file mode 100644
> index 000000000..b40877ed1
> --- /dev/null
> +++ b/testcases/kernel/tracing/ftrace_test/ftrace_lib.h
> @@ -0,0 +1,139 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (c) 2010 FUJITSU LIMITED
> + * Copyright (c) 2024 Linux Test Project
> + * Copyright (c) IBM, 2026
> + *
> + * Author: Li Zefan <lizf@cn.fujitsu.com>
> + * Converted to C by: Praveen K Pandey <praveen@linux.ibm.com>
> + */
> +
> +#ifndef FTRACE_LIB_H
> +#define FTRACE_LIB_H
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <fcntl.h>
> +#include <sys/mount.h>
> +#include <sys/stat.h>
> +#include <sys/types.h>
> +#include <errno.h>
> +#include <limits.h>
> +
> +/* Global paths */
> +extern char *tracing_path;
> +extern char *debugfs_path;
> +
> +/* Saved settings for cleanup */
> +struct ftrace_saved_state {
> +	char *trace_options;
> +	char *tracing_on;
> +	char *buffer_size;
> +	char *tracing_cpumask;
> +	char *tracing_enabled;
> +	char *stack_tracer_enabled;
> +	char *ftrace_enabled;
> +	char *function_profile_enabled;
> +	int saved;
> +};
> +
> +extern struct ftrace_saved_state saved_state;
> +

Why is this leaking into the tests? None of these low level details
should be exposed since you are building a library for the tests to use.

> +/**
> + * ftrace_initialize() - Initialize ftrace test environment
> + *
> + * This function:
> + * - Checks if debugfs is mounted, mounts it if needed
> + * - Verifies tracing support
> + * - Saves current ftrace settings

We use kernel doc comments that are parsed and exported into
documentation.

https://docs.kernel.org/doc-guide/kernel-doc.html

> + */
> +void ftrace_initialize(void);
> +
> +/**
> + * ftrace_cleanup() - Cleanup and restore ftrace settings
> + *
> + * Restores all saved ftrace settings and unmounts debugfs if needed
> + */
> +void ftrace_cleanup(void);
> +
> +/**
> + * ftrace_save_settings() - Save current ftrace settings
> + *
> + * Saves all ftrace configuration to restore later
> + */
> +void ftrace_save_settings(void);
> +
> +/**
> + * ftrace_restore_settings() - Restore saved ftrace settings
> + *
> + * Restores ftrace configuration saved by ftrace_save_settings()
> + */
> +void ftrace_restore_settings(void);
> +
> +/**
> + * ftrace_get_path() - Get full path to a tracing file
> + * @filename: Name of the file in tracing directory
> + *
> + * Returns: Allocated string with full path (caller must free)
> + */
> +char *ftrace_get_path(const char *filename);
> +
> +/**
> + * ftrace_read_file() - Read content from a tracing file
> + * @filename: Name of the file in tracing directory
> + *
> + * Returns: Allocated string with file content (caller must free)
> + */
> +char *ftrace_read_file(const char *filename);
> +
> +/**
> + * ftrace_write_file() - Write content to a tracing file
> + * @filename: Name of the file in tracing directory
> + * @content: Content to write
> + *
> + * Returns: 0 on success, -1 on failure
> + */
> +int ftrace_write_file(const char *filename, const char *content);
> +
> +/**
> + * ftrace_file_exists() - Check if a tracing file exists
> + * @filename: Name of the file in tracing directory
> + *
> + * Returns: 1 if exists, 0 otherwise
> + */
> +int ftrace_file_exists(const char *filename);
> +
> +/**
> + * ftrace_get_available_tracers() - Get list of available tracers
> + * @count: Pointer to store number of tracers
> + *
> + * Returns: Array of tracer names (caller must free)
> + */
> +char **ftrace_get_available_tracers(int *count);
> +
> +/**
> + * ftrace_set_tracer() - Set current tracer
> + * @tracer: Name of the tracer to set
> + *
> + * Returns: 0 on success, -1 on failure
> + */
> +int ftrace_set_tracer(const char *tracer);
> +
> +/**
> + * ftrace_clear_trace() - Clear the trace buffer
> + */
> +void ftrace_clear_trace(void);
> +
> +/**
> + * ftrace_enable_tracing() - Enable tracing
> + */
> +void ftrace_enable_tracing(void);
> +
> +/**
> + * ftrace_disable_tracing() - Disable tracing
> + */
> +void ftrace_disable_tracing(void);
> +
> +#endif /* FTRACE_LIB_H */
> -- 
> 2.50.1
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-08  9:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08  5:49 [LTP] [LTP PATCH v4 0/5] ftrace: Convert shell tests to C Praveen K Pandey
2026-06-08  5:49 ` [LTP] [LTP PATCH v4 1/5] ftrace: Add common library for C implementation Praveen K Pandey
2026-06-08  9:01   ` [LTP] " linuxtestproject.agent
2026-06-08  9:41   ` [LTP] [LTP PATCH v4 1/5] " Cyril Hrubis
2026-06-08  5:49 ` [LTP] [LTP PATCH v4 2/5] ftrace: Convert ftrace_regression01.sh to C Praveen K Pandey
2026-06-08  5:49 ` [LTP] [LTP PATCH v4 3/5] ftrace: Convert ftrace_regression02.sh " Praveen K Pandey
2026-06-08  5:49 ` [LTP] [LTP PATCH v4 4/5] ftrace: Convert ftrace_stress_test.sh " Praveen K Pandey
2026-06-08  5:50 ` [LTP] [LTP PATCH v4 5/5] ftrace: Remove obsolete shell test files Praveen K Pandey

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.