Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146110044
D40611.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D40611.diff
View Options
diff --git a/bin/pwd/Makefile b/bin/pwd/Makefile
--- a/bin/pwd/Makefile
+++ b/bin/pwd/Makefile
@@ -1,7 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD$
+.include <src.opts.mk>
+
PACKAGE=runtime
PROG= pwd
-.include <bsd.prog.mk>
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+.include <bsd.prog.mk>
\ No newline at end of file
diff --git a/bin/pwd/tests/Makefile b/bin/pwd/tests/Makefile
new file mode 100644
--- /dev/null
+++ b/bin/pwd/tests/Makefile
@@ -0,0 +1,6 @@
+PACKAGE= tests
+
+ATF_TESTS_SH= pwd_test
+BINDIR= ${TESTSDIR}
+
+.include <bsd.test.mk>
diff --git a/bin/pwd/tests/pwd_test.sh b/bin/pwd/tests/pwd_test.sh
new file mode 100644
--- /dev/null
+++ b/bin/pwd/tests/pwd_test.sh
@@ -0,0 +1,81 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2023 The FreeBSD Foundation
+#
+# This software was developed1 by Yan-Hao Wang <bses30074@gmail.com>
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE
+#
+
+atf_test_case basic
+basic_head()
+{
+ atf_set "descr" "Test on common directory"
+}
+basic_body()
+{
+ mkdir directory
+ cd directory || exit
+ atf_check -o match:"^.*\/directory$" pwd
+ atf_check -o match:"^.*\/directory$" pwd -L
+ atf_check -o match:"^.*\/directory$" pwd -P
+}
+
+atf_test_case soft_link
+soft_link_head()
+{
+ atf_set "descr" "Test on the softlink directory"
+}
+soft_link_body()
+{
+ mkdir soft_link_src
+ ln -s soft_link_src soft_link_dst
+ cd soft_link_dst || exit
+ atf_check -o match:"^.*\/soft_link_src$" pwd
+ atf_check -o match:"^.*\/soft_link_dst$" pwd -L
+ atf_check -o match:"^.*\/soft_link_src$" pwd -P
+}
+
+atf_test_case broken_soft_link
+broken_soft_link_head()
+{
+ atf_set "descr" "Test on the broken softlink directory"
+}
+broken_soft_link_body()
+{
+ mkdir broken_soft_link_src
+ ln -s broken_soft_link_src broken_soft_link_dst
+ cd broken_soft_link_dst || exit
+ rm -r ../broken_soft_link_src
+ atf_check -s exit:1 -e inline:"pwd: .: No such file or directory\n" pwd
+ atf_check -s exit:1 -e inline:"pwd: .: No such file or directory\n" pwd -L
+ atf_check -s exit:1 -e inline:"pwd: .: No such file or directory\n" pwd -P
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case basic
+ atf_add_test_case soft_link
+ atf_add_test_case broken_soft_link
+}
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -40,6 +40,8 @@
..
rmdir
..
+ pwd
+ ..
sh
builtins
..
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Feb 28, 9:53 PM (6 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29061473
Default Alt Text
D40611.diff (3 KB)
Attached To
Mode
D40611: Add `pwd` test
Attached
Detach File
Event Timeline
Log In to Comment