test: add inc/dec emulation testing
PATCH 1/1 test: add inc/dec emulation testing
Signed-off-by Gleb Natapov <[email protected]>
kvm/test/x86/emulator.c +26 -0
@@ -220,6 +220,31 @@ jmpf:report ("ljmp" , res); } +void test_incdec (void *mem) +{ +unsigned long *m = mem; + + *m =0 ; + + asmvolatile ("incl %0" :"+m" (*m)); +report ("incl" , *m ==1 ); + asmvolatile ("decl %0" :"+m" (*m)); +report ("decl" , *m ==0 ); + asmvolatile ("incb %0" :"+m" (*m)); +report ("incb" , *m ==1 ); + asmvolatile ("decb %0" :"+m" (*m)); +report ("decb" , *m ==0 ); + + asmvolatile ("lock incl %0" :"+m" (*m)); +report ("lock incl" , *m ==1 ); + asmvolatile ("lock decl %0" :"+m" (*m)); +report ("lock decl" , *m ==0 ); + asmvolatile ("lock incb %0" :"+m" (*m)); +report ("lock incb" , *m ==1 ); + asmvolatile ("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.
Marcelo Tosatti
AppliedQuoted 2 lines · Gleb Natapov
Signed-off-by Gleb Natapov <[email protected]>
Applied, thanks.