From owner-svn-src-user@freebsd.org Fri Oct 2 06:34:35 2015 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70A5EA0E45A for ; Fri, 2 Oct 2015 06:34:35 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 544C11203; Fri, 2 Oct 2015 06:34:35 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t926YZPg031764; Fri, 2 Oct 2015 06:34:35 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t926YZW8031763; Fri, 2 Oct 2015 06:34:35 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201510020634.t926YZW8031763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Fri, 2 Oct 2015 06:34:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r288476 - user/ngie/more-tests/bin/ls/tests X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Oct 2015 06:34:35 -0000 Author: ngie Date: Fri Oct 2 06:34:34 2015 New Revision: 288476 URL: https://svnweb.freebsd.org/changeset/base/288476 Log: Add testcases for ls -q, ls -w, and ls -y Modified: user/ngie/more-tests/bin/ls/tests/ls_tests.sh Modified: user/ngie/more-tests/bin/ls/tests/ls_tests.sh ============================================================================== --- user/ngie/more-tests/bin/ls/tests/ls_tests.sh Fri Oct 2 06:24:09 2015 (r288475) +++ user/ngie/more-tests/bin/ls/tests/ls_tests.sh Fri Oct 2 06:34:34 2015 (r288476) @@ -76,40 +76,6 @@ create_test_inputs() atf_check -e empty -s exit:0 touch 0b00001111 } -atf_test_case a_flag -a_flag_head() -{ - atf_set "descr" "Verify -a support" -} - -a_flag_body() -{ - create_test_dir - - # Make sure "." and ".." show up with -a - atf_check -e empty -o match:'\.[[:space:]]+\.\.' -s exit:0 ls -ax - - create_test_inputs - - WITH_a=$PWD/../with_a.out - WITHOUT_a=$PWD/../without_a.out - - atf_check -e empty -o save:$WITH_a -s exit:0 ls -A - atf_check -e empty -o save:$WITHOUT_a -s exit:0 ls - - echo "-A usage" - cat $WITH_a - echo "No -A usage" - cat $WITHOUT_a - - for dot_path in '\.f' '\.g'; do - atf_check -e empty -o not-empty -s exit:0 grep "${dot_path}" \ - $WITH_a - atf_check -e empty -o empty -s not-exit:0 grep "${dot_path}" \ - $WITHOUT_a - done -} - atf_test_case A_flag A_flag_head() { @@ -251,6 +217,60 @@ I_flag_voids_implied_A_flag_when_root_bo atf_check -o match:'\.g' -s exit:0 ls -A -I } +L_flag_and_P_flag_head() +{ + atf_set "descr" "Verify that -L prints out the symbolic link and conversely -P prints out the target for the symbolic link" +} + +L_flag_and_P_flag_body() +{ + atf_expect_fail "XXX: this is currently broken" + + atf_check -e empty -o empty -s exit:0 mkdir a + atf_check -e empty -o empty -s exit:0 ln -s a/ b + atf_check -e empty -o match:b ls -L b + atf_check -e empty -o match:a ls -P b + + atf_check -e empty -o empty -s exit:0 touch c + atf_check -e empty -o empty -s exit:0 ln -s c d + atf_check -e empty -o match:d ls -L d + atf_check -e empty -o match:c ls -P d +} + +atf_test_case a_flag +a_flag_head() +{ + atf_set "descr" "Verify -a support" +} + +a_flag_body() +{ + create_test_dir + + # Make sure "." and ".." show up with -a + atf_check -e empty -o match:'\.[[:space:]]+\.\.' -s exit:0 ls -ax + + create_test_inputs + + WITH_a=$PWD/../with_a.out + WITHOUT_a=$PWD/../without_a.out + + atf_check -e empty -o save:$WITH_a -s exit:0 ls -a + atf_check -e empty -o save:$WITHOUT_a -s exit:0 ls + + echo "-a usage" + cat $WITH_a + echo "No -a usage" + cat $WITHOUT_a + + for dot_path in '\.f' '\.g'; do + atf_check -e empty -o not-empty -s exit:0 grep "${dot_path}" \ + $WITH_a + atf_check -e empty -o empty -s not-exit:0 grep "${dot_path}" \ + $WITHOUT_a + done +} + lcomma_flag_head() { atf_set "descr" "Verify that -l, prints out the size with , delimiters" @@ -265,24 +285,23 @@ lcomma_flag_body() env LC_ALL=en_US.ISO8859-1 ls -l, i } -L_flag_and_P_flag_head() +q_flag_and_w_flag_head() { - atf_set "descr" "Verify that -L prints out the symbolic link and conversely -P prints out the target for the symbolic link" + atf_set "descr" "Verify that the output from ls -q prints out '?' for ESC and ls -w prints out the escape character" } -L_flag_and_P_flag_body() +q_flag_and_w_flag_body() { - atf_expect_fail "XXX: this is currently broken" + atf_skip "kyua report-jenkins doesn't properly escape non-printable chars: https://github.com/jmmv/kyua/issues/136" - atf_check -e empty -o empty -s exit:0 mkdir a - atf_check -e empty -o empty -s exit:0 ln -s a/ b - atf_check -e empty -o match:b ls -L b - atf_check -e empty -o match:a ls -P b + create_test_dir - atf_check -e empty -o empty -s exit:0 touch c - atf_check -e empty -o empty -s exit:0 ln -s c d - atf_check -e empty -o match:d ls -L d - atf_check -e empty -o match:c ls -P d + test_file="$(printf "y\01z")" + + atf_check -e empty -o empty -s exit:0 touch "$test_file" + + atf_check -e empty -o match:'y\?z' -s exit:0 ls -q "$test_file" + atf_check -e empty -o match:"$test_file" -s exit:0 ls -w "$test_file" } x_flag_head() @@ -307,6 +326,29 @@ x_flag_body() egrep "i[[:space:]]+j[[:space:]]+klmn[[:space:]]+opqr[[:space:]]+stuv" $WITH_x } +y_flag_head() +{ + atf_set "descr" "Verify that the output from ls -y sorts the same way as sort(1)" +} + +y_flag_body() +{ + create_test_inputs + + WITH_sort=$PWD/../with_sort.out + WITH_y=$PWD/../with_y.out + + atf_check -e empty -o save:$WITH_sort -s exit:0 sh -c 'ls -1 | sort' + atf_check -e empty -o save:$WITH_y -s exit:0 ls -1y + + echo "Sorted with sort(1)" + cat $WITH_sort + echo "Sorted with -y" + cat $WITH_y + + atf_check_equal "$(cat $WITH_sort)" "$(cat $WITH_y)" +} + 1_flag_head() { atf_set "descr" "Verify that -1 prints out one item per line" @@ -366,13 +408,12 @@ atf_init_test_cases() #atf_add_test_case n_flag #atf_add_test_case o_flag #atf_add_test_case p_flag - #atf_add_test_case q_flag + 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 t_flag #atf_add_test_case u_flag - #atf_add_test_case w_flag atf_add_test_case x_flag - #atf_add_test_case y_flag + atf_add_test_case y_flag atf_add_test_case 1_flag }