aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2024-02-14 13:00:19 +0000
committerPeter Maydell <peter.maydell@linaro.org>2024-02-14 13:00:19 +0000
commit708322660e15e83a37fb6deb8470209307ef43a2 (patch)
tree4e76f7810c64040044d8c9fe7a3af2c9d2c12995 /tests/unit
parent2766e3668c29a5757aa426fc0b8391e55f69e13e (diff)
parentb04c12282b33e81ba29b54dd001667f5c4002252 (diff)
Merge tag 'pull-char-2024-02-12-v2' of https://repo.or.cz/qemu/armbru into staging
Character device backend patches for 2024-02-12 # -----BEGIN PGP SIGNATURE----- # # iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmXMYY0SHGFybWJydUBy # ZWRoYXQuY29tAAoJEDhwtADrkYZTTGYQALEO48lySVjvKEYjUpjFNkwL4sA2wLyp # JMUuUresuH2w/a/pornhgW6ICQWLbxXSinfBy7G68/BqFiqxdLEFe7VE0zzg3wXV # MNY1SHZDQ6nvREqvpj2uAj5nq1dxqbcAnTbGbJeDWKi2+JtvZ3IO9CA6zLfMDd6D # bJpTOoNeGEogFel9enISJteiLJYTRU50Rdn73epSJ8NGoMQja9YoM2sA1VqNuscH # sjzNRMfpAboMkkTCPhi3RivQUUzt45zEwRHFy30Gz9YK9BDKmqJbqfhTAiBgsDBk # TUqwnoyMQwHZ3xkT46s62Z2qy1uSautJOtnbNpnQlEZgc42T0Kli61+p+iPmKr+H # ZxZAKUUtsz7PSBMcnl91VTJZA3+FaWTkm5IPd2bVPuxFtZl0C1EdflsxFY1/3tEy # tr3GbIs6DkXpzmf+o8OXm72XTF7DPgDfsdn0K+9dJLO+G/C5r9euWCTeQeW2QR8d # PfpuNo9iZcRbp3BS/7zsr6dwdW9jVWPE3U3spORRqjX4eS6B6UMmug54EDdnZaM8 # abLDRf2KQuXBD5IazGSQZfC6Kvx2FOqyJD67gWsv0A83sAfhfC+JyIVp67sJPpdf # KoXTjPn2jiBfzibrMWxDJiFS8TiYI5jO28BPPERlrWZ+AojHAnY+ytQ1avggZaCU # Ypv+CgoMG1gC # =bOef # -----END PGP SIGNATURE----- # gpg: Signature made Wed 14 Feb 2024 06:45:33 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * tag 'pull-char-2024-02-12-v2' of https://repo.or.cz/qemu/armbru: qapi/char: Deprecate backend type "memory" qapi/char: Make backend types properly conditional tests/unit/test-char: Fix qemu_socket(), make_udp_socket() check chardev/parallel: Don't close stdin on inappropriate device Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/test-char.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c
index 649fdf64e1..f273ce5226 100644
--- a/tests/unit/test-char.c
+++ b/tests/unit/test-char.c
@@ -556,7 +556,7 @@ static int make_udp_socket(int *port)
socklen_t alen = sizeof(addr);
int ret, sock = qemu_socket(PF_INET, SOCK_DGRAM, 0);
- g_assert_cmpint(sock, >, 0);
+ g_assert_cmpint(sock, >=, 0);
addr.sin_family = AF_INET ;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = 0;
@@ -1203,6 +1203,30 @@ static void char_serial_test(void)
}
#endif
+#if defined(HAVE_CHARDEV_PARALLEL) && !defined(WIN32)
+static void char_parallel_test(void)
+{
+ QemuOpts *opts;
+ Chardev *chr;
+
+ opts = qemu_opts_create(qemu_find_opts("chardev"), "parallel-id",
+ 1, &error_abort);
+ qemu_opt_set(opts, "backend", "parallel", &error_abort);
+ qemu_opt_set(opts, "path", "/dev/null", &error_abort);
+
+ chr = qemu_chr_new_from_opts(opts, NULL, NULL);
+#ifdef __linux__
+ /* fails to PPCLAIM, see qemu_chr_open_pp_fd() */
+ g_assert_null(chr);
+#else
+ g_assert_nonnull(chr);
+ object_unparent(OBJECT(chr));
+#endif
+
+ qemu_opts_del(opts);
+}
+#endif
+
#ifndef _WIN32
static void char_file_fifo_test(void)
{
@@ -1383,7 +1407,7 @@ static void char_hotswap_test(void)
int port;
int sock = make_udp_socket(&port);
- g_assert_cmpint(sock, >, 0);
+ g_assert_cmpint(sock, >=, 0);
chr_args = g_strdup_printf("udp:127.0.0.1:%d", port);
@@ -1545,6 +1569,9 @@ int main(int argc, char **argv)
#if defined(HAVE_CHARDEV_SERIAL) && !defined(WIN32)
g_test_add_func("/char/serial", char_serial_test);
#endif
+#if defined(HAVE_CHARDEV_PARALLEL) && !defined(WIN32)
+ g_test_add_func("/char/parallel", char_parallel_test);
+#endif
g_test_add_func("/char/hotswap", char_hotswap_test);
g_test_add_func("/char/websocket", char_websock_test);