Closed Bug 516799 Opened 10 years ago Closed 10 years ago

test_symlinks.js fails when using the 10.5 SDK

Categories

(Core :: XPCOM, defect, major)

x86
macOS
defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: jaas, Assigned: jaas)

Details

Attachments

(1 file, 1 obsolete file)

No description provided.
TEST-UNEXPECTED-FAIL | (xpcshell/head.js) | [Exception... "Component returned failure code: 0x80520009 (NS_ERROR_FILE_INVALID_PATH) [nsIFile.target]"  nsresult: "0x80520009 (NS_ERROR_FILE_INVALID_PATH)"  location: "JS frame :: /Users/josh/src/mozilla/ff_193_debug/objdir-debug/_tests/xpcshell/xpcom/unit/test_symlinks.js :: makeSymLink :: line 59"  data: no]

The test is failing because the 10.5 SDK changes the way "realpath" works. This is the relevant part of stdlib.h:

#if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH)
char	*realpath(const char * __restrict, char * __restrict) __DARWIN_EXTSN(realpath);
#else /* (!__DARWIN_UNIX03 || _POSIX_C_SOURCE) && !_DARWIN_C_SOURCE && !_DARWIN_BETTER_REALPATH */
char	*realpath(const char * __restrict, char * __restrict) __DARWIN_ALIAS(realpath);
#endif /* (__DARWIN_UNIX03 && _POSIX_C_SOURCE) || _DARWIN_C_SOURCE || _DARWIN_BETTER_REALPATH */

The problematic call to realpath is at "nsLocalFile::GetNativeTarget".
Specifically, this is how realpath changed from the old to the new version (from the manpage):

LEGACY DESCRIPTION
     In legacy mode, the last component of file_name does not need to exist when realpath() is called.
Attached patch fix v1.0 (obsolete) — Splinter Review
Attachment #400928 - Flags: review?(bzbarsky)
Attachment #400928 - Flags: review?(bzbarsky) → review?(benjamin)
Comment on attachment 400928 [details] [diff] [review]
fix v1.0

I'm not an xpcom peer....
For right now I should ifdef this based on the selected SDK.
Attachment #400928 - Flags: review?(benjamin)
Attached patch fix v2.0Splinter Review
Turns out using realpath in GetNativeTarget is a bad idea altogether. The solution should be based on readlink, and it turns out since we don't care about Mac OS X aliases we can just use the UNIX code. This allows us to match symlink behavior exactly.

I didn't write any of the code being added here, it is line-for-line the code from the UNIX impl. I just swapped in the correct variable names.
Attachment #400928 - Attachment is obsolete: true
Attachment #402034 - Flags: review?(benjamin)
Attachment #402034 - Flags: review?(benjamin) → review+
pushed to mozilla-central

http://hg.mozilla.org/mozilla-central/rev/86d9242bd84a
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.