From patchwork Mon Feb 11 19:01:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 219666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C128B2C02BB for ; Tue, 12 Feb 2013 06:01:59 +1100 (EST) Received: from localhost ([::1]:48245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4ydZ-0007Yr-TG for incoming@patchwork.ozlabs.org; Mon, 11 Feb 2013 14:01:57 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4ydC-000782-MT for qemu-devel@nongnu.org; Mon, 11 Feb 2013 14:01:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4yd6-0006cF-BD for qemu-devel@nongnu.org; Mon, 11 Feb 2013 14:01:34 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45587 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4yd6-0006bx-4d for qemu-devel@nongnu.org; Mon, 11 Feb 2013 14:01:28 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 952EBA3A4A; Mon, 11 Feb 2013 20:01:27 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2013 20:01:18 +0100 Message-Id: <1360609282-22051-2-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360609282-22051-1-git-send-email-afaerber@suse.de> References: <1360609282-22051-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH for-next v3 1/5] tmp105-test: Combine assertions of 16-bit responses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Andreas Färber Instead of comparing bytes individually, compare the full values. This aids spotting endianness issues. Signed-off-by: Andreas Färber --- tests/tmp105-test.c | 8 ++++---- 1 Datei geändert, 4 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-) diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c index a6ad213..a1fe99e 100644 --- a/tests/tmp105-test.c +++ b/tests/tmp105-test.c @@ -40,16 +40,16 @@ static void send_and_receive(void) cmd[2] = 0x34; i2c_send(i2c, addr, cmd, 3); i2c_recv(i2c, addr, resp, 2); - g_assert_cmphex(resp[0], ==, cmd[1]); - g_assert_cmphex(resp[1], ==, cmd[2]); + g_assert_cmphex(((uint16_t)resp[0] << 8) | resp[1], ==, + ((uint16_t)cmd[1] << 8) | cmd[2]); cmd[0] = TMP105_REG_T_HIGH; cmd[1] = 0x42; cmd[2] = 0x31; i2c_send(i2c, addr, cmd, 3); i2c_recv(i2c, addr, resp, 2); - g_assert_cmphex(resp[0], ==, cmd[1]); - g_assert_cmphex(resp[1], ==, cmd[2]); + g_assert_cmphex(((uint16_t)resp[0] << 8) | resp[1], ==, + ((uint16_t)cmd[1] << 8) | cmd[2]); } int main(int argc, char **argv)