set test "pr13306"
if {! [installtest_p]} {
    untested "$test"
    return
}

set test "pr13306 plain"
spawn stap $srcdir/$subdir/pr13306.stp
set ok 0
set ko 0
expect {
    -timeout 60
    timeout { fail "$test (timeout)" }
    -re {^ERROR: [^\r\n]*\r\n} { incr ok; exp_continue }
    -re {^WARNING: Number of errors: [0-9]*[^\r\n]*\r\n} { incr ok; exp_continue }
    eof { }
}
catch { close } ; catch { wait }
if {$ok >= 2 && $ko == 0} then { pass $test } else { fail "$test ($ok $ko)" }

set test "pr13306 -t"
spawn stap -t $srcdir/$subdir/pr13306.stp
set ok 0
set ko 0
expect {
    -timeout 60
    timeout { fail "$test (timeout)" }
    -re {^ERROR: [^\r\n]*\r\n} { incr ok; exp_continue }
    -re {^WARNING: Number of errors: [0-9]*[^\r\n]*\r\n} { incr ok; exp_continue }
    -re {^----- probe hit report: \r\n} { incr ok; exp_continue }
    -re {^[^\r\n]*hits:[^\r\n]*cycles:[^\r\n]*from:[^\r\n]*\r\n} { exp_continue }
    -re {^----- refresh report:\r\n} { exp_continue }
}
catch { close } ; catch { wait }
if {$ok >=3 && $ko == 0} then { pass $test } else { fail "$test ($ok $ko)" }

set test "pr13306 --suppress-handler-errors"
spawn stap --suppress-handler-errors $srcdir/$subdir/pr13306.stp
set ok 0
set ko 0
expect {
    -timeout 60
    timeout { fail "$test (timeout)" }
    -re {^ERROR: [^\r\n]*\r\n} { incr ko; exp_continue }
    -re {^WARNING: Number of errors: [0-9]*[^\r\n]*\r\n} { incr ok; exp_continue }
    eof { }
}
catch { close } ; catch { wait }
if {$ok == 1 && $ko == 0} then { pass $test } else { fail "$test ($ok $ko)" }

set test "pr13306 --suppress-handler-errors -t"
spawn stap --suppress-handler-errors -t $srcdir/$subdir/pr13306.stp
set ok 0
set ko 0
expect {
    -timeout 60
    timeout { fail "$test (timeout)" }
    -re {^ERROR: [^\r\n]*\r\n} { incr ko; exp_continue }
    -re {^WARNING: Number of errors: [0-9]*[^\r\n]*\r\n} { incr ok; exp_continue }
    -re {^----- probe hit report: \r\n} { incr ok; exp_continue }
    -re {^[^\r\n]*hits:[^\r\n]*cycles:[^\r\n]*from:[^\r\n]*\r\n} { exp_continue }
    -re {^----- refresh report:\r\n} { exp_continue }
}
catch { close } ; catch { wait }
if {$ok >= 2 && $ko == 0} then { pass $test } else { fail "$test ($ok $ko)" }
