xics/kvm: synchonize state before 'info pic'
[qemu.git] / tests / test-char.c
blob7ac25ff73f4807e5c2ec55f3d7ddc9950e72d07e
1 #include "qemu/osdep.h"
2 #include <glib/gstdio.h>
4 #include "qemu-common.h"
5 #include "qemu/config-file.h"
6 #include "qemu/sockets.h"
7 #include "chardev/char-fe.h"
8 #include "sysemu/sysemu.h"
9 #include "qapi/error.h"
10 #include "qom/qom-qobject.h"
11 #include "qmp-commands.h"
13 static bool quit;
15 typedef struct FeHandler {
16 int read_count;
17 int last_event;
18 char read_buf[128];
19 } FeHandler;
21 static void main_loop(void)
23 quit = false;
24 do {
25 main_loop_wait(false);
26 } while (!quit);
29 static int fe_can_read(void *opaque)
31 FeHandler *h = opaque;
33 return sizeof(h->read_buf) - h->read_count;
36 static void fe_read(void *opaque, const uint8_t *buf, int size)
38 FeHandler *h = opaque;
40 g_assert_cmpint(size, <=, fe_can_read(opaque));
42 memcpy(h->read_buf + h->read_count, buf, size);
43 h->read_count += size;
44 quit = true;
47 static void fe_event(void *opaque, int event)
49 FeHandler *h = opaque;
51 h->last_event = event;
52 if (event != CHR_EVENT_BREAK) {
53 quit = true;
57 #ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
58 #ifdef _WIN32
59 static void char_console_test_subprocess(void)
61 QemuOpts *opts;
62 Chardev *chr;
64 opts = qemu_opts_create(qemu_find_opts("chardev"), "console-label",
65 1, &error_abort);
66 qemu_opt_set(opts, "backend", "console", &error_abort);
68 chr = qemu_chr_new_from_opts(opts, NULL);
69 g_assert_nonnull(chr);
71 qemu_chr_write_all(chr, (const uint8_t *)"CONSOLE", 7);
73 qemu_opts_del(opts);
74 object_unparent(OBJECT(chr));
77 static void char_console_test(void)
79 g_test_trap_subprocess("/char/console/subprocess", 0, 0);
80 g_test_trap_assert_passed();
81 g_test_trap_assert_stdout("CONSOLE");
83 #endif
84 static void char_stdio_test_subprocess(void)
86 Chardev *chr;
87 CharBackend be;
88 int ret;
90 chr = qemu_chr_new("label", "stdio");
91 g_assert_nonnull(chr);
93 qemu_chr_fe_init(&be, chr, &error_abort);
94 qemu_chr_fe_set_open(&be, true);
95 ret = qemu_chr_fe_write(&be, (void *)"buf", 4);
96 g_assert_cmpint(ret, ==, 4);
98 qemu_chr_fe_deinit(&be, true);
101 static void char_stdio_test(void)
103 g_test_trap_subprocess("/char/stdio/subprocess", 0, 0);
104 g_test_trap_assert_passed();
105 g_test_trap_assert_stdout("buf");
107 #endif
109 static void char_ringbuf_test(void)
111 QemuOpts *opts;
112 Chardev *chr;
113 CharBackend be;
114 char *data;
115 int ret;
117 opts = qemu_opts_create(qemu_find_opts("chardev"), "ringbuf-label",
118 1, &error_abort);
119 qemu_opt_set(opts, "backend", "ringbuf", &error_abort);
121 qemu_opt_set(opts, "size", "5", &error_abort);
122 chr = qemu_chr_new_from_opts(opts, NULL);
123 g_assert_null(chr);
124 qemu_opts_del(opts);
126 opts = qemu_opts_create(qemu_find_opts("chardev"), "ringbuf-label",
127 1, &error_abort);
128 qemu_opt_set(opts, "backend", "ringbuf", &error_abort);
129 qemu_opt_set(opts, "size", "2", &error_abort);
130 chr = qemu_chr_new_from_opts(opts, &error_abort);
131 g_assert_nonnull(chr);
132 qemu_opts_del(opts);
134 qemu_chr_fe_init(&be, chr, &error_abort);
135 ret = qemu_chr_fe_write(&be, (void *)"buff", 4);
136 g_assert_cmpint(ret, ==, 4);
138 data = qmp_ringbuf_read("ringbuf-label", 4, false, 0, &error_abort);
139 g_assert_cmpstr(data, ==, "ff");
140 g_free(data);
142 data = qmp_ringbuf_read("ringbuf-label", 4, false, 0, &error_abort);
143 g_assert_cmpstr(data, ==, "");
144 g_free(data);
146 qemu_chr_fe_deinit(&be, true);
148 /* check alias */
149 opts = qemu_opts_create(qemu_find_opts("chardev"), "memory-label",
150 1, &error_abort);
151 qemu_opt_set(opts, "backend", "memory", &error_abort);
152 qemu_opt_set(opts, "size", "2", &error_abort);
153 chr = qemu_chr_new_from_opts(opts, NULL);
154 g_assert_nonnull(chr);
155 object_unparent(OBJECT(chr));
156 qemu_opts_del(opts);
159 static void char_mux_test(void)
161 QemuOpts *opts;
162 Chardev *chr, *base;
163 char *data;
164 FeHandler h1 = { 0, }, h2 = { 0, };
165 CharBackend chr_be1, chr_be2;
167 opts = qemu_opts_create(qemu_find_opts("chardev"), "mux-label",
168 1, &error_abort);
169 qemu_opt_set(opts, "backend", "ringbuf", &error_abort);
170 qemu_opt_set(opts, "size", "128", &error_abort);
171 qemu_opt_set(opts, "mux", "on", &error_abort);
172 chr = qemu_chr_new_from_opts(opts, &error_abort);
173 g_assert_nonnull(chr);
174 qemu_opts_del(opts);
176 qemu_chr_fe_init(&chr_be1, chr, &error_abort);
177 qemu_chr_fe_set_handlers(&chr_be1,
178 fe_can_read,
179 fe_read,
180 fe_event,
181 NULL,
182 &h1,
183 NULL, true);
185 qemu_chr_fe_init(&chr_be2, chr, &error_abort);
186 qemu_chr_fe_set_handlers(&chr_be2,
187 fe_can_read,
188 fe_read,
189 fe_event,
190 NULL,
191 &h2,
192 NULL, true);
193 qemu_chr_fe_take_focus(&chr_be2);
195 base = qemu_chr_find("mux-label-base");
196 g_assert_cmpint(qemu_chr_be_can_write(base), !=, 0);
198 qemu_chr_be_write(base, (void *)"hello", 6);
199 g_assert_cmpint(h1.read_count, ==, 0);
200 g_assert_cmpint(h2.read_count, ==, 6);
201 g_assert_cmpstr(h2.read_buf, ==, "hello");
202 h2.read_count = 0;
204 /* switch focus */
205 qemu_chr_be_write(base, (void *)"\1c", 2);
207 qemu_chr_be_write(base, (void *)"hello", 6);
208 g_assert_cmpint(h2.read_count, ==, 0);
209 g_assert_cmpint(h1.read_count, ==, 6);
210 g_assert_cmpstr(h1.read_buf, ==, "hello");
211 h1.read_count = 0;
213 /* remove first handler */
214 qemu_chr_fe_set_handlers(&chr_be1, NULL, NULL, NULL, NULL,
215 NULL, NULL, true);
216 qemu_chr_be_write(base, (void *)"hello", 6);
217 g_assert_cmpint(h1.read_count, ==, 0);
218 g_assert_cmpint(h2.read_count, ==, 0);
220 qemu_chr_be_write(base, (void *)"\1c", 2);
221 qemu_chr_be_write(base, (void *)"hello", 6);
222 g_assert_cmpint(h1.read_count, ==, 0);
223 g_assert_cmpint(h2.read_count, ==, 6);
224 g_assert_cmpstr(h2.read_buf, ==, "hello");
225 h2.read_count = 0;
227 /* print help */
228 qemu_chr_be_write(base, (void *)"\1?", 2);
229 data = qmp_ringbuf_read("mux-label-base", 128, false, 0, &error_abort);
230 g_assert_cmpint(strlen(data), !=, 0);
231 g_free(data);
233 qemu_chr_fe_deinit(&chr_be1, false);
234 qemu_chr_fe_deinit(&chr_be2, true);
237 typedef struct SocketIdleData {
238 GMainLoop *loop;
239 Chardev *chr;
240 bool conn_expected;
241 CharBackend *be;
242 CharBackend *client_be;
243 } SocketIdleData;
245 static gboolean char_socket_test_idle(gpointer user_data)
247 SocketIdleData *data = user_data;
249 if (object_property_get_bool(OBJECT(data->chr), "connected", NULL)
250 == data->conn_expected) {
251 quit = true;
252 return FALSE;
255 return TRUE;
258 static void socket_read(void *opaque, const uint8_t *buf, int size)
260 SocketIdleData *data = opaque;
262 g_assert_cmpint(size, ==, 1);
263 g_assert_cmpint(*buf, ==, 'Z');
265 size = qemu_chr_fe_write(data->be, (const uint8_t *)"hello", 5);
266 g_assert_cmpint(size, ==, 5);
269 static int socket_can_read(void *opaque)
271 return 10;
274 static void socket_read_hello(void *opaque, const uint8_t *buf, int size)
276 g_assert_cmpint(size, ==, 5);
277 g_assert(strncmp((char *)buf, "hello", 5) == 0);
279 quit = true;
282 static int socket_can_read_hello(void *opaque)
284 return 10;
287 static void char_socket_test(void)
289 Chardev *chr = qemu_chr_new("server", "tcp:127.0.0.1:0,server,nowait");
290 Chardev *chr_client;
291 QObject *addr;
292 QDict *qdict;
293 const char *port;
294 SocketIdleData d = { .chr = chr };
295 CharBackend be;
296 CharBackend client_be;
297 char *tmp;
299 d.be = &be;
300 d.client_be = &be;
302 g_assert_nonnull(chr);
303 g_assert(!object_property_get_bool(OBJECT(chr), "connected", &error_abort));
305 addr = object_property_get_qobject(OBJECT(chr), "addr", &error_abort);
306 qdict = qobject_to_qdict(addr);
307 port = qdict_get_str(qdict, "port");
308 tmp = g_strdup_printf("tcp:127.0.0.1:%s", port);
309 QDECREF(qdict);
311 qemu_chr_fe_init(&be, chr, &error_abort);
312 qemu_chr_fe_set_handlers(&be, socket_can_read, socket_read,
313 NULL, NULL, &d, NULL, true);
315 chr_client = qemu_chr_new("client", tmp);
316 qemu_chr_fe_init(&client_be, chr_client, &error_abort);
317 qemu_chr_fe_set_handlers(&client_be, socket_can_read_hello,
318 socket_read_hello,
319 NULL, NULL, &d, NULL, true);
320 g_free(tmp);
322 d.conn_expected = true;
323 guint id = g_idle_add(char_socket_test_idle, &d);
324 g_source_set_name_by_id(id, "test-idle");
325 g_assert_cmpint(id, >, 0);
326 main_loop();
328 g_assert(object_property_get_bool(OBJECT(chr), "connected", &error_abort));
329 g_assert(object_property_get_bool(OBJECT(chr_client),
330 "connected", &error_abort));
332 qemu_chr_write_all(chr_client, (const uint8_t *)"Z", 1);
333 main_loop();
335 object_unparent(OBJECT(chr_client));
337 d.conn_expected = false;
338 g_idle_add(char_socket_test_idle, &d);
339 main_loop();
341 object_unparent(OBJECT(chr));
344 #ifndef _WIN32
345 static void char_pipe_test(void)
347 gchar *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
348 gchar *tmp, *in, *out, *pipe = g_build_filename(tmp_path, "pipe", NULL);
349 Chardev *chr;
350 CharBackend be;
351 int ret, fd;
352 char buf[10];
353 FeHandler fe = { 0, };
355 in = g_strdup_printf("%s.in", pipe);
356 if (mkfifo(in, 0600) < 0) {
357 abort();
359 out = g_strdup_printf("%s.out", pipe);
360 if (mkfifo(out, 0600) < 0) {
361 abort();
364 tmp = g_strdup_printf("pipe:%s", pipe);
365 chr = qemu_chr_new("pipe", tmp);
366 g_assert_nonnull(chr);
367 g_free(tmp);
369 qemu_chr_fe_init(&be, chr, &error_abort);
371 ret = qemu_chr_fe_write(&be, (void *)"pipe-out", 9);
372 g_assert_cmpint(ret, ==, 9);
374 fd = open(out, O_RDWR);
375 ret = read(fd, buf, sizeof(buf));
376 g_assert_cmpint(ret, ==, 9);
377 g_assert_cmpstr(buf, ==, "pipe-out");
378 close(fd);
380 fd = open(in, O_WRONLY);
381 ret = write(fd, "pipe-in", 8);
382 g_assert_cmpint(ret, ==, 8);
383 close(fd);
385 qemu_chr_fe_set_handlers(&be,
386 fe_can_read,
387 fe_read,
388 fe_event,
389 NULL,
390 &fe,
391 NULL, true);
393 main_loop();
395 g_assert_cmpint(fe.read_count, ==, 8);
396 g_assert_cmpstr(fe.read_buf, ==, "pipe-in");
398 qemu_chr_fe_deinit(&be, true);
400 g_assert(g_unlink(in) == 0);
401 g_assert(g_unlink(out) == 0);
402 g_assert(g_rmdir(tmp_path) == 0);
403 g_free(in);
404 g_free(out);
405 g_free(tmp_path);
406 g_free(pipe);
408 #endif
410 static int make_udp_socket(int *port)
412 struct sockaddr_in addr = { 0, };
413 socklen_t alen = sizeof(addr);
414 int ret, sock = qemu_socket(PF_INET, SOCK_DGRAM, 0);
416 g_assert_cmpint(sock, >, 0);
417 addr.sin_family = AF_INET ;
418 addr.sin_addr.s_addr = htonl(INADDR_ANY);
419 addr.sin_port = 0;
420 ret = bind(sock, (struct sockaddr *)&addr, sizeof(addr));
421 g_assert_cmpint(ret, ==, 0);
422 ret = getsockname(sock, (struct sockaddr *)&addr, &alen);
423 g_assert_cmpint(ret, ==, 0);
425 *port = ntohs(addr.sin_port);
426 return sock;
429 static void char_udp_test_internal(Chardev *reuse_chr, int sock)
431 struct sockaddr_in other;
432 SocketIdleData d = { 0, };
433 Chardev *chr;
434 CharBackend *be;
435 socklen_t alen = sizeof(other);
436 int ret;
437 char buf[10];
438 char *tmp = NULL;
440 if (reuse_chr) {
441 chr = reuse_chr;
442 be = chr->be;
443 } else {
444 int port;
445 sock = make_udp_socket(&port);
446 tmp = g_strdup_printf("udp:127.0.0.1:%d", port);
447 chr = qemu_chr_new("client", tmp);
448 g_assert_nonnull(chr);
450 be = g_alloca(sizeof(CharBackend));
451 qemu_chr_fe_init(be, chr, &error_abort);
454 d.chr = chr;
455 qemu_chr_fe_set_handlers(be, socket_can_read_hello, socket_read_hello,
456 NULL, NULL, &d, NULL, true);
457 ret = qemu_chr_write_all(chr, (uint8_t *)"hello", 5);
458 g_assert_cmpint(ret, ==, 5);
460 ret = recvfrom(sock, buf, sizeof(buf), 0,
461 (struct sockaddr *)&other, &alen);
462 g_assert_cmpint(ret, ==, 5);
463 ret = sendto(sock, buf, 5, 0, (struct sockaddr *)&other, alen);
464 g_assert_cmpint(ret, ==, 5);
466 main_loop();
468 if (!reuse_chr) {
469 close(sock);
470 qemu_chr_fe_deinit(be, true);
472 g_free(tmp);
475 static void char_udp_test(void)
477 char_udp_test_internal(NULL, 0);
480 #ifdef HAVE_CHARDEV_SERIAL
481 static void char_serial_test(void)
483 QemuOpts *opts;
484 Chardev *chr;
486 opts = qemu_opts_create(qemu_find_opts("chardev"), "serial-id",
487 1, &error_abort);
488 qemu_opt_set(opts, "backend", "serial", &error_abort);
489 qemu_opt_set(opts, "path", "/dev/null", &error_abort);
491 chr = qemu_chr_new_from_opts(opts, NULL);
492 g_assert_nonnull(chr);
493 /* TODO: add more tests with a pty */
494 object_unparent(OBJECT(chr));
496 /* test tty alias */
497 qemu_opt_set(opts, "backend", "tty", &error_abort);
498 chr = qemu_chr_new_from_opts(opts, NULL);
499 g_assert_nonnull(chr);
500 object_unparent(OBJECT(chr));
502 qemu_opts_del(opts);
504 #endif
506 #ifndef _WIN32
507 static void char_file_fifo_test(void)
509 Chardev *chr;
510 CharBackend be;
511 char *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
512 char *fifo = g_build_filename(tmp_path, "fifo", NULL);
513 char *out = g_build_filename(tmp_path, "out", NULL);
514 ChardevFile file = { .in = fifo,
515 .has_in = true,
516 .out = out };
517 ChardevBackend backend = { .type = CHARDEV_BACKEND_KIND_FILE,
518 .u.file.data = &file };
519 FeHandler fe = { 0, };
520 int fd, ret;
522 if (mkfifo(fifo, 0600) < 0) {
523 abort();
526 fd = open(fifo, O_RDWR);
527 ret = write(fd, "fifo-in", 8);
528 g_assert_cmpint(ret, ==, 8);
530 chr = qemu_chardev_new("label-file", TYPE_CHARDEV_FILE, &backend,
531 &error_abort);
533 qemu_chr_fe_init(&be, chr, &error_abort);
534 qemu_chr_fe_set_handlers(&be,
535 fe_can_read,
536 fe_read,
537 fe_event,
538 NULL,
539 &fe, NULL, true);
541 g_assert_cmpint(fe.last_event, !=, CHR_EVENT_BREAK);
542 qmp_chardev_send_break("label-foo", NULL);
543 g_assert_cmpint(fe.last_event, !=, CHR_EVENT_BREAK);
544 qmp_chardev_send_break("label-file", NULL);
545 g_assert_cmpint(fe.last_event, ==, CHR_EVENT_BREAK);
547 main_loop();
549 close(fd);
551 g_assert_cmpint(fe.read_count, ==, 8);
552 g_assert_cmpstr(fe.read_buf, ==, "fifo-in");
554 qemu_chr_fe_deinit(&be, true);
556 g_unlink(fifo);
557 g_free(fifo);
558 g_unlink(out);
559 g_free(out);
560 g_rmdir(tmp_path);
561 g_free(tmp_path);
563 #endif
565 static void char_file_test_internal(Chardev *ext_chr, const char *filepath)
567 char *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
568 char *out;
569 Chardev *chr;
570 char *contents = NULL;
571 ChardevFile file = {};
572 ChardevBackend backend = { .type = CHARDEV_BACKEND_KIND_FILE,
573 .u.file.data = &file };
574 gsize length;
575 int ret;
577 if (ext_chr) {
578 chr = ext_chr;
579 out = g_strdup(filepath);
580 file.out = out;
581 } else {
582 out = g_build_filename(tmp_path, "out", NULL);
583 file.out = out;
584 chr = qemu_chardev_new(NULL, TYPE_CHARDEV_FILE, &backend,
585 &error_abort);
587 ret = qemu_chr_write_all(chr, (uint8_t *)"hello!", 6);
588 g_assert_cmpint(ret, ==, 6);
590 ret = g_file_get_contents(out, &contents, &length, NULL);
591 g_assert(ret == TRUE);
592 g_assert_cmpint(length, ==, 6);
593 g_assert(strncmp(contents, "hello!", 6) == 0);
595 if (!ext_chr) {
596 object_unref(OBJECT(chr));
597 g_unlink(out);
599 g_free(contents);
600 g_rmdir(tmp_path);
601 g_free(tmp_path);
602 g_free(out);
605 static void char_file_test(void)
607 char_file_test_internal(NULL, NULL);
610 static void char_null_test(void)
612 Error *err = NULL;
613 Chardev *chr;
614 CharBackend be;
615 int ret;
617 chr = qemu_chr_find("label-null");
618 g_assert_null(chr);
620 chr = qemu_chr_new("label-null", "null");
621 chr = qemu_chr_find("label-null");
622 g_assert_nonnull(chr);
624 g_assert(qemu_chr_has_feature(chr,
625 QEMU_CHAR_FEATURE_FD_PASS) == false);
626 g_assert(qemu_chr_has_feature(chr,
627 QEMU_CHAR_FEATURE_RECONNECTABLE) == false);
629 /* check max avail */
630 qemu_chr_fe_init(&be, chr, &error_abort);
631 qemu_chr_fe_init(&be, chr, &err);
632 error_free_or_abort(&err);
634 /* deinit & reinit */
635 qemu_chr_fe_deinit(&be, false);
636 qemu_chr_fe_init(&be, chr, &error_abort);
638 qemu_chr_fe_set_open(&be, true);
640 qemu_chr_fe_set_handlers(&be,
641 fe_can_read,
642 fe_read,
643 fe_event,
644 NULL,
645 NULL, NULL, true);
647 ret = qemu_chr_fe_write(&be, (void *)"buf", 4);
648 g_assert_cmpint(ret, ==, 4);
650 qemu_chr_fe_deinit(&be, true);
653 static void char_invalid_test(void)
655 Chardev *chr;
657 chr = qemu_chr_new("label-invalid", "invalid");
658 g_assert_null(chr);
661 static int chardev_change(void *opaque)
663 return 0;
666 static int chardev_change_denied(void *opaque)
668 return -1;
671 static void char_hotswap_test(void)
673 char *chr_args;
674 Chardev *chr;
675 CharBackend be;
677 gchar *tmp_path = g_dir_make_tmp("qemu-test-char.XXXXXX", NULL);
678 char *filename = g_build_filename(tmp_path, "file", NULL);
679 ChardevFile file = { .out = filename };
680 ChardevBackend backend = { .type = CHARDEV_BACKEND_KIND_FILE,
681 .u.file.data = &file };
682 ChardevReturn *ret;
684 int port;
685 int sock = make_udp_socket(&port);
686 g_assert_cmpint(sock, >, 0);
688 chr_args = g_strdup_printf("udp:127.0.0.1:%d", port);
690 chr = qemu_chr_new("chardev", chr_args);
691 qemu_chr_fe_init(&be, chr, &error_abort);
693 /* check that chardev operates correctly */
694 char_udp_test_internal(chr, sock);
696 /* set the handler that denies the hotswap */
697 qemu_chr_fe_set_handlers(&be, NULL, NULL,
698 NULL, chardev_change_denied, NULL, NULL, true);
700 /* now, change is denied and has to keep the old backend operating */
701 ret = qmp_chardev_change("chardev", &backend, NULL);
702 g_assert(!ret);
703 g_assert(be.chr == chr);
705 char_udp_test_internal(chr, sock);
707 /* now allow the change */
708 qemu_chr_fe_set_handlers(&be, NULL, NULL,
709 NULL, chardev_change, NULL, NULL, true);
711 /* has to succeed now */
712 ret = qmp_chardev_change("chardev", &backend, &error_abort);
713 g_assert(be.chr != chr);
715 close(sock);
716 chr = be.chr;
718 /* run the file chardev test */
719 char_file_test_internal(chr, filename);
721 object_unparent(OBJECT(chr));
723 qapi_free_ChardevReturn(ret);
724 g_unlink(filename);
725 g_free(filename);
726 g_rmdir(tmp_path);
727 g_free(tmp_path);
728 g_free(chr_args);
731 int main(int argc, char **argv)
733 qemu_init_main_loop(&error_abort);
734 socket_init();
736 g_test_init(&argc, &argv, NULL);
738 module_call_init(MODULE_INIT_QOM);
739 qemu_add_opts(&qemu_chardev_opts);
741 g_test_add_func("/char/null", char_null_test);
742 g_test_add_func("/char/invalid", char_invalid_test);
743 g_test_add_func("/char/ringbuf", char_ringbuf_test);
744 g_test_add_func("/char/mux", char_mux_test);
745 #ifdef CONFIG_HAS_GLIB_SUBPROCESS_TESTS
746 #ifdef _WIN32
747 g_test_add_func("/char/console/subprocess", char_console_test_subprocess);
748 g_test_add_func("/char/console", char_console_test);
749 #endif
750 g_test_add_func("/char/stdio/subprocess", char_stdio_test_subprocess);
751 g_test_add_func("/char/stdio", char_stdio_test);
752 #endif
753 #ifndef _WIN32
754 g_test_add_func("/char/pipe", char_pipe_test);
755 #endif
756 g_test_add_func("/char/file", char_file_test);
757 #ifndef _WIN32
758 g_test_add_func("/char/file-fifo", char_file_fifo_test);
759 #endif
760 g_test_add_func("/char/socket", char_socket_test);
761 g_test_add_func("/char/udp", char_udp_test);
762 #ifdef HAVE_CHARDEV_SERIAL
763 g_test_add_func("/char/serial", char_serial_test);
764 #endif
765 g_test_add_func("/char/hotswap", char_hotswap_test);
767 return g_test_run();