| 1 |
set test "register_x86" |
| 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 "i386" && $arch ne "x86_64"} { untested $test; return } |
| 8 |
|
| 9 |
# --- TEST 1 --- |
| 10 |
|
| 11 |
set subtest1 "TEST 1: 8-bit and 16-bit registers for eax" |
| 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 "eax = 0xffffffffbeefdead |
| 27 |
u eax = 0xbeefdead |
| 28 |
|
| 29 |
ax = 0xffffffffffffdead |
| 30 |
u ax = 0xdead |
| 31 |
|
| 32 |
al = 0xffffffffffffffad |
| 33 |
u al = 0xad |
| 34 |
|
| 35 |
ah = 0xffffffffffffffde |
| 36 |
u ah = 0xde |
| 37 |
" |
| 38 |
is "${test_name}: stdout" $out $exp_out |
| 39 |
is "${test_name}: exit code" $exit_code 0 |
| 40 |
if {$stderr ne ""} { |
| 41 |
send_log "stderr:\n$stderr" |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
# --- TEST 2 --- |
| 47 |
|
| 48 |
set subtest2 "TEST 2: 8-bit and 16-bit registers for edx" |
| 49 |
|
| 50 |
set res [target_compile ${testpath}/${test}_2.c ./a.out executable \ |
| 51 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 52 |
if {$res ne ""} { |
| 53 |
verbose "target_compile failed: $res" 2 |
| 54 |
fail "$test: $subtest2: unable to compile ${test}_2.c" |
| 55 |
} else { |
| 56 |
foreach runtime [get_runtime_list] { |
| 57 |
if {$runtime eq ""} { |
| 58 |
set runtime "kernel" |
| 59 |
} |
| 60 |
set test_name "$test: $subtest2 ($runtime)" |
| 61 |
set cmd "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_2.stp'" |
| 62 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 63 |
set exp_out "edx = 0xffffffffbeefdead |
| 64 |
u edx = 0xbeefdead |
| 65 |
|
| 66 |
dx = 0xffffffffffffdead |
| 67 |
u dx = 0xdead |
| 68 |
|
| 69 |
dl = 0xffffffffffffffad |
| 70 |
u dl = 0xad |
| 71 |
|
| 72 |
dh = 0xffffffffffffffde |
| 73 |
u dh = 0xde |
| 74 |
" |
| 75 |
is "${test_name}: stdout" $out $exp_out |
| 76 |
is "${test_name}: exit code" $exit_code 0 |
| 77 |
if {$stderr ne ""} { |
| 78 |
send_log "stderr:\n$stderr" |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
# --- TEST 3 --- |
| 84 |
|
| 85 |
set subtest3 "TEST 3: 8-bit and 16-bit registers for ecx" |
| 86 |
|
| 87 |
set res [target_compile ${testpath}/${test}_3.c ./a.out executable \ |
| 88 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 89 |
if {$res ne ""} { |
| 90 |
verbose "target_compile failed: $res" 2 |
| 91 |
fail "$test: $subtest3: unable to compile ${test}_3.c" |
| 92 |
} else { |
| 93 |
foreach runtime [get_runtime_list] { |
| 94 |
if {$runtime eq ""} { |
| 95 |
set runtime "kernel" |
| 96 |
} |
| 97 |
set test_name "$test: $subtest3 ($runtime)" |
| 98 |
set cmd "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_3.stp'" |
| 99 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 100 |
set exp_out "ecx = 0xffffffffbeefdead |
| 101 |
u ecx = 0xbeefdead |
| 102 |
|
| 103 |
cx = 0xffffffffffffdead |
| 104 |
u cx = 0xdead |
| 105 |
|
| 106 |
cl = 0xffffffffffffffad |
| 107 |
u cl = 0xad |
| 108 |
|
| 109 |
ch = 0xffffffffffffffde |
| 110 |
u ch = 0xde |
| 111 |
" |
| 112 |
is "${test_name}: stdout" $out $exp_out |
| 113 |
is "${test_name}: exit code" $exit_code 0 |
| 114 |
if {$stderr ne ""} { |
| 115 |
send_log "stderr:\n$stderr" |
| 116 |
} |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
# --- TEST 4 --- |
| 121 |
|
| 122 |
set subtest4 "TEST 4: 8-bit and 16-bit registers for eax" |
| 123 |
|
| 124 |
set res [target_compile ${testpath}/${test}_4.c ./a.out executable \ |
| 125 |
"additional_flags=-O additional_flags=-g additional_flags=-O0"] |
| 126 |
if {$res ne ""} { |
| 127 |
verbose "target_compile failed: $res" 2 |
| 128 |
fail "$test: $subtest4: unable to compile ${test}_4.c" |
| 129 |
} else { |
| 130 |
foreach runtime [get_runtime_list] { |
| 131 |
if {$runtime eq ""} { |
| 132 |
set runtime "kernel" |
| 133 |
} |
| 134 |
set test_name "$test: $subtest4 ($runtime)" |
| 135 |
set cmd "stap --runtime=$runtime -c ./a.out '$srcdir/$subdir/${test}_4.stp'" |
| 136 |
set exit_code [run_cmd_2way $cmd out stderr] |
| 137 |
set exp_out "ebx = 0xffffffffbeefdead |
| 138 |
u ebx = 0xbeefdead |
| 139 |
|
| 140 |
bx = 0xffffffffffffdead |
| 141 |
u bx = 0xdead |
| 142 |
|
| 143 |
bl = 0xffffffffffffffad |
| 144 |
u bl = 0xad |
| 145 |
|
| 146 |
bh = 0xffffffffffffffde |
| 147 |
u bh = 0xde |
| 148 |
" |
| 149 |
is "${test_name}: stdout" $out $exp_out |
| 150 |
is "${test_name}: exit code" $exit_code 0 |
| 151 |
if {$stderr ne ""} { |
| 152 |
send_log "stderr:\n$stderr" |
| 153 |
} |
| 154 |
} |
| 155 |
} |