diff options
author | max99x <max99x@gmail.com> | 2011-07-20 10:20:09 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-07-21 02:48:24 +0300 |
commit | 10ca04685b6e0ec0e8089fbe859e0085d8020622 (patch) | |
tree | e256b40bfbf8324e73c977b82c36cc4a227f7be5 /tests/fcntl | |
parent | 278416d5426493959216d46279d3c40f91f33f81 (diff) |
Implemented <fcntl.h>.
Diffstat (limited to 'tests/fcntl')
-rw-r--r-- | tests/fcntl/output.txt | 42 | ||||
-rw-r--r-- | tests/fcntl/src.c | 80 |
2 files changed, 122 insertions, 0 deletions
diff --git a/tests/fcntl/output.txt b/tests/fcntl/output.txt new file mode 100644 index 00000000..1077e89b --- /dev/null +++ b/tests/fcntl/output.txt @@ -0,0 +1,42 @@ +F_DUPFD: 100 +errno: 0 + +F_DUPFD/error1: -1 +errno: 9 + +F_DUPFD/error2: -1 +errno: 22 + +F_GETFD: 0 +errno: 0 + +F_SETFD: 0 +errno: 0 + +F_GETFL: 2 +errno: 0 + +F_SETFL: 0 +errno: 0 + +F_GETFL/2: 0x402 +errno: 0 + +F_GETLK: 0 +errno: 0 +lk.l_type == F_UNLCK: 1 + +F_SETLK: 0 +errno: 0 + +F_SETLKW: 0 +errno: 0 + +F_SETOWN: -1 +errno: 22 + +F_GETOWN: -1 +errno: 22 + +INVALID: -1 +errno: 22 diff --git a/tests/fcntl/src.c b/tests/fcntl/src.c new file mode 100644 index 00000000..1e9a1536 --- /dev/null +++ b/tests/fcntl/src.c @@ -0,0 +1,80 @@ +#include <stdio.h> +#include <errno.h> +#include <fcntl.h> + +int main() { + int f = open("/test", O_RDWR, 0777); + + printf("F_DUPFD: %d\n", fcntl(f, F_DUPFD, 100)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_DUPFD/error1: %d\n", fcntl(50, F_DUPFD, 200)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_DUPFD/error2: %d\n", fcntl(f, F_DUPFD, -1)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_GETFD: %d\n", fcntl(f, F_GETFD)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_SETFD: %d\n", fcntl(f, F_SETFD)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_GETFL: %d\n", fcntl(f, F_GETFL)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_SETFL: %d\n", fcntl(f, F_SETFL, O_APPEND)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_GETFL/2: %#x\n", fcntl(f, F_GETFL)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + flock lk; + lk.l_type = 42; + printf("F_GETLK: %d\n", fcntl(f, F_GETLK, &lk)); + printf("errno: %d\n", errno); + printf("lk.l_type == F_UNLCK: %d\n", lk.l_type == F_UNLCK); + printf("\n"); + errno = 0; + + printf("F_SETLK: %d\n", fcntl(f, F_SETLK, &lk)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_SETLKW: %d\n", fcntl(f, F_SETLK, &lk)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_SETOWN: %d\n", fcntl(f, F_SETOWN, 123)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("F_GETOWN: %d\n", fcntl(f, F_GETOWN)); + printf("errno: %d\n", errno); + printf("\n"); + errno = 0; + + printf("INVALID: %d\n", fcntl(f, 123)); + printf("errno: %d\n", errno); + + return 0; +} |