* [PATCH] test: add inc/dec emulation testing
@ 2010-07-14 12:27 Gleb Natapov
2010-07-14 16:43 ` Marcelo Tosatti
0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2010-07-14 12:27 UTC (permalink / raw)
To: mtosatti, avi; +Cc: kvm
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/kvm/test/x86/emulator.c b/kvm/test/x86/emulator.c
index 6db1305..87ce9bc 100644
--- a/kvm/test/x86/emulator.c
+++ b/kvm/test/x86/emulator.c
@@ -220,6 +220,31 @@ jmpf:
report("ljmp", res);
}
+void test_incdec(void *mem)
+{
+ unsigned long *m = mem;
+
+ *m = 0;
+
+ asm volatile ("incl %0":"+m"(*m));
+ report("incl", *m == 1);
+ asm volatile ("decl %0":"+m"(*m));
+ report("decl", *m == 0);
+ asm volatile ("incb %0":"+m"(*m));
+ report("incb", *m == 1);
+ asm volatile ("decb %0":"+m"(*m));
+ report("decb", *m == 0);
+
+ asm volatile ("lock incl %0":"+m"(*m));
+ report("lock incl", *m == 1);
+ asm volatile ("lock decl %0":"+m"(*m));
+ report("lock decl", *m == 0);
+ asm volatile ("lock incb %0":"+m"(*m));
+ report("lock incb", *m == 1);
+ asm volatile ("lock decb %0":"+m"(*m));
+ report("lock decb", *m == 0);
+}
+
void test_smsw(void)
{
char mem[16];
@@ -298,6 +323,7 @@ int main()
test_lmsw();
test_ljmp(mem);
test_stringio();
+ test_incdec(mem);
printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
return fails ? 1 : 0;
--
Gleb.
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-14 17:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 12:27 [PATCH] test: add inc/dec emulation testing Gleb Natapov
2010-07-14 16:43 ` Marcelo Tosatti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox