-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Perform I/O testing using socketpair.
- Loading branch information
Showing
8 changed files
with
39 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
============================================================================ | ||
Name : cio-fd.c | ||
Author : hev <[email protected]> | ||
Copyright : Copyright (c) 2024 hev. | ||
Copyright : Copyright (c) 2024 - 2025 hev. | ||
Description : CIO Fd Test | ||
============================================================================ | ||
*/ | ||
|
@@ -12,7 +12,7 @@ | |
|
||
#include <hev-task.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-pipe.h> | ||
#include <hev-task-io-socket.h> | ||
#include <hev-task-cio-fd.h> | ||
#include <hev-task-system.h> | ||
|
||
|
@@ -57,13 +57,13 @@ task_entry (void *data) | |
ssize_t size; | ||
int res; | ||
|
||
res = hev_task_io_pipe_pipe (&fds1[0]); | ||
res = hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, &fds1[0]); | ||
assert (res == 0); | ||
res = hev_task_io_pipe_pipe (&fds1[2]); | ||
res = hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, &fds1[2]); | ||
assert (res == 0); | ||
res = hev_task_io_pipe_pipe (&fds2[0]); | ||
res = hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, &fds2[0]); | ||
assert (res == 0); | ||
res = hev_task_io_pipe_pipe (&fds2[2]); | ||
res = hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, &fds2[2]); | ||
assert (res == 0); | ||
|
||
assert (hev_task_add_fd (task, fds1[3], POLLOUT) == 0); | ||
|
@@ -105,6 +105,11 @@ task_entry (void *data) | |
assert (hev_task_cio_write_dgram (a, buf1, 64, NULL, NULL, NULL) == -1); | ||
assert (hev_task_cio_writev_dgram (a, &iov, 1, NULL, NULL, NULL) == -1); | ||
|
||
assert (hev_task_del_fd (task, fds1[3]) == 0); | ||
assert (hev_task_del_fd (task, fds2[3]) == 0); | ||
assert (hev_task_del_fd (task, fds1[0]) == 0); | ||
assert (hev_task_del_fd (task, fds2[0]) == 0); | ||
|
||
hev_object_unref (HEV_OBJECT (a)); | ||
hev_object_unref (HEV_OBJECT (b)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
============================================================================ | ||
Name : io-poll.c | ||
Author : Heiher <[email protected]> | ||
Copyright : Copyright (c) 2018 everyone. | ||
Copyright : Copyright (c) 2018 - 2025 everyone. | ||
Description : IO Poll Test | ||
============================================================================ | ||
*/ | ||
|
@@ -14,8 +14,9 @@ | |
|
||
#include <hev-task.h> | ||
#include <hev-task-system.h> | ||
#include <hev-task-io-pipe.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-poll.h> | ||
#include <hev-task-io-socket.h> | ||
|
||
static int fds[2]; | ||
|
||
|
@@ -62,7 +63,7 @@ main (int argc, char *argv[]) | |
|
||
assert (hev_task_system_init () == 0); | ||
|
||
assert (hev_task_io_pipe_pipe (fds) == 0); | ||
assert (hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) == 0); | ||
assert (fds[0] >= 0); | ||
assert (fds[1] >= 0); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
============================================================================ | ||
Name : io-read.c | ||
Author : Heiher <[email protected]> | ||
Copyright : Copyright (c) 2018 everyone. | ||
Copyright : Copyright (c) 2018 - 2025 everyone. | ||
Description : IO Read Test | ||
============================================================================ | ||
*/ | ||
|
@@ -14,7 +14,7 @@ | |
#include <hev-task.h> | ||
#include <hev-task-system.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-pipe.h> | ||
#include <hev-task-io-socket.h> | ||
|
||
static void | ||
task_entry (void *data) | ||
|
@@ -25,7 +25,7 @@ task_entry (void *data) | |
char buf[4]; | ||
ssize_t size; | ||
|
||
assert (hev_task_io_pipe_pipe (fds) == 0); | ||
assert (hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) == 0); | ||
|
||
flags = fcntl (fds[1], F_GETFL); | ||
assert (flags >= 0); | ||
|
@@ -37,6 +37,7 @@ task_entry (void *data) | |
size = hev_task_io_read (fds[0], buf, 4, NULL, NULL); | ||
assert (size >= 0); | ||
|
||
assert (hev_task_del_fd (task, fds[0]) == 0); | ||
close (fds[0]); | ||
close (fds[1]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
============================================================================ | ||
Name : io-readv.c | ||
Author : Heiher <[email protected]> | ||
Copyright : Copyright (c) 2018 everyone. | ||
Copyright : Copyright (c) 2018 - 2025 everyone. | ||
Description : IO ReadV Test | ||
============================================================================ | ||
*/ | ||
|
@@ -14,7 +14,7 @@ | |
#include <hev-task.h> | ||
#include <hev-task-system.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-pipe.h> | ||
#include <hev-task-io-socket.h> | ||
|
||
static void | ||
task_entry (void *data) | ||
|
@@ -27,7 +27,7 @@ task_entry (void *data) | |
ssize_t size; | ||
struct iovec iov[2]; | ||
|
||
assert (hev_task_io_pipe_pipe (fds) == 0); | ||
assert (hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) == 0); | ||
|
||
flags = fcntl (fds[1], F_GETFL); | ||
assert (flags >= 0); | ||
|
@@ -43,6 +43,7 @@ task_entry (void *data) | |
size = hev_task_io_readv (fds[0], iov, 2, NULL, NULL); | ||
assert (size >= 0); | ||
|
||
assert (hev_task_del_fd (task, fds[0]) == 0); | ||
close (fds[0]); | ||
close (fds[1]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
============================================================================ | ||
Name : io-write.c | ||
Author : Heiher <[email protected]> | ||
Copyright : Copyright (c) 2018 everyone. | ||
Copyright : Copyright (c) 2018 - 2025 everyone. | ||
Description : IO Write Test | ||
============================================================================ | ||
*/ | ||
|
@@ -13,7 +13,7 @@ | |
#include <hev-task.h> | ||
#include <hev-task-system.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-pipe.h> | ||
#include <hev-task-io-socket.h> | ||
|
||
static void | ||
task_entry (void *data) | ||
|
@@ -23,13 +23,14 @@ task_entry (void *data) | |
char buf[4]; | ||
ssize_t size; | ||
|
||
assert (hev_task_io_pipe_pipe (fds) == 0); | ||
assert (hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) == 0); | ||
|
||
assert (hev_task_add_fd (task, fds[1], POLLOUT) == 0); | ||
|
||
size = hev_task_io_write (fds[1], buf, 4, NULL, NULL); | ||
assert (size >= 0); | ||
|
||
assert (hev_task_del_fd (task, fds[1]) == 0); | ||
close (fds[0]); | ||
close (fds[1]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
============================================================================ | ||
Name : io-writev.c | ||
Author : Heiher <[email protected]> | ||
Copyright : Copyright (c) 2018 everyone. | ||
Copyright : Copyright (c) 2018 - 2025 everyone. | ||
Description : IO WriteV Test | ||
============================================================================ | ||
*/ | ||
|
@@ -13,7 +13,7 @@ | |
#include <hev-task.h> | ||
#include <hev-task-system.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-pipe.h> | ||
#include <hev-task-io-socket.h> | ||
|
||
static void | ||
task_entry (void *data) | ||
|
@@ -24,7 +24,7 @@ task_entry (void *data) | |
ssize_t size; | ||
struct iovec iov[2]; | ||
|
||
assert (hev_task_io_pipe_pipe (fds) == 0); | ||
assert (hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) == 0); | ||
|
||
assert (hev_task_add_fd (task, fds[1], POLLOUT) == 0); | ||
|
||
|
@@ -35,6 +35,7 @@ task_entry (void *data) | |
size = hev_task_io_writev (fds[1], iov, 2, NULL, NULL); | ||
assert (size == 4); | ||
|
||
assert (hev_task_del_fd (task, fds[1]) == 0); | ||
close (fds[0]); | ||
close (fds[1]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
============================================================================ | ||
Name : io-yielder.c | ||
Author : Heiher <[email protected]> | ||
Copyright : Copyright (c) 2018 everyone. | ||
Copyright : Copyright (c) 2018 - 2025 everyone. | ||
Description : IO Yielder Test | ||
============================================================================ | ||
*/ | ||
|
@@ -18,7 +18,7 @@ | |
#include <hev-task.h> | ||
#include <hev-task-system.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-pipe.h> | ||
#include <hev-task-io-socket.h> | ||
|
||
static int | ||
task_io_yielder (HevTaskYieldType type, void *data) | ||
|
@@ -36,7 +36,7 @@ task_entry (void *data) | |
char buf[16]; | ||
ssize_t size; | ||
|
||
assert (hev_task_io_pipe_pipe (fds) == 0); | ||
assert (hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) == 0); | ||
assert (fds[0] >= 0); | ||
assert (fds[1] >= 0); | ||
|
||
|
@@ -45,6 +45,7 @@ task_entry (void *data) | |
size = hev_task_io_read (fds[0], buf, 16, task_io_yielder, NULL); | ||
assert (size == -2); | ||
|
||
assert (hev_task_del_fd (task, fds[0]) == 0); | ||
close (fds[0]); | ||
close (fds[1]); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
============================================================================ | ||
Name : task-fd.c | ||
Author : Heiher <[email protected]> | ||
Copyright : Copyright (c) 2018 everyone. | ||
Copyright : Copyright (c) 2018 - 2025 everyone. | ||
Description : Task FD Test | ||
============================================================================ | ||
*/ | ||
|
@@ -13,9 +13,9 @@ | |
#include <assert.h> | ||
|
||
#include <hev-task.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-pipe.h> | ||
#include <hev-task-system.h> | ||
#include <hev-task-io.h> | ||
#include <hev-task-io-socket.h> | ||
|
||
static int fds[2]; | ||
|
||
|
@@ -55,7 +55,7 @@ main (int argc, char *argv[]) | |
|
||
assert (hev_task_system_init () == 0); | ||
|
||
assert (hev_task_io_pipe_pipe (fds) == 0); | ||
assert (hev_task_io_socket_socketpair (PF_LOCAL, SOCK_STREAM, 0, fds) == 0); | ||
|
||
task = hev_task_new (-1); | ||
assert (task); | ||
|