# Check keep temporary directory
set test "keep temporary directory"

# Script we'll use while testing:
set script "probe begin{exit();}"

set dir ""
spawn stap -k -p1 -e $script
expect {
    -re {Keeping temporary directory \"((/[0-9a-zA-Z]*)+)\"\r\n} {
	set dir $expect_out(1,string); exp_continue
    }
    eof { }
}
catch {close}; catch {wait}

if { $dir != "" && [file isdirectory $dir] == 1 } {
    catch {exec rm -rf $dir}
    pass "$test (pass1 only)"
} else {
    fail "$test (pass1 only)"
}

if {![installtest_p]} { untested "$test (full run)"; return }

set dir ""
spawn stap -k -e $script
expect {
    -re {Keeping temporary directory \"((/[0-9a-zA-Z]*)+)\"\r\n} {
	set dir $expect_out(1,string); exp_continue
    }
    eof { }
}
catch {close}; catch {wait}

if { $dir != "" && [file isdirectory $dir] == 1 } {
    catch {exec rm -rf $dir}
    pass "$test (full run)"
} else {
    fail "$test (full run)"
}

