From: Mohammed Gamal Subject: [PATCH] Add push instructions test in test harness Date: Mon, 17 Aug 2009 22:15:52 +0300 Message-ID: <1250536552-8373-1-git-send-email-m.gamal005@gmail.com> Cc: kvm@vger.kernel.org, Mohammed Gamal To: avi@redhat.com Return-path: Received: from mail-ew0-f214.google.com ([209.85.219.214]:43274 "EHLO mail-ew0-f214.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbZHQTP5 (ORCPT ); Mon, 17 Aug 2009 15:15:57 -0400 Received: by ewy10 with SMTP id 10so3199620ewy.37 for ; Mon, 17 Aug 2009 12:15:57 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Mohammed Gamal --- kvm/user/test/x86/realmode.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 38 insertions(+), 2 deletions(-) diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c index 755b5d1..a9208ff 100644 --- a/kvm/user/test/x86/realmode.c +++ b/kvm/user/test/x86/realmode.c @@ -467,6 +467,41 @@ void test_long_jmp() if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234) print_serial("Long JMP Test: FAIL\n"); } +void test_push() +{ + struct regs inregs = { 0 }, outregs; + MK_INSN(push32, "mov $0x12345678, %eax\n\t" + "push %eax\n\t" + "pop %ebx\n\t"); + MK_INSN(push16, "mov $0x1234, %ax\n\t" + "push %ax\n\t" + "pop %bx\n\t"); + MK_INSN(push_es, "mov $0x231, %bx\n\t" //Just write a dummy value to see if it gets overwritten + "mov $0x123, %ax\n\t" + "mov %ax, %es\n\t" + "push %es\n\t" + "pop %bx \n\t" + ); + + exec_in_big_real_mode(&inregs, &outregs, + insn_push32, + insn_push32_end - insn_push32); + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.eax != outregs.ebx || outregs.eax != 0x12345678) + print_serial("Push Test 1: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_push16, + insn_push16_end - insn_push16); + + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.eax != outregs.ebx || outregs.eax != 0x1234) + print_serial("Push Test 2: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_push_es, + insn_push_es_end - insn_push_es); + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.ebx != outregs.eax || outregs.eax != 0x123) + print_serial("Push Test 3: FAIL\n"); +} void test_null(void) { @@ -479,8 +514,9 @@ void test_null(void) void start(void) { test_null(); - + test_shld(); + test_push(); test_mov_imm(); test_cmp_imm(); test_add_imm(); @@ -492,7 +528,7 @@ void start(void) test_call(); /* long jmp test uses call near so test it after testing call */ test_long_jmp(); - + exit(0); } -- 1.6.0.4