Skip to content

Commit 18d3d9f

Browse files
committed
test: fix test-module-loading-error for musl
When a compiled library file does not have the proper format, musl returns the error message ENOEXEC as 'Exec format error' but glibc returns 'file too short' if the file is under a certain size. Reference: http://git.musl-libc.org/cgit/musl/tree/src/errno/__strerror.h#n46 This patch consists of tolerating musl's error.
1 parent 7b89a3d commit 18d3d9f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/parallel/test-module-loading-error.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var error_desc = {
99
linux: 'file too short',
1010
sunos: 'unknown file type'
1111
};
12+
var musl_errno_enoexec = 'Exec format error';
1213

1314
var dlerror_msg = error_desc[process.platform];
1415

@@ -20,6 +21,9 @@ if (!dlerror_msg) {
2021
try {
2122
require('../fixtures/module-loading-error.node');
2223
} catch (e) {
24+
if (platform === 'linux' && e.toString().indexOf(musl_errno_enoexec) !== -1) {
25+
dlerror_msg = musl_errno_enoexec;
26+
}
2327
assert.notEqual(e.toString().indexOf(dlerror_msg), -1);
2428
}
2529

0 commit comments

Comments
 (0)