diff options
author | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-08 19:07:48 +0100 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ens.fr> | 2015-03-08 19:07:48 +0100 |
commit | 6dd488b87fdc47fb377ba648a6cd598bdab87f59 (patch) | |
tree | 2e69225353054eb43a9869af4ca9766a0f39c828 /src/tests/utests/chan1 | |
parent | bcee004478c6448541ce583e75c706e185190800 (diff) | |
download | kogata-6dd488b87fdc47fb377ba648a6cd598bdab87f59.tar.gz kogata-6dd488b87fdc47fb377ba648a6cd598bdab87f59.zip |
Implement select ; add two tests for channels.
Diffstat (limited to 'src/tests/utests/chan1')
l--------- | src/tests/utests/chan1/Makefile | 1 | ||||
-rw-r--r-- | src/tests/utests/chan1/test.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/utests/chan1/Makefile b/src/tests/utests/chan1/Makefile new file mode 120000 index 0000000..4630a7c --- /dev/null +++ b/src/tests/utests/chan1/Makefile @@ -0,0 +1 @@ +../rules.make
\ No newline at end of file diff --git a/src/tests/utests/chan1/test.c b/src/tests/utests/chan1/test.c new file mode 100644 index 0000000..1b89255 --- /dev/null +++ b/src/tests/utests/chan1/test.c @@ -0,0 +1,30 @@ +#include <string.h> + +#include <malloc.h> + +#include <syscall.h> +#include <debug.h> + +int main(int argc, char **argv) { + + fd_pair_t ch = make_channel(false); + + char* s = "Hello, world!"; + ASSERT(write(ch.a, 0, strlen(s), s) == strlen(s)); + char buf[128]; + ASSERT(read(ch.b, 0, 128, buf) == strlen(s)); + ASSERT(strncmp(s, buf, strlen(s)) == 0); + + close(ch.a); + sel_fd_t sel = { .fd = ch.b, .req_flags = SEL_ERROR }; + ASSERT(select(&sel, 1, 0)); + ASSERT(sel.got_flags & SEL_ERROR); + + close(ch.b); + + dbg_printf("(TEST-OK)\n"); + + return 0; +} + +/* vim: set ts=4 sw=4 tw=0 noet :*/ |