File tree Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Expand file tree Collapse file tree 3 files changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,13 @@ addToLibrary({
113
113
var stream = FS . getStreamChecked ( fd ) ;
114
114
fs . fchownSync ( stream . nfd , owner , group ) ;
115
115
} ,
116
- truncate ( ...args ) { fs . truncateSync ( ...args ) ; } ,
116
+ truncate ( path , len ) {
117
+ // See https://github.com/nodejs/node/issues/35632
118
+ if ( len < 0 ) {
119
+ throw new FS . ErrnoError ( { { { cDefs . EINVAL } } } ) ;
120
+ }
121
+ return fs . truncateSync ( path , len ) ;
122
+ } ,
117
123
ftruncate ( fd , len ) {
118
124
// See https://github.com/nodejs/node/issues/35632
119
125
if ( len < 0 ) {
@@ -160,7 +166,7 @@ addToLibrary({
160
166
} ,
161
167
close ( stream ) {
162
168
VFS . closeStream ( stream . fd ) ;
163
- if ( ! stream . stream_ops && -- stream . shared . refcnt == = 0 ) {
169
+ if ( ! stream . stream_ops && -- stream . shared . refcnt < = 0 ) {
164
170
// This stream is created by our Node.js filesystem, close the
165
171
// native file descriptor when its reference count drops to 0.
166
172
fs . closeSync ( stream . nfd ) ;
Original file line number Diff line number Diff line change @@ -406,7 +406,7 @@ void test_fs_mkdirTree() {
406
406
assert (ex .name == = "ErrnoError" && ex .errno == = 2 /* EACCES */ );
407
407
);
408
408
409
- chdir ("test1" );
409
+ chdir ("/ test1" );
410
410
EM_ASM (
411
411
FS .mkdirTree ("foo/bar" ); // Relative path
412
412
);
@@ -448,22 +448,37 @@ void test_fs_utime() {
448
448
remove ("utimetest" );
449
449
}
450
450
451
+ #if !defined(NODERAWFS )
452
+ // NODERAWFS don't support absolute paths since we cannot write the
453
+ // actual root directory.
454
+ // In addition, abs paths testing is not really running correctly
455
+ // when we build run with NODEFS because the NODEFS filesystem is mounted
456
+ // at /nodefs in that case.
457
+ // TODO(sbc): Refactor these tests such that they test both relative
458
+ // and absolute paths, and don't depend on write access to the root
459
+ // directory.
460
+ #define ABS_PATH_OK
461
+ #endif
462
+
451
463
int main () {
452
- test_fs_open ();
464
+ #ifdef ABS_PATH_OK
453
465
test_fs_createPath ();
466
+ test_fs_mkdirTree ();
467
+ test_fs_close ();
468
+ test_fs_readlink ();
469
+ test_fs_rmdir ();
470
+ #endif
471
+ test_fs_open ();
454
472
test_fs_readFile ();
455
473
test_fs_rename ();
456
- test_fs_readlink ();
457
474
test_fs_read ();
458
- test_fs_rmdir ();
459
- test_fs_close ();
460
475
test_fs_mknod ();
461
476
test_fs_truncate ();
462
477
#if WASMFS
463
478
// TODO: Fix legacy API FS.mmap bug involving emscripten_builtin_memalign
464
479
test_fs_mmap ();
465
480
#endif
466
- test_fs_mkdirTree ();
481
+
467
482
test_fs_utime ();
468
483
469
484
puts ("success" );
Original file line number Diff line number Diff line change @@ -5756,7 +5756,7 @@ def test_fs_writeFile(self):
5756
5756
self .set_setting ("FORCE_FILESYSTEM" )
5757
5757
self .do_run_in_out_file_test ('fs/test_writeFile.cpp' )
5758
5758
5759
- @also_with_wasmfs
5759
+ @with_all_fs
5760
5760
def test_fs_js_api (self ):
5761
5761
self .set_setting ("FORCE_FILESYSTEM" )
5762
5762
self .do_runf ('fs/test_fs_js_api.c' , 'success' )
You can’t perform that action at this time.
0 commit comments