From owner-svn-src-user@freebsd.org Sun Oct 4 23:41:09 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 3F4A4A106DC for ; Sun, 4 Oct 2015 23:41:09 +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 302931C0D; Sun, 4 Oct 2015 23:41:09 +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 t94Nf9rQ085381; Sun, 4 Oct 2015 23:41:09 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t94Nf9Rw085380; Sun, 4 Oct 2015 23:41:09 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201510042341.t94Nf9Rw085380@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sun, 4 Oct 2015 23:41:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r288674 - 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: Sun, 04 Oct 2015 23:41:09 -0000 Author: ngie Date: Sun Oct 4 23:41:08 2015 New Revision: 288674 URL: https://svnweb.freebsd.org/changeset/base/288674 Log: - Speed up the testing process by moving socket creation with nc to the -F testcase - Make the -C testcase more robust to test input change - Adjust some input to adjust to changes in creation of the socket file 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 Sun Oct 4 23:38:35 2015 (r288673) +++ user/ngie/more-tests/bin/ls/tests/ls_tests.sh Sun Oct 4 23:41:08 2015 (r288674) @@ -53,8 +53,6 @@ create_test_inputs() atf_check -e empty -s exit:0 mkdir .g atf_check -e empty -s exit:0 mkfifo h atf_check -e ignore -s exit:0 dd if=/dev/zero of=i count=1000 bs=1 - atf_check -e empty -s exit:0 \ - sh -c "pid=${ATF_TMPDIR}/nc.pid; daemon -p \$pid nc -lU j; sleep 2; pkill -F \$pid" atf_check -e empty -s exit:0 touch klmn atf_check -e empty -s exit:0 touch opqr atf_check -e empty -s exit:0 touch stuv @@ -184,21 +182,53 @@ C_flag_head() atf_set "descr" "Verify that the output from ls -C is multi-column, sorted down" } +print_index() +{ + local i=1 + local wanted_index=$1; shift + + while [ $i -le $wanted_index ]; do + if [ $i -eq $wanted_index ]; then + echo $1 + return + fi + shift + : $(( i += 1 )) + done +} + C_flag_body() { create_test_inputs WITH_C=$PWD/../with_C.out + export COLUMNS=40 atf_check -e empty -o save:$WITH_C -s exit:0 ls -C echo "With -C usage" cat $WITH_C - atf_check -e ignore -o not-empty -s exit:0 \ - egrep "0b00000001[[:space:]]+0b00000111[[:space:]]+0b00001101[[:space:]]+e[[:space:]]+stuv" $WITH_C - atf_check -e ignore -o not-empty -s exit:0 \ - egrep "0b00000010[[:space:]]+0b00001000[[:space:]]+0b00001110[[:space:]]+h[[:space:]]+wxyz" $WITH_C + paths=$(find -s . -mindepth 1 -maxdepth 1 \! -name '.*' -exec basename {} \; ) + set -- $paths + num_paths=$# + num_columns=2 + + max_num_paths_per_column=$(( $(( $num_paths + 1 )) / $num_columns )) + + local i=1 + while [ $i -le $max_num_paths_per_column ]; do + column_1=$(print_index $i $paths) + column_2=$(print_index $(( $i + $max_num_paths_per_column )) $paths) + #echo "paths[$(( $i + $max_num_paths_per_column ))] = $column_2" + expected_expr="$column_1" + if [ -n "$column_2" ]; then + expected_expr="$expected_expr[[:space:]]+$column_2" + fi + atf_check -e ignore -o not-empty -s exit:0 \ + egrep "$expected_expr" $WITH_C + : $(( i += 1 )) + done } atf_test_case D_flag @@ -224,6 +254,9 @@ F_flag_body() { create_test_inputs + atf_check -e empty -s exit:0 \ + sh -c "pid=${ATF_TMPDIR}/nc.pid; daemon -p \$pid nc -lU j; sleep 2; pkill -F \$pid" + atf_check -e empty -o match:'a/' -s exit:0 ls -F atf_check -e empty -o match:'c@' -s exit:0 ls -F atf_check -e empty -o match:'h\|' -s exit:0 ls -F @@ -812,7 +845,7 @@ x_flag_body() atf_check -e ignore -o not-empty -s exit:0 \ egrep "a[[:space:]]+c[[:space:]]+d[[:space:]]+e[[:space:]]+h" $WITH_x atf_check -e ignore -o not-empty -s exit:0 \ - egrep "i[[:space:]]+j[[:space:]]+klmn[[:space:]]+opqr[[:space:]]+stuv" $WITH_x + egrep "i[[:space:]]+klmn[[:space:]]+opqr[[:space:]]+stuv[[:space:]]+wxyz" $WITH_x } atf_test_case y_flag