[PATCH v2 1/2] tests: add getcwd.test
Dmitry V. Levin
ldv at altlinux.org
Fri Mar 18 23:10:17 UTC 2016
On Thu, Mar 17, 2016 at 05:32:11PM +0800, Fei Jie wrote:
> * tests/getcwd.c: New file.
> * tests/getcwd.test: New test.
> * tests/.gitignore: Add getcwd.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (TESTS): Add getcwd.test.
> ---
> tests/.gitignore | 1 +
> tests/Makefile.am | 2 ++
> tests/getcwd.c | 26 ++++++++++++++++++++++++++
> tests/getcwd.test | 11 +++++++++++
> 4 files changed, 40 insertions(+)
> create mode 100644 tests/getcwd.c
> create mode 100755 tests/getcwd.test
>
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 93ffa0b..d5c4a2c 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 6590f95..c6c293e 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -92,6 +92,7 @@ check_PROGRAMS = \
> fstatat64 \
> ftruncate \
> ftruncate64 \
> + getcwd \
> getdents \
> getdents64 \
> getrandom \
> @@ -267,6 +268,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 0000000..ae93307
> --- /dev/null
> +++ b/tests/getcwd.c
> @@ -0,0 +1,26 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_getcwd
> +
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +static char buf[8192];
> +
> +int
> +main(void)
> +{
> + int rc = syscall(__NR_getcwd, buf, sizeof(buf));
> + printf("getcwd(\"%s\", %u) = %d\n",
> + buf, (unsigned) sizeof(buf), rc);
> +
> + puts("+++ exited with 0 +++");
> + return 0;
> +}
That's OK, thanks. May I ask you to add a case of failed getcwd in
addition to this one? Any error code would do. The simplest seems to be
syscall(__NR_getcwd, buf, 0);
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160319/5b1f36a7/attachment.bin>
More information about the Strace-devel
mailing list