| 1 |
set test "register_x64" |
| 2 |
set testpath "$srcdir/$subdir" |
| 3 |
|
| 4 |
if {! [installtest_p]} { untested $test; return } |
| 5 |
if {! [uretprobes_p]} { untested $test; return } |
| 6 |
set arch [exec uname -m] |
| 7 |
if {$arch ne "x86_64"} { untested $test; return } |
| 8 |
|
| 9 |
# --- TEST 1 --- |
| 10 |
|
| 11 |
set subtest1 "TEST 1: 64-bit rax" |
| 12 |
|
| 13 |
set res [target_compile ${testpath}/${test}_1.c ./a.out executable \ |
| 14 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 15 |
if {$res ne ""} { |
| 16 |
verbose "target_compile failed: $res" 2 |
| 17 |
fail "$test: $subtest1: unable to compile ${test}_1.c" |
| 18 |
} else { |
| 19 |
foreach runtime [get_runtime_list] { |
| 20 |
if {$runtime eq ""} { |
| 21 |
set runtime "kernel" |
| 22 |
} |
| 23 |
set test_name "$test: $subtest1 ($runtime)" |
| 24 |
set cmd "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_1.stp'" |
| 25 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 26 |
set exp_out "rax = 0x56781234beefdead |
| 27 |
u rax = 0x56781234beefdead |
| 28 |
|
| 29 |
eax = 0xffffffffbeefdead |
| 30 |
u eax = 0xbeefdead |
| 31 |
" |
| 32 |
is "${test_name}: stdout" $out $exp_out |
| 33 |
is "${test_name}: exit code" $exit_code 0 |
| 34 |
if {$stderr ne ""} { |
| 35 |
send_log "stderr:\n$stderr" |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
# --- TEST 2 --- |
| 41 |
|
| 42 |
set subtest2 "TEST 2: 64-bit rbx" |
| 43 |
|
| 44 |
set res [target_compile ${testpath}/${test}_2.c ./a.out executable \ |
| 45 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 46 |
if {$res ne ""} { |
| 47 |
verbose "target_compile failed: $res" 2 |
| 48 |
fail "$test: $subtest2: unable to compile ${test}_2.c" |
| 49 |
} else { |
| 50 |
foreach runtime [get_runtime_list] { |
| 51 |
if {$runtime eq ""} { |
| 52 |
set runtime "kernel" |
| 53 |
} |
| 54 |
set test_name "$test: $subtest2 ($runtime)" |
| 55 |
set cmd "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_2.stp'" |
| 56 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 57 |
set exp_out "rbx = 0x56781234beefdead |
| 58 |
u rbx = 0x56781234beefdead |
| 59 |
|
| 60 |
ebx = 0xffffffffbeefdead |
| 61 |
u ebx = 0xbeefdead |
| 62 |
" |
| 63 |
is "${test_name}: stdout" $out $exp_out |
| 64 |
is "${test_name}: exit code" $exit_code 0 |
| 65 |
if {$stderr ne ""} { |
| 66 |
send_log "stderr:\n$stderr" |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
# --- TEST 3 --- |
| 72 |
|
| 73 |
set subtest3 "TEST 3: 64-bit rcx" |
| 74 |
|
| 75 |
set res [target_compile ${testpath}/${test}_3.c ./a.out executable \ |
| 76 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 77 |
if {$res ne ""} { |
| 78 |
verbose "target_compile failed: $res" 2 |
| 79 |
fail "$test: $subtest3: unable to compile ${test}_3.c" |
| 80 |
} else { |
| 81 |
foreach runtime [get_runtime_list] { |
| 82 |
if {$runtime eq ""} { |
| 83 |
set runtime "kernel" |
| 84 |
} |
| 85 |
set test_name "$test: $subtest3 ($runtime)" |
| 86 |
set cmd "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_3.stp'" |
| 87 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 88 |
set exp_out "rcx = 0x56781234beefdead |
| 89 |
u rcx = 0x56781234beefdead |
| 90 |
|
| 91 |
ecx = 0xffffffffbeefdead |
| 92 |
u ecx = 0xbeefdead |
| 93 |
" |
| 94 |
is "${test_name}: stdout" $out $exp_out |
| 95 |
is "${test_name}: exit code" $exit_code 0 |
| 96 |
if {$stderr ne ""} { |
| 97 |
send_log "stderr:\n$stderr" |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
|
| 102 |
# --- TEST 4 --- |
| 103 |
|
| 104 |
set subtest4 "TEST 4: 64-bit rdx" |
| 105 |
|
| 106 |
set res [target_compile ${testpath}/${test}_4.c ./a.out executable \ |
| 107 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 108 |
if {$res ne ""} { |
| 109 |
verbose "target_compile failed: $res" 2 |
| 110 |
fail "$test: $subtest4: unable to compile ${test}_4.c" |
| 111 |
} else { |
| 112 |
foreach runtime [get_runtime_list] { |
| 113 |
if {$runtime eq ""} { |
| 114 |
set runtime "kernel" |
| 115 |
} |
| 116 |
set test_name "$test: $subtest4 ($runtime)" |
| 117 |
set cmd "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_4.stp'" |
| 118 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 119 |
set exp_out "rdx = 0x56781234beefdead |
| 120 |
u rdx = 0x56781234beefdead |
| 121 |
|
| 122 |
edx = 0xffffffffbeefdead |
| 123 |
u edx = 0xbeefdead |
| 124 |
" |
| 125 |
is "${test_name}: stdout" $out $exp_out |
| 126 |
is "${test_name}: exit code" $exit_code 0 |
| 127 |
if {$stderr ne ""} { |
| 128 |
send_log "stderr:\n$stderr" |
| 129 |
} |
| 130 |
} |
| 131 |
} |