On Tue, Mar 15, 2016 at 04:38:35PM +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 6059af9..8312930 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 6d1c771..2a2f3a3 100644 > --- a/tests/Makefile.am > +++ b/tests/Makefile.am > @@ -92,6 +92,7 @@ check_PROGRAMS = \ > fstatat64 \ > ftruncate \ > ftruncate64 \ > + getcwd \ > getdents \ > getdents64 \ > getrandom \ > @@ -266,6 +267,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..7683d27 > --- /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, 8192);
Note that getcwd might fail, but you still can assume that it will succeed because a lot of other things are likely to go wrong otherwise. > + printf("getcwd(\"%s\", 8192) = %d\n", > + buf, rc); Using 8192 instead of sizeof(buf) is not an example of good style. > + > + 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 0000000..48e7a91 > --- /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 -a23 $args > "$OUT" > +match_diff "$LOG" "$OUT" > +rm -f "$OUT" 23 might be too big. -- ldv
pgpyilJ7FJxQK.pgp
Description: PGP signature
------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________ Strace-devel mailing list Strace-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/strace-devel