From f52e8a41f8f1ecf894c6fd94fd42c85a3d8324c3 Mon Sep 17 00:00:00 2001 From: Karanbir Singh Date: Jan 27 2014 14:25:18 +0000 Subject: Merge branch 'master' of gitorious.org:testautomation/t_functional --- diff --git a/AUTHORS b/AUTHORS index 7122d5d..bd87de8 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,7 +5,7 @@ Fabian Arrotin Athmane Madjoudj Steve Barnes Johnny Hughes -Christoph Galuschka +Christoph Galuschka Dan Trainor Nikhil Lanjewar Sahil Muthoo diff --git a/centos_ci_build b/centos_ci_build index e0e11e1..3d81147 100755 --- a/centos_ci_build +++ b/centos_ci_build @@ -2,4 +2,5 @@ # Build steps used in CentOS CI yum -y update +uname -a SKIP_QA_HARNESS=1 ./runtests.sh diff --git a/tests/0_common/30_dns_works.sh b/tests/0_common/30_dns_works.sh index 55510b6..4dbee5a 100755 --- a/tests/0_common/30_dns_works.sh +++ b/tests/0_common/30_dns_works.sh @@ -2,7 +2,7 @@ t_Log "Running $0 - testing to see if DNS works" if [ $SKIP_QA_HARNESS -eq 1 ]; then - HOST=wiki.centos.org + HOST=ci.dev.centos.org else HOST=repo.centos.qa fi diff --git a/tests/0_lib/functions.sh b/tests/0_lib/functions.sh index 24847bd..87137a7 100755 --- a/tests/0_lib/functions.sh +++ b/tests/0_lib/functions.sh @@ -97,7 +97,7 @@ function t_GetPkgRel # Description: return the distro release (returns 5 or 6 now) function t_DistCheck { - rpm -q --queryformat '%{version}\n' centos-release + rpm -q $(rpm -qf /etc/redhat-release) --queryformat '%{version}\n'|cut -f 1 -d '.' } # Additionally set distro release to $centos_ver centos_ver=$(t_DistCheck) diff --git a/tests/p_amanda/amanda-server_test.sh b/tests/p_amanda/amanda-server_test.sh index 5c90944..c22d2e7 100755 --- a/tests/p_amanda/amanda-server_test.sh +++ b/tests/p_amanda/amanda-server_test.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Author: Christoph Galuschka +# Author: Christoph Galuschka t_Log "Running $0 - amanda server runs a simple task (backing up /etc)" if (t_GetPkgRel basesystem | grep -q el5) @@ -29,7 +29,7 @@ logdir "/amanda/state/log" indexdir "/amanda/state/index" EOF -if (t_GetPkgRel basesystem | grep -q el5) +if [ $centos_ver == 5 ] then echo 'dumpuser "amanda"' >> /etc/amanda/MyConfig/amanda.conf else @@ -39,7 +39,16 @@ fi cat >> /etc/amanda/MyConfig/amanda.conf <> /etc/amanda/MyConfig/amanda.conf +else + echo 'label_new_tapes "MyData%%"' >> /etc/amanda/MyConfig/amanda.conf +fi + +cat >> /etc/amanda/MyConfig/amanda.conf < +# Author: Christoph Galuschka +# Rene Diepstraten -# Install arpwatch -t_InstallPackage arpwatch +# Install requirements +t_InstallPackage arpwatch psmisc net-tools diff --git a/tests/p_arpwatch/10_arpwatch_test.sh b/tests/p_arpwatch/10_arpwatch_test.sh new file mode 100755 index 0000000..5504364 --- /dev/null +++ b/tests/p_arpwatch/10_arpwatch_test.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# Author: Christoph Galuschka +# Rene Diepstraten + +t_Log "Running $0 - arpwatch on interface with default gateway" + +# arpwatch is broken in el7 +# See https://bugzilla.redhat.com/show_bug.cgi?id=1044062 +[[ $centos_ver -eq 7 ]] && { + t_Log "arpwatch is broken on el7. Skipping test." + exit +} + +# Kill arpwatch instance from previous test +# killall arpwatch + +# getting IP-address of default gateway +defgw=$(ip route | awk '/^default via/ {print $3}') +if [ -z $defgw ] + then + t_Log "No default gateway, can't test arpwatch" + exit +fi + +# setting path to arp.dat +if (t_GetPkgRel basesystem | grep -q el5) + then + arpdat='/var/arpwatch/arp.dat' +else + arpdat='/var/lib/arpwatch/arp.dat' +fi + +# beginning and running test +arpwatch +sleep 4 +arp -d $defgw +sleep 4 +ping -q -i 1 -c 5 $defgw +killall arpwatch +sleep 2 +grep -q $defgw $arpdat + +t_CheckExitStatus $? + +# cleaning up +cat /dev/null > $arpdat + diff --git a/tests/p_arpwatch/arpwatch_test.sh b/tests/p_arpwatch/arpwatch_test.sh deleted file mode 100755 index 3a7eebf..0000000 --- a/tests/p_arpwatch/arpwatch_test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# Christoph Galuschka - -t_Log "Running $0 - arpwatch on eth0" - -# Kill arpwatch instance from previous test -killall arpwatch - -# getting IP-address of default gateway -defgw=$(ip route list | grep default | cut -d' ' -f3) - -# setting path to arp.dat -if (t_GetPkgRel basesystem | grep -q el5) - then - arpdat='/var/arpwatch/arp.dat' -else - arpdat='/var/lib/arpwatch/arp.dat' -fi - -# beginning and running test -arpwatch -sleep 4 -arp -d $defgw -sleep 2 -ping -q -i 0.5 -c 5 $defgw -killall arpwatch -sleep 2 -grep -q $defgw $arpdat - -t_CheckExitStatus $? - -# cleaning up -cat /dev/null > $arpdat - diff --git a/tests/p_autofs/0-install_autofs.sh b/tests/p_autofs/0-install_autofs.sh new file mode 100755 index 0000000..59539d1 --- /dev/null +++ b/tests/p_autofs/0-install_autofs.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Author: Christoph Galuschka + +t_Log "Running $0 - Installing required packages" +t_InstallPackage autofs nfs-utils rpcbind + +t_Log 'Preparing NFS-Share and starting NFS-Server' +echo '/var/lib/ 127.0.0.1(ro)' >> /etc/exports +t_ServiceControl rpcbind restart +t_ServiceControl nfs restart + +t_Log 'verify if NFS is mountable' +mount -t nfs 127.0.0.1:/var/lib /mnt +ls -al /mnt | grep -q yum + +t_CheckExitStatus $? +umount /mnt diff --git a/tests/p_autofs/10-autofs-nfs-mount.sh b/tests/p_autofs/10-autofs-nfs-mount.sh new file mode 100755 index 0000000..440399d --- /dev/null +++ b/tests/p_autofs/10-autofs-nfs-mount.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# Author: Christoph Galuschka + +t_Log "Running $0 - autofs can mount nfs share test." + +t_Log 'Preparing autofs configuration' +cp -a /etc/auto.master /etc/auto.master_orig +echo '/autofs /etc/auto.autofs' >> /etc/auto.master +echo 'nfs -fstype=nfs 127.0.0.1:/var/lib' > /etc/auto.autofs + +t_ServiceControl autofs restart + +t_Log 'Running test - accessing /var/lib via autofs' + +ls -al /autofs/nfs | grep -q yum +t_CheckExitStatus $? + +# return everything to previous state +cp -a /etc/auto.master_orig /etc/auto.master +rm -rf /etc/auto.autofs +cat /dev/null > /etc/exports +t_ServiceControl autofs stop +t_ServiceControl nfs stop +t_ServiceControl rpcbind stop diff --git a/tests/p_busybox/00_install_busybox.sh b/tests/p_busybox/00_install_busybox.sh index b2cae54..eae5d28 100755 --- a/tests/p_busybox/00_install_busybox.sh +++ b/tests/p_busybox/00_install_busybox.sh @@ -1,5 +1,8 @@ -#!/bin/sh +#!/bin/bash # Author: Christoph Galuschka +# Author: Rene Diepstraten + +[[ $centos_ver -ge 7 ]] && { t_Log "busybox is not part of el${centos_ver}" ; exit ; } t_Log "Running $0 - attempting to install busybox." t_InstallPackage busybox diff --git a/tests/p_busybox/10_test_busybox.sh b/tests/p_busybox/10_test_busybox.sh index 6e59516..e7aa2e8 100755 --- a/tests/p_busybox/10_test_busybox.sh +++ b/tests/p_busybox/10_test_busybox.sh @@ -1,6 +1,9 @@ -#!/bin/sh +#!/bin/bash # Author: Athmane Madjoudj # Author: Christoph Galuschka +# Author: Rene Diepstraten + +[[ $centos_ver -ge 7 ]] && exit t_Log "Running $0 - busybox test: busybox lists available functions." diff --git a/tests/p_busybox/20_functiontest_busybox.sh b/tests/p_busybox/20_functiontest_busybox.sh index 171b1de..6d526a4 100755 --- a/tests/p_busybox/20_functiontest_busybox.sh +++ b/tests/p_busybox/20_functiontest_busybox.sh @@ -1,6 +1,9 @@ -#!/bin/sh +#!/bin/bash # Author: Athmane Madjoudj # Author: Christoph Galuschka +# Author: Rene Diepstraten + +[[ $centos_ver -ge 7 ]] && exit t_Log "Running $0 - busybox functional tests: busybox provided functions are working." diff --git a/tests/p_chkconfig/chkconfig_list_services.sh b/tests/p_chkconfig/chkconfig_list_services.sh index 895fdb8..7d4716e 100755 --- a/tests/p_chkconfig/chkconfig_list_services.sh +++ b/tests/p_chkconfig/chkconfig_list_services.sh @@ -1,10 +1,12 @@ #!/bin/bash # Author: Athmane Madjoudj +# Rene Diepstraten t_Log "Running $0 - check if chkconfig can list a service status" -# auditd is used as example because it's standard with minimal install -chkconfig --list auditd | grep -q '3:on' +# network is used as example because it's standard with minimal install + +chkconfig --list network | grep -q '3:on' t_CheckExitStatus $? 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..4bbac69 --- /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 "Basic 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_cron/0-install_cron.sh b/tests/p_cron/0-install_cron.sh index 1b9509f..2b4d727 100755 --- a/tests/p_cron/0-install_cron.sh +++ b/tests/p_cron/0-install_cron.sh @@ -2,7 +2,7 @@ # Author: Athmane Madjoudj t_Log "$0 - Installing crond" -if (t_GetPkgRel basesystem | grep -q el6) +if (t_GetPkgRel basesystem | grep -q -E 'el6|el7') then pn="cronie" else diff --git a/tests/p_curl/curl_test.sh b/tests/p_curl/curl_test.sh index 1ed35d0..27965ba 100755 --- a/tests/p_curl/curl_test.sh +++ b/tests/p_curl/curl_test.sh @@ -6,8 +6,8 @@ t_Log "Running $0 - curl can access http-host and retrieve index.html." if [ $SKIP_QA_HARNESS -eq 1 ]; then - CHECK_FOR="CentOS Wiki" - URL="http://wiki.centos.org/" + CHECK_FOR="CentOS CI test page" + URL="http://ci.dev.centos.org/cstatic/" else CHECK_FOR="Index of /srv" URL="http://repo.centos.qa/srv/CentOS/" 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..eaf6993 100755 --- a/tests/p_diffutils/20-diff-tests +++ b/tests/p_diffutils/20-diff-tests @@ -5,8 +5,353 @@ # 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_dovecot/0-install_dovecot.sh b/tests/p_dovecot/0-install_dovecot.sh index d8dadcf..ede3de3 100755 --- a/tests/p_dovecot/0-install_dovecot.sh +++ b/tests/p_dovecot/0-install_dovecot.sh @@ -4,7 +4,6 @@ t_Log "Running $0 - installation and startup of dovecot IMAP/POP3." # Install some pkgs needed by the tests -t_InstallPackage nc grep +t_InstallPackage nc grep dovecot -t_InstallPackage dovecot t_ServiceControl dovecot start diff --git a/tests/p_dovecot/1-config_dovecot.sh b/tests/p_dovecot/1-config_dovecot.sh index 95912b3..70818bf 100755 --- a/tests/p_dovecot/1-config_dovecot.sh +++ b/tests/p_dovecot/1-config_dovecot.sh @@ -1,7 +1,7 @@ #!/bin/bash # Author: Athmane Madjoudj -if (t_GetPkgRel dovecot | grep -q el6) +if (t_GetPkgRel dovecot | egrep -q 'el6|7') then t_Log "Running $0 - Configuration of Dovecot" diff --git a/tests/p_dovecot/dovecot_imap_login.sh b/tests/p_dovecot/dovecot_imap_login.sh index e74f1b9..7c88962 100755 --- a/tests/p_dovecot/dovecot_imap_login.sh +++ b/tests/p_dovecot/dovecot_imap_login.sh @@ -1,6 +1,6 @@ #!/bin/sh # Author: Athmane Madjoudj -# Christoph Galuschka +# Christoph Galuschka t_Log "Running $0 - adding imaptest local user account + attempting IMAP login" @@ -22,8 +22,17 @@ echo -e "01 LOGIN imaptest imaptest\n" | nc -w 5 localhost 143 | grep -q "Logged sleep 3 echo -e "01 LOGIN imaptest imaptest\n" | nc -w 5 localhost 143 | grep -q "Logged in." +# let's see if a third iteration reduces flakyness of the test +sleep 3 + +echo -e "01 LOGIN imaptest imaptest\n" | nc -w 5 localhost 143 | grep -q "Logged in." ret_val=$? +if [ $ret_val != 0 ] +then + tail /var/log/secure + tail /var/log/maillog +fi t_CheckExitStatus $ret_val userdel -rf imaptest diff --git a/tests/p_exim/20_exim_mta_helo-test.sh b/tests/p_exim/20_exim_mta_helo-test.sh index 01d6adc..f0b373d 100755 --- a/tests/p_exim/20_exim_mta_helo-test.sh +++ b/tests/p_exim/20_exim_mta_helo-test.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Author: Christoph Galuschka +# Author: Christoph Galuschka t_Log "Running $0 - exim can accept and deliver local email." @@ -19,7 +19,7 @@ if [ $centos_ver == '5' ] MTA_ACCEPT=0 fi - sleep 1 + sleep 5 grep -q 't_functional test' $MAILSPOOL* if [ $? = 0 ] then diff --git a/tests/p_exim/30_exim_mta_ehlo-test.sh b/tests/p_exim/30_exim_mta_ehlo-test.sh index e4577b0..e740eb5 100755 --- a/tests/p_exim/30_exim_mta_ehlo-test.sh +++ b/tests/p_exim/30_exim_mta_ehlo-test.sh @@ -5,6 +5,8 @@ t_Log "Running $0 - exim can accept and deliver local email using ESMTP/PIPELINI if [ $centos_ver == '5' ] then + SPOOLFILE=1 + MTA_ACCEPT=1 MAILSPOOL=/var/spool/exim/input/ # make shure spool dir is empty @@ -19,7 +21,7 @@ if [ $centos_ver == '5' ] MTA_ACCEPT=0 fi - sleep 1 + sleep 5 grep -q 't_functional test' $MAILSPOOL* if [ $? = 0 ] then diff --git a/tests/p_file/02_file_mime_image.sh b/tests/p_file/02_file_mime_image.sh index 4bd69b6..57b19c3 100755 --- a/tests/p_file/02_file_mime_image.sh +++ b/tests/p_file/02_file_mime_image.sh @@ -1,10 +1,19 @@ #!/bin/bash # Author: ??? # Christoph Galuschka +# Rene Diepstraten t_Log "Running $0 - checking if file can recognize image mime file type " -file /usr/lib/anaconda-runtime/boot/syslinux-splash.png -i | grep -q 'image/png' +case $centos_ver in + 5|6) + pngfile=/usr/lib/anaconda-runtime/boot/syslinux-splash.png + ;; + *) + pngfile=/usr/share/anaconda/boot/syslinux-splash.png + ;; +esac -t_CheckExitStatus $? +file $pngfile -i | grep -q 'image/png' +t_CheckExitStatus $? \ No newline at end of file diff --git a/tests/p_file/03_file_mime_symlink.sh b/tests/p_file/03_file_mime_symlink.sh index 442334d..d26721a 100755 --- a/tests/p_file/03_file_mime_symlink.sh +++ b/tests/p_file/03_file_mime_symlink.sh @@ -8,13 +8,19 @@ TEST_FILE_PATH="/tmp/p_file_link_test" ln -s /etc/hosts $TEST_FILE_PATH -if (t_GetPkgRel basesystem | grep -q el5) - then - file -i $TEST_FILE_PATH | grep -q 'x-not-regular-file' - ret_val=$? -else - file -i $TEST_FILE_PATH | grep -q 'application/x-symlink' - ret_val=$? -fi +case $centos_ver in + 5) + mimetype='x-not-regular-file' + ;; + 6) + mimetype='application/x-symlink' + ;; + *) + mimetype='inode/symlink' + ;; +esac + +file -i $TEST_FILE_PATH | grep -q $mimetype +ret_val=$? t_CheckExitStatus $ret_val diff --git a/tests/p_findutils/0-install_findutils b/tests/p_findutils/0-install_findutils new file mode 100755 index 0000000..01c525c --- /dev/null +++ b/tests/p_findutils/0-install_findutils @@ -0,0 +1,5 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "$0 - installing findutils" +t_InstallPackage findutils diff --git a/tests/p_findutils/10-find_tests b/tests/p_findutils/10-find_tests new file mode 100755 index 0000000..279e2f7 --- /dev/null +++ b/tests/p_findutils/10-find_tests @@ -0,0 +1,32 @@ +#!/bin/bash +# Author: Iain Douglas +# + +echo "Running $0" +TMPDIR=/var/tmp/find + +[[ -e "$TMPDIR" ]] && rm -rf "$TMPDIR" + +mkdir -p "$TMPDIR" || { t_Log "FAIL: Can't create working area $TMPDIR" ; exit $FAIL; } +touch "$TMPDIR"/file1 +touch "$TMPDIR"/"file space" +# Basic find tests +echo "Basic find tests" + +find "$TMPDIR" &>/dev/null +t_CheckExitStatus $? + +# Check find fails for non existent directory +echo "Check find fails for non existent directory" +find "$TMPDIR"/1 &>/dev/null && { t_Log "FAIL: find incorrectly exited with 0 status"; exit $FAIL ; } +t_Log "PASS" + +# Check print0 works so we can use it for an xargs test +echo "Test -print0" +lines_count=$( find "$TMPDIR" -print0 | wc -l ) + +if [ $lines_count -eq 0 ] ; then + t_CheckExitStatus 0 +else + t_CheckExitStatus 1 +fi diff --git a/tests/p_findutils/20-xargs_tests b/tests/p_findutils/20-xargs_tests new file mode 100755 index 0000000..8f57aee --- /dev/null +++ b/tests/p_findutils/20-xargs_tests @@ -0,0 +1,17 @@ +#!/bin/bash +echo "Running $0" +TMPDIR=/var/tmp/find +# Basic xargs tests + +echo "Basic xargs tests" +find "$TMPDIR" -type f -print0 | xargs -0 ls &>/dev/null +#ls -l >/dev/null +t_CheckExitStatus $? + +echo "Check xargs fails when filenames with spaces are passed in" +find "$TMPDIR" -type f | xargs ls &>/dev/null && { t_Log "FAIL: This test returned 0 status incorrectly"; exit $FAIL; } +t_Log "PASS" + + +# Cleanup +[[ -d "$TMPDIR" ]] && rm -rf "$TMPDIR" diff --git a/tests/p_freeradius/0-install_freeradius.sh b/tests/p_freeradius/0-install_freeradius.sh deleted file mode 100755 index 2691b09..0000000 --- a/tests/p_freeradius/0-install_freeradius.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# Author: Christoph Galuschka - -# Install freeradius -# On C5 both freeradius and freeradius2 are provided, however only freeradius2-utils are provided as well -# so we will install freeradius2 on C5 and freeradius (being freeradius2) on C6 - -t_Log "Running $0 - installation and startup of freeradius." - -if (t_GetPkgRel basesystem | grep -q el6) -then - #Install Freeradius (V2) - t_InstallPackage freeradius -else - #Install Freeradius2 - t_InstallPackage freeradius2 -fi - -# start daemon with default settings -if (t_GetPkgRel basesystem | grep -q el6) -then - t_ServiceControl radiusd start -else - # C5 has an eap-setting in radiusd.conf and 3 "sites-enabled" which prevent successfull start (probably missing some dep) - # as the basic test works without these, the eap settings and 2 sites-enabled will be removed for the test and later restored - # Check if we allready did this - if [ ! -e /etc/raddb/radiusd.conf.orig ] - then - # File not yet copied - /bin/cp -a /etc/raddb/radiusd.conf /etc/raddb/radiusd.conf.orig - grep -iv eap /etc/raddb/radiusd.conf.orig > /etc/raddb/radiusd.conf - fi - rm -rf /etc/raddb/sites-enabled/control-socket - rm -rf /etc/raddb/sites-enabled/inner-tunnel - # /etc/raddb/sites-configured will be changed to include only basic files-authentication - # Check if we allready did this - if [ ! -e /etc/raddb/sites-available/default.orig ] - then - # File not yet copied - /bin/cp -a /etc/raddb/sites-available/default /etc/raddb/sites-available/default.orig - fi -cat > /etc/raddb/sites-available/default < + +# Install freeradius +# On C5 both freeradius and freeradius2 are provided, however only freeradius2-utils are provided as well +# so we will install freeradius2 on C5 and freeradius on C6/7 +# C7 comes with freeradius3 + +t_Log "Running $0 - installation and startup of freeradius." + +if [ $centos_ver -gt 5 ] +then + #Install Freeradius (V2/V3) + t_InstallPackage freeradius freeradius-utils +else + #Install Freeradius2 + t_InstallPackage freeradius2 freeradius2-utils +fi + +# start daemon with default settings +if [ $centos_ver -gt 5 ] +then + t_ServiceControl radiusd start +else + # C5 has an eap-setting in radiusd.conf and 3 "sites-enabled" which prevent successfull start (probably missing some dep) + # as the basic test works without these, the eap settings and 2 sites-enabled will be removed for the test and later restored + # Check if we allready did this + if [ ! -e /etc/raddb/radiusd.conf.orig ] + then + # File not yet copied + /bin/cp -a /etc/raddb/radiusd.conf /etc/raddb/radiusd.conf.orig + grep -iv eap /etc/raddb/radiusd.conf.orig > /etc/raddb/radiusd.conf + fi + rm -rf /etc/raddb/sites-enabled/control-socket + rm -rf /etc/raddb/sites-enabled/inner-tunnel + # /etc/raddb/sites-configured will be changed to include only basic files-authentication + # Check if we allready did this + if [ ! -e /etc/raddb/sites-available/default.orig ] + then + # File not yet copied + /bin/cp -a /etc/raddb/sites-available/default /etc/raddb/sites-available/default.orig + fi +cat > /etc/raddb/sites-available/default < +# Athmane Madjodj + +t_Log "Running $0 - freeradius-access test" + +# Make Backup of /etc/raddb/users and add testuser steve +/bin/cp /etc/raddb/users /etc/raddb/users.orig +echo 'steve Cleartext-Password := "centos"' >> /etc/raddb/users +echo ' Service-Type = Framed-User,' >> /etc/raddb/users + +# Restart Service +service radiusd restart + +#Run test + +t_Log "Running Test" +echo "User-Name=steve,User-Password=centos " | radclient -x localhost:1812 auth testing123 |grep -q 'Access-Accept' +ret_val=$? + +# Restore settings +/bin/cp /etc/raddb/users.orig /etc/raddb/users +rm -rf /etc/raddb/users.orig +service radiusd stop + +t_CheckExitStatus $ret_val diff --git a/tests/p_freeradius/radiusd_test.sh b/tests/p_freeradius/radiusd_test.sh deleted file mode 100755 index 703abac..0000000 --- a/tests/p_freeradius/radiusd_test.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Author: Christoph Galuschka -# Athmane Madjodj - -t_Log "Running $0 - freeradius-access test" - -if (t_GetPkgRel basesystem | grep -q el6) - then - t_InstallPackage freeradius-utils -else - t_InstallPackage freeradius2-utils -fi - -# Make Backup of /etc/raddb/users and add testuser steve -/bin/cp /etc/raddb/users /etc/raddb/users.orig -echo 'steve Cleartext-Password := "centos"' >> /etc/raddb/users -echo ' Service-Type = Framed-User,' >> /etc/raddb/users - -# Restart Service -service radiusd restart - -#Run test - -t_Log "Running Test" -echo "User-Name=steve,Password=centos " | radclient -x localhost:1812 auth testing123 |grep -q 'Access-Accept' -ret_val=$? - -# Restore settings -/bin/cp /etc/raddb/users.orig /etc/raddb/users -rm -rf /etc/raddb/users.orig -service radiusd restart - -t_CheckExitStatus $ret_val diff --git a/tests/p_gzip/10-C5-test-binaries b/tests/p_gzip/10-C5-test-binaries index 5730da8..7f568b2 100755 --- a/tests/p_gzip/10-C5-test-binaries +++ b/tests/p_gzip/10-C5-test-binaries @@ -24,11 +24,12 @@ do $binary --version &>/dev/null || ExitFail done -for binary in zmore -do - echo -n "$binary " - $binary &>/dev/null || ExitFail -done +#disabled, needs to be looked into +#for binary in zmore +#do +# echo -n "$binary " +# $binary &>/dev/null || ExitFail +#done for binary in znew zforce do diff --git a/tests/p_gzip/10-test-binaries b/tests/p_gzip/10-test-binaries index cd67acb..3bb5957 100755 --- a/tests/p_gzip/10-test-binaries +++ b/tests/p_gzip/10-test-binaries @@ -1,5 +1,7 @@ #!/bin/bash # Author: Iain Douglas +# Author: Rene Diepstraten +# Christoph Galuschka # # Check the binaries from the package exist and run ok @@ -8,11 +10,22 @@ function ExitFail { exit $FAIL } -[ $centos_ver != '6' ] && exit -t_Log "Checking binaries are present and run on C6" +if [ $centos_ver -lt 6 ] + then + exit 0 +fi -[ "$(readlink -e /usr/bin/gunzip)" == "/bin/gunzip" ] || ExitFail -[ "$(readlink -e /usr/bin/gzip)" == "/bin/gzip" ] || ExitFail +t_Log "Checking binaries are present and run on C6/C7" + +if [ $centos_ver == 7 ] +then + [ "$(readlink -e /usr/bin/gunzip)" == "/usr/bin/gunzip" ] || ExitFail + [ "$(readlink -e /usr/bin/gzip)" == "/usr/bin/gzip" ] || ExitFail +elif [ $centos_ver == 6 ] +then + [ "$(readlink -e /bin/gunzip)" == "/bin/gunzip" ] || ExitFail + [ "$(readlink -e /bin/gzip)" == "/bin/gzip" ] || ExitFail +fi for binary in gunzip gzip zcat gzexe zcmp zdiff zegrep zfgrep zforce zgrep zless zmore znew do diff --git a/tests/p_gzip/20-gzip-test b/tests/p_gzip/20-gzip-test index 055331e..d7bf553 100755 --- a/tests/p_gzip/20-gzip-test +++ b/tests/p_gzip/20-gzip-test @@ -2,6 +2,7 @@ # Author: Athmane Madjoudj # Author: Christoph Galuschka # Author: Iain Douglas +# Author: Rene Diepstraten function ExitFail { t_Log "FAIL" @@ -65,7 +66,7 @@ t_Log "Check -a is ignored as we're on CentOS" if [ $centos_ver == '5' ] then gunzip -a $FILE.gz 2>&1 | head -n 1 | grep -q 'gunzip: option --ascii ignored on this system' || ExitFail -elif [ $centos_ver == '6' ] +elif [[ $centos_ver =~ ^(6|7)$ ]] then gunzip -a $FILE.gz 2>&1 | head -n 1 | grep -q 'gzip: option --ascii ignored on this system' || ExitFail fi diff --git a/tests/p_httpd/0-install_httpd.sh b/tests/p_httpd/0-install_httpd.sh index 33e3d9a..c9620f2 100755 --- a/tests/p_httpd/0-install_httpd.sh +++ b/tests/p_httpd/0-install_httpd.sh @@ -1,14 +1,14 @@ #!/bin/bash # Author: Athmane Madjoudj -# Christoph Galuschka +# Christoph Galuschka # Install tests deps -t_Log "Running $0 - httpd: installing curl, http, php and mysql" +t_Log "Running $0 - httpd: installing curl, http, php and php-mysql" -t_InstallPackage curl +#t_InstallPackage curl # HTTPD / PHP -t_InstallPackage httpd mod_ssl php php-mysql +t_InstallPackage curl httpd mod_ssl php php-mysql t_ServiceControl httpd stop sleep 3 killall httpd diff --git a/tests/p_iputils/tracepath_test.sh b/tests/p_iputils/tracepath_test.sh index e625da0..b8112ab 100755 --- a/tests/p_iputils/tracepath_test.sh +++ b/tests/p_iputils/tracepath_test.sh @@ -5,7 +5,7 @@ TEST=tracepath # Testing availability of network if [ $SKIP_QA_HARNESS -eq 1 ]; then - HOST="wiki.centos.org" + HOST="ci.dev.centos.org" else HOST="repo.centos.qa" fi diff --git a/tests/p_lftp/10_lftp_http_test.sh b/tests/p_lftp/10_lftp_http_test.sh index 0cb8a2f..cbe1e9e 100755 --- a/tests/p_lftp/10_lftp_http_test.sh +++ b/tests/p_lftp/10_lftp_http_test.sh @@ -6,13 +6,19 @@ # Christoph Galuschka t_Log "Running $0 - lftp: HTTP test" + if [ $SKIP_QA_HARNESS -eq 1 ]; then CHECK_FOR="UTC" URL="http://mirror.centos.org/" FILE="timestamp.txt" else CHECK_FOR="CentOS" - URL="http://repo.centos.qa/srv/CentOS/6/os/x86_64/" + ARCH=$(t_GetArch) + if [ $ARCH == "i686" ]; then + URL="http://repo.centos.qa/srv/CentOS/6/os/i386/" + else + URL="http://repo.centos.qa/srv/CentOS/6/os/x86_64/" + fi FILE="RELEASE-NOTES-en-US.html" fi diff --git a/tests/p_lynx/lynx_dump_page_test.sh b/tests/p_lynx/lynx_dump_page_test.sh index ddafa67..15a2fc8 100755 --- a/tests/p_lynx/lynx_dump_page_test.sh +++ b/tests/p_lynx/lynx_dump_page_test.sh @@ -4,13 +4,13 @@ t_Log "Running $0 - check that lynx can dump remote page." if [ $SKIP_QA_HARNESS -eq 1 ]; then - HOST=wiki.centos.org - CHECK_FOR="Page templates" + URL="http://ci.dev.centos.org/cstatic/" + CHECK_FOR="CentOS CI test page" else - HOST=repo.centos.qa + URL="http://repo.centos.qa/qa/" CHECK_FOR="ks_cfg" fi -lynx -dump http://${HOST}/qa/ | grep "${CHECK_FOR}" >/dev/null 2>&1 +lynx -dump ${URL} | grep "${CHECK_FOR}" >/dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_mod_wsgi/mod_wsgi_test.sh b/tests/p_mod_wsgi/mod_wsgi_test.sh index 95a0aee..65a049f 100755 --- a/tests/p_mod_wsgi/mod_wsgi_test.sh +++ b/tests/p_mod_wsgi/mod_wsgi_test.sh @@ -3,7 +3,8 @@ t_Log "Running $0 - Apache httpd mod_wsgi is functional" if (t_GetPkgRel basesystem | grep -q el6); then while [ `ps fax | grep 'sbin/httpd' | grep -v grep | wc -l` -gt 0 ]; do - t_ServiceControl httpd stop + #t_ServiceControl httpd stop + killall -s KILL httpd sleep 1 done @@ -31,4 +32,4 @@ EOF else echo "Skipped on CentOS 5" -fi \ No newline at end of file +fi diff --git a/tests/p_mtr/mtr_test.sh b/tests/p_mtr/mtr_test.sh index ee4a439..862314e 100755 --- a/tests/p_mtr/mtr_test.sh +++ b/tests/p_mtr/mtr_test.sh @@ -5,7 +5,7 @@ TEST=mtr # Testing availability of network if [ $SKIP_QA_HARNESS -eq 1 ]; then - HOST="wiki.centos.org" + HOST="ci.dev.centos.org" else HOST="repo.centos.qa" fi diff --git a/tests/p_mysql/0-install_mysqld.sh b/tests/p_mysql/0-install_mysqld.sh index 96dfa72..46b96f1 100755 --- a/tests/p_mysql/0-install_mysqld.sh +++ b/tests/p_mysql/0-install_mysqld.sh @@ -1,8 +1,22 @@ #!/bin/bash # Author: Athmane Madjoudj +# Christoph Galuschka t_Log "Running $0 - installing and starting mysql server." +if [ $centos_ver -gt 6 ] +then + t_Log 'mysql is only supported on C5 and C6, skipping' + t_CheckExitStatus 0 + exit 0 +fi + # MySQL -t_InstallPackage mysql-server +# starting with 5.10, we have to add mysql55 +if [ $centos_ver = 5 ] +then + t_InstallPackage mysql55-mysql-server mysql-server nc +else + t_InstallPackage mysql-server nc +fi t_ServiceControl mysqld start >/dev/null 2>&1 diff --git a/tests/p_mysql/10_mysqld_conn_test.sh b/tests/p_mysql/10_mysqld_conn_test.sh new file mode 100755 index 0000000..9a9eaf8 --- /dev/null +++ b/tests/p_mysql/10_mysqld_conn_test.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +t_Log "Running $0 - mysqld client can talk to mysql server." + +if [ $centos_ver -gt 6 ] +then + t_Log 'mysql is only supported on C5 and C6, skipping' + t_CheckExitStatus 0 + exit 0 +fi + +HostName=$(hostname -s) +MySqlHostName=$(mysql -N -B -u root -e "show variables like 'hostname'" | cut -f 2 | cut -d . -f 1) +# printing both variables for debugging purposes +echo $HostName +echo ${MySqlHostName} +if [ $HostName = ${MySqlHostName} ]; then + ret_val=0 +else + ret_val=1 +fi +t_CheckExitStatus $ret_val + +t_Log "Running $0 - mysqld listening test." +grep 'skip-networking' /etc/my.cnf > /dev/null +if [ $? -eq 1 ]; then + # FIXME: Test is very basic + nc -d -w 1 localhost 3306 >/dev/null 2>&1 + t_CheckExitStatus $? +else + t_Log "Skipped, looks like networking is disabled for mysql" +fi diff --git a/tests/p_mysql/15_mysqld_create_db.sh b/tests/p_mysql/15_mysqld_create_db.sh new file mode 100755 index 0000000..9697590 --- /dev/null +++ b/tests/p_mysql/15_mysqld_create_db.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +t_Log "Running $0 - MySQL create database test" + +if [ $centos_ver -gt 6 ] +then + t_Log 'mysql is only supported on C5 and C6, skipping' + t_CheckExitStatus 0 + exit 0 +fi + +mysql -u root -e 'create database mysql_test' >/dev/null 2>&1 +t_CheckExitStatus $? diff --git a/tests/p_mysql/20_mysqld_drop_db.sh b/tests/p_mysql/20_mysqld_drop_db.sh new file mode 100755 index 0000000..d2ded67 --- /dev/null +++ b/tests/p_mysql/20_mysqld_drop_db.sh @@ -0,0 +1,14 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +t_Log "Running $0 - MySQL drop database test." + +if [ $centos_ver -gt 6 ] +then + t_Log 'mysql is only supported on C5 and C6, skipping' + t_CheckExitStatus 0 + exit 0 +fi + +mysql -u root -e 'drop database mysql_test' >/dev/null 2>&1 +t_CheckExitStatus $? diff --git a/tests/p_mysql/25_mysqld_grant_test.sh b/tests/p_mysql/25_mysqld_grant_test.sh new file mode 100755 index 0000000..e6e9704 --- /dev/null +++ b/tests/p_mysql/25_mysqld_grant_test.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Author: Athmane Madjoudj + +t_Log "Running $0 - MySQL GRANT privileges test" + +if [ $centos_ver -gt 6 ] +then + t_Log 'mysql is only supported on C5 and C6, skipping' + t_CheckExitStatus 0 + exit 0 +fi + +mysql -u root -e 'create database mysql_test;' > /dev/null 2>&1 +mysql -u root -e "grant all on mysql_test.* to mysql_test@localhost identified by 'mysqltest'" > /dev/null 2>&1 +mysql -u root -e "flush privileges;" > /dev/null 2>&1 +mysql -u mysql_test -pmysqltest mysql_test -e 'create table test_table(id int);' > /dev/null 2>&1 +ret_val=$? + +# Clean up +mysql -u root -e 'drop database mysql_test;' > /dev/null 2>&1 + +t_CheckExitStatus $ret_val diff --git a/tests/p_mysql/50_switch_to_mysql55.sh b/tests/p_mysql/50_switch_to_mysql55.sh new file mode 100755 index 0000000..aaf5634 --- /dev/null +++ b/tests/p_mysql/50_switch_to_mysql55.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Author: Athmane Madjoudj +# Christoph Galuschka + +t_Log "Running $0 - switching to mysql55 on C5." + +if [ $centos_ver = 5 ] +then + t_ServiceControl mysqld stop + t_ServiceControl mysql55-mysqld start >/dev/null 2>&1 +else + t_Log "This is not a C5 system - skipping" +fi diff --git a/tests/p_mysql/60_mysqld55_conn_test.sh b/tests/p_mysql/60_mysqld55_conn_test.sh new file mode 100755 index 0000000..7b98ade --- /dev/null +++ b/tests/p_mysql/60_mysqld55_conn_test.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +t_Log "Running $0 - mysqld client can talk to mysql55 server." + +if [ $centos_ver -gt 5 ] +then + t_Log 'mysql55 is only avialable on C5, skipping' + t_CheckExitStatus 0 + exit 0 +fi + +HostName=$(hostname -s) +MySqlHostName=$(mysql -N -B -u root -e "show variables like 'hostname'" | cut -f 2 | cut -d . -f 1) +if [ $HostName = ${MySqlHostName} ]; then + ret_val=0 +else + ret_val=1 +fi +t_CheckExitStatus $ret_val + +t_Log "Running $0 - mysqld listening test." +grep 'skip-networking' /etc/my.cnf > /dev/null +if [ $? -eq 1 ]; then + # FIXME: Test is very basic + nc -d -w 1 localhost 3306 >/dev/null 2>&1 + t_CheckExitStatus $? +else + t_Log "Skipped, looks like networking is disabled for mysql" +fi diff --git a/tests/p_mysql/65_mysqld55_create_db.sh b/tests/p_mysql/65_mysqld55_create_db.sh new file mode 100755 index 0000000..43b15bc --- /dev/null +++ b/tests/p_mysql/65_mysqld55_create_db.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# Author: Athmane Madjoudj +# Christoph Galuschka + +t_Log "Running $0 - MySQL55 create database test" + +if [ $centos_ver -gt 5 ] +then + t_Log 'mysql55 is only supported on C5, skipping' + t_CheckExitStatus 0 + exit 0 +fi + +mysql -u root -e 'create database mysql_test' >/dev/null 2>&1 +t_CheckExitStatus $? diff --git a/tests/p_mysql/70_mysqld55_drop_db.sh b/tests/p_mysql/70_mysqld55_drop_db.sh new file mode 100755 index 0000000..177b907 --- /dev/null +++ b/tests/p_mysql/70_mysqld55_drop_db.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# Author: Athmane Madjoudj +# Christoph Galuschka + +t_Log "Running $0 - MySQL55 drop database test." + +if [ $centos_ver -gt 5 ] +then + t_Log 'mysql55 is only supported on C5, skipping' + t_CheckExitStatus 0 + exit 0 +fi + +mysql -u root -e 'drop database mysql_test' >/dev/null 2>&1 +t_CheckExitStatus $? diff --git a/tests/p_mysql/75_mysqld55_grant_test.sh b/tests/p_mysql/75_mysqld55_grant_test.sh new file mode 100755 index 0000000..ff2cb94 --- /dev/null +++ b/tests/p_mysql/75_mysqld55_grant_test.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Author: Athmane Madjoudj +# Christoph Galuschka + +t_Log "Running $0 - MySQL55 GRANT privileges test" + +if [ $centos_ver -gt 5 ] +then + t_Log 'mysql55 is only supported on C5, skipping' + t_CheckExitStatus 0 + exit 0 +fi + +mysql -u root -e 'create database mysql_test;' > /dev/null 2>&1 +mysql -u root -e "grant all on mysql_test.* to mysql_test@localhost identified by 'mysqltest'" > /dev/null 2>&1 +mysql -u root -e "flush privileges;" > /dev/null 2>&1 +mysql -u mysql_test -pmysqltest mysql_test -e 'create table test_table(id int);' > /dev/null 2>&1 +ret_val=$? + +# Clean up +mysql -u root -e 'drop database mysql_test;' > /dev/null 2>&1 + +t_CheckExitStatus $ret_val diff --git a/tests/p_mysql/mysqld_conn_test.sh b/tests/p_mysql/mysqld_conn_test.sh deleted file mode 100755 index 25ce173..0000000 --- a/tests/p_mysql/mysqld_conn_test.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -t_Log "Running $0 - mysqld client can talk to mysql server." -HostName=$(hostname -s) -MySqlHostName=$(mysql -N -B -u root -e "show variables like 'hostname'" | cut -f 2 | cut -d . -f 1) -if [ $HostName = ${MySqlHostName} ]; then - ret_val=0 -else - ret_val=1 -fi -t_CheckExitStatus $ret_val - -t_Log "Running $0 - mysqld listening test." -grep 'skip-networking' /etc/my.cnf > /dev/null -if [ $? -eq 1 ]; then - # FIXME: Test is very basic - nc -d -w 1 localhost 3306 >/dev/null 2>&1 - t_CheckExitStatus $? -else - t_Log "Skipped, looks like networking is disabled for mysql" -fi diff --git a/tests/p_mysql/mysqld_create_db.sh b/tests/p_mysql/mysqld_create_db.sh deleted file mode 100755 index 3c0b911..0000000 --- a/tests/p_mysql/mysqld_create_db.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# Author: Athmane Madjoudj - -t_Log "Running $0 - MySQL create database test" -mysql -u root -e 'create database mysql_test' >/dev/null 2>&1 -t_CheckExitStatus $? diff --git a/tests/p_mysql/mysqld_drop_db.sh b/tests/p_mysql/mysqld_drop_db.sh deleted file mode 100755 index b1db254..0000000 --- a/tests/p_mysql/mysqld_drop_db.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# Author: Athmane Madjoudj - -t_Log "Running $0 - MySQL drop database test." -mysql -u root -e 'drop database mysql_test' >/dev/null 2>&1 -t_CheckExitStatus $? diff --git a/tests/p_mysql/mysqld_grant_test.sh b/tests/p_mysql/mysqld_grant_test.sh deleted file mode 100755 index da21c00..0000000 --- a/tests/p_mysql/mysqld_grant_test.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# Author: Athmane Madjoudj - -t_Log "Running $0 - MySQL GRANT privileges test" - -mysql -u root -e 'create database mysql_test;' > /dev/null 2>&1 -mysql -u root -e "grant all on mysql_test.* to mysql_test@localhost identified by 'mysqltest'" > /dev/null 2>&1 -mysql -u root -e "flush privileges;" > /dev/null 2>&1 -mysql -u mysql_test -pmysqltest mysql_test -e 'create table test_table(id int);' > /dev/null 2>&1 -ret_val=$? - -# Clean up -mysql -u root -e 'drop database mysql_test;' > /dev/null 2>&1 - -t_CheckExitStatus $ret_val diff --git a/tests/p_network/networking_vlan_test.sh b/tests/p_network/networking_vlan_test.sh index 79ab3a9..c4b2c30 100755 --- a/tests/p_network/networking_vlan_test.sh +++ b/tests/p_network/networking_vlan_test.sh @@ -1,56 +1,57 @@ #!/bin/sh # Author: Christoph Galuschka -t_Log "Running $0 - create VLAN IF, assign IP on VLAN IF and tear down VLAN IF using IP command test (C6 only)" +t_Log "Running $0 - create VLAN IF, assign IP on VLAN IF and tear down VLAN IF using IP command test (not on C5)" ret_val=0 -if [ $centos_ver == 6 ] +if [ $centos_ver -lt 6 ] +then + t_Log ' This is a C5 system, skipping test' + exit 0 +fi + +t_Log 'This is no C5-system, commencing test' +# create VLAN-IF 10 on eth0 +ip link add dev eth0.10 link eth0 type vlan id 10 +ip addr list | grep -q eth0.10 +if [ $? == 1 ] then - t_Log 'This is a C6-system, commencing test' - # create VLAN-IF 10 on eth0 - ip link add dev eth0.10 link eth0 type vlan id 10 - ip addr list | grep -q eth0.10 - if [ $? == 1 ] - then - t_Log "VLAN-IF creation failed" - ret_val=1 - else - t_Log "VLAN-IF successfully created" - fi + t_Log "VLAN-IF creation failed" + ret_val=1 +else + t_Log "VLAN-IF successfully created" +fi - #assign IP address on VLAN-IF - ip address add 172.16.30.1/32 dev eth0.10 - ip addr list | grep -q 172.16.30.1 - if [ $? == 1 ] - then - t_Log "IP address assignment on eth0.10 failed" - ret_val=1 - else - t_Log "IP address successfully assigned on eth1.10" - fi +#assign IP address on VLAN-IF +ip address add 172.16.30.1/32 dev eth0.10 +ip addr list | grep -q 172.16.30.1 +if [ $? == 1 ] + then + t_Log "IP address assignment on eth0.10 failed" + ret_val=1 +else + t_Log "IP address successfully assigned on eth0.10" +fi - #testing address with ping - ping -c 4 -q 172.16.30.1 | grep -q '4 received' - if [ $? == 1 ] - then - t_Log "pinging on eth0.10 failed" - ret_val=1 - else - t_Log "local ping on VLAN IF worked" - fi +#testing address with ping +ping -c 4 -q 172.16.30.1 | grep -q '4 received' +if [ $? == 1 ] + then + t_Log "pinging on eth0.10 failed" + ret_val=1 +else + t_Log "local ping on VLAN IF worked" +fi - # delete VLAN-IF 10 on eth0 - ip link delete eth0.10 - ip addr list | grep -q eth0.10 - if [ $? == 0 ] - then - t_Log "Removing VLAN IF failed" - ret_val=1 - else - t_Log "Removing of VLAN IF worked" - fi +# delete VLAN-IF 10 on eth0 +ip link delete eth0.10 +ip addr list | grep -q eth0.10 +if [ $? == 0 ] + then + t_Log "Removing VLAN IF failed" + ret_val=1 else - t_Log ' This is a C5 system, skipping test' + t_Log "Removing of VLAN IF worked" fi t_CheckExitStatus $ret_val diff --git a/tests/p_php/20-php-mysql-test.sh b/tests/p_php/20-php-mysql-test.sh index 9437799..23f4497 100755 --- a/tests/p_php/20-php-mysql-test.sh +++ b/tests/p_php/20-php-mysql-test.sh @@ -1,6 +1,6 @@ #!/bin/sh # Author: Athmane Madjoudj -# Author: Christoph Galuschka +# Author: Christoph Galuschka # reusing the script from LAMP-Tests t_Log "Running $0 - php-cli basic interaction with mysql test." @@ -9,8 +9,20 @@ t_Log "Running $0 - php-cli basic interaction with mysql test." t_InstallPackage php-mysql # we need a working and running mysql server -t_InstallPackage mysql-server -t_ServiceControl mysqld start >/dev/null 2>&1 +#starting with 5.10 we need to reflect mysql55 +if [ $centos_ver = 5 ] +then + t_InstallPackage mysql-server mysql55-mysql-server nc + t_ServiceControl mysql55-mysqld stop + t_ServiceControl mysqld start >/dev/null 2>&1 +elif [ $centos_ver = 6 ] +then + t_InstallPackage mysql-server nc + t_ServiceControl mysqld start >/dev/null 2>&1 +else + t_InstallPackage mariadb-server nc + t_ServiceControl mariadb start >/dev/null 2>&1 +fi #create a little DB to use CREATE='/var/tmp/mysql-php-QA.sql' @@ -74,3 +86,4 @@ t_CheckExitStatus $? #cleaning up /bin/rm $READ $CREATE $INSERT +mysql -u root -e 'drop database phptests' >/dev/null 2>&1 diff --git a/tests/p_php/25-php-mysql55-test.sh b/tests/p_php/25-php-mysql55-test.sh new file mode 100755 index 0000000..d655617 --- /dev/null +++ b/tests/p_php/25-php-mysql55-test.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# Author: Athmane Madjoudj +# Author: Christoph Galuschka +# reusing the script from LAMP-Tests + +t_Log "Running $0 - php-cli basic interaction with mysql55 test." +if [ $centos_ver != 5 ] +then + t_Log "This is not a C5-system - skipping" + exit 0 +fi + +# Install php-mysql-module +t_InstallPackage php-mysql + +# we need a working and running mysql server +#starting with 5.10 we need to reflect mysql55 +t_ServiceControl mysqld stop +t_ServiceControl mysql55-mysqld start >/dev/null 2>&1 + +#create a little DB to use +CREATE='/var/tmp/mysql-php-QA.sql' + +cat >$CREATE <$INSERT < +EOF + +php $INSERT +if [ $? -ne 0 ] + then + t_Log "Inserting into DB failed" + exit 1 +fi + +# create PHP script to read from DB +READ='/var/tmp/read.php' +cat >$READ < +EOF + +# If we execute the script and get '1' it works (1 entry should be in the DB) +php $READ | grep -q '1' + +t_CheckExitStatus $? + +#cleaning up +/bin/rm $READ $CREATE $INSERT +mysql -u root -e 'drop database phptests' >/dev/null 2>&1 diff --git a/tests/p_postfix/0-install_postfix.sh b/tests/p_postfix/0-install_postfix.sh index db7b1ec..798e897 100755 --- a/tests/p_postfix/0-install_postfix.sh +++ b/tests/p_postfix/0-install_postfix.sh @@ -10,5 +10,5 @@ sleep 3 t_RemovePackage sendmail exim # Postfix -t_InstallPackage postfix +t_InstallPackage postfix nc t_ServiceControl postfix start diff --git a/tests/p_postfix/40_postfix_sasl.sh b/tests/p_postfix/40_postfix_sasl.sh new file mode 100755 index 0000000..3ac5c04 --- /dev/null +++ b/tests/p_postfix/40_postfix_sasl.sh @@ -0,0 +1,94 @@ +#!/bin/sh +# Author: Christoph Galuschka + +t_Log "Running $0 - Postfix plain SASL test." +t_Log "Installing prerequisits" + +t_InstallPackage dovecot + +#creating backups of changed files +cp -a /etc/postfix/main.cf /etc/postfix/main.cf_testing +if [ $centos_ver = 5 ] + then + cp -a /etc/dovecot.conf /etc/dovecot.conf_testing +else + cp -a /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf_testing +fi + +#adding parameters to postfix +cat >> /etc/postfix/main.cf < /etc/dovecot.conf <> /etc/dovecot/dovecot.conf < + +t_Log "Running $0 - Postfix plain SASL test." +t_Log "Installing prerequisits" + +t_InstallPackage openssl + +#creating backups of changed files +cp -a /etc/postfix/main.cf /etc/postfix/main.cf_testing +if [ $centos_ver = 5 ] + then + cp -a /etc/dovecot.conf /etc/dovecot.conf_testing +else + cp -a /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf_testing +fi + +#creating certificates +TESTDIR='/var/tmp/openssl-test' +mkdir $TESTDIR +t_Log "creating private key" +if [ $centos_ver = 6 ] + then + openssl genpkey -algorithm rsa -out $TESTDIR/server.key.secure -pkeyopt rsa_keygen_bits:2048 > /dev/null 2>&1 +else + openssl genrsa -passout pass:centos -des3 -rand file1:file2:file3:file4:file5 -out $TESTDIR/server.key.secure 2048 > /dev/null 2>&1 +fi +if [ $? == 1 ] + then t_Log "Creation of private key failed." + ret_val=1 + exit +fi + +#create default answer file +cat > $TESTDIR/openssl_answers< /dev/null 2>&1 +else + openssl rsa -passin pass:centos -in $TESTDIR/server.key.secure -out $TESTDIR/server.key > /dev/null 2>&1 +fi +if [ $? == 1 ] + then t_Log "Creation of server key failed." + ret_val=1 + exit +fi + +openssl req -batch -config $TESTDIR/openssl_answers -new -key $TESTDIR/server.key -out $TESTDIR/server.csr > /dev/null 2>&1 +if [ $? == 1 ] + then t_Log "Creation of CSR failed." + ret_val=1 + exit +fi + +t_Log "creating server certificate" +openssl x509 -req -days 3600 -in $TESTDIR/server.csr -signkey $TESTDIR/server.key -out $TESTDIR/server.crt > /dev/null 2>&1 +if [ $? == 1 ] + then t_Log "Creation of CRT failed." + ret_val=1 + exit +fi + +#copy files to destinations +cp -a $TESTDIR/server.crt /etc/pki/tls/certs/ +cp -a $TESTDIR/server.key /etc/pki/tls/private/ + +#adding parameters to postfix +cat >> /etc/postfix/main.cf < /etc/dovecot.conf <> /etc/dovecot/dovecot.conf </dev/null 2>&1 # Installing additional python/mysql module diff --git a/tests/p_python/25-python-mysql55-test.sh b/tests/p_python/25-python-mysql55-test.sh new file mode 100755 index 0000000..ed62c3a --- /dev/null +++ b/tests/p_python/25-python-mysql55-test.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Author: Athmane Madjoudj +# Author: Christoph Galuschka + +t_Log "Running $0 - python can retrieve mysql55-mysql-server version information." + +# we need a working and running mysql server +# starting with 5.10, we have to differ between mysql55 and mysql +if [ $centos_ver = 5 ] +then + t_ServiceControl mysqld stop + t_ServiceControl mysql55-mysqld start +fi + +# Installing additional python/mysql module +t_InstallPackage MySQL-python + +# create python Scrip +SCRIPT='/var/tmp/test.py' + +cat >$SCRIPT < + +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..12206c6 --- /dev/null +++ b/tests/p_shadow-utils/11-useradd_tests @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "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..49c6279 --- /dev/null +++ b/tests/p_shadow-utils/12-usermod_tests @@ -0,0 +1,10 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "Running $0 - 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..cb47fc5 --- /dev/null +++ b/tests/p_shadow-utils/13-chpasswd_tests @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "Running $0 - Checking chpasswd" + +chpasswd -e < + +t_Log "Running $0 - Testing newusers" +grep -q "^xyssy" /etc/passwd && { t_Log "FAIL: user xyssy alredy exists"; exit $FAIL; } +newusers < + +t_Log "Running $0 - 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..096d68c --- /dev/null +++ b/tests/p_shadow-utils/19-userdel_tests @@ -0,0 +1,9 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "Running $0 - 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..5f85c97 --- /dev/null +++ b/tests/p_shadow-utils/20-chage_tests @@ -0,0 +1,15 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "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..79f4617 --- /dev/null +++ b/tests/p_shadow-utils/30-groupadd_tests @@ -0,0 +1,11 @@ +#!/bin/bash +# Author: Iain Douglas +t_Log "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..179d61c --- /dev/null +++ b/tests/p_shadow-utils/31-gpasswd_tests @@ -0,0 +1,7 @@ +#!/bin/bash +# Author: Iain Douglas +t_Log "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..7e3cc90 --- /dev/null +++ b/tests/p_shadow-utils/32-groupmems_tests @@ -0,0 +1,8 @@ +#!/bin/bash +# Author: Iain Douglas +[ $centos_ver == '5' ] && exit +t_Log "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..41c1da2 --- /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 +# +t_Log "Running $0 - 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 < + +t_Log "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..e48b68d --- /dev/null +++ b/tests/p_shadow-utils/35-grpck-tests @@ -0,0 +1,23 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "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..8677902 --- /dev/null +++ b/tests/p_shadow-utils/36-groupdel-tests @@ -0,0 +1,34 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "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..52dfa81 --- /dev/null +++ b/tests/p_shadow-utils/37-grpconv-tests @@ -0,0 +1,28 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "Running $0" +# 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..76eec52 --- /dev/null +++ b/tests/p_shadow-utils/38-grpunconv-tests @@ -0,0 +1,24 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "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..c25b873 --- /dev/null +++ b/tests/p_shadow-utils/39-sg_tests @@ -0,0 +1,9 @@ +#!/bin/bash +# Author: Iain Douglas +t_Log "Running $0 - 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..ac27fe3 --- /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. + +t_Log "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..5b8b4eb --- /dev/null +++ b/tests/p_shadow-utils/41-pwconv_tests @@ -0,0 +1,25 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "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..6c00213 --- /dev/null +++ b/tests/p_shadow-utils/42-pwunconv_tests @@ -0,0 +1,25 @@ +#!/bin/bash +# Author: Iain Douglas + +t_Log "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 + + diff --git a/tests/p_squid/squid_test.sh b/tests/p_squid/squid_test.sh index 17bb214..982a49e 100755 --- a/tests/p_squid/squid_test.sh +++ b/tests/p_squid/squid_test.sh @@ -4,13 +4,13 @@ t_Log "Running $0 - Squid test." if [ $SKIP_QA_HARNESS -eq 1 ]; then - HOST=wiki.centos.org - CHECK_FOR="Page templates" + URL="http://ci.dev.centos.org/cstatic/" + CHECK_FOR="CentOS CI test page" else - HOST=repo.centos.qa + URL="http://repo.centos.qa/qa/" CHECK_FOR="ks_cfg" fi -squidclient -T 2 http://${HOST}/qa/ | grep "${CHECK_FOR}" >/dev/null 2>&1 +squidclient -T 2 ${URL} | grep "${CHECK_FOR}" >/dev/null 2>&1 t_CheckExitStatus $? diff --git a/tests/p_systemd/10-systemctl_list_services.sh b/tests/p_systemd/10-systemctl_list_services.sh new file mode 100755 index 0000000..1e2b3d5 --- /dev/null +++ b/tests/p_systemd/10-systemctl_list_services.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Athmane Madjoudj +# Rene Diepstraten + +t_Log "Running $0 - Checking if systemctl can check if a service is enabled" +[ ${centos_ver} -lt 7 ] && { t_Log "Systemd is part of el since el7, skipping systemd tests..." ; exit ; } + +# auditd is used as example because it's standard with minimal install + +systemctl is-enabled auditd.service > /dev/null + +t_CheckExitStatus $? \ No newline at end of file diff --git a/tests/p_systemd/15-systemctl_list_non-native-services.sh b/tests/p_systemd/15-systemctl_list_non-native-services.sh new file mode 100755 index 0000000..c9f757d --- /dev/null +++ b/tests/p_systemd/15-systemctl_list_non-native-services.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Athmane Madjoudj +# Rene Diepstraten + +[ ${centos_ver} -lt 7 ] && exit +t_Log "Running $0 - Checking if systemctl can check if a non-native service is enabled" + +# netconsole is used as example because it's a non native service with minimal install + +systemctl is-enabled netconsole.service 2> /dev/null | grep -q -E 'enabled|disabled' + +t_CheckExitStatus $? diff --git a/tests/p_systemd/20-systemctl_list-service-status.sh b/tests/p_systemd/20-systemctl_list-service-status.sh new file mode 100755 index 0000000..ecd2bee --- /dev/null +++ b/tests/p_systemd/20-systemctl_list-service-status.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Author: Rene Diepstraten + +[ ${centos_ver} -lt 7 ] && exit +t_Log "Running $0 - checking if systemctl can check a service status" + +systemctl is-active auditd.service > /dev/null + +t_CheckExitStatus $? \ No newline at end of file diff --git a/tests/p_systemd/25-journalctl.sh b/tests/p_systemd/25-journalctl.sh new file mode 100755 index 0000000..e43631b --- /dev/null +++ b/tests/p_systemd/25-journalctl.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Rene Diepstraten + +[ ${centos_ver} -lt 7 ] && exit +t_Log "Running $0 - Testing journalctl for teststring" + +teststring=098f6bcd4621d373cade4e832627b4f6 +timenow=$(date +'%T') +echo ${teststring} > /dev/kmsg +journalctl --since ${timenow} | grep -q ${teststring} + +t_CheckExitStatus $? \ No newline at end of file diff --git a/tests/p_tcpdump/tcpdump_eth0.sh b/tests/p_tcpdump/tcpdump_eth0.sh index 673b514..88cc391 100755 --- a/tests/p_tcpdump/tcpdump_eth0.sh +++ b/tests/p_tcpdump/tcpdump_eth0.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Author: Christoph Galuschka +# Author: Christoph Galuschka # Athmane Madjoudj t_Log "Running $0 - TCPdump test to Default-GW with IPv4" @@ -13,7 +13,7 @@ if [[ $IP =~ $regex ]] #Dumping 4 pings via eth0 to file FILE='/var/tmp/eth0_test.pcap' COUNT='4' - tcpdump -q -n -p -i eth0 -w $FILE & + tcpdump -q -n -p -w $FILE & # If we don't wait a short time, the first paket will be missed by tcpdump sleep 1 ping -q -c $COUNT -i 0.25 ${BASH_REMATCH[1]} > /dev/null 2>&1 @@ -35,9 +35,9 @@ if [[ $IP =~ $regex ]] fi else # in qa-harness, which is a controlled environment, the script will fail at odd results - if [ $WORKING == $[COUNT*2] ] + if [ $WORKING == $[COUNT*2] ] || [ $WORKING -gt $[COUNT*2] ] then - t_Log "QA-harness: ping to Default-Gateway looks OK. "$WORKING" of "$[COUNT*2]" pakets were dumped to file" + t_Log "QA-harness: ping to Default-Gateway looks OK. At least "$[COUNT*2]" pakets ("$WORKING") were dumped to file" ret_val=0 else t_Log "QA-harness: ping to Default-Gateway droped pakets!! Only "$WORKING" of "$[COUNT*2]" entries were found!!" diff --git a/tests/p_traceroute/traceroute_test.sh b/tests/p_traceroute/traceroute_test.sh index a92e653..b311abd 100755 --- a/tests/p_traceroute/traceroute_test.sh +++ b/tests/p_traceroute/traceroute_test.sh @@ -5,7 +5,7 @@ TEST=traceroute # Testing availability of network if [ $SKIP_QA_HARNESS -eq 1 ]; then - HOST="wiki.centos.org" + HOST="ci.dev.centos.org" else HOST="repo.centos.qa" fi diff --git a/tests/p_vconfig/0_install_vconfig.sh b/tests/p_vconfig/0_install_vconfig.sh index 82ffc73..aa5dbc5 100755 --- a/tests/p_vconfig/0_install_vconfig.sh +++ b/tests/p_vconfig/0_install_vconfig.sh @@ -1,6 +1,10 @@ #!/bin/bash -# Author: Christoph Galuschka - -# Install vconfig -t_InstallPackage vconfig +# Author: Christoph Galuschka +if [ $centos_ver -lt 7 ] +then + # Install vconfig + t_InstallPackage vconfig +else + t_Log 'vconfig is only supported on C5 and C6, skipping' +fi diff --git a/tests/p_vconfig/10_test_vconfig.sh b/tests/p_vconfig/10_test_vconfig.sh index e3fa674..900d6bb 100755 --- a/tests/p_vconfig/10_test_vconfig.sh +++ b/tests/p_vconfig/10_test_vconfig.sh @@ -1,10 +1,17 @@ #!/bin/sh -# Author: Christoph Galuschka +# Author: Christoph Galuschka # Athmane Madjoudj t_Log "Running $0 - create VLAN IF, assign IP on VLAN IF and tear down VLAN IF test" ret_val=0 +if [ $centos_ver -gt 6 ] +then + t_Log 'vconfig is only supported on C5 and C6, skipping' + t_CheckExitStatus $ret_val + exit 0 +fi + # create VLAN-IF 10 on eth0 vconfig add eth0 10 ip addr list | grep -q eth0.10 @@ -24,7 +31,7 @@ if [ $? == 1 ] t_Log "IP address assignment on eth0.10 failed" ret_val=1 else - t_Log "IP address successfully assigned on eth1.10" + t_Log "IP address successfully assigned on eth0.10" fi #testing address with ping diff --git a/tests/p_wget/wget_test.sh b/tests/p_wget/wget_test.sh index 1806ac0..2298a67 100755 --- a/tests/p_wget/wget_test.sh +++ b/tests/p_wget/wget_test.sh @@ -8,7 +8,7 @@ FILE=/var/tmp/index.html if [ $SKIP_QA_HARNESS -eq 1 ]; then CHECK_FOR="CentOS" - URL="http://wiki.centos.org/" + URL="http://ci.dev.centos.org/cstatic/" else CHECK_FOR="CentOS" URL="http://repo.centos.qa/srv/CentOS/" diff --git a/tests/p_xorg-x11-server/00_install-Xorg.sh b/tests/p_xorg-x11-server/00_install-Xorg.sh new file mode 100755 index 0000000..d89b138 --- /dev/null +++ b/tests/p_xorg-x11-server/00_install-Xorg.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +t_Log "Running $0 - installing Xorg (base package)" +t_InstallPackage xorg-x11-server-Xorg + diff --git a/tests/p_xorg-x11-server/01_Xorg-centos-branding-test.sh b/tests/p_xorg-x11-server/01_Xorg-centos-branding-test.sh new file mode 100755 index 0000000..03d94d9 --- /dev/null +++ b/tests/p_xorg-x11-server/01_Xorg-centos-branding-test.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Author: Athmane Madjoudj + +# Ref: http://bugs.centos.org/view.php?id=6809 +t_Log "Running $0 - Testing that Xorg has been patched to use CentOS bugtracker for support" + +if [ $centos_ver = 6 ] +then + X --wrong-arg 2>&1 | grep -q 'wiki.centos.org' +else + t_Log "CentOS 5 Xorg does not need checking" +fi + + +t_CheckExitStatus $? + + diff --git a/tests/p_yum-plugin-fastestmirror/10-fastestmirror.sh b/tests/p_yum-plugin-fastestmirror/10-fastestmirror.sh index b8adbb1..c47166a 100755 --- a/tests/p_yum-plugin-fastestmirror/10-fastestmirror.sh +++ b/tests/p_yum-plugin-fastestmirror/10-fastestmirror.sh @@ -17,7 +17,7 @@ t_Log "Running $0 - Ensure we have mirrorlist enabled." egrep '^mirrorlist' /etc/yum.repos.d/*.repo > /dev/null t_CheckExitStatus $? -t_Log "Running $0 - is y-p-fastestmirror can get hosts" +t_Log "Running $0 - y-p-fastestmirror can get hosts from mirrorlist" find $BaseDir -type f -name timedhosts.txt -exec rm -f {} \; yum -d0 list kernel > /dev/null @@ -35,7 +35,4 @@ else fi t_CheckExitStatus $retval -t_Log "Running $0 - is y-p-fastestmirror can get" - -hostsfound=$( wc -l ${BaseDir}/timedhosts.txt ) - +t_Log "Running $0 - number of hosts y-p-fastestmirror can get: $( wc -l ${BaseDir}/timedhosts.txt )" diff --git a/tests/r_lamp/0_lamp_install.sh b/tests/r_lamp/0_lamp_install.sh index debd64f..a8555cf 100755 --- a/tests/r_lamp/0_lamp_install.sh +++ b/tests/r_lamp/0_lamp_install.sh @@ -4,7 +4,15 @@ t_Log "Running $0 - attempting to install LAMP stack." -t_InstallPackage httpd mysql-server php +# MySQL +# starting with 5.10, we have to differ between mysql55 and mysql +if [ $centos_ver = 5 ] +then + t_InstallPackage mysql-server mysql55-mysql-server httpd php +else + t_InstallPackage mysql-server httpd php +fi + t_ServiceControl httpd stop ps ax | grep -v grep | grep -q httpd if [ $? = 0 ] diff --git a/tests/r_lamp/1_lamp_check.sh b/tests/r_lamp/1_lamp_check.sh index ee86fce..25f1041 100755 --- a/tests/r_lamp/1_lamp_check.sh +++ b/tests/r_lamp/1_lamp_check.sh @@ -1,9 +1,10 @@ #!/bin/bash # Author: Steve Barnes (steve@echo.id.au) +# Christoph Galuschka # Filename: 1_lamp_check.sh -# Version: 0.1 -# Last Updated: Saturday, 30 April 2011 2:23 PM AEST +# Version: 0.2 +# Last Updated: Saturday, 09 November 2013 2:23 # Description: A simple Bash script to start LAMP daemons (httpd, mysqld), and confirm PHP is working. readonly DAEMONS=( httpd mysqld ) @@ -20,30 +21,29 @@ t_Log "Running $0 - starting LAMP daemon startup test" # Iterate through our daemons, start each and check for the presence of each process for D in "${DAEMONS[@]}" do - t_Log "Attempting startup of '$D'" - - $SERVICE $D start &>/dev/null - - RETVAL=$? - - if [ $RETVAL -ne 0 ]; then - - t_Log "FAIL: service startup for '$D' failed ($RETVAL)" - exit $FAIL - - fi - - # See if our process exists - PIDS=$(pidof $D) - - if [ -z "$PIDS" ]; then - - t_Log "FAIL: couldn't find '$D' in the process list." - exit $FAIL - fi - - echo "OK" + t_Log "Attempting startup of '$D'" + $SERVICE $D start &>/dev/null + + RETVAL=$? + + if [ $RETVAL -ne 0 ]; then + + t_Log "FAIL: service startup for '$D' failed ($RETVAL)" + exit $FAIL + + fi + + # See if our process exists + PIDS=$(pidof $D) + + if [ -z "$PIDS" ]; then + + t_Log "FAIL: couldn't find '$D' in the process list." + exit $FAIL + fi + + echo "OK" done # Finally, a basic check to see if PHP is working correctly. @@ -60,7 +60,7 @@ RETVAL=$PHP_BIN $PHP_CHECK &>/dev/null if [ $RETVAL -ne 0 ]; then - t_Log "FAIL: php_info() check failed ($RETVAL)" + t_Log "FAIL: php_info() check failed ($RETVAL)" fi diff --git a/tests/r_lamp/40_basic_lamp.sh b/tests/r_lamp/40_basic_lamp.sh index 98d1542..4253a7b 100755 --- a/tests/r_lamp/40_basic_lamp.sh +++ b/tests/r_lamp/40_basic_lamp.sh @@ -1,8 +1,20 @@ #!/bin/bash +# Author: Karanbir Singh +# Athmane Madjoudj +# Christoph Galuschka + t_Log "Running $0 - install a minimal lamp stack, and test it" -t_InstallPackage httpd mysql mysql-server php php-mysql wget +# MySQL +# starting with 5.10, we have to differ between mysql55 and mysql +if [ $centos_ver = 5 ] +then + t_InstallPackage mysql55-mysql-server httpd mysql55-mysql php php-mysql wget + t_ServiceControl mysql55-mysqld stop +else + t_InstallPackage httpd mysql mysql-server php php-mysql wget +fi t_ServiceControl mysqld restart t_ServiceControl httpd restart diff --git a/tests/r_lamp/45_basic_lamp_mysql55.sh b/tests/r_lamp/45_basic_lamp_mysql55.sh new file mode 100755 index 0000000..04c48e3 --- /dev/null +++ b/tests/r_lamp/45_basic_lamp_mysql55.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# Author: Karanbir Singh +# Athmane Madjoudj +# Christoph Galuschka + +t_Log "Running $0 - install a minimal lamp stack, and test it" + +# MySQL +# starting with 5.10, we have to differ between mysql55 and mysql +if [ $centos_ver = 5 ] +then + t_ServiceControl mysqld stop + t_ServiceControl mysql55-mysqld start +fi +t_ServiceControl httpd restart + +# Initializing a small MySQL db +cat >/tmp/mysql-QA.sql </var/www/html/mysql.php < +EOF + +#################################################### +# testing +#################################################### + +curl -s http://localhost/mysql.php + +t_Log "Performing basic LAMP test" +content=`echo "select * from qatests.tests where name='mysqltest'"|mysql -B --skip-column-names` + +# Clean up +mysql -u root -e 'drop database qatests;' +service httpd stop + +if [ "$content" = "mysqltest" ] ; then + ret_val=0; +else + ret_val=1; +fi + +t_CheckExitStatus $ret_val diff --git a/tests/r_lamp/50_lamp_check_mysql55.sh b/tests/r_lamp/50_lamp_check_mysql55.sh new file mode 100755 index 0000000..905a7d4 --- /dev/null +++ b/tests/r_lamp/50_lamp_check_mysql55.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +# Author: Steve Barnes (steve@echo.id.au) +# Christoph Galuschka +# Filename: 1_lamp_check.sh +# Version: 0.2 +# Last Updated: Saturday, 09 November 2013 2:23 +# Description: A simple Bash script to start LAMP daemons (httpd, mysqld), and confirm PHP is working. + +# starting with 5.10, we have to differ between mysql55 and mysql +if [ $centos_ver = 5 ] +then + readonly DAEMONS=( httpd mysql55-mysqld ) +else + readonly DAEMONS=( httpd mysqld ) +fi +readonly DAEMONSPID=( httpd mysqld ) + +readonly SERVICE=/sbin/service +readonly PHP_BIN=/usr/bin/php +readonly PHP_CHECK=/tmp/check.php + +# Make sure we cleanup after ourselves. +trap "/bin/rm -f $PHP_CHECK" EXIT + +t_Log "Running $0 - starting LAMP daemon startup test" + +# Iterate through our daemons, start each and check for the presence of each process +for D in "${DAEMONS[@]}" +do + t_Log "Attempting startup of '$D'" + + $SERVICE $D start &>/dev/null + + RETVAL=$? + + if [ $RETVAL -ne 0 ]; then + + t_Log "FAIL: service startup for '$D' failed ($RETVAL)" + exit $FAIL + + fi +done +for D in "${DAEMONSPID[@]}" +do + + # See if our process exists + PIDS=$(pidof $D) + + if [ -z "$PIDS" ]; then + + t_Log "FAIL: couldn't find '$D' in the process list." + exit $FAIL + fi + + echo "OK" +done + + +# Finally, a basic check to see if PHP is working correctly. + +t_Log "Performing php script check..." + +cat < $PHP_CHECK + +EOL + +RETVAL=$PHP_BIN $PHP_CHECK &>/dev/null + +if [ $RETVAL -ne 0 ]; then + + t_Log "FAIL: php_info() check failed ($RETVAL)" + +fi + +t_CheckExitStatus $RETVAL