|
Packit |
33f14e |
#!/bin/sh
|
|
Packit |
33f14e |
# Test the --no-dereference option.
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
. "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
echo 'Simple contents' > regular1
|
|
Packit |
33f14e |
echo 'Sample contents' > regular2
|
|
Packit |
33f14e |
echo 'Sample contents' > regular3
|
|
Packit |
33f14e |
ln -s regular1 symlink1
|
|
Packit |
33f14e |
ln -s regular1 symlink1bis
|
|
Packit |
33f14e |
ln -s regular2 symlink2
|
|
Packit |
33f14e |
ln -s regular3 symlink3
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Non-recursive comparisons.
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 3: Compare regular file with regular file.
|
|
Packit |
33f14e |
returns_ 1 diff --no-dereference regular1 regular2 > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
1c1
|
|
Packit |
33f14e |
< Simple contents
|
|
Packit |
33f14e |
---
|
|
Packit |
33f14e |
> Sample contents
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 4: Compare regular file with symbolic link.
|
|
Packit |
33f14e |
returns_ 1 diff --no-dereference regular1 symlink1 > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
File regular1 is a regular file while file symlink1 is a symbolic link
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 5: Compare symbolic link with regular file.
|
|
Packit |
33f14e |
returns_ 1 diff --no-dereference symlink1 regular1 > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
File symlink1 is a symbolic link while file regular1 is a regular file
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 6: Compare symbolic links with same value.
|
|
Packit |
33f14e |
diff --no-dereference symlink1 symlink1bis > out || fail=1
|
|
Packit |
33f14e |
compare /dev/null out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 7: Compare symbolic links with different value and different target
|
|
Packit |
33f14e |
# contents.
|
|
Packit |
33f14e |
returns_ 1 diff --no-dereference symlink1 symlink2 > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
Symbolic links symlink1 and symlink2 differ
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 8: Compare symbolic links with different value and same target
|
|
Packit |
33f14e |
# contents.
|
|
Packit |
33f14e |
returns_ 1 diff --no-dereference symlink2 symlink3 > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
Symbolic links symlink2 and symlink3 differ
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Recursive comparisons.
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 1: Compare symbolic link with nonexistent file.
|
|
Packit |
33f14e |
mkdir subdir1a
|
|
Packit |
33f14e |
mkdir subdir1b
|
|
Packit |
33f14e |
ln -s nonexistent subdir1a/foo
|
|
Packit |
33f14e |
ln -s ../regular1 subdir1a/bar
|
|
Packit |
33f14e |
returns_ 1 diff -r --no-dereference subdir1a subdir1b > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
Only in subdir1a: bar
|
|
Packit |
33f14e |
Only in subdir1a: foo
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 1: Compare nonexistent file with symbolic link.
|
|
Packit |
33f14e |
mkdir subdir2a
|
|
Packit |
33f14e |
mkdir subdir2b
|
|
Packit |
33f14e |
ln -s nonexistent subdir2b/foo
|
|
Packit |
33f14e |
ln -s ../regular1 subdir2b/bar
|
|
Packit |
33f14e |
returns_ 1 diff -r --no-dereference subdir2a subdir2b > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
Only in subdir2b: bar
|
|
Packit |
33f14e |
Only in subdir2b: foo
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 3: Compare regular file with regular file.
|
|
Packit |
33f14e |
mkdir subdir3a
|
|
Packit |
33f14e |
mkdir subdir3b
|
|
Packit |
33f14e |
cp regular1 subdir3a/foo
|
|
Packit |
33f14e |
cp regular2 subdir3b/foo
|
|
Packit |
33f14e |
returns_ 1 diff -r --no-dereference subdir3a subdir3b > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
diff -r --no-dereference subdir3a/foo subdir3b/foo
|
|
Packit |
33f14e |
1c1
|
|
Packit |
33f14e |
< Simple contents
|
|
Packit |
33f14e |
---
|
|
Packit |
33f14e |
> Sample contents
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 4: Compare regular file with symbolic link.
|
|
Packit |
33f14e |
mkdir subdir4a
|
|
Packit |
33f14e |
mkdir subdir4b
|
|
Packit |
33f14e |
cp regular1 subdir4a/foo
|
|
Packit |
33f14e |
ln -s ../regular1 subdir4b/foo
|
|
Packit |
33f14e |
returns_ 1 diff -r --no-dereference subdir4a subdir4b > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
File subdir4a/foo is a regular file while file subdir4b/foo is a symbolic link
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 5: Compare symbolic link with regular file.
|
|
Packit |
33f14e |
mkdir subdir5a
|
|
Packit |
33f14e |
mkdir subdir5b
|
|
Packit |
33f14e |
ln -s ../regular1 subdir5a/foo
|
|
Packit |
33f14e |
cp regular1 subdir5b/foo
|
|
Packit |
33f14e |
returns_ 1 diff -r --no-dereference subdir5a subdir5b > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
File subdir5a/foo is a symbolic link while file subdir5b/foo is a regular file
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 6: Compare symbolic links with same value.
|
|
Packit |
33f14e |
mkdir subdir6a
|
|
Packit |
33f14e |
mkdir subdir6b
|
|
Packit |
33f14e |
ln -s ../regular1 subdir6a/foo
|
|
Packit |
33f14e |
ln -s ../regular1 subdir6b/foo
|
|
Packit |
33f14e |
diff -r --no-dereference subdir6a subdir6b > out || fail=1
|
|
Packit |
33f14e |
compare /dev/null out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 7: Compare symbolic links with different value and different target
|
|
Packit |
33f14e |
# contents.
|
|
Packit |
33f14e |
mkdir subdir7a
|
|
Packit |
33f14e |
mkdir subdir7b
|
|
Packit |
33f14e |
ln -s ../regular1 subdir7a/foo
|
|
Packit |
33f14e |
ln -s ../regular2 subdir7b/foo
|
|
Packit |
33f14e |
returns_ 1 diff -r --no-dereference subdir7a subdir7b > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
Symbolic links subdir7a/foo and subdir7b/foo differ
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Test case 8: Compare symbolic links with different value and same target
|
|
Packit |
33f14e |
# contents.
|
|
Packit |
33f14e |
mkdir subdir8a
|
|
Packit |
33f14e |
mkdir subdir8b
|
|
Packit |
33f14e |
ln -s ../regular2 subdir8a/foo
|
|
Packit |
33f14e |
ln -s ../regular3 subdir8b/foo
|
|
Packit |
33f14e |
returns_ 1 diff -r --no-dereference subdir8a subdir8b > out || fail=1
|
|
Packit |
33f14e |
cat <<EOF > expected || framework_failure_
|
|
Packit |
33f14e |
Symbolic links subdir8a/foo and subdir8b/foo differ
|
|
Packit |
33f14e |
EOF
|
|
Packit |
33f14e |
compare expected out || fail=1
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
Exit $fail
|