link.test 821 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. # Copyright 2014 Divya Kothari <divya.s.kothari@gmail.com>
  3. # Copyright 2014 Naha Maggu <maggu.neha@gmail.com>
  4. [ -f testing.sh ] && . testing.sh
  5. #testing "name" "command" "result" "infile" "stdin"
  6. echo "" >foo
  7. testing "fails on non-existent file" "link foo/foo baz 2>/dev/null || echo GOOD" "GOOD\n" "" ""
  8. rm -f foo bar
  9. echo file1 > file
  10. testing "create_hardlink" "link file hlink && [ file -ef hlink ] &&
  11. echo 'yes'; rm -rf hlink" "yes\n" "" ""
  12. echo hlink1 > hlink
  13. set +e
  14. testing "preserves_hardlinks" "link file hlink 2>/dev/null || echo 'yes'; rm -rf hlink" \
  15. "yes\n" "" ""
  16. echo file1 > file
  17. testing "create_hardlink_and_remove_sourcefile" "link file hlink &&
  18. [ file -ef hlink ] && rm -rf file && [ -f hlink ] && echo 'yes'; rm -f file hlink" \
  19. "yes\n" "" ""