Date: Tue, 25 Jul 2017 13:11:20 +0000 (UTC) From: Li-Wen Hsu <lwhsu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r321469 - head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs Message-ID: <201707251311.v6PDBKgC089032@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: lwhsu (ports committer) Date: Tue Jul 25 13:11:20 2017 New Revision: 321469 URL: https://svnweb.freebsd.org/changeset/base/321469 Log: Make this test case accepts basename() in D script returns "" or "." In Solaris, basename(1) and basename(3) both return "." while being given an empty string (""), while in BSD (and Linux) basename(1) returns "" and basename(3) returns "." While here, also change #!/usr/bin/ksh to #!/usr/bin/env ksh to find ksh in $PATH Reviewed by: gnn, markj (earlier version), ngie (earlier version) Differential Revision: https://reviews.freebsd.org/D11707 Modified: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out Modified: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d ============================================================================== --- head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d Tue Jul 25 13:07:06 2017 (r321468) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d Tue Jul 25 13:11:20 2017 (r321469) @@ -55,12 +55,16 @@ BEGIN dir[i++] = "f"; dir[i++] = "f/"; dir[i++] = "/////"; + /* + * basename(3) and basename(1) return different results for the empty + * string on FreeBSD, so we need special handling. dir[i++] = ""; + */ end = i; i = 0; - printf("#!/usr/bin/ksh\n\n"); + printf("#!/usr/bin/env ksh\n\n"); } tick-1ms @@ -84,5 +88,19 @@ tick-1ms tick-1ms /i == end/ { + dir[i] = ""; + printf("if [ \"`basename \"%s\"`\" != \"%s\" -a \".\" != \"%s\" ]; then\n", + dir[i], basename(dir[i]), basename(dir[i])); + printf(" echo \"basename(\\\"%s\\\") is \\\"%s\\\"; ", + dir[i], basename(dir[i])); + printf("expected \\\"`basename \"%s\"`\\\" or \\\".\\\"\"\n", dir[i]); + printf("fi\n\n"); + printf("if [ `dirname \"%s\"` != \"%s\" ]; then\n", + dir[i], dirname(dir[i])); + printf(" echo \"dirname(\\\"%s\\\") is \\\"%s\\\"; ", + dir[i], dirname(dir[i])); + printf("expected \\\"`dirname \"%s\"`\"\\\"\n", dir[i]); + printf("fi\n\n"); + exit(0); } Modified: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out ============================================================================== --- head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out Tue Jul 25 13:07:06 2017 (r321468) +++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.basename.d.out Tue Jul 25 13:11:20 2017 (r321469) @@ -1,4 +1,4 @@ -#!/usr/bin/ksh +#!/usr/bin/env ksh if [ `basename "/foo/bar/baz"` != "baz" ]; then echo "basename(\"/foo/bar/baz\") is \"baz\"; expected \"`basename "/foo/bar/baz"`"\" @@ -152,8 +152,8 @@ if [ `dirname "/////"` != "/" ]; then echo "dirname(\"/////\") is \"/\"; expected \"`dirname "/////"`"\" fi -if [ `basename ""` != "." ]; then - echo "basename(\"\") is \".\"; expected \"`basename ""`"\" +if [ "`basename ""`" != "." -a "." != "." ]; then + echo "basename(\"\") is \".\"; expected \"`basename ""`\" or \".\"" fi if [ `dirname ""` != "." ]; then
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707251311.v6PDBKgC089032>