Page MenuHomeFreeBSD

D11315.id29977.diff
No OneTemporary

D11315.id29977.diff

Index: bin/getfacl/tests/Makefile
===================================================================
--- /dev/null
+++ bin/getfacl/tests/Makefile
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+ATF_TESTS_SH+= getfacl_test
+
+.include <bsd.test.mk>
Index: bin/getfacl/tests/getfacl_test.sh
===================================================================
--- /dev/null
+++ bin/getfacl/tests/getfacl_test.sh
@@ -0,0 +1,157 @@
+#
+# Copyright 2017 Shivansh Rai
+# All rights reserved.
+#
+# 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.
+#
+# $FreeBSD$
+#
+
+set_umask()
+{
+ if ! umask 022; then
+ atf_fail "setting umask failed"
+ fi
+}
+
+check_acl()
+{
+ # Check if ACL is enabled on the root partition.
+ atf_check -s exit:0 -o match:'acls' echo "$(mount | head -n1)"
+}
+
+get_user()
+{
+ stat -f "%Su" "$1"
+}
+
+get_group()
+{
+ stat -f "%Sg" "$1"
+}
+
+get_user_perm()
+{
+ stat -f "%SHp" "$1"
+}
+
+get_group_perm()
+{
+ stat -f "%SMp" "$1"
+}
+
+get_other_perm()
+{
+ stat -f "%SLp" "$1"
+}
+
+atf_test_case no_opt_output
+no_opt_output_head()
+{
+ atf_set "descr" "Verify the output of the getfacl(1) command " \
+ "without any options."
+}
+
+no_opt_output_body()
+{
+ check_acl
+ set_umask
+ atf_check touch A
+ atf_check setfacl -m u::rw,g::r,o::r A
+ user_A=$(get_user A)
+ group_A=$(get_group A)
+ user_perm_A=$(get_user_perm A)
+ group_perm_A=$(get_group_perm A)
+ other_perm_A=$(get_other_perm A)
+ atf_check -o inline:'# file: A\n# owner: '"$user_A"'\n# group: '"$group_A"'\nuser::'"$user_perm_A"'\ngroup::'"$group_perm_A"'\nmask::'"$group_perm_A"'\nother::'"$other_perm_A"'\n' getfacl A
+}
+
+atf_test_case h_output_symbolic
+h_output_symbolic_head()
+{
+ atf_set "descr" "Verify that if the target of the operation is a symbolic " \
+ "link, then '-h' option returns the ACL from the symbolic " \
+ "link rather than following the link."
+}
+
+h_output_symbolic_body()
+{
+ check_acl
+ set_umask
+ atf_check touch A
+ atf_check setfacl -m u::rw,g::r,o::r A
+ atf_check ln -s A B
+ user_perm_B=$(get_user_perm B)
+ group_perm_B=$(get_group_perm B)
+ other_perm_B=$(get_other_perm B)
+ atf_check -o inline:'user::'"$user_perm_B"'\ngroup::'"$group_perm_B"'\nother::'"$other_perm_B"'\n' getfacl -hq B
+}
+
+atf_test_case q_output
+q_output_head()
+{
+ atf_set "descr" "Verify that '-q' option does not display commented " \
+ "information about file name and ownership."
+}
+
+q_output_body()
+{
+ check_acl
+ set_umask
+ atf_check touch A
+ atf_check setfacl -m u::rw,g::r,o::r A
+ user_perm_A=$(get_user_perm A)
+ group_perm_A=$(get_group_perm A)
+ other_perm_A=$(get_other_perm A)
+ atf_check -o inline:'user::'"$user_perm_A"'\ngroup::'"$group_perm_A"'\nmask::'"$group_perm_A"'\nother::'"$other_perm_A"'\n' getfacl -q A
+}
+
+atf_test_case symbolic_output
+symbolic_output_head()
+{
+ atf_set "descr" "Verify that if the target of the operation is a symbolic " \
+ "link, then getfacl(1) returns the ACL from the source of " \
+ "the symbolic link."
+}
+
+symbolic_output_body()
+{
+ check_acl
+ set_umask
+ atf_check touch A
+ atf_check setfacl -m u::rw,g::r,o::r A
+ atf_check ln -s A B
+ user_A=$(get_user A)
+ group_A=$(get_group A)
+ user_perm_A=$(get_user_perm A)
+ group_perm_A=$(get_group_perm A)
+ other_perm_A=$(get_other_perm A)
+ atf_check -o inline:'# file: B\n# owner: '"$user_A"'\n# group: '"$group_A"'\nuser::'"$user_perm_A"'\ngroup::'"$group_perm_A"'\nmask::'"$group_perm_A"'\nother::'"$other_perm_A"'\n' getfacl B
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case no_opt_output
+ atf_add_test_case h_output_symbolic
+ atf_add_test_case q_output
+ atf_add_test_case symbolic_output
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 12:14 AM (13 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30854782
Default Alt Text
D11315.id29977.diff (4 KB)

Event Timeline