doc/SystemTap_Beginners_Guide/testsuite/systemtap.bpf/bpf_tests/globals3.stp
raw| 1 | // Tests whether globals are correctly initialized without |
| 2 | // a begin probe being present. In this case the translator |
| 3 | // creates a begin probe in which to perform the assignments. |
| 4 | global x = 1, y, z = 3, flag |
| 5 | probe kernel.function("vfs_read") { |
| 6 | printf("BEGIN\n") |
| 7 | if (x == 1 && y == 0 && z == 3) { |
| 8 | flag = 1 |
| 9 | } |
| 10 | exit() |
| 11 | } |
| 12 | |
| 13 | probe end { |
| 14 | if (x == 1 && y == 0 && z == 3 && flag) |
| 15 | printf("END PASS\n") |
| 16 | else |
| 17 | printf("END FAIL\n") |
| 18 | } |