11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciconst common = require('../common');
41cb0ef41Sopenharmony_ciif (!common.isLinux)
51cb0ef41Sopenharmony_ci  common.skip('Test is linux specific.');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst path = require('path');
81cb0ef41Sopenharmony_ciconst fs = require('fs');
91cb0ef41Sopenharmony_ciconst assert = require('assert');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
121cb0ef41Sopenharmony_citmpdir.refresh();
131cb0ef41Sopenharmony_ciconst filename = '\uD83D\uDC04';
141cb0ef41Sopenharmony_ciconst root = Buffer.from(`${tmpdir.path}${path.sep}`);
151cb0ef41Sopenharmony_ciconst filebuff = Buffer.from(filename, 'ucs2');
161cb0ef41Sopenharmony_ciconst fullpath = Buffer.concat([root, filebuff]);
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_citry {
191cb0ef41Sopenharmony_ci  fs.closeSync(fs.openSync(fullpath, 'w+'));
201cb0ef41Sopenharmony_ci} catch (e) {
211cb0ef41Sopenharmony_ci  if (e.code === 'EINVAL')
221cb0ef41Sopenharmony_ci    common.skip('test requires filesystem that supports UCS2');
231cb0ef41Sopenharmony_ci  throw e;
241cb0ef41Sopenharmony_ci}
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_cifs.readdir(tmpdir.path, 'ucs2', common.mustSucceed((list) => {
271cb0ef41Sopenharmony_ci  assert.strictEqual(list.length, 1);
281cb0ef41Sopenharmony_ci  const fn = list[0];
291cb0ef41Sopenharmony_ci  assert.deepStrictEqual(Buffer.from(fn, 'ucs2'), filebuff);
301cb0ef41Sopenharmony_ci  assert.strictEqual(fn, filename);
311cb0ef41Sopenharmony_ci}));
32