set test bz6905

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

if {![utrace_p]} {
    untested "$test -p2"
} else {
    spawn stap -p2 $srcdir/$subdir/$test.stp
    set hint 0
    set probes 0
    expect {
	-timeout 60
	-re "# probes" { incr hint; exp_continue }
	-re {process.*statement.*} { incr probes; exp_continue }
	timeout { fail "$test (timeout)" }
	eof { }
    }
    wait
    if { $hint == 1 && $probes > 0 } then {
	pass "$test -p2"
    } else {
	fail "$test -p2 ($probes)"
    }
}
if { $verbose == 0 } { catch { exec rm -f $test } }

set test bz10294

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

if {![utrace_p]} {
    untested "$test -p2"
} else {
    spawn stap -p2 $srcdir/$subdir/$test.stp
    set hint 0
    set probes 0
    expect {
        -timeout 60
        -re "# probes" { incr hint; exp_continue }
        -re {process.*statement.*} { incr probes; exp_continue }
        timeout { fail "$test (timeout)" }
        eof { }
    }
    wait
    if { $hint == 1 && $probes == 1 } then {
	pass "$test -p2"
    } else {
	fail "$test -p2 ($probes)"
    }
}

set no_func stmtnofunc
if {![utrace_p]} {
    untested "$no_func"
} else {
    set func_script "probe process(\"%s\").statement(\"foo@%s.c:*\") {}"
    set script [format $func_script "./$test" "$test"]
    spawn stap -p2 -we $script
    expect {
        -timeout 60
        -re {semantic error: .*while resolving probe point.*\r\n} { xfail $no_func }
        timeout { fail "$no_func (timeout)" }
        eof { fail $no_func }
    }
    wait
}
if { $verbose == 0 } { catch { exec rm -f $test } }


set test bz14774

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

if {![utrace_p]} {
    untested "$test -p2"
} else {
    set func_script "probe process(\"%s\").statement(\"*@%s.c:*\") {}"
    set script [format $func_script "./$test" "$test"]
    spawn stap -p2 -we $script
    set hint 0
    set probes 0
    set skipped 0
    expect {
        -timeout 60
        -re "# probes" { incr hint; exp_continue }
        -re {process\("[^"]+"\)\.statement\("[^"]+"\) /\*} { incr probes; exp_continue }
        timeout { fail "$test (timeout)" }
        eof { }
    }
    catch { wait }
    catch { close }
    if { $hint == 1 && $probes >= 9 } then { pass "$test -p2" } else { fail "$test -p2 ($probes)" }
}
if { $verbose == 0 } { catch { exec rm -f $test } }
