From: JayRJoshi Date: Wed, 23 Mar 2016 13:38:35 +0000 (+0530) Subject: tests: add getcwd.test X-Git-Tag: v4.12~507 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=39ab12062611579720be6f64f40a34599c8195af;p=strace tests: add getcwd.test * tests/getcwd.c: New file. * tests/getcwd.test: New test. * tests/.gitignore: Add getcwd. * tests/Makefile.am (check_PROGRAMS): Likewise. (TESTS): Add getcwd.test. --- diff --git a/tests/.gitignore b/tests/.gitignore index 449af182..d1fb6d49 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -42,6 +42,7 @@ fstat64 fstatat64 ftruncate ftruncate64 +getcwd getdents getdents64 getrandom diff --git a/tests/Makefile.am b/tests/Makefile.am index add44efe..60b1087e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -93,6 +93,7 @@ check_PROGRAMS = \ fstatat64 \ ftruncate \ ftruncate64 \ + getcwd \ getdents \ getdents64 \ getrandom \ @@ -269,6 +270,7 @@ TESTS = \ fstatat64.test \ ftruncate.test \ ftruncate64.test \ + getcwd.test \ getdents.test \ getdents64.test \ getrandom.test \ diff --git a/tests/getcwd.c b/tests/getcwd.c new file mode 100644 index 00000000..3135df22 --- /dev/null +++ b/tests/getcwd.c @@ -0,0 +1,39 @@ +#include "tests.h" + +#include + +#ifdef __NR_getcwd + +# include +# include +# include + +int +main(void) +{ + long res; + char cur_dir[PATH_MAX + 1]; + + res = syscall(__NR_getcwd, cur_dir, sizeof(cur_dir)); + + if (res <= 0) + perror_msg_and_fail("getcwd"); + + printf("getcwd(\""); + print_quoted_string(cur_dir); + printf("\", %zu) = %ld\n", sizeof(cur_dir), res); + + syscall(__NR_getcwd, cur_dir, 0); + + printf("getcwd(%p, 0) = -1 ERANGE (%m)\n", cur_dir); + + puts("+++ exited with 0 +++"); + + return 0; +} + +#else + +SKIP_MAIN_UNDEFINED("__NR_getcwd"); + +#endif diff --git a/tests/getcwd.test b/tests/getcwd.test new file mode 100755 index 00000000..12f77edc --- /dev/null +++ b/tests/getcwd.test @@ -0,0 +1,11 @@ +#!/bin/sh + +# Check getcwd syscall decoding. + +. "${srcdir=.}/init.sh" + +run_prog > /dev/null +OUT="$LOG.out" +run_strace -egetcwd -a18 $args > "$OUT" +match_diff "$LOG" "$OUT" +rm -f "$OUT"