[PATCH v2 1/2] tests: add getcwd.test

Dmitry V. Levin ldv at altlinux.org
Fri Mar 18 23:29:21 UTC 2016


On Sat, Mar 19, 2016 at 02:10:17AM +0300, Dmitry V. Levin wrote:
> On Thu, Mar 17, 2016 at 05:32:11PM +0800, Fei Jie wrote:
[...]
> > +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.

getcwd is a bit more complicated than it looks.  Two more comments:

1. While 8192 is greater than PATH_MAX, I'd rather use PATH_MAX.
2. This test will fail if cwd contains special characters because
string_quote() will quote them but this printf won't.


-- 
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/e44b8e1b/attachment.bin>


More information about the Strace-devel mailing list