From patchwork Tue Oct 30 04:28:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10660453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6D6713A4 for ; Tue, 30 Oct 2018 04:30:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D51032A183 for ; Tue, 30 Oct 2018 04:30:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C89ED2A18E; Tue, 30 Oct 2018 04:30:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 365322A183 for ; Tue, 30 Oct 2018 04:30:25 +0000 (UTC) Received: from localhost ([::1]:50684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHLfd-0003Ow-0S for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 00:30:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHLeM-0002R0-OK for qemu-devel@nongnu.org; Tue, 30 Oct 2018 00:29:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHLeL-0001ib-R8 for qemu-devel@nongnu.org; Tue, 30 Oct 2018 00:29:06 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:43885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHLeL-0001hw-JY for qemu-devel@nongnu.org; Tue, 30 Oct 2018 00:29:05 -0400 Received: by mail-pf1-x442.google.com with SMTP id h4-v6so5125989pfi.10 for ; Mon, 29 Oct 2018 21:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EnuGByxCNTfSK93ua6tBaFW3p1nHFsWf2nh0Wbb440M=; b=pFiIWTA/bJfYyxSV7BQFKqLwUsqqfIo17y4WxhEaZR6emnoOr9QGp3tFRqNzf2njcd qkW2oFBuZxVHIClyl0HLsjHnHx74Tf/8l854H3e/XNDL/zsxONjYguY86ZBeD3OkG1YQ Gl2WNWwM/6uym5DkDD09qe7wnPziOBczz7JcBPtBwnlkVSV2c9H2+Q1rbqOexUiE0fWL VfjqXFK0YhwoB4zRqjgK7iS+qk6HD20VsY5cvNawn/mGexUmTnzzcXcsogz/wxpGHa0m iRL1Ebs7B2m+14+Zw+BI5IlG3yksekObZuN2KvPao7idt5uflDF9YCdhcs6KCEcOFd97 OgGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EnuGByxCNTfSK93ua6tBaFW3p1nHFsWf2nh0Wbb440M=; b=d1SrdDj26VTcsrhsrSKrqZPxn7UlS0+3JuUQhSYD+4ahWfOh8IFC9C4Coz+e0v6IZm HJA6Pjwvj8Xm5oN8FM2WSOjjE8o/tylbUvuWiip8xx+U78aQx85vevdQeduLnpy15N1R RNx0vyE3vV8mElxjeux12ZRS8sTiAy5YOEFsX2bsjkpFFU1BuMBBrXChtwn9RlC9uIRQ j8R/ItPaygAg7La/LZPIVBd32/sM4pExFoUYjKm8CJh4ncn8GfDvcWeH/P5ZPy3TBPma n0eGPiCHAyPLw2/hPIbykiCsROtW4HhrpxaAuq16eJ5RoTrgk/vWJTHOyweSfuwJmFvO lDFg== X-Gm-Message-State: AGRZ1gJ/RZ8iJ+0TgesZB975zrkMuBz2+zdLoZ9YhIQhBAEX/CUwRQvX xIK8U8cvPKPytdhgIjVS0i6C14So0O8= X-Google-Smtp-Source: AJdET5dRwf0uIrncAGuGi1/i0xe8xloe8M27iVTdUHEV0+hRITrzSSExgywzC1itOdllI2iaoWeU9Q== X-Received: by 2002:a62:6b41:: with SMTP id g62-v6mr1333984pfc.106.1540873744728; Mon, 29 Oct 2018 21:29:04 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id 64-v6sm48233059pfq.10.2018.10.29.21.29.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 21:29:04 -0700 (PDT) From: Li Qiang To: pbonzini@redhat.com, thuth@redhat.com, lvivier@redhat.com, philmd@redhat.com Date: Mon, 29 Oct 2018 21:28:51 -0700 Message-Id: <1540873732-3503-2-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540873732-3503-1-git-send-email-liq3ea@gmail.com> References: <1540873732-3503-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH v2 1/2] tests: fw_cfg: add a function to get the fw_cfg file entry X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is useful to write qtest about fw_cfg file entry. Signed-off-by: Li Qiang --- tests/libqos/fw_cfg.c | 33 +++++++++++++++++++++++++++++++++ tests/libqos/fw_cfg.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c index d0889d1e22..45338655f4 100644 --- a/tests/libqos/fw_cfg.c +++ b/tests/libqos/fw_cfg.c @@ -16,6 +16,7 @@ #include "libqos/fw_cfg.h" #include "libqtest.h" #include "qemu/bswap.h" +#include "standard-headers/linux/qemu_fw_cfg.h" void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key) { @@ -54,6 +55,38 @@ uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key) return le64_to_cpu(value); } +size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename, + void *data, size_t buflen) +{ + uint32_t count; + uint32_t i; + unsigned char *filesbuf = NULL; + uint32_t dsize; + struct fw_cfg_file *p; + size_t filesize = 0; + + qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, &count, sizeof(count)); + count = be32_to_cpu(count); + dsize = sizeof(uint32_t) + count * sizeof(struct fw_cfg_file); + filesbuf = g_malloc0(dsize); + qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, filesbuf, dsize); + p = (struct fw_cfg_file *)(filesbuf + 4); + for (i = 0; i < count; ++i, ++p) { + if (!strcmp(p->name, filename)) { + uint32_t len = be32_to_cpu(p->size); + uint16_t sel = be16_to_cpu(p->select); + filesize = len; + if (len > buflen) { + len = buflen; + } + qfw_cfg_get(fw_cfg, sel, data, len); + break; + } + } + g_free(filesbuf); + return filesize; +} + static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) { qtest_writew(fw_cfg->qts, fw_cfg->base, key); diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index 0353416af0..de73722e67 100644 --- a/tests/libqos/fw_cfg.h +++ b/tests/libqos/fw_cfg.h @@ -31,6 +31,8 @@ void qfw_cfg_get(QFWCFG *fw_cfg, uint16_t key, void *data, size_t len); uint16_t qfw_cfg_get_u16(QFWCFG *fw_cfg, uint16_t key); uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key); uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key); +size_t qfw_cfg_get_file(QFWCFG *fw_cfg, const char *filename, + void *data, size_t buflen); QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base); QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base); From patchwork Tue Oct 30 04:28:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10660455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90B7B13A4 for ; Tue, 30 Oct 2018 04:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FAEA2A183 for ; Tue, 30 Oct 2018 04:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73C532A18E; Tue, 30 Oct 2018 04:30:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D6022A183 for ; Tue, 30 Oct 2018 04:30:36 +0000 (UTC) Received: from localhost ([::1]:50685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHLfn-0003UO-Fu for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Oct 2018 00:30:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHLeX-0002Ww-Tt for qemu-devel@nongnu.org; Tue, 30 Oct 2018 00:29:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHLeT-0001oF-9n for qemu-devel@nongnu.org; Tue, 30 Oct 2018 00:29:16 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:38847) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHLeP-0001k6-1I for qemu-devel@nongnu.org; Tue, 30 Oct 2018 00:29:11 -0400 Received: by mail-pg1-x541.google.com with SMTP id f8-v6so4975248pgq.5 for ; Mon, 29 Oct 2018 21:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NaJfmgLGSXqRTJYxDStGL9uHcp2CbcbfdoDgygrcGss=; b=CQhGTrEuLUEHbGio+YaTnpXKZxXSBoAYZIgorP5/fJjUGnLqzkabirChd4JrOvAZo/ GF4hxkM+rIyqWGtKeOXOSYzCtPVdvsD6GIvQvUkmdfuRYXDD92Y+g9VcI4/Z6crOjNeu UONuf7OkxuGZVNIi9/XaKJW0+7Qg4zy/msPSXWMNnacwL9t0hzHtkr5zr6rk9QO0xTLa KM8fHqxDNCvp2o7nae9Y+5Qa/Pg3A2cKmR40+EyhfA3i2hR3g+PqBYaCz01ZvFvP6lp8 6HQu4Rbudv58KqG0to6r5uetfcHFYJn5rlejGm3hYkwZQMl7C6hoSv7EFOJKwwDPe/xr hm7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NaJfmgLGSXqRTJYxDStGL9uHcp2CbcbfdoDgygrcGss=; b=XagMdlhWZYtKdX6uimXP2b4Xs2+bdGKTFjvvPGIYAgy5UgW92LLobA/F/Pv+3yfmlj TwJKO7+Ve/1GpqkKM52yfkm3jMzNipGgA+E+Of7Sn7LRL29rt30lf9pkR07iho/H6EFJ YlnGRvzcHLP5LsRgreGJWuyfvtgCsF6OHXtcoQBHbdlnC93ugXMleyGQMxOCRk+OTuuX T2/sVRmx48R5GfiKNV1jW9BrzMzdDhZa58nd5jiUtRWed6Kj7lpoVkQ9RyFL0/BhutrL MAFZV2IGcFiE48MUXgxi0KMLPZ9TW2AROHXHMWJjSJLixuNQVUqrVTCz23bkDDfv7PBD BgbA== X-Gm-Message-State: AGRZ1gLDwFOoto3v01kQrsn+T8rgm1rmdOT/4J7n8DYwfDBHheDJ/vb3 YvwNE0yDZ5OQne3JurDsBkM= X-Google-Smtp-Source: AJdET5faqCbZVANavJFdp2+DdhMdZNFmkrQtWSY+PHITtkeiUQBaR9D5fJHX/KUL5L74wnRQDAoxWQ== X-Received: by 2002:a63:c40c:: with SMTP id h12-v6mr16377980pgd.298.1540873747681; Mon, 29 Oct 2018 21:29:07 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id 64-v6sm48233059pfq.10.2018.10.29.21.29.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 21:29:07 -0700 (PDT) From: Li Qiang To: pbonzini@redhat.com, thuth@redhat.com, lvivier@redhat.com, philmd@redhat.com Date: Mon, 29 Oct 2018 21:28:52 -0700 Message-Id: <1540873732-3503-3-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1540873732-3503-1-git-send-email-liq3ea@gmail.com> References: <1540873732-3503-1-git-send-email-liq3ea@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v2 2/2] tests: fw_cfg: add reboot_timeout test case X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Li Qiang --- tests/fw_cfg-test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 1c5103fe1c..aeabd17ec0 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -99,6 +99,15 @@ static void test_fw_cfg_boot_menu(void) g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), ==, boot_menu); } +static void test_fw_cfg_reboot_timeout(void) +{ + uint32_t reboot_timeout; + + qfw_cfg_get_file(fw_cfg, "etc/boot-fail-wait", + &reboot_timeout, sizeof(reboot_timeout)); + g_assert_cmpint(reboot_timeout, <=, 65535); +} + int main(int argc, char **argv) { QTestState *s; @@ -125,6 +134,7 @@ int main(int argc, char **argv) qtest_add_func("fw_cfg/max_cpus", test_fw_cfg_max_cpus); qtest_add_func("fw_cfg/numa", test_fw_cfg_numa); qtest_add_func("fw_cfg/boot_menu", test_fw_cfg_boot_menu); + qtest_add_func("fw_cfg/reboot_timeout", test_fw_cfg_reboot_timeout); ret = g_test_run();