From db3ab5873ceee29f701b909a2ff0b6befb578092 Mon Sep 17 00:00:00 2001 From: Christoph Galuschka Date: Dec 02 2012 16:27:47 +0000 Subject: Merge commit 'refs/merge-requests/32' of git://gitorious.org/testautomation/t_functional into merge-requests/32 --- diff --git a/tests/p_diffutils/0_install_diffutils b/tests/p_diffutils/0_install_diffutils new file mode 100755 index 0000000..b877b34 --- /dev/null +++ b/tests/p_diffutils/0_install_diffutils @@ -0,0 +1,6 @@ +#!/bin/bash +# Author: Iain Doglas +#Ensure the packeages we require are available + +t_Log "Running $0 installing required packages" +t_InstallPackage diffutils diff --git a/tests/p_diffutils/10-cmp-tests b/tests/p_diffutils/10-cmp-tests new file mode 100755 index 0000000..76504b0 --- /dev/null +++ b/tests/p_diffutils/10-cmp-tests @@ -0,0 +1,60 @@ +#!/bin/bash +# Author: Iain Douglas + +# Tests for cmp + +function ExitFail { + t_Log "FAIL" + exit $FAIL +} +# Basic Tests + +t_Log "Running $0 - cmp tests" + +t_Log "Basic Check" +cmp -v &>/dev/null || ExitFail + +FILE=/var/tmp/diffutils +# Cleanup just in case we exited without doing so earlier. +rm ${FILE}a ${FILE}b &>/dev/null + +# Create some files to work with +cat << EOF >${FILE}a +This is some text to play with +EOF + +cat << EOF >${FILE}b +This is some test to play with +EOF + +# Basic check of 2 files +t_Log "Compare 2 files" +cmp ${FILE}a ${FILE}b | grep -q "byte 16, line 1" || ExitFail + +t_Log "Compare 2 files -b" +cmp -b ${FILE}a ${FILE}b | grep -q " line 1 is 170 x 163 s" || ExitFail +t_Log "Check -i - skip bytes " + +# Expect this to pass as the difference is at byte 16 +cmp -b -i 16 ${FILE}a ${FILE}b || ExitFail + +t_Log "check -i skip1:skip2" + +# Expect this to have a different output to earlier +cmp -i 15:16 ${FILE}a ${FILE}b | grep -q "byte 1, line 1"|| ExitFail + +# Chek that -n works +t_Log "Check -n limit bytes" +cmp -n 15 ${FILE}a ${FILE}b || ExitFail + +# Verbose output +t_Log "Check -l - verbose output" +cmp -l ${FILE}a ${FILE}b | grep -q "16 170 163" || ExitFail + +# Silent - exit status only, first scheck that there is no output +t_Log "Check -s - silent mode" +cmp -s ${FILE}a ${FILE}b | wc -m | grep -q "^0" || ExitFail +cmp -i 16 -s ${FILE}a ${FILE}b +t_CheckExitStatus $? + +rm ${FILE}a ${FILE}b &>/dev/null diff --git a/tests/p_diffutils/20-diff-tests b/tests/p_diffutils/20-diff-tests new file mode 100755 index 0000000..9560e06 --- /dev/null +++ b/tests/p_diffutils/20-diff-tests @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Iain Douglas + +# Tests for diff + +# Basic Tests + +t_Log "Running $0 - diff tests" + +diff -v &>/dev/null + +t_CheckExitStatus $? diff --git a/tests/p_diffutils/30-diff3-tests b/tests/p_diffutils/30-diff3-tests new file mode 100755 index 0000000..4283313 --- /dev/null +++ b/tests/p_diffutils/30-diff3-tests @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Iain Douglas + +# Tests for diff3 + +# Basic Tests + +t_Log "Running $0 - diff3 tests" + +diff3 -v &>/dev/null + +t_CheckExitStatus $? diff --git a/tests/p_diffutils/40-sdiff-tests b/tests/p_diffutils/40-sdiff-tests new file mode 100755 index 0000000..192512a --- /dev/null +++ b/tests/p_diffutils/40-sdiff-tests @@ -0,0 +1,12 @@ +#!/bin/bash +# Author: Iain Douglas + +# Tests for sdiff + +# Basic Tests + +t_Log "Running $0 - sdiff tests" + +sdiff -v &>/dev/null + +t_CheckExitStatus $?