From c6f45238ecdd933016c6bd7cedc6cfa7a9f79886 Mon Sep 17 00:00:00 2001 From: Fabian Arrotin Date: Jun 30 2014 07:15:12 +0000 Subject: Merge branch 'master' of https://git.centos.org/git/sig-core/t_functional --- diff --git a/tests/p_ipa-server/99-postclean.sh b/tests/p_ipa-server/99-postclean.sh index 1ba0b4a..b300fac 100755 --- a/tests/p_ipa-server/99-postclean.sh +++ b/tests/p_ipa-server/99-postclean.sh @@ -4,27 +4,35 @@ if (t_GetPkgRel basesystem | grep -qE 'el(6|7)') then + if (t_GetPkgRel basesystem | grep -qE 'el(6)') + then + CP=/bin/cp + fi + if (t_GetPkgRel basesystem | grep -qE 'el(7)') + then + CP=/usr/bin/cp + fi t_Log "Running $0 - Restoring up resolv.conf" - /usr/bin/cp /tmp/resolv.conf.ipa-tests /etc/resolv.conf + ${CP} /tmp/resolv.conf.ipa-tests /etc/resolv.conf t_Log "Running $0 - Restoring nsswitch.conf" - /usr/bin/cp /tmp/nsswitch.conf.ipa-tests /etc/nsswitch.conf + ${CP} /tmp/nsswitch.conf.ipa-tests /etc/nsswitch.conf t_Log "Running $0 - Restoring hosts file" - /usr/bin/cp /tmp/hosts.ipa-tests /etc/hosts + ${CP} /tmp/hosts.ipa-tests /etc/hosts if [[ -f /tmp/ntp.conf.ipa-tests ]] then t_Log "Running $0 - Restoring ntp.conf file" - /usr/bin/cp /tmp/ntp.conf.ipa-tests /etc/ntp.conf + ${CP} /tmp/ntp.conf.ipa-tests /etc/ntp.conf fi t_Log "Running $0 - Rolling back to yum history id - this will take some time" /usr/bin/yum -y history rollback $(cat /tmp/yum-rollback-id.ipa-tests) &> /dev/null t_Log "Running $0 - Restoring ssh_config" - /usr/bin/cp /etc/ssh/ssh_config.ipa-tests /etc/ssh/ssh_config + ${CP} /etc/ssh/ssh_config.ipa-tests /etc/ssh/ssh_config rm -f /tmp/*.ipa-test /etc/httpd/conf.d/* diff --git a/tests/p_tcpdump/00_install_tcpdump.sh b/tests/p_tcpdump/00_install_tcpdump.sh new file mode 100755 index 0000000..878cf02 --- /dev/null +++ b/tests/p_tcpdump/00_install_tcpdump.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Author: Christoph Galuschka + +t_Log "Running $0 - install package tcpdump" +t_InstallPackage tcpdump + diff --git a/tests/p_tcpdump/01_tcpdump_nic.sh b/tests/p_tcpdump/01_tcpdump_nic.sh new file mode 100755 index 0000000..ee232eb --- /dev/null +++ b/tests/p_tcpdump/01_tcpdump_nic.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Author: Christoph Galuschka +# Athmane Madjoudj + +t_Log "Running $0 - TCPdump test to Default-GW with IPv4" + +# Grabing Default-Router if NIC +IP=$(ip route list default | grep 'default via ') +regex='.*via\ (.*)\ dev.*' +if [[ $IP =~ $regex ]] + then + t_Log "Found Default-GW - starting tcpdump test" + #Dumping 4 pings via NIC to file + FILE='/var/tmp/nic_test.pcap' + COUNT='4' + 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 + sleep 1 + killall -s SIGINT tcpdump + sleep 1 + # reading from file, for each ping we should see two pakets + WORKING=$( tcpdump -r $FILE | grep -ci icmp ) + if [ $SKIP_QA_HARNESS -eq 1 ] + then + # treat qa-harness and non qa-harness differently, + # the script will always succeed outside qa, but will log results + ret_val=0 + if [ $WORKING != $[COUNT*2] ] + then + t_Log "ping to Default-Gateway did not return the number of pakets we expect. "$WORKING" of "$[COUNT*2]" pakets were dumped to file" + else + t_Log "ping to Default-Gateway looks OK. "$WORKING" of "$[COUNT*2]" pakets were dumped to file" + fi + else + # in qa-harness, which is a controlled environment, the script will fail at odd results + if [ $WORKING == $[COUNT*2] ] || [ $WORKING -gt $[COUNT*2] ] + then + 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!!" + ret_val=1 + fi + fi +else + t_Log "No Default-GW found - skiping test" + ret_val=0 +fi +# Remove file afterwards +/bin/rm $FILE + +t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/02_tcpdump_lo.sh b/tests/p_tcpdump/02_tcpdump_lo.sh new file mode 100755 index 0000000..f606e11 --- /dev/null +++ b/tests/p_tcpdump/02_tcpdump_lo.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Author: Christoph Galuschka +# Athmane Madjoudj + +t_Log "Running $0 - TCPdump test to lo" + +#Dumping pings to loopback to file +FILE='/var/tmp/lo_test.pcap' +COUNT='4' + +tcpdump -q -n -p -i lo -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 127.0.0.1 > /dev/null 2>&1 +sleep 1 +killall -s SIGINT tcpdump +sleep 1 +# reading from file, for each ping we should see two pakets +WORKING=$( tcpdump -r $FILE | grep -ci icmp ) +if [ $WORKING == $[COUNT*2] ] + then + ret_val=0 +else + t_Log "ping to loopback droped pakets!! This should not happen on loopback" + ret_val=1 +fi + +# Remove file afterwards +/bin/rm $FILE + +t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/03_tcpdump_lo_ipv6.sh b/tests/p_tcpdump/03_tcpdump_lo_ipv6.sh new file mode 100755 index 0000000..d533fbf --- /dev/null +++ b/tests/p_tcpdump/03_tcpdump_lo_ipv6.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Author: Christoph Galuschka +# Athmane Madjoudj + +t_Log "Running $0 - TCPdump test IPv6 to lo" + +# Grabing IPv6 address of lo to check if IPv6 is enabled +IP=$(ip addr list lo | grep 'inet6 ') +regex='\t*inet6\ (.*)\/.*' +if [[ $IP =~ $regex ]] + then + t_Log "IPv6 seems to be enabled - runing test" + FILE='/var/tmp/lo_test6.pcap' + COUNT='4' + #Dumping ping6s to loopback to file + tcpdump -q -n -p -i lo -w $FILE & + # If we don't wait a short time, the first paket will be missed by tcpdump + sleep 1 + ping6 -q -c $COUNT -i 0.25 ::1 > /dev/null 2>&1 + sleep 1 + killall -s SIGINT tcpdump + sleep 1 + + # reading from file, for each ping we should see two pakets + WORKING=$( tcpdump -r $FILE | grep -ci icmp6 ) + if [ $WORKING == $[COUNT*2] ]; then + ret_val=0 + else + t_Log "ping6 to loopback droped pakets!! This should not happen on loopback" + ret_val=1 + fi + # Remove file afterwards + /bin/rm $FILE +else + t_Log "IPv6 seems to be disabled - skipping test" + ret_val=0 +fi + +t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/0_install_tcpdump.sh b/tests/p_tcpdump/0_install_tcpdump.sh deleted file mode 100755 index 5436056..0000000 --- a/tests/p_tcpdump/0_install_tcpdump.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Author: Christoph Galuschka - -t_Log "Running $0 - install package tcpdump" -t_InstallPackage tcpdump - diff --git a/tests/p_tcpdump/tcpdump_eth0.sh b/tests/p_tcpdump/tcpdump_eth0.sh deleted file mode 100755 index 88cc391..0000000 --- a/tests/p_tcpdump/tcpdump_eth0.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# Author: Christoph Galuschka -# Athmane Madjoudj - -t_Log "Running $0 - TCPdump test to Default-GW with IPv4" - -# Grabing Default-Router of eth0 -IP=$(ip route list default | grep 'default via ') -regex='.*via\ (.*)\ dev.*' -if [[ $IP =~ $regex ]] - then - t_Log "Found Default-GW - starting tcpdump test" - #Dumping 4 pings via eth0 to file - FILE='/var/tmp/eth0_test.pcap' - COUNT='4' - 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 - sleep 1 - killall -s SIGINT tcpdump - sleep 1 - # reading from file, for each ping we should see two pakets - WORKING=$( tcpdump -r $FILE | grep -ci icmp ) - if [ $SKIP_QA_HARNESS -eq 1 ] - then - # treat qa-harness and non qa-harness differently, - # the script will always succeed outside qa, but will log results - ret_val=0 - if [ $WORKING != $[COUNT*2] ] - then - t_Log "ping to Default-Gateway did not return the number of pakets we expect. "$WORKING" of "$[COUNT*2]" pakets were dumped to file" - else - t_Log "ping to Default-Gateway looks OK. "$WORKING" of "$[COUNT*2]" pakets were dumped to file" - fi - else - # in qa-harness, which is a controlled environment, the script will fail at odd results - if [ $WORKING == $[COUNT*2] ] || [ $WORKING -gt $[COUNT*2] ] - then - 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!!" - ret_val=1 - fi - fi -else - t_Log "No Default-GW found - skiping test" - ret_val=0 -fi -# Remove file afterwards -/bin/rm $FILE - -t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/tcpdump_lo.sh b/tests/p_tcpdump/tcpdump_lo.sh deleted file mode 100755 index 1347168..0000000 --- a/tests/p_tcpdump/tcpdump_lo.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Author: Christoph Galuschka -# Athmane Madjoudj - -t_Log "Running $0 - TCPdump test to lo" - -#Dumping pings to loopback to file -FILE='/var/tmp/lo_test.pcap' -COUNT='4' - -tcpdump -q -n -p -i lo -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 127.0.0.1 > /dev/null 2>&1 -sleep 1 -killall -s SIGINT tcpdump -sleep 1 -# reading from file, for each ping we should see two pakets -WORKING=$( tcpdump -r $FILE | grep -ci icmp ) -if [ $WORKING == $[COUNT*2] ] - then - ret_val=0 -else - t_Log "ping to loopback droped pakets!! This should not happen on loopback" - ret_val=1 -fi - -# Remove file afterwards -/bin/rm $FILE - -t_CheckExitStatus $ret_val diff --git a/tests/p_tcpdump/tcpdump_lo_ipv6.sh b/tests/p_tcpdump/tcpdump_lo_ipv6.sh deleted file mode 100755 index c6929ae..0000000 --- a/tests/p_tcpdump/tcpdump_lo_ipv6.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Author: Christoph Galuschka -# Athmane Madjoudj - -t_Log "Running $0 - TCPdump test IPv6 to lo" - -# Grabing IPv6 address of lo to check if IPv6 is enabled -IP=$(ip addr list lo | grep 'inet6 ') -regex='\t*inet6\ (.*)\/.*' -if [[ $IP =~ $regex ]] - then - t_Log "IPv6 seems to be enabled - runing test" - FILE='/var/tmp/lo_test6.pcap' - COUNT='4' - #Dumping ping6s to loopback to file - tcpdump -q -n -p -i lo -w $FILE & - # If we don't wait a short time, the first paket will be missed by tcpdump - sleep 1 - ping6 -q -c $COUNT -i 0.25 ::1 > /dev/null 2>&1 - sleep 1 - killall -s SIGINT tcpdump - sleep 1 - - # reading from file, for each ping we should see two pakets - WORKING=$( tcpdump -r $FILE | grep -ci icmp6 ) - if [ $WORKING == $[COUNT*2] ]; then - ret_val=0 - else - t_Log "ping6 to loopback droped pakets!! This should not happen on loopback" - ret_val=1 - fi - # Remove file afterwards - /bin/rm $FILE -else - t_Log "IPv6 seems to be disabled - skipping test" - ret_val=0 -fi - -t_CheckExitStatus $ret_val diff --git a/tests/r_pdf/00_install_requirements.sh b/tests/r_pdf/00_install_requirements.sh new file mode 100755 index 0000000..df2114b --- /dev/null +++ b/tests/r_pdf/00_install_requirements.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# Author: Christoph Galuschka + +t_Log "Running $0 - install package enscript, ghostscript and pdftotext" +t_InstallPackage enscript ghostscript poppler-utils + diff --git a/tests/r_pdf/01_pdf-test.sh b/tests/r_pdf/01_pdf-test.sh new file mode 100755 index 0000000..2f91401 --- /dev/null +++ b/tests/r_pdf/01_pdf-test.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# Author: Christoph Galuschka + +t_Log "Running $0 - Create PDF from postscript from text, and convert PDF back to text and check contents" + +FILE=/etc/redhat-release +FIND='CentOS' +PS_FILE=/var/tmp/test.ps +PDF_FILE=/var/tmp/test.pdf +TEST_FILE=/var/tmp/result + +# generate postscript file +enscript -q -p $PS_FILE $FILE + +# check-file +t_Log 'Check created PS-File' +grep -q $FIND $PS_FILE +t_CheckExitStatus $? + +# convert to PDF +ps2pdf $PS_FILE $PDF_FILE + +# read file and check +pdftotext -q $PDF_FILE $TEST_FILE +t_Log 'Check Textfile after conversion' +grep -q $FIND $TEST_FILE +t_CheckExitStatus $? + +#clean up +rm -rf $PDF_FILE $TEST_FILE $PS_FILE