QTest cleanups

* Change fw_cfg-test and i440fx-test GTester paths
 * Extend libqtest API as necessary
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABAgAGBQJVGYgDAAoJEPou0S0+fgE/Rv0P/i4ONP1W4lVhXJFCvPRUNwM8
 aOTLbCbixY6bJeXfVykfArjOlBw44aj0zEaRWdu3KYq4GEn+zt0/ZpMA/RZGD1z3
 yssoa1bjzv0SqnrAfDcF/AMLkzpquJyo1RV0XpXLuYJ/9gSaSDYqVwj+84HWJOJr
 kfJXBtCZT9iUh3hoW0wEY9wMCaHe53DaI3OBh3QewE4ys5goJ50XhDlkjWF2b+vg
 lxNJUMHBY09c2B57FKytNshO8oRoNQTSOaf7iVcMiaNuGztujyV5jpN50k6vtIS/
 bTzWdrqAgWUzKLQORaz+L8gMo/nBb+4WvyPYA7hNWUYEGwBrTtuPxWD8pGjw4fk9
 AEsU7Qpu/uJcwxaaRYioTWGRXEzTVsENjxbEWmUDza0KIWE8R5Qbg7k60VwfW3Vo
 5NQqoUsuTOAtv+dDst9CdMj5Ib15wmmu28kxAmz8iwYa0rz8bHRs8h5EWvX5Vwxg
 p1ed0Gxe7VOaWYbSe3p/WqzN7IaPpQVex2V4WvjcqkJGxl7zk9JNSqoZKPEKi4Ut
 V8KYTbOp2RfS1dNM7wW8X9k6VKY4Y8FfuSPsQKz9z61fk257Lk9r7Uppj7KXDsY0
 cbaOdE0RR3RZ3Irmg9lfONDCwfzOQUDFOQWmRE7PyOO029ZN48ht7HS4dFn/uJyC
 zEWs8Huet7chj0ysaKOX
 =I+Qw
 -----END PGP SIGNATURE-----

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>
This commit is contained in:
Peter Maydell 2015-03-31 10:55:33 +01:00
commit 9e0ad3472d
4 changed files with 58 additions and 19 deletions

View File

@ -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);

View File

@ -383,7 +383,7 @@ static void add_firmware_test(const char *testpath,
void (*setup_fixture)(FirmwareTestFixture *f,
gconstpointer test_data))
{
g_test_add(testpath, FirmwareTestFixture, NULL, setup_fixture,
qtest_add(testpath, FirmwareTestFixture, NULL, setup_fixture,
test_i440fx_firmware, NULL);
}
@ -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;

View File

@ -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;

View File

@ -344,6 +344,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