1'use strict'; 2 3const common = require('../common'); 4if (!common.isLinux) 5 common.skip('Test is linux specific.'); 6 7const path = require('path'); 8const fs = require('fs'); 9const assert = require('assert'); 10 11const tmpdir = require('../common/tmpdir'); 12tmpdir.refresh(); 13const filename = '\uD83D\uDC04'; 14const root = Buffer.from(`${tmpdir.path}${path.sep}`); 15const filebuff = Buffer.from(filename, 'ucs2'); 16const fullpath = Buffer.concat([root, filebuff]); 17 18try { 19 fs.closeSync(fs.openSync(fullpath, 'w+')); 20} catch (e) { 21 if (e.code === 'EINVAL') 22 common.skip('test requires filesystem that supports UCS2'); 23 throw e; 24} 25 26fs.readdir(tmpdir.path, 'ucs2', common.mustSucceed((list) => { 27 assert.strictEqual(list.length, 1); 28 const fn = list[0]; 29 assert.deepStrictEqual(Buffer.from(fn, 'ucs2'), filebuff); 30 assert.strictEqual(fn, filename); 31})); 32