1 #include "qemu/osdep.h"
2 #include <glib/gstdio.h>
4 #include "qemu/config-file.h"
5 #include "qemu/option.h"
6 #include "qemu/sockets.h"
7 #include "chardev/char-fe.h"
8 #include "chardev/char-mux.h"
9 #include "sysemu/sysemu.h"
10 #include "qapi/error.h"
11 #include "qapi/qapi-commands-char.h"
12 #include "qapi/qmp/qdict.h"
13 #include "qom/qom-qobject.h"
17 typedef struct FeHandler
{
23 static void main_loop(void)
27 main_loop_wait(false);
31 static int fe_can_read(void *opaque
)
33 FeHandler
*h
= opaque
;
35 return sizeof(h
->read_buf
) - h
->read_count
;
38 static void fe_read(void *opaque
, const uint8_t *buf
, int size
)
40 FeHandler
*h
= opaque
;
42 g_assert_cmpint(size
, <=, fe_can_read(opaque
));
44 memcpy(h
->read_buf
+ h
->read_count
, buf
, size
);
45 h
->read_count
+= size
;
49 static void fe_event(void *opaque
, int event
)
51 FeHandler
*h
= opaque
;
53 h
->last_event
= event
;
54 if (event
!= CHR_EVENT_BREAK
) {
60 static void char_console_test_subprocess(void)
65 opts
= qemu_opts_create(qemu_find_opts("chardev"), "console-label",
67 qemu_opt_set(opts
, "backend", "console", &error_abort
);
69 chr
= qemu_chr_new_from_opts(opts
, NULL
);
70 g_assert_nonnull(chr
);
72 qemu_chr_write_all(chr
, (const uint8_t *)"CONSOLE", 7);
75 object_unparent(OBJECT(chr
));
78 static void char_console_test(void)
80 g_test_trap_subprocess("/char/console/subprocess", 0, 0);
81 g_test_trap_assert_passed();
82 g_test_trap_assert_stdout("CONSOLE");
85 static void char_stdio_test_subprocess(void)
91 chr
= qemu_chr_new("label", "stdio");
92 g_assert_nonnull(chr
);
94 qemu_chr_fe_init(&be
, chr
, &error_abort
);
95 qemu_chr_fe_set_open(&be
, true);
96 ret
= qemu_chr_fe_write(&be
, (void *)"buf", 4);
97 g_assert_cmpint(ret
, ==, 4);
99 qemu_chr_fe_deinit(&be
, true);
102 static void char_stdio_test(void)
104 g_test_trap_subprocess("/char/stdio/subprocess", 0, 0);
105 g_test_trap_assert_passed();
106 g_test_trap_assert_stdout("buf");
109 static void char_ringbuf_test(void)
117 opts
= qemu_opts_create(qemu_find_opts("chardev"), "ringbuf-label",
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
);
126 opts
= qemu_opts_create(qemu_find_opts("chardev"), "ringbuf-label",
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
);
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");
142 data
= qmp_ringbuf_read("ringbuf-label", 4, false, 0, &error_abort
);
143 g_assert_cmpstr(data
, ==, "");
146 qemu_chr_fe_deinit(&be
, true);
149 opts
= qemu_opts_create(qemu_find_opts("chardev"), "memory-label",
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
));
159 static void char_mux_test(void)
164 FeHandler h1
= { 0, }, h2
= { 0, };
165 CharBackend chr_be1
, chr_be2
;
167 opts
= qemu_opts_create(qemu_find_opts("chardev"), "mux-label",
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
);
176 qemu_chr_fe_init(&chr_be1
, chr
, &error_abort
);
177 qemu_chr_fe_set_handlers(&chr_be1
,
185 qemu_chr_fe_init(&chr_be2
, chr
, &error_abort
);
186 qemu_chr_fe_set_handlers(&chr_be2
,
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");
204 g_assert_cmpint(h1
.last_event
, !=, 42); /* should be MUX_OUT or OPENED */
205 g_assert_cmpint(h2
.last_event
, !=, 42); /* should be MUX_IN or OPENED */
206 /* sending event on the base broadcast to all fe, historical reasons? */
207 qemu_chr_be_event(base
, 42);
208 g_assert_cmpint(h1
.last_event
, ==, 42);
209 g_assert_cmpint(h2
.last_event
, ==, 42);
210 qemu_chr_be_event(chr
, -1);
211 g_assert_cmpint(h1
.last_event
, ==, 42);
212 g_assert_cmpint(h2
.last_event
, ==, -1);
215 qemu_chr_be_write(base
, (void *)"\1b", 2);
216 g_assert_cmpint(h1
.last_event
, ==, 42);
217 g_assert_cmpint(h2
.last_event
, ==, CHR_EVENT_BREAK
);
219 qemu_chr_be_write(base
, (void *)"\1c", 2);
220 g_assert_cmpint(h1
.last_event
, ==, CHR_EVENT_MUX_IN
);
221 g_assert_cmpint(h2
.last_event
, ==, CHR_EVENT_MUX_OUT
);
222 qemu_chr_be_event(chr
, -1);
223 g_assert_cmpint(h1
.last_event
, ==, -1);
224 g_assert_cmpint(h2
.last_event
, ==, CHR_EVENT_MUX_OUT
);
226 qemu_chr_be_write(base
, (void *)"hello", 6);
227 g_assert_cmpint(h2
.read_count
, ==, 0);
228 g_assert_cmpint(h1
.read_count
, ==, 6);
229 g_assert_cmpstr(h1
.read_buf
, ==, "hello");
232 qemu_chr_be_write(base
, (void *)"\1b", 2);
233 g_assert_cmpint(h1
.last_event
, ==, CHR_EVENT_BREAK
);
234 g_assert_cmpint(h2
.last_event
, ==, CHR_EVENT_MUX_OUT
);
236 /* remove first handler */
237 qemu_chr_fe_set_handlers(&chr_be1
, NULL
, NULL
, NULL
, NULL
,
239 qemu_chr_be_write(base
, (void *)"hello", 6);
240 g_assert_cmpint(h1
.read_count
, ==, 0);
241 g_assert_cmpint(h2
.read_count
, ==, 0);
243 qemu_chr_be_write(base
, (void *)"\1c", 2);
244 qemu_chr_be_write(base
, (void *)"hello", 6);
245 g_assert_cmpint(h1
.read_count
, ==, 0);
246 g_assert_cmpint(h2
.read_count
, ==, 6);
247 g_assert_cmpstr(h2
.read_buf
, ==, "hello");
251 qemu_chr_be_write(base
, (void *)"\1?", 2);
252 data
= qmp_ringbuf_read("mux-label-base", 128, false, 0, &error_abort
);
253 g_assert_cmpint(strlen(data
), !=, 0);
256 qemu_chr_fe_deinit(&chr_be1
, false);
257 qemu_chr_fe_deinit(&chr_be2
, true);
260 typedef struct SocketIdleData
{
265 CharBackend
*client_be
;
268 static gboolean
char_socket_test_idle(gpointer user_data
)
270 SocketIdleData
*data
= user_data
;
272 if (object_property_get_bool(OBJECT(data
->chr
), "connected", NULL
)
273 == data
->conn_expected
) {
281 static void socket_read(void *opaque
, const uint8_t *buf
, int size
)
283 SocketIdleData
*data
= opaque
;
285 g_assert_cmpint(size
, ==, 1);
286 g_assert_cmpint(*buf
, ==, 'Z');
288 size
= qemu_chr_fe_write(data
->be
, (const uint8_t *)"hello", 5);
289 g_assert_cmpint(size
, ==, 5);
292 static int socket_can_read(void *opaque
)
297 static void socket_read_hello(void *opaque
, const uint8_t *buf
, int size
)
299 g_assert_cmpint(size
, ==, 5);
300 g_assert(strncmp((char *)buf
, "hello", 5) == 0);
305 static int socket_can_read_hello(void *opaque
)
310 static void char_socket_test_common(Chardev
*chr
, bool reconnect
)
316 SocketIdleData d
= { .chr
= chr
};
318 CharBackend client_be
;
324 g_assert_nonnull(chr
);
325 g_assert(!object_property_get_bool(OBJECT(chr
), "connected", &error_abort
));
327 addr
= object_property_get_qobject(OBJECT(chr
), "addr", &error_abort
);
328 qdict
= qobject_to(QDict
, addr
);
329 port
= qdict_get_str(qdict
, "port");
330 tmp
= g_strdup_printf("tcp:127.0.0.1:%s%s", port
,
331 reconnect
? ",reconnect=1" : "");
332 qobject_unref(qdict
);
334 qemu_chr_fe_init(&be
, chr
, &error_abort
);
335 qemu_chr_fe_set_handlers(&be
, socket_can_read
, socket_read
,
336 NULL
, NULL
, &d
, NULL
, true);
338 chr_client
= qemu_chr_new("client", tmp
);
339 qemu_chr_fe_init(&client_be
, chr_client
, &error_abort
);
340 qemu_chr_fe_set_handlers(&client_be
, socket_can_read_hello
,
342 NULL
, NULL
, &d
, NULL
, true);
345 d
.conn_expected
= true;
346 guint id
= g_idle_add(char_socket_test_idle
, &d
);
347 g_source_set_name_by_id(id
, "test-idle");
348 g_assert_cmpint(id
, >, 0);
352 id
= g_idle_add(char_socket_test_idle
, &d
);
353 g_source_set_name_by_id(id
, "test-idle");
354 g_assert_cmpint(id
, >, 0);
357 g_assert(object_property_get_bool(OBJECT(chr
), "connected", &error_abort
));
358 g_assert(object_property_get_bool(OBJECT(chr_client
),
359 "connected", &error_abort
));
361 qemu_chr_write_all(chr_client
, (const uint8_t *)"Z", 1);
364 object_unparent(OBJECT(chr_client
));
367 d
.conn_expected
= false;
368 g_idle_add(char_socket_test_idle
, &d
);
371 object_unparent(OBJECT(chr
));
375 static void char_socket_basic_test(void)
377 Chardev
*chr
= qemu_chr_new("server", "tcp:127.0.0.1:0,server,nowait");
379 char_socket_test_common(chr
, false);
383 static void char_socket_reconnect_test(void)
385 Chardev
*chr
= qemu_chr_new("server", "tcp:127.0.0.1:0,server,nowait");
387 char_socket_test_common(chr
, true);
391 static void char_socket_fdpass_test(void)
397 SocketAddress
*addr
= g_new0(SocketAddress
, 1);
399 addr
->type
= SOCKET_ADDRESS_TYPE_INET
;
400 addr
->u
.inet
.host
= g_strdup("127.0.0.1");
401 addr
->u
.inet
.port
= g_strdup("0");
403 fd
= socket_listen(addr
, &error_abort
);
406 qapi_free_SocketAddress(addr
);
408 optstr
= g_strdup_printf("socket,id=cdev,fd=%d,server,nowait", fd
);
410 opts
= qemu_opts_parse_noisily(qemu_find_opts("chardev"),
413 g_assert_nonnull(opts
);
415 chr
= qemu_chr_new_from_opts(opts
, &error_abort
);
419 char_socket_test_common(chr
, false);
424 static void char_pipe_test(void)
426 gchar
*tmp_path
= g_dir_make_tmp("qemu-test-char.XXXXXX", NULL
);
427 gchar
*tmp
, *in
, *out
, *pipe
= g_build_filename(tmp_path
, "pipe", NULL
);
432 FeHandler fe
= { 0, };
434 in
= g_strdup_printf("%s.in", pipe
);
435 if (mkfifo(in
, 0600) < 0) {
438 out
= g_strdup_printf("%s.out", pipe
);
439 if (mkfifo(out
, 0600) < 0) {
443 tmp
= g_strdup_printf("pipe:%s", pipe
);
444 chr
= qemu_chr_new("pipe", tmp
);
445 g_assert_nonnull(chr
);
448 qemu_chr_fe_init(&be
, chr
, &error_abort
);
450 ret
= qemu_chr_fe_write(&be
, (void *)"pipe-out", 9);
451 g_assert_cmpint(ret
, ==, 9);
453 fd
= open(out
, O_RDWR
);
454 ret
= read(fd
, buf
, sizeof(buf
));
455 g_assert_cmpint(ret
, ==, 9);
456 g_assert_cmpstr(buf
, ==, "pipe-out");
459 fd
= open(in
, O_WRONLY
);
460 ret
= write(fd
, "pipe-in", 8);
461 g_assert_cmpint(ret
, ==, 8);
464 qemu_chr_fe_set_handlers(&be
,
474 g_assert_cmpint(fe
.read_count
, ==, 8);
475 g_assert_cmpstr(fe
.read_buf
, ==, "pipe-in");
477 qemu_chr_fe_deinit(&be
, true);
479 g_assert(g_unlink(in
) == 0);
480 g_assert(g_unlink(out
) == 0);
481 g_assert(g_rmdir(tmp_path
) == 0);
489 static int make_udp_socket(int *port
)
491 struct sockaddr_in addr
= { 0, };
492 socklen_t alen
= sizeof(addr
);
493 int ret
, sock
= qemu_socket(PF_INET
, SOCK_DGRAM
, 0);
495 g_assert_cmpint(sock
, >, 0);
496 addr
.sin_family
= AF_INET
;
497 addr
.sin_addr
.s_addr
= htonl(INADDR_ANY
);
499 ret
= bind(sock
, (struct sockaddr
*)&addr
, sizeof(addr
));
500 g_assert_cmpint(ret
, ==, 0);
501 ret
= getsockname(sock
, (struct sockaddr
*)&addr
, &alen
);
502 g_assert_cmpint(ret
, ==, 0);
504 *port
= ntohs(addr
.sin_port
);
508 static void char_udp_test_internal(Chardev
*reuse_chr
, int sock
)
510 struct sockaddr_in other
;
511 SocketIdleData d
= { 0, };
514 socklen_t alen
= sizeof(other
);
524 sock
= make_udp_socket(&port
);
525 tmp
= g_strdup_printf("udp:127.0.0.1:%d", port
);
526 chr
= qemu_chr_new("client", tmp
);
527 g_assert_nonnull(chr
);
529 be
= g_alloca(sizeof(CharBackend
));
530 qemu_chr_fe_init(be
, chr
, &error_abort
);
534 qemu_chr_fe_set_handlers(be
, socket_can_read_hello
, socket_read_hello
,
535 NULL
, NULL
, &d
, NULL
, true);
536 ret
= qemu_chr_write_all(chr
, (uint8_t *)"hello", 5);
537 g_assert_cmpint(ret
, ==, 5);
539 ret
= recvfrom(sock
, buf
, sizeof(buf
), 0,
540 (struct sockaddr
*)&other
, &alen
);
541 g_assert_cmpint(ret
, ==, 5);
542 ret
= sendto(sock
, buf
, 5, 0, (struct sockaddr
*)&other
, alen
);
543 g_assert_cmpint(ret
, ==, 5);
549 qemu_chr_fe_deinit(be
, true);
554 static void char_udp_test(void)
556 char_udp_test_internal(NULL
, 0);
559 #ifdef HAVE_CHARDEV_SERIAL
560 static void char_serial_test(void)
565 opts
= qemu_opts_create(qemu_find_opts("chardev"), "serial-id",
567 qemu_opt_set(opts
, "backend", "serial", &error_abort
);
568 qemu_opt_set(opts
, "path", "/dev/null", &error_abort
);
570 chr
= qemu_chr_new_from_opts(opts
, NULL
);
571 g_assert_nonnull(chr
);
572 /* TODO: add more tests with a pty */
573 object_unparent(OBJECT(chr
));
576 qemu_opt_set(opts
, "backend", "tty", &error_abort
);
577 chr
= qemu_chr_new_from_opts(opts
, NULL
);
578 g_assert_nonnull(chr
);
579 object_unparent(OBJECT(chr
));
586 static void char_file_fifo_test(void)
590 char *tmp_path
= g_dir_make_tmp("qemu-test-char.XXXXXX", NULL
);
591 char *fifo
= g_build_filename(tmp_path
, "fifo", NULL
);
592 char *out
= g_build_filename(tmp_path
, "out", NULL
);
593 ChardevFile file
= { .in
= fifo
,
596 ChardevBackend backend
= { .type
= CHARDEV_BACKEND_KIND_FILE
,
597 .u
.file
.data
= &file
};
598 FeHandler fe
= { 0, };
601 if (mkfifo(fifo
, 0600) < 0) {
605 fd
= open(fifo
, O_RDWR
);
606 ret
= write(fd
, "fifo-in", 8);
607 g_assert_cmpint(ret
, ==, 8);
609 chr
= qemu_chardev_new("label-file", TYPE_CHARDEV_FILE
, &backend
,
612 qemu_chr_fe_init(&be
, chr
, &error_abort
);
613 qemu_chr_fe_set_handlers(&be
,
620 g_assert_cmpint(fe
.last_event
, !=, CHR_EVENT_BREAK
);
621 qmp_chardev_send_break("label-foo", NULL
);
622 g_assert_cmpint(fe
.last_event
, !=, CHR_EVENT_BREAK
);
623 qmp_chardev_send_break("label-file", NULL
);
624 g_assert_cmpint(fe
.last_event
, ==, CHR_EVENT_BREAK
);
630 g_assert_cmpint(fe
.read_count
, ==, 8);
631 g_assert_cmpstr(fe
.read_buf
, ==, "fifo-in");
633 qemu_chr_fe_deinit(&be
, true);
644 static void char_file_test_internal(Chardev
*ext_chr
, const char *filepath
)
646 char *tmp_path
= g_dir_make_tmp("qemu-test-char.XXXXXX", NULL
);
649 char *contents
= NULL
;
650 ChardevFile file
= {};
651 ChardevBackend backend
= { .type
= CHARDEV_BACKEND_KIND_FILE
,
652 .u
.file
.data
= &file
};
658 out
= g_strdup(filepath
);
661 out
= g_build_filename(tmp_path
, "out", NULL
);
663 chr
= qemu_chardev_new(NULL
, TYPE_CHARDEV_FILE
, &backend
,
666 ret
= qemu_chr_write_all(chr
, (uint8_t *)"hello!", 6);
667 g_assert_cmpint(ret
, ==, 6);
669 ret
= g_file_get_contents(out
, &contents
, &length
, NULL
);
670 g_assert(ret
== TRUE
);
671 g_assert_cmpint(length
, ==, 6);
672 g_assert(strncmp(contents
, "hello!", 6) == 0);
675 object_unref(OBJECT(chr
));
684 static void char_file_test(void)
686 char_file_test_internal(NULL
, NULL
);
689 static void char_null_test(void)
696 chr
= qemu_chr_find("label-null");
699 chr
= qemu_chr_new("label-null", "null");
700 chr
= qemu_chr_find("label-null");
701 g_assert_nonnull(chr
);
703 g_assert(qemu_chr_has_feature(chr
,
704 QEMU_CHAR_FEATURE_FD_PASS
) == false);
705 g_assert(qemu_chr_has_feature(chr
,
706 QEMU_CHAR_FEATURE_RECONNECTABLE
) == false);
708 /* check max avail */
709 qemu_chr_fe_init(&be
, chr
, &error_abort
);
710 qemu_chr_fe_init(&be
, chr
, &err
);
711 error_free_or_abort(&err
);
713 /* deinit & reinit */
714 qemu_chr_fe_deinit(&be
, false);
715 qemu_chr_fe_init(&be
, chr
, &error_abort
);
717 qemu_chr_fe_set_open(&be
, true);
719 qemu_chr_fe_set_handlers(&be
,
726 ret
= qemu_chr_fe_write(&be
, (void *)"buf", 4);
727 g_assert_cmpint(ret
, ==, 4);
729 qemu_chr_fe_deinit(&be
, true);
732 static void char_invalid_test(void)
736 chr
= qemu_chr_new("label-invalid", "invalid");
740 static int chardev_change(void *opaque
)
745 static int chardev_change_denied(void *opaque
)
750 static void char_hotswap_test(void)
756 gchar
*tmp_path
= g_dir_make_tmp("qemu-test-char.XXXXXX", NULL
);
757 char *filename
= g_build_filename(tmp_path
, "file", NULL
);
758 ChardevFile file
= { .out
= filename
};
759 ChardevBackend backend
= { .type
= CHARDEV_BACKEND_KIND_FILE
,
760 .u
.file
.data
= &file
};
764 int sock
= make_udp_socket(&port
);
765 g_assert_cmpint(sock
, >, 0);
767 chr_args
= g_strdup_printf("udp:127.0.0.1:%d", port
);
769 chr
= qemu_chr_new("chardev", chr_args
);
770 qemu_chr_fe_init(&be
, chr
, &error_abort
);
772 /* check that chardev operates correctly */
773 char_udp_test_internal(chr
, sock
);
775 /* set the handler that denies the hotswap */
776 qemu_chr_fe_set_handlers(&be
, NULL
, NULL
,
777 NULL
, chardev_change_denied
, NULL
, NULL
, true);
779 /* now, change is denied and has to keep the old backend operating */
780 ret
= qmp_chardev_change("chardev", &backend
, NULL
);
782 g_assert(be
.chr
== chr
);
784 char_udp_test_internal(chr
, sock
);
786 /* now allow the change */
787 qemu_chr_fe_set_handlers(&be
, NULL
, NULL
,
788 NULL
, chardev_change
, NULL
, NULL
, true);
790 /* has to succeed now */
791 ret
= qmp_chardev_change("chardev", &backend
, &error_abort
);
792 g_assert(be
.chr
!= chr
);
797 /* run the file chardev test */
798 char_file_test_internal(chr
, filename
);
800 object_unparent(OBJECT(chr
));
802 qapi_free_ChardevReturn(ret
);
810 int main(int argc
, char **argv
)
812 qemu_init_main_loop(&error_abort
);
815 g_test_init(&argc
, &argv
, NULL
);
817 module_call_init(MODULE_INIT_QOM
);
818 qemu_add_opts(&qemu_chardev_opts
);
820 g_test_add_func("/char/null", char_null_test
);
821 g_test_add_func("/char/invalid", char_invalid_test
);
822 g_test_add_func("/char/ringbuf", char_ringbuf_test
);
823 g_test_add_func("/char/mux", char_mux_test
);
825 g_test_add_func("/char/console/subprocess", char_console_test_subprocess
);
826 g_test_add_func("/char/console", char_console_test
);
828 g_test_add_func("/char/stdio/subprocess", char_stdio_test_subprocess
);
829 g_test_add_func("/char/stdio", char_stdio_test
);
831 g_test_add_func("/char/pipe", char_pipe_test
);
833 g_test_add_func("/char/file", char_file_test
);
835 g_test_add_func("/char/file-fifo", char_file_fifo_test
);
837 g_test_add_func("/char/socket/basic", char_socket_basic_test
);
838 g_test_add_func("/char/socket/reconnect", char_socket_reconnect_test
);
839 g_test_add_func("/char/socket/fdpass", char_socket_fdpass_test
);
840 g_test_add_func("/char/udp", char_udp_test
);
841 #ifdef HAVE_CHARDEV_SERIAL
842 g_test_add_func("/char/serial", char_serial_test
);
844 g_test_add_func("/char/hotswap", char_hotswap_test
);