summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/global_init.stp
blob: 304788464a7a34fdc33dc9202a657b67a82c9c3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * global_init.stp
 *
 * Check that global variables are initialized before all begin probes
 */

probe begin {  println("systemtap starting probe")  }
probe end   {  println("systemtap ending probe")    }

global gnum = 42
global gstr = "foobar"

global gnum_saved
global gstr_saved
probe begin(-9223372036854775808) {
    gnum_saved = gnum
    gstr_saved = gstr
}

probe end {
  if (gnum_saved == 42)
    println("systemtap test success")
  else
    printf("systemtap test failure - gnum_saved:%d != 42\n", gnum_saved)

  if (gstr_saved == "foobar")
    println("systemtap test success")
  else
    printf("systemtap test failure - gstr_saved:%s != foobar\n", gstr_saved)
}