Skip to content

Commit e4ac4b6

Browse files
test,android: adapt node v10.13 tests for mobile
1 parent 278a6ee commit e4ac4b6

9 files changed

+49
-8
lines changed

test/parallel/test-dgram-socket-buffer-size.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function getExpectedError(type) {
9494
socket.setSendBufferSize(10000);
9595

9696
// note: linux will double the buffer size
97-
const expectedBufferSize = common.isLinux ? 20000 : 10000;
97+
const expectedBufferSize = ( common.isLinux || common.isAndroid ) ? 20000 : 10000;
9898
assert.strictEqual(socket.getRecvBufferSize(), expectedBufferSize);
9999
assert.strictEqual(socket.getSendBufferSize(), expectedBufferSize);
100100
socket.close();

test/parallel/test-fs-error-messages.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const fixtures = require('../common/fixtures');
2525
const tmpdir = require('../common/tmpdir');
2626
const assert = require('assert');
2727
const fs = require('fs');
28+
const path = require('path');
2829

2930
tmpdir.refresh();
3031

@@ -37,6 +38,12 @@ const existingDir2 = fixtures.path('keys');
3738
const { COPYFILE_EXCL } = fs.constants;
3839
const uv = process.binding('uv');
3940

41+
if (common.isAndroid) {
42+
// Change the working dir for what would be expected of the test framework
43+
//running in a Desktop environment.
44+
process.chdir(path.join(__dirname, '..', '..'));
45+
}
46+
4047
// Template tag function for escaping special characters in strings so that:
4148
// new RegExp(re`${str}`).test(str) === true
4249
function re(literals, ...values) {
@@ -575,7 +582,7 @@ function re(literals, ...values) {
575582
}
576583

577584
// chown
578-
if (!common.isWindows) {
585+
if (!common.isWindows && !common.isAndroid) {
579586
const validateError = (err) => {
580587
assert.strictEqual(nonexistentFile, err.path);
581588
assert.strictEqual(
@@ -759,7 +766,7 @@ if (!common.isAIX) {
759766
}
760767

761768
// fchown
762-
if (!common.isWindows) {
769+
if (!common.isWindows && !common.isAndroid) {
763770
const validateError = (err) => {
764771
assert.strictEqual(err.message, 'EBADF: bad file descriptor, fchown');
765772
assert.strictEqual(err.errno, uv.UV_EBADF);

test/parallel/test-fs-mkdir-mode-mask.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ if (common.isWindows) {
1515
} else {
1616
mode = 0o644;
1717
}
18+
if (common.isAndroid) {
19+
// On Android, writing in the Application files only sets permissions
20+
// for the user associated with the App.
21+
mode = mode & 0o700;
22+
}
1823

1924
const maskToIgnore = 0o10000;
2025

test/parallel/test-fs-open-mode-mask.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ if (common.isWindows) {
1414
} else {
1515
mode = 0o644;
1616
}
17+
if (common.isAndroid) {
18+
// On Android, writing in the Application files only sets permissions
19+
// for the user associated with the App.
20+
mode = mode & 0o700;
21+
}
1722

1823
const maskToIgnore = 0o10000;
1924

test/parallel/test-fs-promises-file-handle-chmod.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ const tmpDir = tmpdir.path;
1515
tmpdir.refresh();
1616

1717
async function validateFilePermission() {
18+
let testmode = 0o444;
19+
if (common.isAndroid) {
20+
// On Android, writing in the Application files only sets permissions
21+
// for the user associated with the App.
22+
testmode = testmode & 0o700;
23+
}
1824
const filePath = path.resolve(tmpDir, 'tmp-chmod.txt');
19-
const fileHandle = await open(filePath, 'w+', 0o444);
25+
const fileHandle = await open(filePath, 'w+', testmode);
2026
// file created with r--r--r-- 444
2127
const statsBeforeMod = fs.statSync(filePath);
22-
assert.deepStrictEqual(statsBeforeMod.mode & 0o444, 0o444);
28+
assert.deepStrictEqual(statsBeforeMod.mode & testmode, testmode);
2329

2430
let expectedAccess;
2531
const newPermissions = 0o765;

test/parallel/test-fs-readdir-stack-overflow.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
const common = require('../common');
44

55
const fs = require('fs');
6+
const path = require('path');
7+
8+
if (common.isAndroid) {
9+
// Change the working dir for what would be expected of the test framework
10+
//running in a Desktop environment.
11+
process.chdir(path.join(__dirname, '..', '..'));
12+
}
613

714
function recurse() {
815
fs.readdirSync('.');

test/parallel/test-fs-realpath-native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path');
66

77
const filename = __filename.toLowerCase();
88

9-
if(common.isIOS) {
9+
if(common.isIOS || common.isAndroid) {
1010
// Change the working dir for what would be expected of the test framework
1111
//running in a Desktop environment.
1212
process.chdir(path.join(__dirname,'..','..'));

test/parallel/test-fs-realpath.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,12 @@ function test_cyclic_link_overprotection(realpath, realpathSync, callback) {
234234
const folder = `${cycles}/folder`;
235235
const link = `${folder}/cycles`;
236236
let testPath = cycles;
237-
testPath += '/folder/cycles'.repeat(10);
237+
if(common.isAndroid) {
238+
// MAXSYMLINKS is defined as 8 in the NDK, so we can only test up to that value for Android.
239+
testPath += '/folder/cycles'.repeat(8);
240+
} else {
241+
testPath += '/folder/cycles'.repeat(10);
242+
}
238243
try { fs.unlinkSync(link); } catch (ex) {}
239244
fs.symlinkSync(cycles, link, 'dir');
240245
unlink.push(link);

test/parallel/test-worker-memory.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ const assert = require('assert');
55
const util = require('util');
66
const { Worker } = require('worker_threads');
77

8-
const numWorkers = +process.env.JOBS || require('os').cpus().length;
8+
let numWorkers;
9+
if (common.isAndroid) {
10+
// Unable to get os.cpus() on Android.
11+
numWorkers = 4;
12+
} else {
13+
numWorkers = +process.env.JOBS || require('os').cpus().length;
14+
}
915

1016
// Verify that a Worker's memory isn't kept in memory after the thread finishes.
1117

0 commit comments

Comments
 (0)