set test "at_var_unresolved_lvalue"
set testpath "$srcdir/$subdir"

# Check unresolved @var used as lvalue.

# Only run on make installcheck and uprobes present.
if {! [installtest_p]} { untested "$test"; return }
if {! [uprobes_p]} { untested "$test"; return }

set res [target_compile ${testpath}/at_var.c $test executable \
    "additional_flags=-O2 additional_flags=-g"]

if { $res != "" } {
    verbose "target_compile failed: $res" 2
    fail "unable to compile ${test}.c"
}

spawn stap $srcdir/$subdir/$test.stp -c ./$test $test -g
set ok 0

expect {
    -timeout 180

    -re {^semantic error: unable to find global 'no_such_variable' in at_var_unresolved_lvalue} {
        incr ok; exp_continue
    }

    -re {^[^\r\n]*\r\n} { exp_continue }

    timeout { fail "$test (timeout)" }
    eof { }
}
wait

if {$ok == 1} {
    pass "$test"
} {
    fail "$test"
}

# Cleanup
if { $verbose == 0 } { catch { exec rm -f $test } }
