readlink.tests 977 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. # Readlink tests.
  3. # Copyright 2006 by Natanael Copa <n@tanael.org>
  4. # Licensed under GPLv2, see file LICENSE in this source tree.
  5. . ./testing.sh
  6. TESTDIR=readlink_testdir
  7. TESTFILE="$TESTDIR/testfile"
  8. TESTLINK="testlink"
  9. FAILLINK="$TESTDIR/$TESTDIR/testlink"
  10. # create the dir and test files
  11. mkdir -p "./$TESTDIR"
  12. touch "./$TESTFILE"
  13. ln -s "./$TESTFILE" "./$TESTLINK"
  14. testing "readlink on a file" "readlink ./$TESTFILE" "" "" ""
  15. testing "readlink on a link" "readlink ./$TESTLINK" "./$TESTFILE\n" "" ""
  16. optional FEATURE_READLINK_FOLLOW
  17. testing "readlink -f on a file" "readlink -f ./$TESTFILE" "$PWD/$TESTFILE\n" "" ""
  18. testing "readlink -f on a link" "readlink -f ./$TESTLINK" "$PWD/$TESTFILE\n" "" ""
  19. testing "readlink -f on an invalid link" "readlink -f ./$FAILLINK" "" "" ""
  20. testing "readlink -f on a wierd dir" "readlink -f $TESTDIR/../$TESTFILE" "$PWD/$TESTFILE\n" "" ""
  21. # clean up
  22. rm -r "$TESTLINK" "$TESTDIR"
  23. exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255))