summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-02-19 14:34:18 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-02-20 15:42:06 +0000
commitf5723961ef7fc9c71222e8b45e0de39e7f15e90e (patch)
tree65053585b750a65424b7695d72f6104ea5b5ee7f
parent20e5304f40148d43c6ab57dea0abe400475e7e9f (diff)
downloadtbdiff-f5723961ef7fc9c71222e8b45e0de39e7f15e90e.tar.gz
Update 'baserock-system-config-sync' tests to check permissions
-rwxr-xr-xtests/run_tests.sh32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index ea92924..36dff01 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -12,6 +12,34 @@ then
exit 1
fi
+compare_dirs() {
+
+ # Temporary files used to compare the file permissions
+ file1=$(mktemp)
+ file2=$(mktemp)
+
+ set +e
+ (
+ set -e
+ # Getting the file permissions
+ (cd "$1" && busybox find * -exec busybox stat -c '%n %a' {} + | sort) > "$file1"
+ (cd "$2" && busybox find * -exec busybox stat -c '%n %a' {} + | sort) > "$file2"
+
+ # Compare file contents
+ diff -r "$1" "$2"
+
+ # Compare permissions
+ diff "$file1" "$file2"
+ )
+ local ret="$?"
+
+ # Clean temporary files
+ rm "$file1"
+ rm "$file2"
+
+ return $ret
+}
+
echo "Starting baserock-system-config-sync tests"
merge_pass_folder="bscs-merge.pass"
merge_fail_folder="bscs-merge.fail"
@@ -33,7 +61,7 @@ for folder in "$merge_pass_folder/"*.in; do
if [ "$exit_code" -ne 0 ]; then
echo ": FAILED (exit code "$exit_code")" 1>&2
exit 1
- elif ! diff -r "$TMPDIR/"*/ "$out_folder/" &>> "$bscs_log"; then
+ elif ! compare_dirs "$TMPDIR/"*/ "$out_folder/" &>> "$bscs_log"; then
echo ": FAILED (different diff)" 1>&2
exit 1
else
@@ -73,7 +101,7 @@ exit_code="$?"
if [ "$exit_code" -ne 0 ]; then
echo ": FAILED (exit code "$exit_code")" 1>&2
exit 1
-elif ! diff -r "$TMPDIR/"*/ "$out_folder/" &>> "$bscs_log"; then
+elif ! compare_dirs "$TMPDIR/"*/ "$out_folder/" &>> "$bscs_log"; then
echo ": FAILED (different diff)" 1>&2a
exit 1
else