/*
 * 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 {
  rc = 0
  if (gnum_saved == 42)
    rc += 1
  else
    printf("systemtap test failure - gnum_saved:%d != 42\n", gnum_saved)

  if (gstr_saved == "foobar")
    rc += 1
  else
    printf("systemtap test failure - gstr_saved:%s != foobar\n", gstr_saved)

  if (rc == 2)
    println("systemtap test success")
  else
    printf("systemtap test failure (%d passes)\n", rc)
}

