Skip to content

ftrace: Convert shell tests to C

Praveen K Pandey ltp 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest5 patches 2 repliesIn review
  2. v55 patches 1 replySuperseded
  3. v45 patches 2 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v35 patches1 replySuperseded
v25 patches1 replySuperseded
v15 patches1 replySuperseded

Changes in v6 from the cover letter · 16 lines

- ftrace_lib.c:
* Removed C++ style comment
* Removed unused variable 'ret' in ftrace_set_tracer()
* Added NULL check for strdup() in ftrace_restore_settings()
* Added Suggested-by tag for Cyril Hrubis who provided the refactoring suggestions implemented in v5
- ftrace_regression01.c:
* Fixed commit message to accurately describe the test (tests for kernel panic with userstacktrace, not "all tracers")
* Removed incorrect .min_kver reference from commit message
- ftrace_regression02.c:
* Fixed commit message to correctly state .min_kver = "3.2"
- ftrace_stress_test.c:
* Fixed pthread_join() being called twice (undefined behavior) by resetting thread_count to 0 in stop_stress_tests()
* Reset stop_testing and thread_count at start of run_test() to support multiple iterations (-i N)
* Simplified cleanup() to avoid redundant stop_testing assignment
- Makefile changes:
* Moved to patch 1 to maintain bisectability - each commit in the series now builds independently

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5ftrace: Add common library for C implementationtestcases/kernel/tracing/ftrace_test/.gitignore testcases/kernel/tracing/ftrace_test/Makefile testcases/kernel/tracing/ftrace_test/ftrace_lib.c +1 more+528 -22 replies
2/5ftrace: Convert ftrace_regression01.sh to Cruntest/tracing testcases/kernel/tracing/ftrace_test/ftrace_regression01.c testcases/kernel/tracing/ftrace_test/ftrace_regression01.sh+129 -860 replies
3/5ftrace: Convert ftrace_regression02.sh to Ctestcases/kernel/tracing/ftrace_test/ftrace_regression02.c testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh+101 -630 replies
4/5ftrace: Convert ftrace_stress_test.sh to Ctestcases/kernel/tracing/ftrace_test/ftrace_stress_test.c testcases/kernel/tracing/ftrace_test/ftrace_stress_test.sh+328 -1210 replies
5/5ftrace: Remove obsolete shell test filestestcases/kernel/tracing/ftrace_test/ftrace_lib.sh testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_current_tracer.sh +16 more+0 -9840 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [LTP] [PATCH v6 0/5] ftrace: Convert shell tests to C

This patch series converts the ftrace shell-based tests to C using the new LTP test API. This addresses issue #1282 and provides better error handling, maintainability, and integration with LTP's modern test infrastructure.

Changes in v6:
- ftrace_lib.c:
* Removed C++ style comment
* Removed unused variable 'ret' in ftrace_set_tracer()
* Added NULL check for strdup() in ftrace_restore_settings()
* Added Suggested-by tag for Cyril Hrubis who provided the refactoring suggestions implemented in v5
- ftrace_regression01.c:
* Fixed commit message to accurately describe the test (tests for kernel panic with userstacktrace, not "all tracers")
* Removed incorrect .min_kver reference from commit message
- ftrace_regression02.c:
* Fixed commit message to correctly state .min_kver = "3.2"
- ftrace_stress_test.c:
* Fixed pthread_join() being called twice (undefined behavior) by resetting thread_count to 0 in stop_stress_tests()
* Reset stop_testing and thread_count at start of run_test() to support multiple iterations (-i N)
* Simplified cleanup() to avoid redundant stop_testing assignment
- Makefile changes:
* Moved to patch 1 to maintain bisectability - each commit in the series now builds independently

Changes in v5:
- ftrace_lib.c: Major refactoring based on review feedback
* Removed static variable initialization to 0/NULL (C standard)
* Removed obvious comments for cleaner code
* Replaced manual debugfs mount check with tst_is_mounted()
* Used SAFE_ASPRINTF() for all path construction
* Used SAFE_FILE_PRINTF() in ftrace_set_tracer()
* Simplified ftrace_get_available_tracers() to read line by line
* Added proper error checking for strdup() calls
- ftrace_lib.h: Cleaned up API
* Fixed kernel-doc comment format (use - instead of ())
* Removed low-level implementation details from header
- ftrace_regression01.c/ftrace_regression02.c:
* Removed deprecated [Description] header line
- ftrace_stress_test.c:
* Fixed use-after-free: join threads before ftrace_cleanup()

Changes in v4:
- Fixed trailing whitespace issues
- Corrected commit message format and content
- Replaced tst_kvercmp() with .min_kver = "2.6.29"
- Removed LTP_TIMEOUT_MUL parsing (handled by framework)
- Updated documentation to reflect root requirement

Changes in v3:
- Fixed tst_tmpdir_path() usage in ftrace_lib.c
- Removed CVE tag from test documentation
- Fixed memory leaks in ftrace_get_available_tracers()
- Changed Algorithm sections to bullet points
- Added root requirement to test documentation
- Fixed Makefile to include ftrace_lib.o in LDLIBS
- Created .gitignore for compiled binaries
- Removed deprecated tst_reinit.h include
- Deleted orphaned shell test files

Changes in v2:
- Moved TST_NO_DEFAULT_MAIN before includes
- Fixed include order (tst_test.h before tst_safe_*.h)
- Removed tst_reinit() calls (not needed with new API)
- Fixed test structure initialization
- Improved error messages

The conversion provides:
- Better error handling using LTP's SAFE_* macros
- Proper resource cleanup and state restoration
- Modern LTP test API usage
- Improved code maintainability
- Type safety and compile-time checks
- Bisectable commit history

Testing:
- Compiled successfully on x86_64 and ppc64le
- All tests pass on systems with ftrace support
- Proper cleanup verified (settings restored after test)
- Multiple iterations tested (-i N flag)

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   | 374 ++++++++++++++++++
 .../kernel/tracing/ftrace_test/ftrace_lib.h   | 136 +++++++
 .../kernel/tracing/ftrace_test/ftrace_lib.sh  | 180 ---------
 .../tracing/ftrace_test/ftrace_regression01.c | 126 ++++++
 .../ftrace_test/ftrace_regression01.sh        |  83 ----
 .../tracing/ftrace_test/ftrace_regression02.c | 101 +++++
 .../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  | 328 +++++++++++++++
 ./tracing/ftrace_test/ftrace_stress_test.sh | 121 ------
 30 files changed, 1086 insertions(+), 1256 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
Signature · 5 lines
2.50.1


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