readlink.tests 925 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. # Readlink tests.
  3. # Copyright 2006 by Natanael Copa <n@tanael.org>
  4. # Licensed under GPL v2, see file LICENSE for details.
  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"