/*
 * be_order.stp
 *
 * Check that ordering of begin/end probes works
 */

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

global beginstr, endstr

probe begin { beginstr .= "c" }
probe begin(1) { beginstr .= "d" }
probe begin(-1) { beginstr .= "b" }
probe begin(0) { beginstr .= "c" }
probe begin(9223372036854775807) { beginstr .= "e" }
probe begin(-9223372036854775808) { beginstr .= "a" }

probe end { endstr .= "x" }
probe end(1) { endstr .= "y" }
probe end(-1) { endstr .= "w" }
probe end(0) { endstr .= "x" }
probe end(9223372036854775807) {
  endstr .= "z"
  rc = 0

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

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

  if (rc == 2)
    println("systemtap test success")
  else
    printf("systemtap test failure (%d passes)\n", rc)
}
probe end(-9223372036854775808) { endstr .= "v" }

