view tests/test-link.sh @ 11655:ed090c498dd0

version-etc: fix regression * lib/version-etc.h (ATTRIBUTE_SENTINEL): Define for new enough gcc. (version_etc): Use it, to catch bugs with trailing NULL. * lib/version-etc.c (version_etc_arn): Delete unused argument. (version_etc_va): Fix logic bug. * modules/version-etc-tests: Add test. * tests/test-version-etc.c: New file. * tests/test-version-etc.sh: Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Thu, 25 Jun 2009 12:13:35 -0600
parents 7a0a9b657190
children
line wrap: on
line source

#!/bin/sh

tmpfiles="test-link-a.txt test-link-b.txt test-link-c.txt"
trap 'rm -fr $tmpfiles' 1 2 3 15

# Create a file.
echo "hello" > test-link-a.txt || exit 1

# Use link() to create a new name for it.
./test-link${EXEEXT} test-link-a.txt test-link-b.txt
case $? in
  0) ;;
  77)
    echo "Skipping test: hard links are not supported on this file system"
    rm -fr $tmpfiles
    exit 77
    ;;
  *) exit 1 ;;
esac
cmp test-link-a.txt test-link-b.txt || exit 1

# Modify the contents of the first file.
echo "world" >> test-link-a.txt || exit 1
cmp test-link-a.txt test-link-b.txt || exit 1

# Modify the contents of the second file.
echo "some text" >> test-link-b.txt || exit 1
cmp test-link-a.txt test-link-b.txt || exit 1

# Delete the first file, then verity the second file still has the same
# contents.
cp test-link-a.txt test-link-c.txt || exit 1
rm test-link-a.txt || exit 1
cmp test-link-b.txt test-link-c.txt || exit 1

rm -fr $tmpfiles
exit 0