From 536354a9c18c2488df9893bd2e13be4cc3f395fe Mon Sep 17 00:00:00 2001 From: Athmane Madjoudj Date: Jul 25 2013 03:08:16 +0000 Subject: Add tests from iaind's branch --- diff --git a/tests/p_cpio/0_install_cpio b/tests/p_cpio/0_install_cpio new file mode 100755 index 0000000..a42ac10 --- /dev/null +++ b/tests/p_cpio/0_install_cpio @@ -0,0 +1,6 @@ +#!/bin/bash +# Author: Iain Douglas +#Ensure the packeages we require are available + +t_Log "Running $0 installing required packages" +t_InstallPackage cpio diffutils diff --git a/tests/p_cpio/10-cpio-tests b/tests/p_cpio/10-cpio-tests new file mode 100755 index 0000000..80c8d41 --- /dev/null +++ b/tests/p_cpio/10-cpio-tests @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Author: Iain Douglas +# + +ExitFail() { + t_Log "FAIL" + exit $FAIL +} + +# Basic tests for cpio + +OUTDIR=/var/tmp/cpio/cpio_out +INDIR=/var/tmp/cpio/cpio_in +PASSDIR=/var/tmp/cpio/cpio_pass + +[ -d /var/tmp/cpio ] && rm -rf /var/tmp/cpio +mkdir -p "$OUTDIR" +mkdir -p "$INDIR" +mkdir -p "$PASSDIR" + +# create a basic cpio archive +echo "Basic copy out test" + +ls | cpio -o > "$OUTDIR"/cpio.out +t_CheckExitStatus $? + +# Basic copy incheck" +echo "Basic copy in test" +pushd "$INDIR" +cpio -i <"$OUTDIR"/cpio.out +t_CheckExitStatus $? +popd +# Basic pass through mode" +echo "Basis pass through test" + +pushd $INDIR +find . | cpio -pd "$PASSDIR" +t_CheckExitStatus $? +popd + +# Check that $PASSDIR and $INDIR are the same +echo "Check that the working directories are the same" +diff $PASSDIR $INDIR &>/dev/null +t_CheckExitStatus $? + +#rm -rf /var/tmp/cpio diff --git a/tests/p_diffutils/0_install_diffutils b/tests/p_diffutils/0_install_diffutils index b877b34..5da57fa 100755 --- a/tests/p_diffutils/0_install_diffutils +++ b/tests/p_diffutils/0_install_diffutils @@ -1,5 +1,5 @@ #!/bin/bash -# Author: Iain Doglas +# Author: Iain Douglas #Ensure the packeages we require are available t_Log "Running $0 installing required packages" diff --git a/tests/p_diffutils/20-diff-tests b/tests/p_diffutils/20-diff-tests index 9560e06..878842c 100755 --- a/tests/p_diffutils/20-diff-tests +++ b/tests/p_diffutils/20-diff-tests @@ -5,8 +5,352 @@ # Basic Tests +ExitFail() { + t_Log "FAIL" + exit $FAIL +} + t_Log "Running $0 - diff tests" diff -v &>/dev/null t_CheckExitStatus $? +F1=/var/tmp/testf1.txt +F2=/var/tmp/testf2.txt + + +# Most of the following tests are taken from the examples in the info +# documentation for diffutils. +# +# Create a couple of files to work with. We'll use sed to make changes as we +# go. + +TEXT="Here lyeth muche rychnesse in lytell space. -- John Heywood" +echo $TEXT >$F1 +cp $F1 $F2 + +# Start by checking the options that determine how whitespace and case are +# handled -E -b -w -B -i -I -q and their long form variants + +# Baseline check to ensure diff sees the files are the same. +echo "Check files are the same" +diff $F1 $F2 +t_CheckExitStatus $? + +# Convert a to in F2 then check that diff sees the change +# as it should. + +sed -i 's/ / \t/' $F2 +echo "Check different files" +diff $F1 $F2 &>/dev/null && ExitFail +t_Log "PASS" + +# Convert the first space in $F1 to 4 spaces and check that -E and +# --ignore-tab-expansion works and sees no difference between the +# two files. + +echo "Check diff -E" +sed -i 's/ / /' $F1 +diff -E $F1 $F2 +t_CheckExitStatus $? +echo "Check diff --ignore-tab-expansion" +diff --ignore-tab-expansion $F1 $F2 +t_CheckExitStatus $? + +# reduce the 4 spaces to 3 and check diff -E sees a difference +echo "Check diff -E sees a difference in whitespace" +sed -i 's/ / /' $F1 +diff -E $F1 $F2 &>/dev/null && ExitFail +t_Log "PASS" + +# Check -b --ignore-space-change add some spaces to the end of the line +# to make sure. +sed -i 's/$/ /' $F1 +echo "Check diff -b" +diff -b $F1 $F2 +t_CheckExitStatus $? +echo "Check diff --ignore-space-change" +diff --ignore-space-change $F1 $F2 +t_CheckExitStatus $? + +# The -b option ignotes difference in whitespace where it already exists. +# Check that whitespace added in $F1 where non exists in $F2 is caught by +# -b +echo "Check diff -b sees whitespace where non exists" +sed -i 's/ss/s s/' $F1 +diff -b $F1 $F2 &>/dev/null && ExitFail +t_Log "PASS" + +# Check -w --ignore-all-space +echo "Check diff -w" +diff -w $F1 $F2 +t_CheckExitStatus $? +echo "Check diff --ignore-all-space" +diff --ignore-all-space $F1 $F2 +t_CheckExitStatus $? + +# Check -B --ignore blank lines, create some new files to work with first. + +echo $TEXT>$F1 +echo $TEXT>>$F1 +echo $TEXT>$F2 +echo "" >>$F2 +echo $TEXT>>$F2 + +# Check that diff sees the new test files are different. +echo "-B --ignore blank lines, pre check files are different" +diff $F1 $F2 &>/dev/null && ExitFail +t_Log "PASS" + +echo "Check diff -B" +diff -B $F1 $F2 +t_CheckExitStatus $? +echo "Check diff --ignore-blank-lines" +diff --ignore-blank-lines $F1 $F2 +t_CheckExitStatus $? + +# Check -i --ignore-case, first ensure that diff sees a difference in case, +# as we're using the files from the earlier test we need to use the -B option +# too. + +echo "Check test file is different" +sed -i 's/l/L/g' $F1 +diff -B $F1 $F2 &>/dev/null && ExitFail +t_Log "PASS" + +# Check that -i causes diff to ignore the difference in case. +echo "Check diff -i" +diff -B -i $F1 $F2 +t_CheckExitStatus $? +echo "Check diff --ignore-case" +diff -B --ignore-case $F1 $F2 +t_CheckExitStatus $? + +# Check -I --ignore-matching-lines=regexp +echo $TEXT >$F1 +echo "1"$TEXT"1" >>$F1 +echo "1"$TEXT >$F2 +echo $TEXT >>$F2 +echo "Check test files are different" +diff $F1 $F2 &>/dev/null && ExitFail +t_Log "PASS" +echo "Check -I" +diff -I '^[[:digit:]]' $F1 $F2 +t_CheckExitStatus $? +echo "Check --ignore-matching-lines=regexp" +diff --ignore-matching-lines='^[[:digit:]]' $F1 $F2 +t_CheckExitStatus $? + +# Check -q --brief +echo "Check diff -q" +diff -q $F1 $F2 | grep -q "Files /var/tmp/testf1.txt and /var/tmp/testf2.txt differ" +t_CheckExitStatus $? +echo "diff --brief" +diff --brief $F1 $F2 | grep -q "Files /var/tmp/testf1.txt and /var/tmp/testf2.txt differ" +t_CheckExitStatus $? + +# Check output formats are correct, again the examples from the info docs are +# used in the tests as are the lao and tzu texts. As we've previously testes +# cmp it should be safe to use to compare the generated output against known +# correct output. +# +# start with normal format +echo "Check diff output formats" + +DIR=./tests/p_diffutils +FILES="$DIR"/files + +echo "Check normal output format" +diff "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/normal_format - +t_CheckExitStatus $? + +# Check contxt format - note that this outputs time information that we will +# ignore by skipping the first 3 lines + +echo Check default context format -c + +diff -c "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/context_format - +t_CheckExitStatus $? + +# Check contect format with only 1 line +echo "Check context format with Less Context -C 1" +diff -C 1 "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/context_format-1 - +t_CheckExitStatus $? + +# Check unified format again there are timestams which we will ignore +echo "Check unified format " +diff -u "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/unified_format - +t_CheckExitStatus $? + +# Check unified shortend format -U lines and the long form option +# --unified=lines, in both cases we'll use 1 for lines. +echo "Check unified output with less context -U 1" +diff -U 1 "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/unified_format-1 - +t_CheckExitStatus $? + +echo "Check unified output with less context --unified=1" +diff --unified=1 "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/unified_format-1 - +t_CheckExitStatus $? + +# Check we can change the labels +echo "Check the --label option" +diff -C 2 --label=original --label=modified "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/label-change +t_CheckExitStatus $? + +# Check side-by-side output width = 72 +echo "Check side-by-side" output -y -W 72 +diff -t -y -W 72 "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/side-by-side-W72 - +t_CheckExitStatus $? + +# Check side-by-side with left column suppression +echo "Check left column suppression in side-by-side output" +diff --width=72 -y --left-column "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/left_column -t_CheckExitStatus $? + +# Check side-by-side with common line suppression +echo "Check left column suppression in side-by-side output" +diff --width=72 -y --suppress-common-lines "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/supress_common_lines - +t_CheckExitStatus $? + +# Check an ed script is correctly generated +echo "Check an ed script is correctly generated diff -e" +diff -e "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/ed_script - +t_CheckExitStatus $? + +# Check diff -f --forward-ed works +echo "Check that a forward ed script is generated -f " +diff -f "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/ed_script-f - +t_CheckExitStatus $? +echo "Check that a forward ed script is generated --forward-ed " +diff --forward-ed "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/ed_script-f - +t_CheckExitStatus $? + +# Check RCS script generation -n --rcs +echo "Check RCS scripts are generated -n" +diff -n "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/rcs_script - +t_CheckExitStatus $? +echo "Check RCS scripts are generated --rcs" +diff --rcs "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/rcs_script - +t_CheckExitStatus $? + +# Check if-then-else output diff -D --ifdef +echo "Check -D output" +diff -DTWO "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/if_then_else - +t_CheckExitStatus $? + +echo "Check --ifdef output" +diff --ifdef=TWO "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/if_then_else - +t_CheckExitStatus $? + +# Check Incomplete last line (no \n) +echo "Checking incomplete last line - normal" +diff "$FILES"/F "$FILES"/G | cmp "$FILES"/F-G - +t_CheckExitStatus $? + +echo "Checking incomplete last line -n" +diff -n "$FILES"/F "$FILES"/G | cmp "$FILES"/n_F-G - +t_CheckExitStatus $? + +echo "Checking incomplete last line -e" +diff -e "$FILES"/F "$FILES"/G 2>&1 | cmp "$FILES"/e_F-G +t_CheckExitStatus $? + +# Check diff output to -l --paginate, the header is variable so skip over it +echo "Check diff output to pager -l" +diff -l "$FILES"/lao "$FILES"/tzu |tail -n +4 | cmp "$FILES"/paginate - +t_CheckExitStatus $? + +echo "Check diff output to pager -l" +diff -l "$FILES"/lao "$FILES"/tzu | tail -n +4 | cmp "$FILES"/paginate - +t_CheckExitStatus $? + + +# Directories tested from here down +# Setup a directory structure and populate it with files to work with +# +DIRTEST=/var/tmp/difftest + +[[ -d "$DIRTEST" ]] && rm -r "$DIRTEST" +mkdir "$DIRTEST" +mkdir -p "$DIRTEST"/a/1 +mkdir -p "$DIRTEST"/b/1 +cp "$FILES"/lao "$DIRTEST"/a +cp "$FILES"/lao "$DIRTEST"/b +cp "$FILES"/tzu "$DIRTEST"/a +cp "$FILES"/tao "$DIRTEST"/a/1 + +# Check plain diff of 2 directories +echo "Check basic directory comparison" +diff "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir - +t_CheckExitStatus $? + +# Check -s --report-identical-files +echo "Check identical files reported -s" +diff -s "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_s - +t_CheckExitStatus $? + +echo "Check identical files reported --report-identical-files" +diff --report-identical-files "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_s - +t_CheckExitStatus $? + +# Check recursive directory diff +echo "Check recursive directory diff -r" +diff -sr "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_r - +t_CheckExitStatus $? + +echo "Check recursive directory diff --recursive" +diff -s --recursive "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_r - +t_CheckExitStatus $? + +# Check -N --new-file output +echo "Check directory diff -N" +diff -Nsr "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_N - +t_CheckExitStatus $? + +echo "Check directory diff --new-file" +diff --new-file -sr "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_new_file - +t_CheckExitStatus $? + +# Check diff --unidirectional-new-file. Swap the command line arguments +# around to make this work + +echo "Check directory diff --unidirectional-new-file" +diff --unidirectional-new-file "$DIRTEST"/b "$DIRTEST"/a | cmp "$FILES"/dir_unidirectional - +t_CheckExitStatus $? + +# Check we can ignore patterns with diff in directory mode -x +echo "Check diff -x excludes file patterns" +diff -x tz* "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_x - +t_CheckExitStatus $? + +# Check we can ignore patterns read from a file with diff in directory mode +# -X --exclude-from= +echo "Check diff -X excludes file patterns" +diff -X "$FILES"/exclude "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_x - +t_CheckExitStatus $? + +echo "Check diff --exclude-from excludes file patterns" +diff --exclude-from="$FILES"/exclude "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_x - +t_CheckExitStatus $? + +# Check we can exclude differences based on file name case +# https://bugzilla.redhat.com/show_bug.cgi?id=719001 +# +mv "$DIRTEST"/a/lao "$DIRTEST"/a/LAO +echo "Checking --ignore-file-name-case" +echo "see https://bugzilla.redhat.com/show_bug.cgi?id=719001" +echo "If this fails then the bug has been fixed" +diff --ignore-file-name-case "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_case +t_CheckExitStatus $? + +# Check the --to-file option +echo "Checking the --to-file option against a file" +diff --to-file $FILES/lao $DIRTEST/a/LAO +t_CheckExitStatus $? + +echo "Checking the --to-file option against a directory" +diff --to-file $FILES/lao $DIRTEST/b +t_CheckExitStatus $? + +rm -f "$F1" +rm -f "$F2" +rm -r "$DIRTEST" diff --git a/tests/p_diffutils/30-diff3-tests b/tests/p_diffutils/30-diff3-tests index 4283313..36ab2de 100755 --- a/tests/p_diffutils/30-diff3-tests +++ b/tests/p_diffutils/30-diff3-tests @@ -8,5 +8,95 @@ t_Log "Running $0 - diff3 tests" diff3 -v &>/dev/null +t_CheckExitStatus $? + +DIR=./tests/p_diffutils +FILES=$DIR/files + +# Test the diff3 normal output. As we've already tested diff +# we can now use it to test our output. +echo "Check diff3 normal output" +diff3 $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_normal - +t_CheckExitStatus $? + +# Check the -e output --ed +echo "Check the diff3 -e output" +diff3 -e $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_ed_script - +t_CheckExitStatus $? + +echo "Check the diff3 --ed output" +diff3 --ed $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_ed_script - +t_CheckExitStatus $? + +# Check the -3 --easy-only output +echo "Check the diff3 -3 output" +diff3 -3 $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_easy_only - +t_CheckExitStatus $? + +echo "Check the diff3 --easy-only output" +diff3 --easy-only $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_easy_only - +t_CheckExitStatus $? + +# Check the -x --overlap-only output +echo "Check the diff3 -x output" +diff3 -x $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_overlap_only - +t_CheckExitStatus $? + +echo "Check the diff3 --overlap-only output" +diff3 --overlap-only $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_overlap_only - +t_CheckExitStatus $? + +# Check the -A --show-all option +echo "Check the diff3 -A output" +diff3 -A $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_show_all - +t_CheckExitStatus $? + +echo "Check the diff3 --show-all output" +diff3 --show-all $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_show_all - +t_CheckExitStatus $? + +# Check the -E --show-overlap option +echo "Check the diff3 -E output" +diff3 -E $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_show_overlap - +t_CheckExitStatus $? + +echo "Check the diff3 --show-overlap output" +diff3 --show-overlap $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_show_overlap - +t_CheckExitStatus $? +# Check the -m --merge option +echo "Check the diff3 -m output" +diff3 -m $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_merge - t_CheckExitStatus $? + +echo "Check the diff3 --merge output" +diff3 --merge $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_merge - +t_CheckExitStatus $? + +# Check the -i option to write the changes +echo "Check the diff3 -i output" +diff3 -i -3 $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_i - +t_CheckExitStatus $? + +# Check the -L --label output +echo "Check the diff3 -L output" +diff3 -m -L LAO -L TZU -L TAO $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_label - +t_CheckExitStatus $? + +echo "Check the diff3 --label= output" +diff3 -m --label=LAO --label=TZU --label=TAO $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_label - +t_CheckExitStatus $? + +# Check the --diff-program. Copy /usr/bin/diff to /var/tmp/newdiff then +# use --diff-program=/var/tmp/newdiff to force diff3 to use it. +# + +echo "Check --diff-program" + +[[ -e /var/tmp/newdiff ]] && rm /var/tmp/newdiff +cp /usr/bin/diff /var/tmp/newdiff + +diff3 --diff-program=/var/tmp/newdiff $FILES/lao $FILES/tzu $FILES/tao | diff $FILES/diff3_normal - +t_CheckExitStatus $? + +rm /var/tmp/newdiff diff --git a/tests/p_diffutils/40-sdiff-tests b/tests/p_diffutils/40-sdiff-tests index 192512a..de8d0db 100755 --- a/tests/p_diffutils/40-sdiff-tests +++ b/tests/p_diffutils/40-sdiff-tests @@ -10,3 +10,14 @@ t_Log "Running $0 - sdiff tests" sdiff -v &>/dev/null t_CheckExitStatus $? + +FILES=./tests/p_diffutils/files + +# sdiff will take it's commands from a /dev/null && Exitfail +diff "$FILES"/sdiff_output /var/tmp/sdiff.out +t_CheckExitStatus $? + +# Clean up +rm -f /var/tmp/sdiff.out diff --git a/tests/p_diffutils/TODO b/tests/p_diffutils/TODO new file mode 100644 index 0000000..c26949b --- /dev/null +++ b/tests/p_diffutils/TODO @@ -0,0 +1,15 @@ +The following haven't been tested mostly because I can't figure out how to do so. +diff --minimal +diff --horizon-lines +diff --speed-large-files +diff --show-c-function +diff --show-function-line +diff --starting-file + +diff -x | -X in combination with --ignore-file-name-case as the latter doesn't work due to a bug. + +diff3 -a +diff3 -T + + + diff --git a/tests/p_diffutils/files/F b/tests/p_diffutils/files/F new file mode 100644 index 0000000..4d1ae35 --- /dev/null +++ b/tests/p_diffutils/files/F @@ -0,0 +1 @@ +f \ No newline at end of file diff --git a/tests/p_diffutils/files/F-G b/tests/p_diffutils/files/F-G new file mode 100644 index 0000000..bcdaec0 --- /dev/null +++ b/tests/p_diffutils/files/F-G @@ -0,0 +1,6 @@ +1c1 +< f +\ No newline at end of file +--- +> g +\ No newline at end of file diff --git a/tests/p_diffutils/files/G b/tests/p_diffutils/files/G new file mode 100644 index 0000000..7937c68 --- /dev/null +++ b/tests/p_diffutils/files/G @@ -0,0 +1 @@ +g \ No newline at end of file diff --git a/tests/p_diffutils/files/H b/tests/p_diffutils/files/H new file mode 100644 index 0000000..be54354 --- /dev/null +++ b/tests/p_diffutils/files/H @@ -0,0 +1 @@ +h \ No newline at end of file diff --git a/tests/p_diffutils/files/context_format b/tests/p_diffutils/files/context_format new file mode 100644 index 0000000..475bba3 --- /dev/null +++ b/tests/p_diffutils/files/context_format @@ -0,0 +1,25 @@ +*************** +*** 1,7 **** +- The Way that can be told of is not the eternal Way; +- The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +! The Named is the mother of all things. + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +--- 1,6 ---- + The Nameless is the origin of Heaven and Earth; +! The named is the mother of all things. +! + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +*************** +*** 9,11 **** +--- 8,13 ---- + The two are the same, + But after they are produced, + they have different names. ++ They both may be called deep and profound. ++ Deeper and more profound, ++ The door of all subtleties! diff --git a/tests/p_diffutils/files/context_format-1 b/tests/p_diffutils/files/context_format-1 new file mode 100644 index 0000000..2a0cd28 --- /dev/null +++ b/tests/p_diffutils/files/context_format-1 @@ -0,0 +1,19 @@ +*************** +*** 1,5 **** +- The Way that can be told of is not the eternal Way; +- The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +! The Named is the mother of all things. + Therefore let there always be non-being, +--- 1,4 ---- + The Nameless is the origin of Heaven and Earth; +! The named is the mother of all things. +! + Therefore let there always be non-being, +*************** +*** 11 **** +--- 10,13 ---- + they have different names. ++ They both may be called deep and profound. ++ Deeper and more profound, ++ The door of all subtleties! diff --git a/tests/p_diffutils/files/diff3_easy_only b/tests/p_diffutils/files/diff3_easy_only new file mode 100644 index 0000000..0602759 --- /dev/null +++ b/tests/p_diffutils/files/diff3_easy_only @@ -0,0 +1,3 @@ +8c + so we may see their result. +. diff --git a/tests/p_diffutils/files/diff3_ed_script b/tests/p_diffutils/files/diff3_ed_script new file mode 100644 index 0000000..c826f81 --- /dev/null +++ b/tests/p_diffutils/files/diff3_ed_script @@ -0,0 +1,7 @@ +11a + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +. +8c + so we may see their result. +. diff --git a/tests/p_diffutils/files/diff3_i b/tests/p_diffutils/files/diff3_i new file mode 100644 index 0000000..3be59be --- /dev/null +++ b/tests/p_diffutils/files/diff3_i @@ -0,0 +1,5 @@ +8c + so we may see their result. +. +w +q diff --git a/tests/p_diffutils/files/diff3_label b/tests/p_diffutils/files/diff3_label new file mode 100644 index 0000000..33be896 --- /dev/null +++ b/tests/p_diffutils/files/diff3_label @@ -0,0 +1,23 @@ +<<<<<<< TZU +======= +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +>>>>>>> TAO +The Nameless is the origin of Heaven and Earth; +The Named is the mother of all things. +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their result. +The two are the same, +But after they are produced, + they have different names. +<<<<<<< LAO +||||||| TZU +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> TAO diff --git a/tests/p_diffutils/files/diff3_merge b/tests/p_diffutils/files/diff3_merge new file mode 100644 index 0000000..a556686 --- /dev/null +++ b/tests/p_diffutils/files/diff3_merge @@ -0,0 +1,23 @@ +<<<<<<< ./tests/p_diffutils/files/tzu +======= +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +>>>>>>> ./tests/p_diffutils/files/tao +The Nameless is the origin of Heaven and Earth; +The Named is the mother of all things. +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their result. +The two are the same, +But after they are produced, + they have different names. +<<<<<<< ./tests/p_diffutils/files/lao +||||||| ./tests/p_diffutils/files/tzu +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> ./tests/p_diffutils/files/tao diff --git a/tests/p_diffutils/files/diff3_normal b/tests/p_diffutils/files/diff3_normal new file mode 100644 index 0000000..9dfcad8 --- /dev/null +++ b/tests/p_diffutils/files/diff3_normal @@ -0,0 +1,28 @@ +====2 +1:1,2c +3:1,2c + The Way that can be told of is not the eternal Way; + The name that can be named is not the eternal name. +2:0a +====1 +1:4c + The Named is the mother of all things. +2:2,3c +3:4,5c + The named is the mother of all things. + +====3 +1:8c +2:7c + so we may see their outcome. +3:9c + so we may see their result. +==== +1:11a +2:11,13c + They both may be called deep and profound. + Deeper and more profound, + The door of all subtleties! +3:13,14c + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan diff --git a/tests/p_diffutils/files/diff3_overlap_only b/tests/p_diffutils/files/diff3_overlap_only new file mode 100644 index 0000000..75d6ffa --- /dev/null +++ b/tests/p_diffutils/files/diff3_overlap_only @@ -0,0 +1,4 @@ +11a + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +. diff --git a/tests/p_diffutils/files/diff3_show_all b/tests/p_diffutils/files/diff3_show_all new file mode 100644 index 0000000..e185188 --- /dev/null +++ b/tests/p_diffutils/files/diff3_show_all @@ -0,0 +1,23 @@ +11a +||||||| ./tests/p_diffutils/files/tzu +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> ./tests/p_diffutils/files/tao +. +11a +<<<<<<< ./tests/p_diffutils/files/lao +. +8c + so we may see their result. +. +2a +>>>>>>> ./tests/p_diffutils/files/tao +. +0a +<<<<<<< ./tests/p_diffutils/files/tzu +======= +. diff --git a/tests/p_diffutils/files/diff3_show_overlap b/tests/p_diffutils/files/diff3_show_overlap new file mode 100644 index 0000000..b6273b5 --- /dev/null +++ b/tests/p_diffutils/files/diff3_show_overlap @@ -0,0 +1,12 @@ +11a +======= + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan +>>>>>>> ./tests/p_diffutils/files/tao +. +11a +<<<<<<< ./tests/p_diffutils/files/lao +. +8c + so we may see their result. +. diff --git a/tests/p_diffutils/files/diff_pager b/tests/p_diffutils/files/diff_pager new file mode 100644 index 0000000..ac8a3e1 --- /dev/null +++ b/tests/p_diffutils/files/diff_pager @@ -0,0 +1,66 @@ + + +2013-01-09 13:57 diff -lc lao tzu Page 1 + + +*** lao 2013-01-02 22:36:20.628242206 +0100 +--- tzu 2013-01-02 22:36:38.412254788 +0100 +*************** +*** 1,7 **** +- The Way that can be told of is not the eternal Way; +- The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +! The Named is the mother of all things. + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +--- 1,6 ---- + The Nameless is the origin of Heaven and Earth; +! The named is the mother of all things. +! + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +*************** +*** 9,11 **** +--- 8,13 ---- + The two are the same, + But after they are produced, + they have different names. ++ They both may be called deep and profound. ++ Deeper and more profound, ++ The door of all subtleties! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/p_diffutils/files/dir b/tests/p_diffutils/files/dir new file mode 100644 index 0000000..4aaa9c6 --- /dev/null +++ b/tests/p_diffutils/files/dir @@ -0,0 +1,2 @@ +Common subdirectories: /var/tmp/difftest/a/1 and /var/tmp/difftest/b/1 +Only in /var/tmp/difftest/a: tzu diff --git a/tests/p_diffutils/files/dir_N b/tests/p_diffutils/files/dir_N new file mode 100644 index 0000000..583b736 --- /dev/null +++ b/tests/p_diffutils/files/dir_N @@ -0,0 +1,32 @@ +diff -Nsr /var/tmp/difftest/a/1/tao /var/tmp/difftest/b/1/tao +1,14d0 +< The Way that can be told of is not the eternal Way; +< The name that can be named is not the eternal name. +< The Nameless is the origin of Heaven and Earth; +< The named is the mother of all things. +< +< Therefore let there always be non-being, +< so we may see their subtlety, +< And let there always be being, +< so we may see their result. +< The two are the same, +< But after they are produced, +< they have different names. +< +< -- The Way of Lao-Tzu, tr. Wing-tsit Chan +Files /var/tmp/difftest/a/lao and /var/tmp/difftest/b/lao are identical +diff -Nsr /var/tmp/difftest/a/tzu /var/tmp/difftest/b/tzu +1,13d0 +< The Nameless is the origin of Heaven and Earth; +< The named is the mother of all things. +< +< Therefore let there always be non-being, +< so we may see their subtlety, +< And let there always be being, +< so we may see their outcome. +< The two are the same, +< But after they are produced, +< they have different names. +< They both may be called deep and profound. +< Deeper and more profound, +< The door of all subtleties! diff --git a/tests/p_diffutils/files/dir_X b/tests/p_diffutils/files/dir_X new file mode 100644 index 0000000..41bcf1f --- /dev/null +++ b/tests/p_diffutils/files/dir_X @@ -0,0 +1 @@ +Common subdirectories: /var/tmp/difftest/a/1 and /var/tmp/difftest/b/1 diff --git a/tests/p_diffutils/files/dir_case b/tests/p_diffutils/files/dir_case new file mode 100644 index 0000000..dccf148 --- /dev/null +++ b/tests/p_diffutils/files/dir_case @@ -0,0 +1,4 @@ +Common subdirectories: /var/tmp/difftest/a/1 and /var/tmp/difftest/b/1 +Only in /var/tmp/difftest/b: lao +Only in /var/tmp/difftest/a: LAO +Only in /var/tmp/difftest/a: tzu diff --git a/tests/p_diffutils/files/dir_new_file b/tests/p_diffutils/files/dir_new_file new file mode 100644 index 0000000..aac18c9 --- /dev/null +++ b/tests/p_diffutils/files/dir_new_file @@ -0,0 +1,32 @@ +diff --new-file -sr /var/tmp/difftest/a/1/tao /var/tmp/difftest/b/1/tao +1,14d0 +< The Way that can be told of is not the eternal Way; +< The name that can be named is not the eternal name. +< The Nameless is the origin of Heaven and Earth; +< The named is the mother of all things. +< +< Therefore let there always be non-being, +< so we may see their subtlety, +< And let there always be being, +< so we may see their result. +< The two are the same, +< But after they are produced, +< they have different names. +< +< -- The Way of Lao-Tzu, tr. Wing-tsit Chan +Files /var/tmp/difftest/a/lao and /var/tmp/difftest/b/lao are identical +diff --new-file -sr /var/tmp/difftest/a/tzu /var/tmp/difftest/b/tzu +1,13d0 +< The Nameless is the origin of Heaven and Earth; +< The named is the mother of all things. +< +< Therefore let there always be non-being, +< so we may see their subtlety, +< And let there always be being, +< so we may see their outcome. +< The two are the same, +< But after they are produced, +< they have different names. +< They both may be called deep and profound. +< Deeper and more profound, +< The door of all subtleties! diff --git a/tests/p_diffutils/files/dir_r b/tests/p_diffutils/files/dir_r new file mode 100644 index 0000000..cc7f7ff --- /dev/null +++ b/tests/p_diffutils/files/dir_r @@ -0,0 +1,3 @@ +Only in /var/tmp/difftest/a/1: tao +Files /var/tmp/difftest/a/lao and /var/tmp/difftest/b/lao are identical +Only in /var/tmp/difftest/a: tzu diff --git a/tests/p_diffutils/files/dir_s b/tests/p_diffutils/files/dir_s new file mode 100644 index 0000000..7e21b71 --- /dev/null +++ b/tests/p_diffutils/files/dir_s @@ -0,0 +1,3 @@ +Common subdirectories: /var/tmp/difftest/a/1 and /var/tmp/difftest/b/1 +Files /var/tmp/difftest/a/lao and /var/tmp/difftest/b/lao are identical +Only in /var/tmp/difftest/a: tzu diff --git a/tests/p_diffutils/files/dir_unidirectional b/tests/p_diffutils/files/dir_unidirectional new file mode 100644 index 0000000..dd80b10 --- /dev/null +++ b/tests/p_diffutils/files/dir_unidirectional @@ -0,0 +1,16 @@ +Common subdirectories: /var/tmp/difftest/b/1 and /var/tmp/difftest/a/1 +diff --unidirectional-new-file /var/tmp/difftest/b/tzu /var/tmp/difftest/a/tzu +0a1,13 +> The Nameless is the origin of Heaven and Earth; +> The named is the mother of all things. +> +> Therefore let there always be non-being, +> so we may see their subtlety, +> And let there always be being, +> so we may see their outcome. +> The two are the same, +> But after they are produced, +> they have different names. +> They both may be called deep and profound. +> Deeper and more profound, +> The door of all subtleties! diff --git a/tests/p_diffutils/files/dir_x b/tests/p_diffutils/files/dir_x new file mode 100644 index 0000000..41bcf1f --- /dev/null +++ b/tests/p_diffutils/files/dir_x @@ -0,0 +1 @@ +Common subdirectories: /var/tmp/difftest/a/1 and /var/tmp/difftest/b/1 diff --git a/tests/p_diffutils/files/e_F-G b/tests/p_diffutils/files/e_F-G new file mode 100644 index 0000000..07de368 --- /dev/null +++ b/tests/p_diffutils/files/e_F-G @@ -0,0 +1,7 @@ +1c +g +. +diff: ./tests/p_diffutils/files/F: No newline at end of file + +diff: ./tests/p_diffutils/files/G: No newline at end of file + diff --git a/tests/p_diffutils/files/ed_script b/tests/p_diffutils/files/ed_script new file mode 100644 index 0000000..43c2b2f --- /dev/null +++ b/tests/p_diffutils/files/ed_script @@ -0,0 +1,10 @@ +11a +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +. +4c +The named is the mother of all things. + +. +1,2d diff --git a/tests/p_diffutils/files/ed_script-f b/tests/p_diffutils/files/ed_script-f new file mode 100644 index 0000000..12d00b1 --- /dev/null +++ b/tests/p_diffutils/files/ed_script-f @@ -0,0 +1,10 @@ +d1 2 +c4 +The named is the mother of all things. + +. +a11 +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +. diff --git a/tests/p_diffutils/files/exclude b/tests/p_diffutils/files/exclude new file mode 100644 index 0000000..df3b51d --- /dev/null +++ b/tests/p_diffutils/files/exclude @@ -0,0 +1 @@ +tz* diff --git a/tests/p_diffutils/files/if_then_else b/tests/p_diffutils/files/if_then_else new file mode 100644 index 0000000..ed3e990 --- /dev/null +++ b/tests/p_diffutils/files/if_then_else @@ -0,0 +1,23 @@ +#ifndef TWO +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +#endif /* ! TWO */ +The Nameless is the origin of Heaven and Earth; +#ifndef TWO +The Named is the mother of all things. +#else /* TWO */ +The named is the mother of all things. + +#endif /* TWO */ +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their outcome. +The two are the same, +But after they are produced, + they have different names. +#ifdef TWO +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! +#endif /* TWO */ diff --git a/tests/p_diffutils/files/label-change b/tests/p_diffutils/files/label-change new file mode 100644 index 0000000..0e29ee9 --- /dev/null +++ b/tests/p_diffutils/files/label-change @@ -0,0 +1,24 @@ +*** original +--- modified +*************** +*** 1,6 **** +- The Way that can be told of is not the eternal Way; +- The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +! The Named is the mother of all things. + Therefore let there always be non-being, + so we may see their subtlety, +--- 1,5 ---- + The Nameless is the origin of Heaven and Earth; +! The named is the mother of all things. +! + Therefore let there always be non-being, + so we may see their subtlety, +*************** +*** 10,11 **** +--- 9,13 ---- + But after they are produced, + they have different names. ++ They both may be called deep and profound. ++ Deeper and more profound, ++ The door of all subtleties! diff --git a/tests/p_diffutils/files/lao b/tests/p_diffutils/files/lao new file mode 100644 index 0000000..635ef2c --- /dev/null +++ b/tests/p_diffutils/files/lao @@ -0,0 +1,11 @@ +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +The Nameless is the origin of Heaven and Earth; +The Named is the mother of all things. +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their outcome. +The two are the same, +But after they are produced, + they have different names. diff --git a/tests/p_diffutils/files/left_column b/tests/p_diffutils/files/left_column new file mode 100644 index 0000000..5c9e8aa --- /dev/null +++ b/tests/p_diffutils/files/left_column @@ -0,0 +1,15 @@ +The Way that can be told of is n < +The name that can be named is no < +The Nameless is the origin of He ( +The Named is the mother of all t | The named is the mother of all t + > +Therefore let there always be no ( + so we may see their subtlety, ( +And let there always be being, ( + so we may see their outcome. ( +The two are the same, ( +But after they are produced, ( + they have different names. ( + > They both may be called deep and + > Deeper and more profound, + > The door of all subtleties! diff --git a/tests/p_diffutils/files/n_F-G b/tests/p_diffutils/files/n_F-G new file mode 100644 index 0000000..801a80d --- /dev/null +++ b/tests/p_diffutils/files/n_F-G @@ -0,0 +1,3 @@ +d1 1 +a1 1 +g \ No newline at end of file diff --git a/tests/p_diffutils/files/normal_format b/tests/p_diffutils/files/normal_format new file mode 100644 index 0000000..6f82a1c --- /dev/null +++ b/tests/p_diffutils/files/normal_format @@ -0,0 +1,12 @@ +1,2d0 +< The Way that can be told of is not the eternal Way; +< The name that can be named is not the eternal name. +4c2,3 +< The Named is the mother of all things. +--- +> The named is the mother of all things. +> +11a11,13 +> They both may be called deep and profound. +> Deeper and more profound, +> The door of all subtleties! diff --git a/tests/p_diffutils/files/paginate b/tests/p_diffutils/files/paginate new file mode 100644 index 0000000..0ce2850 --- /dev/null +++ b/tests/p_diffutils/files/paginate @@ -0,0 +1,63 @@ + + +1,2d0 +< The Way that can be told of is not the eternal Way; +< The name that can be named is not the eternal name. +4c2,3 +< The Named is the mother of all things. +--- +> The named is the mother of all things. +> +11a11,13 +> They both may be called deep and profound. +> Deeper and more profound, +> The door of all subtleties! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/p_diffutils/files/rcs_script b/tests/p_diffutils/files/rcs_script new file mode 100644 index 0000000..0806979 --- /dev/null +++ b/tests/p_diffutils/files/rcs_script @@ -0,0 +1,9 @@ +d1 2 +d4 1 +a4 2 +The named is the mother of all things. + +a11 3 +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! diff --git a/tests/p_diffutils/files/sdiff_input b/tests/p_diffutils/files/sdiff_input new file mode 100644 index 0000000..7b53344 --- /dev/null +++ b/tests/p_diffutils/files/sdiff_input @@ -0,0 +1,5 @@ +l +r +l + + diff --git a/tests/p_diffutils/files/sdiff_output b/tests/p_diffutils/files/sdiff_output new file mode 100644 index 0000000..69bc7d8 --- /dev/null +++ b/tests/p_diffutils/files/sdiff_output @@ -0,0 +1,12 @@ +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +The Nameless is the origin of Heaven and Earth; +The named is the mother of all things. + +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their outcome. +The two are the same, +But after they are produced, + they have different names. diff --git a/tests/p_diffutils/files/side-by-side-W72 b/tests/p_diffutils/files/side-by-side-W72 new file mode 100644 index 0000000..a47bfd6 --- /dev/null +++ b/tests/p_diffutils/files/side-by-side-W72 @@ -0,0 +1,15 @@ +The Way that can be told of is not < +The name that can be named is not < +The Nameless is the origin of Heav The Nameless is the origin of Heav +The Named is the mother of all thi | The named is the mother of all thi + > +Therefore let there always be non- Therefore let there always be non- + so we may see their subtlety, so we may see their subtlety, +And let there always be being, And let there always be being, + so we may see their outcome. so we may see their outcome. +The two are the same, The two are the same, +But after they are produced, But after they are produced, + they have different names. they have different names. + > They both may be called deep and p + > Deeper and more profound, + > The door of all subtleties! diff --git a/tests/p_diffutils/files/supress_common_lines b/tests/p_diffutils/files/supress_common_lines new file mode 100644 index 0000000..58adc38 --- /dev/null +++ b/tests/p_diffutils/files/supress_common_lines @@ -0,0 +1,7 @@ +The Way that can be told of is n < +The name that can be named is no < +The Named is the mother of all t | The named is the mother of all t + > + > They both may be called deep and + > Deeper and more profound, + > The door of all subtleties! diff --git a/tests/p_diffutils/files/tao b/tests/p_diffutils/files/tao new file mode 100644 index 0000000..ffe1ba3 --- /dev/null +++ b/tests/p_diffutils/files/tao @@ -0,0 +1,14 @@ +The Way that can be told of is not the eternal Way; +The name that can be named is not the eternal name. +The Nameless is the origin of Heaven and Earth; +The named is the mother of all things. + +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their result. +The two are the same, +But after they are produced, + they have different names. + + -- The Way of Lao-Tzu, tr. Wing-tsit Chan diff --git a/tests/p_diffutils/files/tzu b/tests/p_diffutils/files/tzu new file mode 100644 index 0000000..5af88a8 --- /dev/null +++ b/tests/p_diffutils/files/tzu @@ -0,0 +1,13 @@ +The Nameless is the origin of Heaven and Earth; +The named is the mother of all things. + +Therefore let there always be non-being, + so we may see their subtlety, +And let there always be being, + so we may see their outcome. +The two are the same, +But after they are produced, + they have different names. +They both may be called deep and profound. +Deeper and more profound, +The door of all subtleties! diff --git a/tests/p_diffutils/files/unified_format b/tests/p_diffutils/files/unified_format new file mode 100644 index 0000000..00bb63c --- /dev/null +++ b/tests/p_diffutils/files/unified_format @@ -0,0 +1,17 @@ +@@ -1,7 +1,6 @@ +-The Way that can be told of is not the eternal Way; +-The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +-The Named is the mother of all things. ++The named is the mother of all things. ++ + Therefore let there always be non-being, + so we may see their subtlety, + And let there always be being, +@@ -9,3 +8,6 @@ + The two are the same, + But after they are produced, + they have different names. ++They both may be called deep and profound. ++Deeper and more profound, ++The door of all subtleties! diff --git a/tests/p_diffutils/files/unified_format-1 b/tests/p_diffutils/files/unified_format-1 new file mode 100644 index 0000000..e980ad1 --- /dev/null +++ b/tests/p_diffutils/files/unified_format-1 @@ -0,0 +1,13 @@ +@@ -1,5 +1,4 @@ +-The Way that can be told of is not the eternal Way; +-The name that can be named is not the eternal name. + The Nameless is the origin of Heaven and Earth; +-The Named is the mother of all things. ++The named is the mother of all things. ++ + Therefore let there always be non-being, +@@ -11 +10,4 @@ + they have different names. ++They both may be called deep and profound. ++Deeper and more profound, ++The door of all subtleties! diff --git a/tests/p_rootfiles/0-install-rootfiles b/tests/p_rootfiles/0-install-rootfiles new file mode 100755 index 0000000..8e83618 --- /dev/null +++ b/tests/p_rootfiles/0-install-rootfiles @@ -0,0 +1,5 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "$0 - installing rootfiles" +t_InstallPackage rootfiles diff --git a/tests/p_rootfiles/10-rootfiles b/tests/p_rootfiles/10-rootfiles new file mode 100755 index 0000000..24e9e8f --- /dev/null +++ b/tests/p_rootfiles/10-rootfiles @@ -0,0 +1,15 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "Running $0 test rootfiles exist" + +# +# Simply test that the files in the package exist in /root +# + +for file in .bash_logout .bash_profile .bashrc .cshrc .tcshrc +do + echo "Checking $file" + [ -e /root/$file ] || { t_Log "FAIL: $file is missing"; exit $FAIL; } + t_Log "PASS" +done diff --git a/tests/p_shadow-utils/0-install_shadow_utils b/tests/p_shadow-utils/0-install_shadow_utils new file mode 100755 index 0000000..68660e7 --- /dev/null +++ b/tests/p_shadow-utils/0-install_shadow_utils @@ -0,0 +1,6 @@ +#!/bin/bash +# Author: Iain Douglas +# Ensure the packages we require are available + +t_Log "Running $0 installing required packages" +t_InstallPackage shadow-utils diff --git a/tests/p_shadow-utils/10-basic_test b/tests/p_shadow-utils/10-basic_test new file mode 100755 index 0000000..a8371b4 --- /dev/null +++ b/tests/p_shadow-utils/10-basic_test @@ -0,0 +1,13 @@ +#!/bin/bash +# Author: Iain Douglas +# +# Basic tests for the shadow utils package. Check that the /etc/default +# directory and /etc/default/useradd files exist. + +t_Log "Running $0 Basic tests" + +echo "Check packace files exist" +[[ -d /etc/default ]] || { t_Log "FAIL: /etc/default missing"; exit $FAIL; } +[[ -e /etc/default/useradd ]] || { t_Log "FAIL: /etc/default/useradd missing"; exit $FAIL; } +[[ -e /etc/login.defs ]] || { t_Log "FAIL: /etc/login.defs missing"; exit $FAIL; } +t_Log "PASS" diff --git a/tests/p_shadow-utils/11-useradd_tests b/tests/p_shadow-utils/11-useradd_tests new file mode 100755 index 0000000..960cc2d --- /dev/null +++ b/tests/p_shadow-utils/11-useradd_tests @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" + +# Basic useradd tests +echo "Add user shadowuser" +useradd shadowuser +t_CheckExitStatus $? +echo "Check user was created" +grep -q "^shadowuser" /etc/passwd +t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/12-usermod_tests b/tests/p_shadow-utils/12-usermod_tests new file mode 100755 index 0000000..a11025f --- /dev/null +++ b/tests/p_shadow-utils/12-usermod_tests @@ -0,0 +1,11 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" +echo "Modify user shadowuser" +usermod -c "Comment plugh" shadowuser +t_CheckExitStatus $? +echo "Check /etc/passwd was modified" +grep "^shadowuser" /etc/passwd | grep -q "Comment plugh" +t_CheckExitStatus $? + diff --git a/tests/p_shadow-utils/13-chpasswd_tests b/tests/p_shadow-utils/13-chpasswd_tests new file mode 100755 index 0000000..c7825fc --- /dev/null +++ b/tests/p_shadow-utils/13-chpasswd_tests @@ -0,0 +1,13 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" +echo "Checking chpasswd" + +chpasswd -e < + +echo "Running $0" +echo "Testing newusers" +grep -q "^xyssy" /etc/passwd && { t_Log "FAIL: user xyssy alredy exists"; exit $FAIL; } +newusers < + +echo "Running $0" +echo "Checking lastlog" +lastlog -u shadowuser | grep -q '**Never logged in**' +t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/19-userdel_tests b/tests/p_shadow-utils/19-userdel_tests new file mode 100755 index 0000000..946d631 --- /dev/null +++ b/tests/p_shadow-utils/19-userdel_tests @@ -0,0 +1,10 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" +echo "Delete user shadowuser" +userdel -r shadowuser +t_CheckExitStatus $? +echo "Check user was deleted" +grep -q "^shadowuser" /etc/passwd && { t_Log "FAIL: shadowuser not deletd"; exit $FAIL;} +t_Log "PASS" diff --git a/tests/p_shadow-utils/20-chage_tests b/tests/p_shadow-utils/20-chage_tests new file mode 100755 index 0000000..57cb630 --- /dev/null +++ b/tests/p_shadow-utils/20-chage_tests @@ -0,0 +1,15 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" + +userdel -rf testshadow; useradd testshadow +echo "testshadow" | passwd --stdin testshadow + +echo "Set last date passwd changed to 2013-01-01" +chage -d 2013-01-01 testshadow +t_CheckExitStatus $? + +echo "Check that last passwd change is reported correctly" +chage -l testshadow | grep Last | grep -q "Jan 01, 2013" +t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/30-groupadd_tests b/tests/p_shadow-utils/30-groupadd_tests new file mode 100755 index 0000000..40dce6c --- /dev/null +++ b/tests/p_shadow-utils/30-groupadd_tests @@ -0,0 +1,11 @@ +#!/bin/bash +# Author: Iain Douglas +echo "Running $0 group add tests" + +# Delete any info from previous runs, use sed because we haven't yet tested +# groupdel +sed -i /testgroup/d /etc/group + +echo "Create a new group" +groupadd -g 1010 testgroup +t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/31-gpasswd_tests b/tests/p_shadow-utils/31-gpasswd_tests new file mode 100755 index 0000000..086a2d9 --- /dev/null +++ b/tests/p_shadow-utils/31-gpasswd_tests @@ -0,0 +1,7 @@ +#!/bin/bash +# Author: Iain Douglas +echo "Running $0 gpasswd tests" + +echo "Add a user to testgroup and create /etc/gshadow" +gpasswd -a testshadow testgroup +t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/32-groupmems_tests b/tests/p_shadow-utils/32-groupmems_tests new file mode 100755 index 0000000..a99c52c --- /dev/null +++ b/tests/p_shadow-utils/32-groupmems_tests @@ -0,0 +1,8 @@ +#!/bin/bash +# Author: Iain Douglas +[ $centos_ver == '5' ] && exit +echo "Running $0 group add tests" + +echo "Simple groupmems test" +groupmems -g testgroup -l | grep -q "testshadow" +t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/33-newgrp_tests b/tests/p_shadow-utils/33-newgrp_tests new file mode 100755 index 0000000..c73633a --- /dev/null +++ b/tests/p_shadow-utils/33-newgrp_tests @@ -0,0 +1,16 @@ +#!/bin/bash +# Author: Iain Douglas + +# Check that the user can change their primary group. This relies on the +# observation that the current primary group is printed first +# +echo "Basic newgrp test" +groups testshadow | grep -q "testshadow testgroup" || { t_Log "FAIL: Default testshadow user group information incorrect"; exit $FAIL; } +echo OK +echo $( su - testshadow < + +echo "Running $0" + +# Check that the testgroup exists with GID 1010 +grep -q "testgroup:x:1010:testshadow" /etc/group || { t_Log "FAIL Test group doesn't exist"; exit $FAIL; } + +echo "Changing GID for group testgroup to 1011" +groupmod -g 1011 testgroup +t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/35-grpck-tests b/tests/p_shadow-utils/35-grpck-tests new file mode 100755 index 0000000..3dee694 --- /dev/null +++ b/tests/p_shadow-utils/35-grpck-tests @@ -0,0 +1,23 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" + +# If we're on C5 delete the group 990991 which was added by newusers +if (( $centos_ver == 5 )) +then + sed -i /990991/d /etc/group +fi +echo "Testing valid files" +[[ -e /etc/group ]] || { t_Log { "FAIL: /etc/group doesn't exist"; exit $FAIL; } +#Check system files +echo "Checking /etc files are correect" +grpck +t_CheckExitStatus $? +echo "Checking malformed files are detected" + +echo "test:x::" >/var/tmp/gshadow +echo ":test:x:0::" >/var/tmp/group +grpck -r /var/tmp/group /var/tmp/gshadow && { t_Log "FAIL: Malformed files not detected"; exit $FAIL; } +t_Log "PASS" +rm /var/tmp/group /var/tmp/gshadow diff --git a/tests/p_shadow-utils/36-groupdel-tests b/tests/p_shadow-utils/36-groupdel-tests new file mode 100755 index 0000000..0e1e21b --- /dev/null +++ b/tests/p_shadow-utils/36-groupdel-tests @@ -0,0 +1,34 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" + +# Check that we can delete the testgroup +echo "Check we can delete the group 'testgroup'" + +grep -q testgroup /etc/group || { t_Log "FAIL: testgroup doesn't exist"; exit $FAIL; } +groupdel testgroup +t_CheckExitStatus $? + +# Try and remove the same group shoudl fail +echo "Additional tests - non existent group" +groupdel testgroup +if (( $? == 6 )) +then + t_Log "PASS" +else + t_Log "Fail" + exit $FAIL +fi + +# Try and remove a user's primary group - should fail +echo "Additional tests - users primary group" +groupdel testshadow +if (( $? == 8 )) +then + t_Log "PASS" +else + t_Log "Fail" + exit $FAIL +fi + diff --git a/tests/p_shadow-utils/37-grpconv-tests b/tests/p_shadow-utils/37-grpconv-tests new file mode 100755 index 0000000..5900530 --- /dev/null +++ b/tests/p_shadow-utils/37-grpconv-tests @@ -0,0 +1,27 @@ +#!/bin/bash +# Author: Iain Douglas + +# Test grpconv +cleanup() { +echo "Reverting files to original state" +[[ -e /var/tmp/grpconv/gshadow ]] && cp /var/tmp/grpconv/* /etc && rm -r /var/tmp/grpconv +} + +# Check we have a group file to work with and exit if not +[[ -e /etc/group ]] || { t_Log "Fail: /etc/group does not exist"; exit $FAIL; } + +mkdir -p /var/tmp/grpconv &>/dev/null + +# If it exists, save the /etc/gshadow file then delete it +[[ -e /etc/gshadow ]] && cp /etc/gshadow /var/tmp/gconv || { t_Log "FAIL: unable to make a safe copy of /etc/gshadow"; exit $FAIL; } + +[[ -e /etc/gshadow ]] && rm /etc/gshadow || { t_Log "FAIL: unable to remove /etc/gshadow"; exit $FAIL;} + +trap cleanup EXIT +echo "Test grpconv creates a new /etc/gshadow" +grpconv +t_CheckExitStatus $? +echo "Check format is correct with grpck" +grpck +t_CheckExitStatus $? + diff --git a/tests/p_shadow-utils/38-grpunconv-tests b/tests/p_shadow-utils/38-grpunconv-tests new file mode 100755 index 0000000..6165f41 --- /dev/null +++ b/tests/p_shadow-utils/38-grpunconv-tests @@ -0,0 +1,24 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" +cleanup() { +echo "Reverting files to original state" +[[ -d /var/tmp/grpunconv ]] && cp /var/tmp/grpunconv/* /etc && rm -r /var/tmp/grpunconv +} + +# Test grpunconv +# Check we have both /etc/group and /etc/gshadow then save them +[[ -e /etc/group && -e /etc/gshadow ]] || { t_Log "FAIL: missing source file"; exit $FAIL; } + +mkdir -p /var/tmp/grpunconv || { t_Log "FAIL: Unable to create directory to save source files in "; exit $FAIL; } +cp /etc/group /etc/gshadow /var/tmp/grpunconv || { t_Log "FAIL: Unable to save source files"; exit $FAIL; } + +#Check the source files are sane +echo "Checking source files are sane" +grpck +t_CheckExitStatus $? +trap cleanup EXIT +echo "Converting /etc/group and /etc/gshadow to merged /etc/group" +grpunconv +t_CheckExitStatus $? diff --git a/tests/p_shadow-utils/39-sg_tests b/tests/p_shadow-utils/39-sg_tests new file mode 100755 index 0000000..f747b50 --- /dev/null +++ b/tests/p_shadow-utils/39-sg_tests @@ -0,0 +1,10 @@ +#!/bin/bash +# Author: Iain Douglas +echo "Running $0" +echo "Testing sg" +sg testshadow "touch /var/tmp/sg" +t_CheckExitStatus $? +echo "Check sg worked" +ls -l /var/tmp/sg | grep -q testshadow +t_CheckExitStatus $? +rm /var/tmp/sg diff --git a/tests/p_shadow-utils/40-pwck_tests b/tests/p_shadow-utils/40-pwck_tests new file mode 100755 index 0000000..8c9af95 --- /dev/null +++ b/tests/p_shadow-utils/40-pwck_tests @@ -0,0 +1,22 @@ +#!/bin/bash +# Author: Iain Douglas + +# Even on a completely new clean system pwck fails because some accounts +# (e.g. adm) aren't created correctly so all we can really test is dummy +# files. + +echo "Running $0" + +echo "Check pwck passes correctly formed files" +echo "test:x:500:500::/tmp:/bin/bash" >/var/tmp/passwd +echo "test:$6$.vxxSAQB$4hvumoZoQ/83Z9PGKFYnFyEzFztcYky6zLUBKf/40MUTJzfzjWCHd/0bVdYXWc8OgyA31.:15656:0:99999:7:::" >/var/tmp/shadow +pwck -rq /var/tmp/passwd /var/tmp/shadow +t_CheckExitStatus "$?" + +# Check for malformed files +echo "Checking pwck detects malformed files" +echo ":test:x:500:500::/tmp:/bin/bash" >/var/tmp/passwd +echo "test:$6$.vxxSAQB$4hvumoZoQ/83Z9PGKFYnFyEzFztcYky6zLUBKf/40MUTJzfzjWCHd/0bVdYXWc8OgyA31.:15656:0:99999:7:::" >/var/tmp/shadow +pwck -rq /var/tmp/passwd /var/tmp/shadow && { t_Log "FAIL: Malformed files not detected"; exit $FAIL; } +t_Log "PASS" +rm /var/tmp/passwd /var/tmp/shadow diff --git a/tests/p_shadow-utils/41-pwconv_tests b/tests/p_shadow-utils/41-pwconv_tests new file mode 100755 index 0000000..5785c44 --- /dev/null +++ b/tests/p_shadow-utils/41-pwconv_tests @@ -0,0 +1,25 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" +echo "*****************************************************************" +echo "Note: The original /etc/passwd and /etc/shadow files are saved to" +echo "directory /var/tmp/pwconv". +echo "*****************************************************************" + +cleanup(){ +echo "Reverting files to original state" +[[ -d /var/tmp/pwconv ]] && cp /var/tmp/pwconv/* /etc +t_CheckExitStatus $? +} + +# check that /etc/passwd and /etc/shadow exist before continuing. +[[ -e /etc/passwd && -e /etc/shadow ]] || { t_Log "FAIL: missing source file"; exit $FAIL; } + +mkdir -p /var/tmp/pwconv || { t_Log "FAIL: Unable to create directory to save source files in "; exit $FAIL; } +cp /etc/passwd /etc/shadow /var/tmp/pwconv || { t_Log "FAIL: Unable to save source files"; exit $FAIL; } +trap cleanup EXIT +echo "Running pwconv" +pwconv +t_CheckExitStatus $? + diff --git a/tests/p_shadow-utils/42-pwunconv_tests b/tests/p_shadow-utils/42-pwunconv_tests new file mode 100755 index 0000000..dbded82 --- /dev/null +++ b/tests/p_shadow-utils/42-pwunconv_tests @@ -0,0 +1,25 @@ +#!/bin/bash +# Author: Iain Douglas + +echo "Running $0" +echo "*****************************************************************" +echo "Note: The original /etc/passwd and /etc/shadow files are saved to" +echo "directory /var/tmp/pwunconv". +echo "*****************************************************************" + +cleanup(){ +echo "Reverting files to original state" +[[ -d /var/tmp/pwunconv ]] && cp /var/tmp/pwunconv/* /etc +t_CheckExitStatus $? +} + +# check that /etc/passwd and /etc/shadow exist before continuing. +[[ -e /etc/passwd && -e /etc/shadow ]] || { t_Log "FAIL: missing source file"; exit $FAIL; } + +mkdir -p /var/tmp/pwunconv || { t_Log "FAIL: Unable to create directory to save source files in "; exit $FAIL; } +cp /etc/passwd /etc/shadow /var/tmp/pwunconv || { t_Log "FAIL: Unable to save source files"; exit $FAIL; } +trap cleanup EXIT +echo "Running pwunconv" +pwunconv +t_CheckExitStatus $? + diff --git a/tests/p_shadow-utils/99-cleanup b/tests/p_shadow-utils/99-cleanup new file mode 100755 index 0000000..c188788 --- /dev/null +++ b/tests/p_shadow-utils/99-cleanup @@ -0,0 +1,11 @@ +#!/bin/bash +# Author: Iain Douglas + +# Have a go at cleaning up the temporary files and accounts etc +userdel -r xyssy &>/dev/null +userdel -r testshadow &>/dev/null +rm -r /var/tmp/pwconv +rm -r /var/tmp/grpconv +rm -r /var/tmp/pwunconv + +