From patchwork Fri Aug 6 09:11:09 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 117758 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o769EQYT014502 for ; Fri, 6 Aug 2010 09:14:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934242Ab0HFJNE (ORCPT ); Fri, 6 Aug 2010 05:13:04 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:59853 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S933784Ab0HFJNA (ORCPT ); Fri, 6 Aug 2010 05:13:00 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 9422417010C; Fri, 6 Aug 2010 17:12:57 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o7699sLD023289; Fri, 6 Aug 2010 17:09:54 +0800 Received: from [10.167.141.76] (unknown [10.167.141.76]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id C102A10C1F6; Fri, 6 Aug 2010 17:13:46 +0800 (CST) Message-ID: <4C5BD1AD.10207@cn.fujitsu.com> Date: Fri, 06 Aug 2010 17:11:09 +0800 From: Wei Yongjun User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100528 Thunderbird/3.0.5 MIME-Version: 1.0 To: Avi Kivity , kvm@vger.kernel.org Subject: [PATCH] test: Add test for setcc instruction Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 06 Aug 2010 09:14:34 +0000 (UTC) diff --git a/x86/emulator.c b/x86/emulator.c index e278812..5c8093e 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -375,6 +375,44 @@ void test_btc(void *mem) report("btcl reg, r/m", a[0] == 1 && a[1] == 2 && a[2] == 0x80000004); } +void test_setcc(void *mem) +{ + unsigned char *memb = mem; + + asm ("seto %0":"=m"(*memb)); + report("seto r/m8", *memb == 0); + asm ("setno %0":"=m"(*memb)); + report("setno r/m8", *memb == 1); + asm ("setc %0":"=m"(*memb)); + report("setc r/m8", *memb == 0); + asm ("setnc %0":"=m"(*memb)); + report("setnc r/m8", *memb == 1); + asm ("sete %0":"=m"(*memb)); + report("setz r/m8", *memb == 0); + asm ("setne %0":"=m"(*memb)); + report("setnz r/m8", *memb == 1); + asm ("seta %0":"=m"(*memb)); + report("seta r/m8", *memb == 1); + asm ("setna %0":"=m"(*memb)); + report("setna r/m8", *memb == 0); + asm ("sets %0":"=m"(*memb)); + report("sets r/m8", *memb == 0); + asm ("setns %0":"=m"(*memb)); + report("setns r/m8", *memb == 1); + asm ("setp %0":"=m"(*memb)); + report("setp r/m8", *memb == 0); + asm ("setnp %0":"=m"(*memb)); + report("setnp r/m8", *memb == 1); + asm ("setl %0":"=m"(*memb)); + report("setl r/m8", *memb == 0); + asm ("setnl %0":"=m"(*memb)); + report("setnl r/m8", *memb == 1); + asm ("setle %0":"=m"(*memb)); + report("setle r/m8", *memb == 0); + asm ("setnle %0":"=m"(*memb)); + report("setnle r/m8", *memb == 1); +} + int main() { void *mem; @@ -407,6 +445,7 @@ int main() test_stringio(); test_incdecnotneg(mem); test_btc(mem); + test_setcc(mem); printf("\nSUMMARY: %d tests, %d failures\n", tests, fails); return fails ? 1 : 0;