# This file was written by Yao Qi <qiyao@cn.ibm.com>.

set testfile "ia64-sigill"
set srcfile ${testfile}.s
set binfile ${testfile}

if { [istarget ia64-*] } then {
    verbose "compiling source file now....."
    # Build the shared libraries this test case needs.
    if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.s" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
	 send_user "Testcase compile failed, so all tests in this file will automatically fail\n."
    }

    # Run PUT for ltarce.
    set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]

    # Check the output of this program.
    verbose "ltrace runtest output: $exec_output\n"
    if [regexp {ELF from incompatible architecture} $exec_output] {
	    fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
	    return
    } elseif [ regexp {Couldn't get .hash data} $exec_output ] {
	    fail "Couldn't get .hash data!"
	    return
    }

    catch "exec sh -c {grep SIGILL ${srcdir}/${subdir}/${testfile}.ltrace | wc -l ;exit}" output
    if { $output == 0 } then {
	pass "ltrace did interpret SIGILL as breakpoint."
    } else {
	fail "ltrace failed to interpret SIGILL as breakpoint."
    }
}