Some enhancements to the zosfile unit#643
Conversation
- Aligns the handling of symbolic links with system commands - Extracts the directory traversal code into shared functions Signed-off-by: ch.zhou <chong.zhou@broadcom.com>
aafcea3 to
61094e5
Compare
|
| } | ||
|
|
||
| int fileCreateSymlink(const char *from, const char *to, int *returnCode, int *reasonCode) { | ||
| int fromLen = strlen(from); |
|
|
||
| int fileCreateSymlink(const char *from, const char *to, int *returnCode, int *reasonCode) { | ||
| int fromLen = strlen(from); | ||
| int toLen = strlen(to); |
|
Can you turn the "hints for testing" into tests that are part of this PR. The scripts should go in a subdir of zowe-common-c/tests that you create and one script should build the directory structure that can reproduce the problem, another can compile a tiny program to run the test. That would allow me show that the bug existed and was cleared by this fix by running the test in a local repo that does NOT have this fix in it yet. |
|
After seeing your proposal to convert "hints for testing" into actual test cases, I’ve been wondering: since you are already building a ZSS-based regression testing framework, do we still need unit tests? Assuming for a moment that we do need unit tests, could they also be structured as a framework? Here is the concept:
This is just a concept for now, and I’m not yet certain if implementation is necessary, but I believe it is technically feasible. |


Purpose of the PR
This is an extension (a super set) of the old unmerged PR #633 . The old one was closed.
The previous PR aligned the
directoryDeleteRecursive()function with the system commandrm -rfwith regards to the handling of symbolic links.After that, I noticed that the
directoryCopy()function has the same issue about symbolic links.The issue can be summarized as follows: when deleting or copying a directory, symbolic links within the source directory should be unlinked or recreated in the target directory, rather than deleting or copying the files or directories to which those links point.
This PR fixes the inconsistant behavior of the previous implementation.
Additionally, it also extracts the directory traversal code into a function shared by all directory operation functions.
Summary of major changes
directoryDeleteRecursive()anddirectoryCopy()no longer follow links, now they only delete or create links;directoryListEntries()was added and shared by all directory functions.fileReadLink2()was added to implement a convenient and consistent way for checking if a path is a symlink and what the real path is.Hints for unit tests
directoryDeleteRecursive,directoryCopy,directoryChangeModeRecursive,directoryChangeOwnerRecursive,fileReadLink2,directoryListEntries;All files must be in mode 644, all directories must be in mode 755.
All files and directories must owned by user1 and group1.