From e2298f9e1bb95f21291ffd5a992b3fa9cfd27690 Mon Sep 17 00:00:00 2001 From: Aaron Merey Date: Thu, 12 Oct 2017 13:38:22 -0400 Subject: [PATCH] stapbpf: add while loop test * while.stp: basic test for while loops. * array.stp: changed location of exit call. --- testsuite/systemtap.bpf/bpf_tests/array.stp | 2 +- testsuite/systemtap.bpf/bpf_tests/while.stp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 testsuite/systemtap.bpf/bpf_tests/while.stp diff --git a/testsuite/systemtap.bpf/bpf_tests/array.stp b/testsuite/systemtap.bpf/bpf_tests/array.stp index 576018921..4518faf01 100644 --- a/testsuite/systemtap.bpf/bpf_tests/array.stp +++ b/testsuite/systemtap.bpf/bpf_tests/array.stp @@ -4,7 +4,6 @@ probe begin { arr[0] = 1 arr[10] = 2 arr[199] = 3 - exit() } probe kernel.function("vfs_read") { @@ -13,6 +12,7 @@ probe kernel.function("vfs_read") { arr[10]++ arr[199]++ flag = 0 + exit() } } diff --git a/testsuite/systemtap.bpf/bpf_tests/while.stp b/testsuite/systemtap.bpf/bpf_tests/while.stp new file mode 100644 index 000000000..df8af1fc9 --- /dev/null +++ b/testsuite/systemtap.bpf/bpf_tests/while.stp @@ -0,0 +1,20 @@ +global flag = 1 +probe begin { + x = 0 + printf("BEGIN\n") + while (x != 10) + x++ + if (x != 10) + flag = 0 + exit() +} + +probe end { + x = 0 + while (x != 10) + x++ + if (x == 10 && flag) + printf("END PASS\n") + else + printf("END FAIL\n") +} -- 2.43.5