From patchwork Sat Apr 20 10:00:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10910113 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 5915617E0 for ; Sat, 20 Apr 2019 10:05:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4142328DAD for ; Sat, 20 Apr 2019 10:05:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3585B28DB0; Sat, 20 Apr 2019 10:05:47 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0537928DAD for ; Sat, 20 Apr 2019 10:05:45 +0000 (UTC) Received: from localhost ([127.0.0.1]:39436 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmsS-00026X-KS for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Apr 2019 06:05:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmrA-000119-Nw for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:04:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHmoC-00057g-Ey for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:01:21 -0400 Received: from m12-14.163.com ([220.181.12.14]:59356) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmoB-00055l-HT for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:01:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=jBwT8u+D5E4FyKIYFq gHgB2KBaSBCqDOj62EMzvj7ow=; b=b3A7zxCCooGPWIOWTx78SHDScS7t/P3ecN 0WoJXaZqmq9rJkmXHYwF+8krmkUHIUa6V9b3fzckr96tU+sHA2VjCxGZRHyzRkdo k3yj0wX7UthMiseQc5mKDrolSXGRk/PL3MS/c87I053JRXc91LvMIlpaTjrJAgDI 3Fb70xADU= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp10 (Coremail) with SMTP id DsCowACHzxnk7bpcMStGBQ--.39886S3; Sat, 20 Apr 2019 18:01:12 +0800 (CST) From: Li Qiang To: thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, philmd@redhat.com, lersek@redhat.com, kraxel@redhat.com Date: Sat, 20 Apr 2019 03:00:53 -0700 Message-Id: <20190420100056.116305-2-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190420100056.116305-1-liq3ea@163.com> References: <20190420100056.116305-1-liq3ea@163.com> X-CM-TRANSID: DsCowACHzxnk7bpcMStGBQ--.39886S3 X-Coremail-Antispam: 1Uf129KBjvJXoW3JryfKFWDGryDtF1rWFWkXrb_yoW7uw1fpr y7uF1YkrZ3JFsaqry3Jr1Ut3W3t34xW34kGw4Utay5tw4Uur4UJF4kAw1akw1DXrW8Zay5 Aa1vyr1YkFn8WaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UliihUUUUU= X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiFB2cbVaD0T3+BAAAs7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH 1/4] tests: refactor fw_cfg_test 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 , liq3ea@gmail.com, 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 Currently, fw_cfg_test uses one QTestState for every test case. This will add all command lines for every test case and this is unnecessary. This patch split the test cases and for every test case it uses his own QTestState. This patch does following things: 1. Get rid of the global 'fw_cfg', this need add a uninit function 2. Convert every test case in a separate QTestState After this patch, we can add fw_cfg test case freely and will not have efect other test cases. Signed-off-by: Li Qiang Acked-by: Thomas Huth --- tests/fw_cfg-test.c | 86 ++++++++++++++++++++++++++++++++++++++----- tests/libqos/fw_cfg.c | 10 +++++ tests/libqos/fw_cfg.h | 7 ++++ 3 files changed, 94 insertions(+), 9 deletions(-) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 1c5103fe1c..c22503619f 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -21,62 +21,127 @@ static uint16_t nb_cpus = 1; static uint16_t max_cpus = 1; static uint64_t nb_nodes = 0; static uint16_t boot_menu = 0; -static QFWCFG *fw_cfg = NULL; static void test_fw_cfg_signature(void) { + QFWCFG *fw_cfg; + QTestState *s; char buf[5]; + s = qtest_init(""); + fw_cfg = pc_fw_cfg_init(s); + qfw_cfg_get(fw_cfg, FW_CFG_SIGNATURE, buf, 4); buf[4] = 0; g_assert_cmpstr(buf, ==, "QEMU"); + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); } static void test_fw_cfg_id(void) { - uint32_t id = qfw_cfg_get_u32(fw_cfg, FW_CFG_ID); + QFWCFG *fw_cfg; + QTestState *s; + uint32_t id; + + s = qtest_init(""); + fw_cfg = pc_fw_cfg_init(s); + + id = qfw_cfg_get_u32(fw_cfg, FW_CFG_ID); g_assert((id == 1) || (id == 3)); + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); } static void test_fw_cfg_uuid(void) { + QFWCFG *fw_cfg; + QTestState *s; + uint8_t buf[16]; static const uint8_t uuid[16] = { 0x46, 0x00, 0xcb, 0x32, 0x38, 0xec, 0x4b, 0x2f, 0x8a, 0xcb, 0x81, 0xc6, 0xea, 0x54, 0xf2, 0xd8, }; + s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8"); + fw_cfg = pc_fw_cfg_init(s); + qfw_cfg_get(fw_cfg, FW_CFG_UUID, buf, 16); g_assert(memcmp(buf, uuid, sizeof(buf)) == 0); + + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); + } static void test_fw_cfg_ram_size(void) { + QFWCFG *fw_cfg; + QTestState *s; + + s = qtest_init(""); + fw_cfg = pc_fw_cfg_init(s); + g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), ==, ram_size); + + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); } static void test_fw_cfg_nographic(void) { + QFWCFG *fw_cfg; + QTestState *s; + + s = qtest_init(""); + fw_cfg = pc_fw_cfg_init(s); + g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), ==, 0); + + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); } static void test_fw_cfg_nb_cpus(void) { + QFWCFG *fw_cfg; + QTestState *s; + + s = qtest_init(""); + fw_cfg = pc_fw_cfg_init(s); + g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), ==, nb_cpus); + + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); } static void test_fw_cfg_max_cpus(void) { + QFWCFG *fw_cfg; + QTestState *s; + + s = qtest_init(""); + fw_cfg = pc_fw_cfg_init(s); + g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), ==, max_cpus); + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); } static void test_fw_cfg_numa(void) { + QFWCFG *fw_cfg; + QTestState *s; uint64_t *cpu_mask; uint64_t *node_mask; + s = qtest_init(""); + fw_cfg = pc_fw_cfg_init(s); + g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_NUMA), ==, nb_nodes); cpu_mask = g_new0(uint64_t, max_cpus); @@ -92,24 +157,29 @@ static void test_fw_cfg_numa(void) g_free(node_mask); g_free(cpu_mask); + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); } static void test_fw_cfg_boot_menu(void) { + QFWCFG *fw_cfg; + QTestState *s; + + s = qtest_init(""); + fw_cfg = pc_fw_cfg_init(s); + g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), ==, boot_menu); + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); } int main(int argc, char **argv) { - QTestState *s; int ret; g_test_init(&argc, &argv, NULL); - s = qtest_init("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8"); - - fw_cfg = pc_fw_cfg_init(s); - qtest_add_func("fw_cfg/signature", test_fw_cfg_signature); qtest_add_func("fw_cfg/id", test_fw_cfg_id); qtest_add_func("fw_cfg/uuid", test_fw_cfg_uuid); @@ -128,7 +198,5 @@ int main(int argc, char **argv) ret = g_test_run(); - qtest_quit(s); - return ret; } diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c index d0889d1e22..c6839c53c8 100644 --- a/tests/libqos/fw_cfg.c +++ b/tests/libqos/fw_cfg.c @@ -81,6 +81,11 @@ QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base) return fw_cfg; } +void mm_fw_cfg_uninit(QFWCFG *fw_cfg) +{ + g_free(fw_cfg); +} + static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) { qtest_outw(fw_cfg->qts, fw_cfg->base, key); @@ -107,3 +112,8 @@ QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base) return fw_cfg; } + +void io_fw_cfg_uninit(QFWCFG *fw_cfg) +{ + g_free(fw_cfg); +} diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index 0353416af0..60de81e863 100644 --- a/tests/libqos/fw_cfg.h +++ b/tests/libqos/fw_cfg.h @@ -33,11 +33,18 @@ uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key); uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key); QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base); +void mm_fw_cfg_uninit(QFWCFG *fw_cfg); QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base); +void io_fw_cfg_uninit(QFWCFG *fw_cfg); static inline QFWCFG *pc_fw_cfg_init(QTestState *qts) { return io_fw_cfg_init(qts, 0x510); } +static inline void pc_fw_cfg_uninit(QFWCFG *fw_cfg) +{ + io_fw_cfg_uninit(fw_cfg); +} + #endif From patchwork Sat Apr 20 10:00:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10910119 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 020EA17E0 for ; Sat, 20 Apr 2019 10:06:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7F5C28D59 for ; Sat, 20 Apr 2019 10:06:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC3AA28DAE; Sat, 20 Apr 2019 10:06:08 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7E30A28D59 for ; Sat, 20 Apr 2019 10:06:08 +0000 (UTC) Received: from localhost ([127.0.0.1]:39442 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmsp-0002SA-PP for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Apr 2019 06:06:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmrN-000119-BH for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:04:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHmoC-00057s-OV for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:01:21 -0400 Received: from m12-14.163.com ([220.181.12.14]:59446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmoC-000567-5q for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:01:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=sCb8YXqnwMWDwlRe9R QnvuJNlooEDF6qc4SA035rRd4=; b=athGMK9X21oIAEwkWLaeyRFiChqWxTwTA6 z8SBfGpuI34BBf56vb5yjzNYaSC9MIbAmxZSUXipuoklWrRSOrp0kdl7gagYQh7N uEZSw3g2/45F3n2875Q8PpZZlnQO8HEQ6mCNg65/yKG/BHHhMtO4IdVeW7l92H2J SJt7o7kuw= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp10 (Coremail) with SMTP id DsCowACHzxnk7bpcMStGBQ--.39886S4; Sat, 20 Apr 2019 18:01:14 +0800 (CST) From: Li Qiang To: thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, philmd@redhat.com, lersek@redhat.com, kraxel@redhat.com Date: Sat, 20 Apr 2019 03:00:54 -0700 Message-Id: <20190420100056.116305-3-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190420100056.116305-1-liq3ea@163.com> References: <20190420100056.116305-1-liq3ea@163.com> X-CM-TRANSID: DsCowACHzxnk7bpcMStGBQ--.39886S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxWr4kZF45Xr4DtF4DCFWUXFb_yoW5ArWkpF ZxAF13trZ3G3WfKrnxJw13JF1a9rykXr1UG3y3ZFWFyw17Arn8tF42k34F9ryUXrW8ZF45 A3yq9Fyak3Z7XaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jOjjgUUUUU= X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiFB2cbVaD0T3+BQABs7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH 2/4] tests: fw_cfg: add a function to get the fw_cfg file 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 , liq3ea@gmail.com, 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 Acked-by: Thomas Huth --- tests/libqos/fw_cfg.c | 45 +++++++++++++++++++++++++++++++++++++++++++ tests/libqos/fw_cfg.h | 2 ++ 2 files changed, 47 insertions(+) diff --git a/tests/libqos/fw_cfg.c b/tests/libqos/fw_cfg.c index c6839c53c8..1f46258f96 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 "hw/nvram/fw_cfg.h" void qfw_cfg_select(QFWCFG *fw_cfg, uint16_t key) { @@ -59,6 +60,50 @@ static void mm_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key) qtest_writew(fw_cfg->qts, fw_cfg->base, key); } +/* + * The caller need check the return value. When the return value is + * nonzero, it means that some bytes have been transferred. + * + * If the fw_cfg file in question is smaller than the allocated & passed-in + * buffer, then the buffer has been populated only in part. + * + * If the fw_cfg file in question is larger than the passed-in + * buffer, then the return value explains how much room would have been + * necessary in total. And, while the caller's buffer has been fully + * populated, it has received only a starting slice of the fw_cfg file. + */ +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; + size_t dsize; + FWCfgFile *pdir_entry; + 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_malloc(dsize); + qfw_cfg_get(fw_cfg, FW_CFG_FILE_DIR, filesbuf, dsize); + pdir_entry = (FWCfgFile *)(filesbuf + sizeof(uint32_t)); + for (i = 0; i < count; ++i, ++pdir_entry) { + if (!strcmp(pdir_entry->name, filename)) { + uint32_t len = be32_to_cpu(pdir_entry->size); + uint16_t sel = be16_to_cpu(pdir_entry->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_read(QFWCFG *fw_cfg, void *data, size_t len) { uint8_t *ptr = data; diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index 60de81e863..13325cc4ff 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); void mm_fw_cfg_uninit(QFWCFG *fw_cfg); From patchwork Sat Apr 20 10:00:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10910115 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 5FE2117E0 for ; Sat, 20 Apr 2019 10:06:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F57828D59 for ; Sat, 20 Apr 2019 10:06:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 437CC28DAE; Sat, 20 Apr 2019 10:06:05 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED20428D59 for ; Sat, 20 Apr 2019 10:06:04 +0000 (UTC) Received: from localhost ([127.0.0.1]:39440 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmsm-0002PK-4h for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Apr 2019 06:06:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmrJ-000119-4a for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:04:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHmoD-00058K-LP for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:01:22 -0400 Received: from m12-14.163.com ([220.181.12.14]:59555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmoC-00056X-HD for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:01:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=WutwQeyfp9GXWhkPQ9 MxzsQDlnRQ/i/PTU1PssIvR+8=; b=GGdm3ck+IWWatnqPRDfOgoZxisKW3fZ0Ru 19mH96zfvLOiUG64UXnVySlsfHkI8CRTD0DlUL9kVXASL09vqkoFhPuE52PkHKyP qUUyyv6w0N391GB1eTRIBgZtrdwEncYWWov/QJ0exl/JuG1V0seCYEM0QOEEgCn5 MWHKNK7yk= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp10 (Coremail) with SMTP id DsCowACHzxnk7bpcMStGBQ--.39886S5; Sat, 20 Apr 2019 18:01:15 +0800 (CST) From: Li Qiang To: thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, philmd@redhat.com, lersek@redhat.com, kraxel@redhat.com Date: Sat, 20 Apr 2019 03:00:55 -0700 Message-Id: <20190420100056.116305-4-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190420100056.116305-1-liq3ea@163.com> References: <20190420100056.116305-1-liq3ea@163.com> X-CM-TRANSID: DsCowACHzxnk7bpcMStGBQ--.39886S5 X-Coremail-Antispam: 1Uf129KBjvJXoW7AryDuw1UCrWDuFyUGw1kAFb_yoW8JF43pr 1jkF1qkrZ3JFW2qr13Kr1qqr13tr97Cw48ArZrXFWIyw18Gr1Dta18CasYg3WDWFWIvFs8 Z3WvqF13KF1DJaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UGksgUUUUU= X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBoQOcbVQHEkbMsAAAso X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH 3/4] 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 , liq3ea@gmail.com, 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index c22503619f..9f75dbb5f4 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -174,6 +174,24 @@ static void test_fw_cfg_boot_menu(void) qtest_quit(s); } +static void test_fw_cfg_reboot_timeout(void) +{ + QFWCFG *fw_cfg; + QTestState *s; + uint32_t reboot_timeout = 0; + size_t filesize; + + s = qtest_init("-boot reboot-timeout=15"); + fw_cfg = pc_fw_cfg_init(s); + + filesize = qfw_cfg_get_file(fw_cfg, "etc/boot-fail-wait", + &reboot_timeout, sizeof(reboot_timeout)); + g_assert_cmpint(filesize, ==, sizeof(reboot_timeout)); + g_assert_cmpint(reboot_timeout, ==, 15); + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); +} + int main(int argc, char **argv) { int ret; @@ -195,6 +213,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(); From patchwork Sat Apr 20 10:00:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10910121 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 AD2F814DB for ; Sat, 20 Apr 2019 10:08:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CC8B28D59 for ; Sat, 20 Apr 2019 10:08:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9085A28DAE; Sat, 20 Apr 2019 10:08:28 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0047428D59 for ; Sat, 20 Apr 2019 10:08:27 +0000 (UTC) Received: from localhost ([127.0.0.1]:39460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmv5-0004Il-7T for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Apr 2019 06:08:27 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmrK-000119-56 for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:04:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHmoD-000586-F0 for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:01:22 -0400 Received: from m12-14.163.com ([220.181.12.14]:59714) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHmoC-00056s-Th for qemu-devel@nongnu.org; Sat, 20 Apr 2019 06:01:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=w4ygKr81NYHHj0JHeC mMA9n1b8fxsPI3UkzRPp2GlvU=; b=RSMQ0VpRKsI0u/18CJHFF4q51jt9TpRgJ/ oZr6TOQOV5V9YIVX1zABR5V4ChBTdKd/hf3+C0VRjlEp7OukLxB/P8j9gMGeG6ff ea1yRiZe7h9ZL04px0mArK2M1TPikz/r3hRyKQv4lpU7s42iccwaKbHiZ/IsWI0h DmCITqxGw= Received: from localhost.localdomain (unknown [183.159.69.175]) by smtp10 (Coremail) with SMTP id DsCowACHzxnk7bpcMStGBQ--.39886S6; Sat, 20 Apr 2019 18:01:17 +0800 (CST) From: Li Qiang To: thuth@redhat.com, lvivier@redhat.com, pbonzini@redhat.com, philmd@redhat.com, lersek@redhat.com, kraxel@redhat.com Date: Sat, 20 Apr 2019 03:00:56 -0700 Message-Id: <20190420100056.116305-5-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190420100056.116305-1-liq3ea@163.com> References: <20190420100056.116305-1-liq3ea@163.com> X-CM-TRANSID: DsCowACHzxnk7bpcMStGBQ--.39886S6 X-Coremail-Antispam: 1Uf129KBjvJXoWrZF48CF17GFyxAFW3Ar1xuFg_yoW8JF13pF 1Uu3WYkrZ5JFZFqr13Gr1qqr1ftr97Cw18JrZxXFWjyw48Xr1DKa10ka4Fgrn8JF48Xanx Z3ZYqF43KF1DXaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jUHUDUUUUU= X-Originating-IP: [183.159.69.175] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBoQWcbVQHEkbMwQAAsf X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH 4/4] tests: fw_cfg: add splash time 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 , liq3ea@gmail.com, 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 9f75dbb5f4..de8e81ea9d 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -192,6 +192,24 @@ static void test_fw_cfg_reboot_timeout(void) qtest_quit(s); } +static void test_fw_cfg_splash_time(void) +{ + QFWCFG *fw_cfg; + QTestState *s; + uint16_t splash_time = 0; + size_t filesize; + + s = qtest_init("-boot splash-time=12"); + fw_cfg = pc_fw_cfg_init(s); + + filesize = qfw_cfg_get_file(fw_cfg, "etc/boot-menu-wait", + &splash_time, sizeof(splash_time)); + g_assert_cmpint(filesize, ==, sizeof(splash_time)); + g_assert_cmpint(splash_time, ==, 12); + pc_fw_cfg_uninit(fw_cfg); + qtest_quit(s); +} + int main(int argc, char **argv) { int ret; @@ -214,6 +232,7 @@ int main(int argc, char **argv) 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); + qtest_add_func("fw_cfg/splash_time", test_fw_cfg_splash_time); ret = g_test_run();