set test speculate

catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err
if {$err == "" && [file exists $test]} then { pass "$test compile" } else { fail "$test compile" }

set rc [stap_run_batch $srcdir/$subdir/$test.stp]
if {$rc == 0} then { pass "$test -p4" } else { fail "$test -p4" }

if {! [installtest_p]} {
    catch {exec rm -f $test}
    untested "$test -p5"
    return
}

spawn stap $srcdir/$subdir/$test.stp -c ./$test -w
set ok 0
expect {
	-timeout 60
	-re {^open[^\r\n]*\r\n} { incr ok; exp_continue }
	-re {^write[^\r\n]*\r\n} { incr ok; exp_continue }
	timeout { fail "$test (timeout)" }
	eof { }
}
catch { close }
wait
if {$ok == 4} then { pass "$test -p5" } else { fail "$test -p5 ($ok)" }
exec rm -f $test
