Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/test_fprobe: Add a testcase for skipping exit_handler

Add a testcase for skipping exit_handler if entry_handler
returns !0.

Link: https://lkml.kernel.org/r/167526700658.433354.12922388040490848613.stgit@mhiramat.roam.corp.google.com

Cc: Florent Revest <revest@chromium.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

authored by

Masami Hiramatsu (Google) and committed by
Steven Rostedt (Google)
87de2163 39d95420

+25 -1
+25 -1
lib/test_fprobe.c
··· 21 21 static unsigned long target_ip; 22 22 static unsigned long target2_ip; 23 23 static unsigned long target_nest_ip; 24 + static int entry_return_value; 24 25 25 26 static noinline u32 fprobe_selftest_target(u32 value) 26 27 { ··· 53 52 } else 54 53 KUNIT_EXPECT_NULL(current_test, data); 55 54 56 - return 0; 55 + return entry_return_value; 57 56 } 58 57 59 58 static notrace void fp_exit_handler(struct fprobe *fp, unsigned long ip, ··· 206 205 KUNIT_EXPECT_EQ(test, 0, unregister_fprobe(&fp)); 207 206 } 208 207 208 + static void test_fprobe_skip(struct kunit *test) 209 + { 210 + struct fprobe fp = { 211 + .entry_handler = fp_entry_handler, 212 + .exit_handler = fp_exit_handler, 213 + }; 214 + 215 + current_test = test; 216 + KUNIT_EXPECT_EQ(test, 0, register_fprobe(&fp, "fprobe_selftest_target", NULL)); 217 + 218 + entry_return_value = 1; 219 + entry_val = 0; 220 + exit_val = 0; 221 + target(rand1); 222 + KUNIT_EXPECT_NE(test, 0, entry_val); 223 + KUNIT_EXPECT_EQ(test, 0, exit_val); 224 + KUNIT_EXPECT_EQ(test, 0, fp.nmissed); 225 + entry_return_value = 0; 226 + 227 + KUNIT_EXPECT_EQ(test, 0, unregister_fprobe(&fp)); 228 + } 229 + 209 230 static unsigned long get_ftrace_location(void *func) 210 231 { 211 232 unsigned long size, addr = (unsigned long)func; ··· 257 234 KUNIT_CASE(test_fprobe_syms), 258 235 KUNIT_CASE(test_fprobe_data), 259 236 KUNIT_CASE(test_fprobe_nest), 237 + KUNIT_CASE(test_fprobe_skip), 260 238 {} 261 239 }; 262 240