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. PR-URL: https://github.com/nodejs/node/pull/3657 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
42 lines
922 B
JavaScript
42 lines
922 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
console.error('load test-module-loading-error.js');
|
|
|
|
var error_desc = {
|
|
win32: '%1 is not a valid Win32 application',
|
|
linux: 'file too short',
|
|
sunos: 'unknown file type'
|
|
};
|
|
var musl_errno_enoexec = 'Exec format error';
|
|
|
|
var dlerror_msg = error_desc[process.platform];
|
|
|
|
if (!dlerror_msg) {
|
|
console.log('1..0 # Skipped: platform not supported.');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
require('../fixtures/module-loading-error.node');
|
|
} catch (e) {
|
|
if (process.platform === 'linux' &&
|
|
e.toString().indexOf(musl_errno_enoexec) !== -1) {
|
|
dlerror_msg = musl_errno_enoexec;
|
|
}
|
|
assert.notEqual(e.toString().indexOf(dlerror_msg), -1);
|
|
}
|
|
|
|
try {
|
|
require();
|
|
} catch (e) {
|
|
assert.notEqual(e.toString().indexOf('missing path'), -1);
|
|
}
|
|
|
|
try {
|
|
require({});
|
|
} catch (e) {
|
|
assert.notEqual(e.toString().indexOf('path must be a string'), -1);
|
|
}
|