[{"id":1763005,"web_url":"http://patchwork.ozlabs.org/comment/1763005/","msgid":"<a1f65bd1-6307-63bd-6404-7f3fbb49c81d@redhat.com>","list_archive_url":null,"date":"2017-09-05T07:04:06","subject":"Re: [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: Drop\n\tdependence on global_qtest","submitter":{"id":66152,"url":"http://patchwork.ozlabs.org/api/people/66152/","name":"Thomas Huth","email":"thuth@redhat.com"},"content":"On 01.09.2017 20:03, Eric Blake wrote:\n> As a general rule, we prefer avoiding implicit global state\n> because it makes code harder to safely copy and paste without\n> thinking about the global state.  Adjust the helper code to\n> use explicit state instead, and update all callers.\n> \n> Fix some trailing whitespace while touching the file.\n> \n> Signed-off-by: Eric Blake <eblake@redhat.com>\n> ---\n>  tests/boot-sector.h      | 6 ++++--\n>  tests/bios-tables-test.c | 2 +-\n>  tests/boot-sector.c      | 8 ++++----\n>  tests/pxe-test.c         | 2 +-\n>  tests/vmgenid-test.c     | 2 +-\n>  5 files changed, 11 insertions(+), 9 deletions(-)\n\nReviewed-by: Thomas Huth <thuth@redhat.com>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=thuth@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xmd514C2Jz9sNc\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  5 Sep 2017 17:04:51 +1000 (AEST)","from localhost ([::1]:57169 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dp7ui-0003LE-OU\n\tfor incoming@patchwork.ozlabs.org; Tue, 05 Sep 2017 03:04:48 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:40279)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1dp7uD-0003Kk-Sj\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 03:04:27 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <thuth@redhat.com>) id 1dp7u9-0001lg-BI\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 03:04:17 -0400","from mx1.redhat.com ([209.132.183.28]:46096)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <thuth@redhat.com>) id 1dp7u9-0001lN-5V\n\tfor qemu-devel@nongnu.org; Tue, 05 Sep 2017 03:04:13 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id D32E813A5F;\n\tTue,  5 Sep 2017 07:04:11 +0000 (UTC)","from [10.36.116.114] (ovpn-116-114.ams2.redhat.com [10.36.116.114])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 018FD812C0;\n\tTue,  5 Sep 2017 07:04:07 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com D32E813A5F","To":"Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org","References":"<20170901180340.30009-1-eblake@redhat.com>\n\t<20170901180340.30009-23-eblake@redhat.com>","From":"Thomas Huth <thuth@redhat.com>","Message-ID":"<a1f65bd1-6307-63bd-6404-7f3fbb49c81d@redhat.com>","Date":"Tue, 5 Sep 2017 09:04:06 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170901180340.30009-23-eblake@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.29]);\n\tTue, 05 Sep 2017 07:04:12 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: Drop\n\tdependence on global_qtest","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"pbonzini@redhat.com, \"Michael S. Tsirkin\" <mst@redhat.com>,\n\tarmbru@redhat.com, Ben Warren <ben@skyportsystems.com>,\n\tIgor Mammedov <imammedo@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}},{"id":1765305,"web_url":"http://patchwork.ozlabs.org/comment/1765305/","msgid":"<20170908154837-mutt-send-email-mst@kernel.org>","list_archive_url":null,"date":"2017-09-08T12:48:41","subject":"Re: [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: Drop\n\tdependence on global_qtest","submitter":{"id":2235,"url":"http://patchwork.ozlabs.org/api/people/2235/","name":"Michael S. Tsirkin","email":"mst@redhat.com"},"content":"On Fri, Sep 01, 2017 at 01:03:33PM -0500, Eric Blake wrote:\n> As a general rule, we prefer avoiding implicit global state\n> because it makes code harder to safely copy and paste without\n> thinking about the global state.  Adjust the helper code to\n> use explicit state instead, and update all callers.\n> \n> Fix some trailing whitespace while touching the file.\n> \n> Signed-off-by: Eric Blake <eblake@redhat.com>\n\nAcked-by: Michael S. Tsirkin <mst@redhat.com>\n\n> ---\n>  tests/boot-sector.h      | 6 ++++--\n>  tests/bios-tables-test.c | 2 +-\n>  tests/boot-sector.c      | 8 ++++----\n>  tests/pxe-test.c         | 2 +-\n>  tests/vmgenid-test.c     | 2 +-\n>  5 files changed, 11 insertions(+), 9 deletions(-)\n> \n> diff --git a/tests/boot-sector.h b/tests/boot-sector.h\n> index 35d61c7e2b..6ee6bb4d97 100644\n> --- a/tests/boot-sector.h\n> +++ b/tests/boot-sector.h\n> @@ -5,7 +5,7 @@\n>   *\n>   * Authors:\n>   *  Michael S. Tsirkin <mst@redhat.com>\n> - *  Victor Kaplansky <victork@redhat.com>    \n> + *  Victor Kaplansky <victork@redhat.com>\n>   *\n>   * This work is licensed under the terms of the GNU GPL, version 2 or later.\n>   * See the COPYING file in the top-level directory.\n> @@ -14,11 +14,13 @@\n>  #ifndef TEST_BOOT_SECTOR_H\n>  #define TEST_BOOT_SECTOR_H\n> \n> +#include \"libqtest.h\"\n> +\n>  /* Create boot disk file. fname must be a suitable string for mkstemp() */\n>  int boot_sector_init(char *fname);\n> \n>  /* Loop until signature in memory is OK.  */\n> -void boot_sector_test(void);\n> +void boot_sector_test(QTestState *qts);\n> \n>  /* unlink boot disk file.  */\n>  void boot_sector_cleanup(const char *fname);\n> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c\n> index 564da45f65..bde62bf1cf 100644\n> --- a/tests/bios-tables-test.c\n> +++ b/tests/bios-tables-test.c\n> @@ -632,7 +632,7 @@ static void test_acpi_one(const char *params, test_data *data)\n> \n>      qtest_start(args);\n> \n> -    boot_sector_test();\n> +    boot_sector_test(global_qtest);\n> \n>      test_acpi_rsdp_address(data);\n>      test_acpi_rsdp_table(data);\n> diff --git a/tests/boot-sector.c b/tests/boot-sector.c\n> index 9ee85370b0..8c8ac7f124 100644\n> --- a/tests/boot-sector.c\n> +++ b/tests/boot-sector.c\n> @@ -5,7 +5,7 @@\n>   *\n>   * Authors:\n>   *  Michael S. Tsirkin <mst@redhat.com>\n> - *  Victor Kaplansky <victork@redhat.com>    \n> + *  Victor Kaplansky <victork@redhat.com>\n>   *\n>   * This work is licensed under the terms of the GNU GPL, version 2 or later.\n>   * See the COPYING file in the top-level directory.\n> @@ -130,7 +130,7 @@ int boot_sector_init(char *fname)\n>  }\n> \n>  /* Loop until signature in memory is OK.  */\n> -void boot_sector_test(void)\n> +void boot_sector_test(QTestState *qts)\n>  {\n>      uint8_t signature_low;\n>      uint8_t signature_high;\n> @@ -146,8 +146,8 @@ void boot_sector_test(void)\n>       * instruction.\n>       */\n>      for (i = 0; i < TEST_CYCLES; ++i) {\n> -        signature_low = readb(SIGNATURE_ADDR);\n> -        signature_high = readb(SIGNATURE_ADDR + 1);\n> +        signature_low = qtest_readb(qts, SIGNATURE_ADDR);\n> +        signature_high = qtest_readb(qts, SIGNATURE_ADDR + 1);\n>          signature = (signature_high << 8) | signature_low;\n>          if (signature == SIGNATURE) {\n>              break;\n> diff --git a/tests/pxe-test.c b/tests/pxe-test.c\n> index 0d70afccd6..e2d3853534 100644\n> --- a/tests/pxe-test.c\n> +++ b/tests/pxe-test.c\n> @@ -31,7 +31,7 @@ static void test_pxe_one(const char *params, bool ipv6)\n>                             ipv6 ? \"on\" : \"off\", params);\n> \n>      qtest_start(args);\n> -    boot_sector_test();\n> +    boot_sector_test(global_qtest);\n>      qtest_quit(global_qtest);\n>      g_free(args);\n>  }\n> diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c\n> index 3d5c1c3615..4bdc8a15e7 100644\n> --- a/tests/vmgenid-test.c\n> +++ b/tests/vmgenid-test.c\n> @@ -47,7 +47,7 @@ static uint32_t acpi_find_vgia(void)\n>      int i;\n> \n>      /* Wait for guest firmware to finish and start the payload. */\n> -    boot_sector_test();\n> +    boot_sector_test(global_qtest);\n> \n>      /* Tables should be initialized now. */\n>      rsdp_offset = acpi_find_rsdp_address();\n> -- \n> 2.13.5\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=mst@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xpcb10P1fz9s7G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  8 Sep 2017 22:49:16 +1000 (AEST)","from localhost ([::1]:45298 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dqIih-0002zS-2f\n\tfor incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 08:49:15 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:50500)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mst@redhat.com>) id 1dqIiD-0002yo-Li\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 08:48:50 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mst@redhat.com>) id 1dqIiC-0001CR-Bu\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 08:48:45 -0400","from mx1.redhat.com ([209.132.183.28]:38744)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mst@redhat.com>) id 1dqIiC-0001BU-1w\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 08:48:44 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 14656356F0;\n\tFri,  8 Sep 2017 12:48:43 +0000 (UTC)","from redhat.com (ovpn-120-144.rdu2.redhat.com [10.10.120.144])\n\tby smtp.corp.redhat.com (Postfix) with SMTP id 56EE9614C0;\n\tFri,  8 Sep 2017 12:48:42 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 14656356F0","Date":"Fri, 8 Sep 2017 15:48:41 +0300","From":"\"Michael S. Tsirkin\" <mst@redhat.com>","To":"Eric Blake <eblake@redhat.com>","Message-ID":"<20170908154837-mutt-send-email-mst@kernel.org>","References":"<20170901180340.30009-1-eblake@redhat.com>\n\t<20170901180340.30009-23-eblake@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170901180340.30009-23-eblake@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tFri, 08 Sep 2017 12:48:43 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v6 22/29] tests/boot-sector: Drop\n\tdependence on global_qtest","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"pbonzini@redhat.com, Ben Warren <ben@skyportsystems.com>,\n\tqemu-devel@nongnu.org, armbru@redhat.com,\n\tIgor Mammedov <imammedo@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]