aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2022-10-13 13:55:38 -0400
committerStefan Hajnoczi <stefanha@redhat.com>2022-10-13 13:55:38 -0400
commit644eb9ceb4582ee2ccb84b6b7f7cb6d3b2d0c692 (patch)
tree5f135302cf16318ff59729447b1a8b446d6911e5 /tests/unit
parent7a37814aeb0fdf6bfce321f83c111f1ff092ca2f (diff)
parent76f5148c21b4543e62a6ad605ac4b44133421401 (diff)
downloadqemu-644eb9ceb4582ee2ccb84b6b7f7cb6d3b2d0c692.zip
qemu-644eb9ceb4582ee2ccb84b6b7f7cb6d3b2d0c692.tar.gz
qemu-644eb9ceb4582ee2ccb84b6b7f7cb6d3b2d0c692.tar.bz2
Merge tag 'win32-pull-request' of https://gitlab.com/marcandre.lureau/qemu into staging
win32-related misc patches # -----BEGIN PGP SIGNATURE----- # # iQJPBAABCAA6FiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmNG488cHG1hcmNhbmRy # ZS5sdXJlYXVAcmVkaGF0LmNvbQAKCRDa6OEJdZac5eQTD/j/rEcONwL4gZn/Rcp8 # aJlr39GEHo0JxBAF3eoxCLJlebPcdaUQ4pu/FTegS1A4abPaajDH7rdtcA58ciAG # rCQjUOrobHzxmI9XaTIPT4PQh3DA4HB58rTpAvb/6P/UDRc0MpkcvaOkGlJVhi+7 # WB63+gnQOBEjcieNcQtmRwYRkx7K5/9G4qEESl0i2E+SE4DM+/vcVa7lfqEZ+6HS # bsDy2BslxtPFmHj1UElwXjTbCs4Y7pfTFd+9z8ySsGL1Komf45MZs0iS4FmZLqL/ # 7Cuj+xRWibnPN9jnAc+Sdua3FAFZbqmfPQaH6DN6SICZ6Txf2hxFkAgTahagcxYX # 9EiKGHZzI4L3l/YAxFg9RfK+AsF44ZLPId58AVvUnG1jWwxl3nRaTmvtvHaEwJuZ # PgnbAdsNzQAJjLnk8ndpTq4mQFM+9/mrQo+iaOCwmB5s07woyEq+L+KJHMUgyk2D # lECn3vlqVGGb6GA6MS5gSXh0TDRxPxLyr9ofIG5i5YaTo4nH56S80tHrzZMUYNKD # xe2yUrEZ7UjeV4/6M19xdw3haPOdrG3BoBshb61vI1bF/4iQxYNo8AxptCRhzNNM # 5Jrn/gyt47SEgMYpGIvHa/qo1lQiLsQAVKAK3O2QWd5T58V6J1a804zhTuT7T45O # kZS2c8XEdAiBtUAkYNgFxwGM # =Lpqm # -----END PGP SIGNATURE----- # gpg: Signature made Wed 12 Oct 2022 11:57:03 EDT # gpg: using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5 # gpg: issuer "marcandre.lureau@redhat.com" # gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full] # gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full] # Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5 * tag 'win32-pull-request' of https://gitlab.com/marcandre.lureau/qemu: tests/unit: make test-io-channel-command work on win32 io/command: implement support for win32 io/command: use glib GSpawn, instead of open-coding fork/exec tests/channel-helper: set blocking in main thread util: make do_send_recv work with partial send/recv osdep: make readv_writev() work with partial read/write win32: set threads name Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/io-channel-helpers.c9
-rw-r--r--tests/unit/test-io-channel-command.c37
2 files changed, 22 insertions, 24 deletions
diff --git a/tests/unit/io-channel-helpers.c b/tests/unit/io-channel-helpers.c
index ff156ed..c0799c2 100644
--- a/tests/unit/io-channel-helpers.c
+++ b/tests/unit/io-channel-helpers.c
@@ -25,7 +25,6 @@
struct QIOChannelTest {
QIOChannel *src;
QIOChannel *dst;
- bool blocking;
size_t len;
size_t niov;
char *input;
@@ -42,8 +41,6 @@ static gpointer test_io_thread_writer(gpointer opaque)
{
QIOChannelTest *data = opaque;
- qio_channel_set_blocking(data->src, data->blocking, NULL);
-
qio_channel_writev_all(data->src,
data->inputv,
data->niov,
@@ -58,8 +55,6 @@ static gpointer test_io_thread_reader(gpointer opaque)
{
QIOChannelTest *data = opaque;
- qio_channel_set_blocking(data->dst, data->blocking, NULL);
-
qio_channel_readv_all(data->dst,
data->outputv,
data->niov,
@@ -113,7 +108,9 @@ void qio_channel_test_run_threads(QIOChannelTest *test,
test->src = src;
test->dst = dst;
- test->blocking = blocking;
+
+ qio_channel_set_blocking(test->dst, blocking, NULL);
+ qio_channel_set_blocking(test->src, blocking, NULL);
reader = g_thread_new("reader",
test_io_thread_reader,
diff --git a/tests/unit/test-io-channel-command.c b/tests/unit/test-io-channel-command.c
index aa09c55..7eee939 100644
--- a/tests/unit/test-io-channel-command.c
+++ b/tests/unit/test-io-channel-command.c
@@ -24,29 +24,30 @@
#include "qapi/error.h"
#include "qemu/module.h"
-#ifndef WIN32
+#define TEST_FIFO "test-io-channel-command.fifo"
+
+#define SOCAT_SRC "PIPE:" TEST_FIFO ",wronly"
+#define SOCAT_DST "PIPE:" TEST_FIFO ",rdonly"
+
+static char *socat = NULL;
+
static void test_io_channel_command_fifo(bool async)
{
-#define TEST_FIFO "tests/test-io-channel-command.fifo"
QIOChannel *src, *dst;
QIOChannelTest *test;
- const char *srcfifo = "PIPE:" TEST_FIFO ",wronly";
- const char *dstfifo = "PIPE:" TEST_FIFO ",rdonly";
const char *srcargv[] = {
- "/bin/socat", "-", srcfifo, NULL,
+ socat, "-", SOCAT_SRC, NULL,
};
const char *dstargv[] = {
- "/bin/socat", dstfifo, "-", NULL,
+ socat, SOCAT_DST, "-", NULL,
};
- unlink(TEST_FIFO);
- if (access("/bin/socat", X_OK) < 0) {
- g_test_skip("socat is missing");
+ if (!socat) {
+ g_test_skip("socat is not found in PATH");
return;
}
- if (mkfifo(TEST_FIFO, 0600) < 0) {
- abort();
- }
+
+ unlink(TEST_FIFO);
src = QIO_CHANNEL(qio_channel_command_new_spawn(srcargv,
O_WRONLY,
&error_abort));
@@ -81,11 +82,12 @@ static void test_io_channel_command_echo(bool async)
QIOChannel *ioc;
QIOChannelTest *test;
const char *socatargv[] = {
- "/bin/socat", "-", "-", NULL,
+ socat, "-", "-", NULL,
};
- if (access("/bin/socat", X_OK) < 0) {
- return; /* Pretend success if socat is not present */
+ if (!socat) {
+ g_test_skip("socat is not found in PATH");
+ return;
}
ioc = QIO_CHANNEL(qio_channel_command_new_spawn(socatargv,
@@ -108,7 +110,6 @@ static void test_io_channel_command_echo_sync(void)
{
test_io_channel_command_echo(false);
}
-#endif
int main(int argc, char **argv)
{
@@ -116,7 +117,8 @@ int main(int argc, char **argv)
g_test_init(&argc, &argv, NULL);
-#ifndef WIN32
+ socat = g_find_program_in_path("socat");
+
g_test_add_func("/io/channel/command/fifo/sync",
test_io_channel_command_fifo_sync);
g_test_add_func("/io/channel/command/fifo/async",
@@ -125,7 +127,6 @@ int main(int argc, char **argv)
test_io_channel_command_echo_sync);
g_test_add_func("/io/channel/command/echo/async",
test_io_channel_command_echo_async);
-#endif
return g_test_run();
}