- Verify that when creating a hard link to a symbolic link, '-L' option creates a hard link to the target of the symbolic link
- Verify that when creating a hard link to a symbolic link, '-P' option creates a hard link to the symbolic link itself
- Verify that if the target file already exists, '-f' option unlinks it so that link may occur
- Verify that if the target file or directory is a symbolic link, '-shf' option prevents following the link
- Verify that if the target file or directory is a symbolic link, '-snf' option prevents following the link
- Verify that '-s' option creates a symbolic link
- Verify that '-w' option produces a warning if the source of a symbolic link does not currently exist
Details
- Reviewers
asomers brooks ngie - Commits
- rS320680: MFC r319714, r319854
rS319714: Add tests for ln(1)
- Run make install from bin/ln/tests.
- Run kyua test from /usr/tests/bin/ln. All 9 test cases should succeed.
Diff Detail
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 9725 Build 10164: arc lint + arc unit
Event Timeline
bin/ln/tests/ln_test.sh | ||
---|---|---|
32 |
if ! umask 022; then atf_fail "setting umask failed" fi | |
49 | I see you're copying my pattern from bin/chmod :)... To be honest, the inode number here is more important than the file mode (my focus in the chmod testcases were with the file mode, and my focus with the chown testcases I'm writing is path ownership). I still need to add symbolic chmod calls to the tests, but that's an aside :).. Example: $ ln -s A B; touch A $ stat -f %i A B 1850138 1850137 $ Testing for inodes are a bit trickier, because you have to read/compare them differently, but you can use something like: stat_A=$(stat -f %i A) stat_B=$(stat -f %i B) atf_check_equal "$stat_A" "$stat_B" Checking that they aren't equal doesn't have a nice analog, e.g., atf_check_not_equal, yet. | |
72–73 | A negative case for this should probably be added as well, i.e., ln A B ln A B # would fail ln -f A B # would pass Testing with -s could be done as well. | |
93 | It would be a good idea to check the -sf case as well. | |
174–177 | Please add -sf testcases. |
Address changes pointed by @ngie
- Update usage of umask.
- Update checks to compare inode numbers when testing hard links.
- Add tests for failure of creation of symbolic and hard links when target file already exists and '-f' option is absent.
- Add test for '-sf' option.
I'm ok with the changes made, but I still think that inodes (and use of test to check file types) should be compared instead of modes.
bin/ln/tests/ln_test.sh | ||
---|---|---|
135 | How is "ln -shf" different than "ln -sf" here? Does the "-h" make a difference when the target is not a directory? | |
218 | You're not testing the right error condition here. By trying to make a hard link, ln actually fails. The "-w" doesn't matter. "-w" only makes a difference when creating a symlink. |
Address changes pointed by @asomers. Thanks for pointing these out!
- Update the tests for '-shf', '-snf' and '-w' options
Add following test case -
- Verify that if the source file does not exists, '-s' option creates a broken symbolic link to the source file
etc/mtree/BSD.tests.dist | ||
---|---|---|
23 | This is sorted incorrectly: ln should be before ls. |