aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-03-31 10:55:33 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-03-31 10:55:33 +0100
commit9e0ad3472dae5236052d455948396d8579bfc904 (patch)
treeb2adb20b45f89974e18a58734f602b4afd864c22
parentadbeb458eece2263039e5a1f6501b87ae3713319 (diff)
parent6ca90ffeec8e3b4e306be32efd930d75a6d0b295 (diff)
Merge remote-tracking branch 'remotes/afaerber/tags/qtest-for-2.3' into staging
QTest cleanups * Change fw_cfg-test and i440fx-test GTester paths * Extend libqtest API as necessary # gpg: Signature made Mon Mar 30 18:29:39 2015 BST using RSA key ID 3E7E013F # gpg: Good signature from "Andreas Färber <afaerber@suse.de>" # gpg: aka "Andreas Färber <afaerber@suse.com>" * remotes/afaerber/tags/qtest-for-2.3: i440fx-test: Fix test paths to include architecture qtest: Add qtest_add() wrapper macro qtest: Add qtest_add_data_func() wrapper function fw_cfg-test: Fix test path to include architecture Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--tests/fw_cfg-test.c26
-rw-r--r--tests/i440fx-test.c12
-rw-r--r--tests/libqtest.c7
-rw-r--r--tests/libqtest.h32
4 files changed, 58 insertions, 19 deletions
diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c
index 5c8f8d6c24..9be78e9564 100644
--- a/tests/fw_cfg-test.c
+++ b/tests/fw_cfg-test.c
@@ -109,21 +109,21 @@ int main(int argc, char **argv)
fw_cfg = pc_fw_cfg_init();
- g_test_add_func("/fw_cfg/signature", test_fw_cfg_signature);
- g_test_add_func("/fw_cfg/id", test_fw_cfg_id);
- g_test_add_func("/fw_cfg/uuid", test_fw_cfg_uuid);
- g_test_add_func("/fw_cfg/ram_size", test_fw_cfg_ram_size);
- g_test_add_func("/fw_cfg/nographic", test_fw_cfg_nographic);
- g_test_add_func("/fw_cfg/nb_cpus", test_fw_cfg_nb_cpus);
+ 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);
+ qtest_add_func("fw_cfg/ram_size", test_fw_cfg_ram_size);
+ qtest_add_func("fw_cfg/nographic", test_fw_cfg_nographic);
+ qtest_add_func("fw_cfg/nb_cpus", test_fw_cfg_nb_cpus);
#if 0
- g_test_add_func("/fw_cfg/machine_id", test_fw_cfg_machine_id);
- g_test_add_func("/fw_cfg/kernel", test_fw_cfg_kernel);
- g_test_add_func("/fw_cfg/initrd", test_fw_cfg_initrd);
- g_test_add_func("/fw_cfg/boot_device", test_fw_cfg_boot_device);
+ qtest_add_func("fw_cfg/machine_id", test_fw_cfg_machine_id);
+ qtest_add_func("fw_cfg/kernel", test_fw_cfg_kernel);
+ qtest_add_func("fw_cfg/initrd", test_fw_cfg_initrd);
+ qtest_add_func("fw_cfg/boot_device", test_fw_cfg_boot_device);
#endif
- g_test_add_func("/fw_cfg/max_cpus", test_fw_cfg_max_cpus);
- g_test_add_func("/fw_cfg/numa", test_fw_cfg_numa);
- g_test_add_func("/fw_cfg/boot_menu", test_fw_cfg_boot_menu);
+ 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);
cmdline = g_strdup_printf("-uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8 ");
s = qtest_start(cmdline);
diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
index a3f72790ea..d0bc8de25a 100644
--- a/tests/i440fx-test.c
+++ b/tests/i440fx-test.c
@@ -383,8 +383,8 @@ static void add_firmware_test(const char *testpath,
void (*setup_fixture)(FirmwareTestFixture *f,
gconstpointer test_data))
{
- g_test_add(testpath, FirmwareTestFixture, NULL, setup_fixture,
- test_i440fx_firmware, NULL);
+ qtest_add(testpath, FirmwareTestFixture, NULL, setup_fixture,
+ test_i440fx_firmware, NULL);
}
static void request_bios(FirmwareTestFixture *fixture,
@@ -408,10 +408,10 @@ int main(int argc, char **argv)
data.num_cpus = 1;
- g_test_add_data_func("/i440fx/defaults", &data, test_i440fx_defaults);
- g_test_add_data_func("/i440fx/pam", &data, test_i440fx_pam);
- add_firmware_test("/i440fx/firmware/bios", request_bios);
- add_firmware_test("/i440fx/firmware/pflash", request_pflash);
+ qtest_add_data_func("i440fx/defaults", &data, test_i440fx_defaults);
+ qtest_add_data_func("i440fx/pam", &data, test_i440fx_pam);
+ add_firmware_test("i440fx/firmware/bios", request_bios);
+ add_firmware_test("i440fx/firmware/pflash", request_pflash);
ret = g_test_run();
return ret;
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 9a92aa70e4..12d65bd1e6 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -652,6 +652,13 @@ void qtest_add_func(const char *str, void (*fn))
g_free(path);
}
+void qtest_add_data_func(const char *str, const void *data, void (*fn))
+{
+ gchar *path = g_strdup_printf("/%s/%s", qtest_get_arch(), str);
+ g_test_add_data_func(path, data, fn);
+ g_free(path);
+}
+
void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size)
{
const uint8_t *ptr = data;
diff --git a/tests/libqtest.h b/tests/libqtest.h
index e7413d52dc..03469b8781 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -345,6 +345,38 @@ const char *qtest_get_arch(void);
void qtest_add_func(const char *str, void (*fn));
/**
+ * qtest_add_data_func:
+ * @str: Test case path.
+ * @data: Test case data
+ * @fn: Test case function
+ *
+ * Add a GTester testcase with the given name, data and function.
+ * The path is prefixed with the architecture under test, as
+ * returned by qtest_get_arch().
+ */
+void qtest_add_data_func(const char *str, const void *data, void (*fn));
+
+/**
+ * qtest_add:
+ * @testpath: Test case path
+ * @Fixture: Fixture type
+ * @tdata: Test case data
+ * @fsetup: Test case setup function
+ * @ftest: Test case function
+ * @fteardown: Test case teardown function
+ *
+ * Add a GTester testcase with the given name, data and functions.
+ * The path is prefixed with the architecture under test, as
+ * returned by qtest_get_arch().
+ */
+#define qtest_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \
+ do { \
+ char *path = g_strdup_printf("/%s/%s", qtest_get_arch(), testpath); \
+ g_test_add(path, Fixture, tdata, fsetup, ftest, fteardown); \
+ g_free(path); \
+ } while (0)
+
+/**
* qtest_start:
* @args: other arguments to pass to QEMU
*