Skip to content

Commit

Permalink
Fix new IPC test with large messages
Browse files Browse the repository at this point in the history
The test was added in commit 568dacb:

    Test passing large buffers through IPC

10 KiB buffer works fine on Linux, but overflows the pipe buffer on OS X
and Windows.  Run a second thread and make sure that a large message can
go through the IPC.
  • Loading branch information
xaizek committed Jul 23, 2023
1 parent 222ade7 commit 505c2c1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions tests/misc/ipc.c
@@ -1,7 +1,7 @@
#include <stic.h>

#include <stddef.h> /* NULL */
#include <stdlib.h> /* free() */
#include <stdlib.h> /* free() malloc() */
#include <string.h> /* memset() strcmp() strdup() */

#include <test-utils.h>
Expand Down Expand Up @@ -120,19 +120,23 @@ TEST(message_is_delivered, IF(enabled_and_not_in_wine))

TEST(large_message_is_delivered, IF(enabled_and_not_in_wine))
{
char msg[10*1024 + 1];
memset(msg, 'x', sizeof(msg) - 1);
msg[sizeof(msg) - 1] = '\0';
enum { LEN = 64*1024 };

char *msg = malloc(LEN + 1);
memset(msg, 'x', LEN - 1);
msg[LEN - 1] = '\0';

char *data[] = { msg, NULL };

ipc_t *const ipc1 = ipc_init(NAME, &test_ipc_args, &test_ipc_eval);
ipc_t *const ipc2 = ipc_init(NAME, &test_ipc_args2, &test_ipc_eval);

assert_success(bg_execute("", "", 0, 1, &other_instance, ipc2));

assert_success(ipc_send(ipc1, ipc_get_name(ipc2), data));
assert_false(ipc_check(ipc1));
assert_true(ipc_check(ipc2));
assert_false(ipc_check(ipc2));

wait_for_bg();

ipc_free(ipc1);
ipc_free(ipc2);
Expand All @@ -141,6 +145,8 @@ TEST(large_message_is_delivered, IF(enabled_and_not_in_wine))
assert_string_equal(NULL, message);
assert_int_equal(2, nmessages2);
assert_string_equal(msg, message2);

free(msg);
}

TEST(expr_is_evaluated, IF(enabled_and_not_in_wine))
Expand Down

0 comments on commit 505c2c1

Please sign in to comment.