From: Mohammed Gamal Subject: [PATCH][RESEND] kvm: testsuite: Consolidate mov r, imm testing in one function Date: Wed, 27 Aug 2008 17:57:36 +0300 Message-ID: <20080827145736.GA7140@mohd-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@qumranet.com, riel@surriel.com To: kvm@vger.kernel.org Return-path: Received: from fg-out-1718.google.com ([72.14.220.153]:28496 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757885AbYH0O5l (ORCPT ); Wed, 27 Aug 2008 10:57:41 -0400 Received: by fg-out-1718.google.com with SMTP id 19so1575956fgg.17 for ; Wed, 27 Aug 2008 07:57:40 -0700 (PDT) Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Consolidate mov r, imm testing in one function Signed-off-by: Mohammed Gamal --- user/test/x86/realmode.c | 51 +++++++++++++++++++++++++-------------------- 1 files changed, 28 insertions(+), 23 deletions(-) diff --git a/user/test/x86/realmode.c b/user/test/x86/realmode.c index 6002909..c2f88c8 100644 --- a/user/test/x86/realmode.c +++ b/user/test/x86/realmode.c @@ -129,49 +129,54 @@ int regs_equal(const struct regs *r1, const struct regs *r2, int ignore) ); \ extern u8 insn_##name[], insn_##name##_end[] -MK_INSN(mov_r32_imm_1, "mov $1234567890, %eax"); -MK_INSN(mov_r16_imm_1, "mov $1234, %ax"); -MK_INSN(mov_r8_imm_1, "mov $0x12, %ah"); -MK_INSN(mov_r8_imm_2, "mov $0x34, %al"); -MK_INSN(mov_r8_imm_3, "mov $0x12, %ah\n\t" "mov $0x34, %al\n\t"); - -void start(void) +void test_mov_imm(const struct regs *inregs, struct regs *outregs) { - struct regs inregs = { 0 }, outregs; + MK_INSN(mov_r32_imm_1, "mov $1234567890, %eax"); + MK_INSN(mov_r16_imm_1, "mov $1234, %ax"); + MK_INSN(mov_r8_imm_1, "mov $0x12, %ah"); + MK_INSN(mov_r8_imm_2, "mov $0x34, %al"); + MK_INSN(mov_r8_imm_3, "mov $0x12, %ah\n\t" "mov $0x34, %al\n\t"); - print_serial("abc\n"); - exec_in_big_real_mode(&inregs, &outregs, 0, 0); - if (!regs_equal(&inregs, &outregs, 0)) - print_serial("null test: FAIL\n"); - exec_in_big_real_mode(&inregs, &outregs, + exec_in_big_real_mode(inregs, outregs, insn_mov_r16_imm_1, insn_mov_r16_imm_1_end - insn_mov_r16_imm_1); - if (!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 1234) + if (!regs_equal(inregs, outregs, R_AX) || outregs->eax != 1234) print_serial("mov test 1: FAIL\n"); /* test mov $imm, %eax */ - exec_in_big_real_mode(&inregs, &outregs, + exec_in_big_real_mode(inregs, outregs, insn_mov_r32_imm_1, insn_mov_r32_imm_1_end - insn_mov_r32_imm_1); - if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 1234567890) + if(!regs_equal(inregs, outregs, R_AX) || outregs->eax != 1234567890) print_serial("mov test 2: FAIL\n"); /* test mov $imm, %al/%ah */ - exec_in_big_real_mode(&inregs, &outregs, + exec_in_big_real_mode(inregs, outregs, insn_mov_r8_imm_1, insn_mov_r8_imm_1_end - insn_mov_r8_imm_1); - if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1200) + if(!regs_equal(inregs, outregs, R_AX) || outregs->eax != 0x1200) print_serial("mov test 3: FAIL\n"); - exec_in_big_real_mode(&inregs, &outregs, + exec_in_big_real_mode(inregs, outregs, insn_mov_r8_imm_2, insn_mov_r8_imm_2_end - insn_mov_r8_imm_2); - if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x34) + if(!regs_equal(inregs, outregs, R_AX) || outregs->eax != 0x34) print_serial("mov test 4: FAIL\n"); - exec_in_big_real_mode(&inregs, &outregs, + exec_in_big_real_mode(inregs, outregs, insn_mov_r8_imm_3, insn_mov_r8_imm_3_end - insn_mov_r8_imm_3); - if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234) - print_serial("mov test 5: FAIL\n"); + if(!regs_equal(inregs, outregs, R_AX) || outregs->eax != 0x1234) + print_serial("mov test 5: FAIL\n"); +} + +void start(void) +{ + struct regs inregs = { 0 }, outregs; + + print_serial("abc\n"); + exec_in_big_real_mode(&inregs, &outregs, 0, 0); + if (!regs_equal(&inregs, &outregs, 0)) + print_serial("null test: FAIL\n"); + test_mov_imm(&inregs, &outregs); exit(0); } -- 1.5.4.3