aboutsummaryrefslogtreecommitdiff
path: root/bin/ls/tests/ls_tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ls/tests/ls_tests.sh')
-rwxr-xr-xbin/ls/tests/ls_tests.sh51
1 files changed, 41 insertions, 10 deletions
diff --git a/bin/ls/tests/ls_tests.sh b/bin/ls/tests/ls_tests.sh
index 14f7895e699c..c732b60b21a4 100755
--- a/bin/ls/tests/ls_tests.sh
+++ b/bin/ls/tests/ls_tests.sh
@@ -24,7 +24,6 @@
# (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$
#
create_test_dir()
@@ -525,18 +524,19 @@ f_flag_body()
atf_test_case g_flag
g_flag_head()
{
- atf_set "descr" "Verify that -g does nothing (compatibility flag)"
+ atf_set "descr" "Verify that -g implies -l but omits the owner name field"
}
g_flag_body()
{
- create_test_inputs2
- for file in $files; do
- atf_check -e empty -o match:"$(ls -a $file)" -s exit:0 \
- ls -ag $file
- atf_check -e empty -o match:"$(ls -la $file)" -s exit:0 \
- ls -alg $file
- done
+ atf_check -e empty -o empty -s exit:0 touch a.file
+
+ mtime_in_secs=$(stat -f "%m" -t "%s" a.file)
+ mtime=$(date -j -f "%s" $mtime_in_secs +"%b[[:space:]]+%e[[:space:]]+%H:%M")
+
+ expected_output=$(stat -f "%Sp[[:space:]]+%l[[:space:]]+%Sg[[:space:]]+%z[[:space:]]+$mtime[[:space:]]+a\\.file" a.file)
+
+ atf_check -e empty -o match:"$expected_output" -s exit:0 ls -g a.file
}
atf_test_case h_flag
@@ -689,7 +689,7 @@ n_flag_body()
atf_check -e empty \
-o match:'\-rw\-r\-\-r\-\-[[:space:]]+1[[:space:]]+'"$nobody_uid[[:space:]]+$daemon_gid"'[[:space:]]+.+a\.file' \
- ls -ln a.file
+ ls -n a.file
}
@@ -800,6 +800,21 @@ s_flag_body()
done
}
+atf_test_case scomma_flag
+scomma_flag_head()
+{
+ atf_set "descr" "Verify that -s, prints out the size with ',' delimiters"
+}
+
+scomma_flag_body()
+{
+ export LC_ALL=en_US.UTF-8
+ atf_check -e ignore dd if=/dev/urandom of=file bs=65536 count=64
+ blocks=$(stat -f "%b" file)
+ cblocks=$(printf "%'d" $blocks)
+ atf_check -e empty -o match:"$cblocks[[:space:]]+file" ls -s, file
+}
+
atf_test_case t_flag
t_flag_head()
{
@@ -846,6 +861,20 @@ u_flag_body()
atf_check -e empty -o match:'a\.file.*b\.file' -s exit:0 ls -Cu
}
+atf_test_case v_flag
+v_flag_head()
+{
+ atf_set "descr" "Verify that the output from ls -v sorts based on strverscmp(3)"
+}
+
+v_flag_body()
+{
+ create_test_dir
+
+ atf_check -e empty -o empty -s exit:0 touch 000 00 01 010 09 0 1 9 10
+ atf_check -e empty -o match:"000.00.01.010.09.0.1.9.10" -s exit:0 sh -c 'ls -Cv'
+}
+
atf_test_case x_flag
x_flag_head()
{
@@ -958,8 +987,10 @@ atf_init_test_cases()
atf_add_test_case q_flag_and_w_flag
atf_add_test_case r_flag
atf_add_test_case s_flag
+ atf_add_test_case scomma_flag
atf_add_test_case t_flag
atf_add_test_case u_flag
+ atf_add_test_case v_flag
atf_add_test_case x_flag
atf_add_test_case y_flag
atf_add_test_case 1_flag