ia64/xen-unstable
changeset 13344:ddea7363fa41
[TEST] Fix x86_emulate tests on x86/64 host.
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kfraser@localhost.localdomain |
---|---|
date | Tue Jan 09 17:11:46 2007 +0000 (2007-01-09) |
parents | c98f3f3f7099 |
children | 761f695043ff |
files | tools/tests/test_x86_emulator.c |
line diff
1.1 --- a/tools/tests/test_x86_emulator.c Tue Jan 09 16:59:52 2007 +0000 1.2 +++ b/tools/tests/test_x86_emulator.c Tue Jan 09 17:11:46 2007 +0000 1.3 @@ -106,9 +106,12 @@ int main(int argc, char **argv) 1.4 { 1.5 struct x86_emulate_ctxt ctxt; 1.6 struct cpu_user_regs regs; 1.7 - char instr[20] = { 0x01, 0x08 }; /* add %ecx,(%eax) */ 1.8 - unsigned int *res, bcdres_native, bcdres_emul; 1.9 - int rc, i; 1.10 + char *instr; 1.11 + unsigned int *res; 1.12 + int rc; 1.13 +#ifndef __x86_64__ 1.14 + unsigned int i, bcdres_native, bcdres_emul; 1.15 +#endif 1.16 1.17 ctxt.regs = ®s; 1.18 ctxt.address_bytes = 4; 1.19 @@ -120,6 +123,7 @@ int main(int argc, char **argv) 1.20 fprintf(stderr, "mmap to low address failed\n"); 1.21 exit(1); 1.22 } 1.23 + instr = (char *)res + 0x100; 1.24 1.25 printf("%-40s", "Testing addl %%ecx,(%%eax)..."); 1.26 instr[0] = 0x01; instr[1] = 0x08; 1.27 @@ -409,6 +413,7 @@ int main(int argc, char **argv) 1.28 printf("okay\n"); 1.29 1.30 printf("%-40s", "Testing daa/das (all inputs)..."); 1.31 +#ifndef __x86_64__ 1.32 /* Bits 0-7: AL; Bit 8: EFLG_AF; Bit 9: EFLG_CF; Bit 10: DAA vs. DAS. */ 1.33 for ( i = 0; i < 0x800; i++ ) 1.34 { 1.35 @@ -426,6 +431,9 @@ int main(int argc, char **argv) 1.36 "pushf; popl %1" 1.37 : "=a" (bcdres_native), "=r" (regs.eflags) 1.38 : "0" (i & 0xff), "1" (regs.eflags) ); 1.39 + bcdres_native |= (regs.eflags & EFLG_PF) ? 0x1000 : 0; 1.40 + bcdres_native |= (regs.eflags & EFLG_ZF) ? 0x800 : 0; 1.41 + bcdres_native |= (regs.eflags & EFLG_SF) ? 0x400 : 0; 1.42 bcdres_native |= (regs.eflags & EFLG_CF) ? 0x200 : 0; 1.43 bcdres_native |= (regs.eflags & EFLG_AF) ? 0x100 : 0; 1.44 1.45 @@ -436,6 +444,9 @@ int main(int argc, char **argv) 1.46 regs.eax = (unsigned char)i; 1.47 rc = x86_emulate(&ctxt, &emulops); 1.48 bcdres_emul = regs.eax; 1.49 + bcdres_emul |= (regs.eflags & EFLG_PF) ? 0x1000 : 0; 1.50 + bcdres_emul |= (regs.eflags & EFLG_ZF) ? 0x800 : 0; 1.51 + bcdres_emul |= (regs.eflags & EFLG_SF) ? 0x400 : 0; 1.52 bcdres_emul |= (regs.eflags & EFLG_CF) ? 0x200 : 0; 1.53 bcdres_emul |= (regs.eflags & EFLG_AF) ? 0x100 : 0; 1.54 if ( (rc != 0) || (regs.eax > 255) || 1.55 @@ -445,8 +456,8 @@ int main(int argc, char **argv) 1.56 if ( bcdres_emul != bcdres_native ) 1.57 { 1.58 printf("%s: AL=%02x %s %s\n" 1.59 - "Output: AL=%02x %s %s\n" 1.60 - "Emul.: AL=%02x %s %s\n", 1.61 + "Output: AL=%02x %s %s %s %s %s\n" 1.62 + "Emul.: AL=%02x %s %s %s %s %s\n", 1.63 (i & 0x400) ? "DAS" : "DAA", 1.64 (unsigned char)i, 1.65 (i & 0x200) ? "CF" : " ", 1.66 @@ -454,13 +465,22 @@ int main(int argc, char **argv) 1.67 (unsigned char)bcdres_native, 1.68 (bcdres_native & 0x200) ? "CF" : " ", 1.69 (bcdres_native & 0x100) ? "AF" : " ", 1.70 + (bcdres_native & 0x1000) ? "PF" : " ", 1.71 + (bcdres_native & 0x800) ? "ZF" : " ", 1.72 + (bcdres_native & 0x400) ? "SF" : " ", 1.73 (unsigned char)bcdres_emul, 1.74 (bcdres_emul & 0x200) ? "CF" : " ", 1.75 - (bcdres_emul & 0x100) ? "AF" : " "); 1.76 + (bcdres_emul & 0x100) ? "AF" : " ", 1.77 + (bcdres_emul & 0x1000) ? "PF" : " ", 1.78 + (bcdres_emul & 0x800) ? "ZF" : " ", 1.79 + (bcdres_emul & 0x400) ? "SF" : " "); 1.80 goto fail; 1.81 } 1.82 } 1.83 printf("okay\n"); 1.84 +#else 1.85 + printf("skipped\n"); 1.86 +#endif 1.87 1.88 return 0; 1.89