Debian Codegraph @

testsuite/systemtap.context/pid_ns.stp

raw
1 #! stap -p5
2
3 global hit_pp = 0;
4
5 function check_for_pid_ns:long () %{ /* unprivilged */ /* pure */
6 #ifdef CONFIG_PID_NS
7 STAP_RETVALUE = 1;
8 #else
9 STAP_RETVALUE = 0;
10 #endif
11 %}
12
13 // this should be in a different pid ns that the stap process
14 probe process("sleep").begin{
15 // all that we can really do is make a comparison between the original
16 // and the namespace aware versions.
17 // need to check all the conditionals otherwise this test case will fail when it should just be untested
18 if (check_for_pid_ns()) {
19 if (!hit_pp) {
20 hit_pp = 1;
21 if (pid() == ns_pid()) println("FAIL: pid() matches ns_pid()");;
22 if (tid() == ns_tid()) println("FAIL: tid() matches ns_tid()");
23 if (ppid() == ns_ppid()) println("FAIL: ppid() matches ns_ppid()");
24 if (sid() == ns_sid()) println("FAIL: sid() matches ns_sid()");
25 if (pgrp() == ns_pgrp()) println("FAIL: pgrp() matches ns_pgrp()");
26 }
27 } else {
28 // this test case is kind of skipped. this should be checked in the tcl file
29 println("FAIL: not configured for pid namespaces");
30 }
31 exit();
32 }
33
34 probe begin {
35 printf("systemtap starting probe\n");
36 }
37
38 probe end {
39 printf("systemtap ending probe\n");
40 if (hit_pp){
41 printf("END\n");
42 } else {
43 println("FAIL: never hit probe point; never tested tapsets");
44 println("(make sure you run the testsuite with sudo");
45 }
46 }