xref: /third_party/node/test/parallel/test-fs-fmap.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_cirequire('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst fs = require('fs');
51cb0ef41Sopenharmony_ciconst join = require('path').join;
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst {
81cb0ef41Sopenharmony_ci  O_CREAT = 0,
91cb0ef41Sopenharmony_ci  O_RDONLY = 0,
101cb0ef41Sopenharmony_ci  O_TRUNC = 0,
111cb0ef41Sopenharmony_ci  O_WRONLY = 0,
121cb0ef41Sopenharmony_ci  UV_FS_O_FILEMAP = 0
131cb0ef41Sopenharmony_ci} = fs.constants;
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
161cb0ef41Sopenharmony_citmpdir.refresh();
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci// Run this test on all platforms. While UV_FS_O_FILEMAP is only available on
191cb0ef41Sopenharmony_ci// Windows, it should be silently ignored on other platforms.
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ciconst filename = join(tmpdir.path, 'fmap.txt');
221cb0ef41Sopenharmony_ciconst text = 'Memory File Mapping Test';
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ciconst mw = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY;
251cb0ef41Sopenharmony_ciconst mr = UV_FS_O_FILEMAP | O_RDONLY;
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_cifs.writeFileSync(filename, text, { flag: mw });
281cb0ef41Sopenharmony_ciconst r1 = fs.readFileSync(filename, { encoding: 'utf8', flag: mr });
291cb0ef41Sopenharmony_ciassert.strictEqual(r1, text);
30

Indexes created Thu Nov 07 10:32:03 CST 2024