summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/task_local_storage.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/task_local_storage.c b/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
index 7bee33797c71..1b26c12f255a 100644
--- a/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
+++ b/tools/testing/selftests/bpf/prog_tests/task_local_storage.c
@@ -25,24 +25,30 @@
static void test_sys_enter_exit(void)
{
struct task_local_storage *skel;
+ pid_t pid = sys_gettid();
int err;
skel = task_local_storage__open_and_load();
if (!ASSERT_OK_PTR(skel, "skel_open_and_load"))
return;
- skel->bss->target_pid = sys_gettid();
-
err = task_local_storage__attach(skel);
if (!ASSERT_OK(err, "skel_attach"))
goto out;
+ /* Set target_pid after attach so that syscalls made during
+ * attach are not counted.
+ */
+ skel->bss->target_pid = pid;
+
sys_gettid();
sys_gettid();
- /* 3x syscalls: 1x attach and 2x gettid */
- ASSERT_EQ(skel->bss->enter_cnt, 3, "enter_cnt");
- ASSERT_EQ(skel->bss->exit_cnt, 3, "exit_cnt");
+ skel->bss->target_pid = 0;
+
+ /* 2x gettid syscalls */
+ ASSERT_EQ(skel->bss->enter_cnt, 2, "enter_cnt");
+ ASSERT_EQ(skel->bss->exit_cnt, 2, "exit_cnt");
ASSERT_EQ(skel->bss->mismatch_cnt, 0, "mismatch_cnt");
out:
task_local_storage__destroy(skel);