diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/meson.build | 10 | ||||
-rw-r--r-- | tests/qapi-schema/meson.build | 2 | ||||
-rwxr-xr-x | tests/qemu-iotests/check | 2 | ||||
-rw-r--r-- | tests/qtest/fuzz/fuzz.c | 5 | ||||
-rw-r--r-- | tests/qtest/qmp-cmd-test.c | 10 | ||||
-rw-r--r-- | tests/socket-helpers.c | 3 | ||||
-rw-r--r-- | tests/test-io-channel-file.c | 12 | ||||
-rw-r--r-- | tests/test-io-channel-socket.c | 2 | ||||
-rw-r--r-- | tests/test-logging.c | 5 | ||||
-rw-r--r-- | tests/test-qdev-global-props.c | 9 | ||||
-rw-r--r-- | tests/test-replication.c | 22 | ||||
-rw-r--r-- | tests/test-util-sockets.c | 6 | ||||
-rw-r--r-- | tests/test-vmstate.c | 3 |
13 files changed, 65 insertions, 26 deletions
diff --git a/tests/meson.build b/tests/meson.build index dae8a77..8c3e930 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -145,7 +145,8 @@ if have_block 'test-crypto-block': [io], } if 'CONFIG_GNUTLS' in config_host and \ - 'CONFIG_TASN1' in config_host + 'CONFIG_TASN1' in config_host and \ + 'CONFIG_POSIX' in config_host tests += { 'test-crypto-tlscredsx509': ['crypto-tls-x509-helpers.c', 'pkix_asn1_tab.c', tasn1, crypto], @@ -195,8 +196,13 @@ if have_system # are not runnable under TSan due to a known issue. # https://github.com/google/sanitizers/issues/1116 if 'CONFIG_TSAN' not in config_host + if 'CONFIG_POSIX' in config_host + tests += { + 'test-char': ['socket-helpers.c', qom, io, chardev] + } + endif + tests += { - 'test-char': ['socket-helpers.c', qom, io, chardev], 'test-qdev-global-props': [qom, hwcore, testqapi] } endif diff --git a/tests/qapi-schema/meson.build b/tests/qapi-schema/meson.build index c87d141..f144929 100644 --- a/tests/qapi-schema/meson.build +++ b/tests/qapi-schema/meson.build @@ -220,6 +220,6 @@ qapi_doc = custom_target('QAPI doc', # "full_path()" needed here to work around # https://github.com/mesonbuild/meson/issues/7585 -test('QAPI doc', diff, args: ['-u', files('doc-good.texi'), qapi_doc[0].full_path()], +test('QAPI doc', diff, args: ['-b', '-u', files('doc-good.texi'), qapi_doc[0].full_path()], depends: qapi_doc, suite: ['qapi-schema', 'qapi-doc']) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index e14a1f3..678b6e4 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -44,7 +44,7 @@ then _init_error "failed to obtain source tree name from check symlink" fi source_iotests=$(cd "$source_iotests"; pwd) || _init_error "failed to enter source tree" - build_iotests=$(readlink -f $(dirname "$0")) + build_iotests=$(cd "$(dirname "$0")"; pwd) else # called from the source tree source_iotests=$PWD diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 1ceea84..7f266ff 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -202,9 +202,8 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) /* Run QEMU's softmmu main with the fuzz-target dependent arguments */ GString *cmd_line = fuzz_target->get_init_cmdline(fuzz_target); - g_string_append_printf(cmd_line, - " -qtest /dev/null -qtest-log %s", - getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null"); + g_string_append_printf(cmd_line, " %s -qtest /dev/null ", + getenv("QTEST_LOG") ? "" : "-qtest-log none"); /* Split the runcmd into an argv and argc */ wordexp_t result; diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 3109a9f..8a4c570 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -82,9 +82,9 @@ static void test_query(const void *data) qtest_quit(qts); } -static bool query_is_blacklisted(const char *cmd) +static bool query_is_ignored(const char *cmd) { - const char *blacklist[] = { + const char *ignored[] = { /* Not actually queries: */ "add-fd", /* Success depends on target arch: */ @@ -101,8 +101,8 @@ static bool query_is_blacklisted(const char *cmd) }; int i; - for (i = 0; blacklist[i]; i++) { - if (!strcmp(cmd, blacklist[i])) { + for (i = 0; ignored[i]; i++) { + if (!strcmp(cmd, ignored[i])) { return true; } } @@ -179,7 +179,7 @@ static void add_query_tests(QmpSchema *schema) continue; } - if (query_is_blacklisted(si->name)) { + if (query_is_ignored(si->name)) { continue; } diff --git a/tests/socket-helpers.c b/tests/socket-helpers.c index 19a51e8..f704fd1 100644 --- a/tests/socket-helpers.c +++ b/tests/socket-helpers.c @@ -59,8 +59,7 @@ static int socket_can_bind_connect(const char *hostname, int family) /* lookup */ rc = getaddrinfo(hostname, NULL, &ai, &res); if (rc != 0) { - if (rc == EAI_ADDRFAMILY || - rc == EAI_FAMILY) { + if (rc == EAI_ADDRFAMILY || rc == EAI_FAMILY || rc == EAI_NONAME) { errno = EADDRNOTAVAIL; } else { errno = EINVAL; diff --git a/tests/test-io-channel-file.c b/tests/test-io-channel-file.c index bac2b07..0aa0477 100644 --- a/tests/test-io-channel-file.c +++ b/tests/test-io-channel-file.c @@ -28,6 +28,16 @@ #define TEST_FILE "tests/test-io-channel-file.txt" #define TEST_MASK 0600 +/* + * On Windows the stat() function in the C library checks only + * the FAT-style READONLY attribute and does not look at the ACL at all. + */ +#ifdef _WIN32 +#define TEST_MASK_EXPECT 0700 +#else +#define TEST_MASK_EXPECT 0777 +#endif + static void test_io_channel_file_helper(int flags) { QIOChannel *src, *dst; @@ -56,7 +66,7 @@ static void test_io_channel_file_helper(int flags) umask(mask); ret = stat(TEST_FILE, &st); g_assert_cmpint(ret, >, -1); - g_assert_cmpuint(TEST_MASK & ~mask, ==, st.st_mode & 0777); + g_assert_cmpuint(TEST_MASK & ~mask, ==, st.st_mode & TEST_MASK_EXPECT); unlink(TEST_FILE); object_unref(OBJECT(src)); diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c index d43083a..743577d 100644 --- a/tests/test-io-channel-socket.c +++ b/tests/test-io-channel-socket.c @@ -25,6 +25,7 @@ #include "socket-helpers.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qemu/main-loop.h" static void test_io_channel_set_socket_bufs(QIOChannel *src, @@ -556,6 +557,7 @@ int main(int argc, char **argv) bool has_ipv4, has_ipv6; module_call_init(MODULE_INIT_QOM); + qemu_init_main_loop(&error_abort); socket_init(); g_test_init(&argc, &argv, NULL); diff --git a/tests/test-logging.c b/tests/test-logging.c index 8a1161d..8b1522c 100644 --- a/tests/test-logging.c +++ b/tests/test-logging.c @@ -196,7 +196,7 @@ static void rmdir_full(gchar const *root) int main(int argc, char **argv) { - gchar *tmp_path = g_dir_make_tmp("qemu-test-logging.XXXXXX", NULL); + g_autofree gchar *tmp_path = g_dir_make_tmp("qemu-test-logging.XXXXXX", NULL); int rc; g_test_init(&argc, &argv, NULL); @@ -210,8 +210,9 @@ int main(int argc, char **argv) tmp_path, test_logfile_lock); rc = g_test_run(); + qemu_log_close(); + drain_call_rcu(); rmdir_full(tmp_path); - g_free(tmp_path); return rc; } diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c index 8a3c14d..c8862ca 100644 --- a/tests/test-qdev-global-props.c +++ b/tests/test-qdev-global-props.c @@ -251,10 +251,13 @@ static void test_dynamic_globalprop(void) g_test_trap_assert_passed(); g_test_trap_assert_stderr_unmatched("*prop1*"); g_test_trap_assert_stderr_unmatched("*prop2*"); - g_test_trap_assert_stderr("*warning: global dynamic-prop-type-bad.prop3 has invalid class name\n*"); + g_test_trap_assert_stderr( + "*warning: global dynamic-prop-type-bad.prop3 has invalid class name*"); g_test_trap_assert_stderr_unmatched("*prop4*"); - g_test_trap_assert_stderr("*warning: global nohotplug-type.prop5=105 not used\n*"); - g_test_trap_assert_stderr("*warning: global nondevice-type.prop6 has invalid class name\n*"); + g_test_trap_assert_stderr( + "*warning: global nohotplug-type.prop5=105 not used*"); + g_test_trap_assert_stderr( + "*warning: global nondevice-type.prop6 has invalid class name*"); g_test_trap_assert_stdout(""); } diff --git a/tests/test-replication.c b/tests/test-replication.c index 9ab3666..b067240 100644 --- a/tests/test-replication.c +++ b/tests/test-replication.c @@ -23,14 +23,14 @@ /* primary */ #define P_ID "primary-id" -static char p_local_disk[] = "/tmp/p_local_disk.XXXXXX"; +static char *p_local_disk; /* secondary */ #define S_ID "secondary-id" #define S_LOCAL_DISK_ID "secondary-local-disk-id" -static char s_local_disk[] = "/tmp/s_local_disk.XXXXXX"; -static char s_active_disk[] = "/tmp/s_active_disk.XXXXXX"; -static char s_hidden_disk[] = "/tmp/s_hidden_disk.XXXXXX"; +static char *s_local_disk; +static char *s_active_disk; +static char *s_hidden_disk; /* FIXME: steal from blockdev.c */ QemuOptsList qemu_drive_opts = { @@ -392,6 +392,7 @@ static void test_secondary_write(void) teardown_secondary(); } +#ifndef _WIN32 static void test_secondary_start(void) { BlockBackend *top_blk, *local_blk; @@ -546,6 +547,7 @@ static void test_secondary_get_error_all(void) teardown_secondary(); } +#endif static void sigabrt_handler(int signo) { @@ -571,6 +573,11 @@ static void setup_sigabrt_handler(void) int main(int argc, char **argv) { int ret; + const char *tmpdir = g_get_tmp_dir(); + p_local_disk = g_strdup_printf("%s/p_local_disk.XXXXXX", tmpdir); + s_local_disk = g_strdup_printf("%s/s_local_disk.XXXXXX", tmpdir); + s_active_disk = g_strdup_printf("%s/s_active_disk.XXXXXX", tmpdir); + s_hidden_disk = g_strdup_printf("%s/s_hidden_disk.XXXXXX", tmpdir); qemu_init_main_loop(&error_fatal); bdrv_init(); @@ -592,6 +599,7 @@ int main(int argc, char **argv) /* Secondary */ g_test_add_func("/replication/secondary/read", test_secondary_read); g_test_add_func("/replication/secondary/write", test_secondary_write); +#ifndef _WIN32 g_test_add_func("/replication/secondary/start", test_secondary_start); g_test_add_func("/replication/secondary/stop", test_secondary_stop); g_test_add_func("/replication/secondary/continuous_replication", @@ -600,10 +608,16 @@ int main(int argc, char **argv) test_secondary_do_checkpoint); g_test_add_func("/replication/secondary/get_error_all", test_secondary_get_error_all); +#endif ret = g_test_run(); cleanup_imgs(); + g_free(p_local_disk); + g_free(s_local_disk); + g_free(s_active_disk); + g_free(s_hidden_disk); + return ret; } diff --git a/tests/test-util-sockets.c b/tests/test-util-sockets.c index af9f5c0..1bbb16d 100644 --- a/tests/test-util-sockets.c +++ b/tests/test-util-sockets.c @@ -75,7 +75,7 @@ int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { abort(); } void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp) {} void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp) {} - +#ifndef _WIN32 static void test_socket_fd_pass_name_good(void) { SocketAddress addr; @@ -227,6 +227,7 @@ static void test_socket_fd_pass_num_nocli(void) g_free(addr.u.fd.str); } +#endif #ifdef __linux__ static gchar *abstract_sock_name; @@ -321,6 +322,7 @@ int main(int argc, char **argv) { bool has_ipv4, has_ipv6; + qemu_init_main_loop(&error_abort); socket_init(); g_test_init(&argc, &argv, NULL); @@ -340,6 +342,7 @@ int main(int argc, char **argv) test_fd_is_socket_bad); g_test_add_func("/util/socket/is-socket/good", test_fd_is_socket_good); +#ifndef _WIN32 g_test_add_func("/socket/fd-pass/name/good", test_socket_fd_pass_name_good); g_test_add_func("/socket/fd-pass/name/bad", @@ -352,6 +355,7 @@ int main(int argc, char **argv) test_socket_fd_pass_num_bad); g_test_add_func("/socket/fd-pass/num/nocli", test_socket_fd_pass_num_nocli); +#endif } #ifdef __linux__ diff --git a/tests/test-vmstate.c b/tests/test-vmstate.c index 1c76301..a001879 100644 --- a/tests/test-vmstate.c +++ b/tests/test-vmstate.c @@ -34,7 +34,6 @@ #include "qemu/module.h" #include "io/channel-file.h" -static char temp_file[] = "/tmp/vmst.test.XXXXXX"; static int temp_fd; @@ -1484,6 +1483,8 @@ static void test_tmp_struct(void) int main(int argc, char **argv) { + g_autofree char *temp_file = g_strdup_printf("%s/vmst.test.XXXXXX", + g_get_tmp_dir()); temp_fd = mkstemp(temp_file); module_call_init(MODULE_INIT_QOM); |