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({
113113 var stream = FS . getStreamChecked ( fd ) ;
114114 fs . fchownSync ( stream . nfd , owner , group ) ;
115115 } ,
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+ } ,
117123 ftruncate ( fd , len ) {
118124 // See https://github.com/nodejs/node/issues/35632
119125 if ( len < 0 ) {
@@ -160,7 +166,7 @@ addToLibrary({
160166 } ,
161167 close ( stream ) {
162168 VFS . closeStream ( stream . fd ) ;
163- if ( ! stream . stream_ops && -- stream . shared . refcnt == = 0 ) {
169+ if ( ! stream . stream_ops && -- stream . shared . refcnt < = 0 ) {
164170 // This stream is created by our Node.js filesystem, close the
165171 // native file descriptor when its reference count drops to 0.
166172 fs . closeSync ( stream . nfd ) ;
Original file line number Diff line number Diff line change @@ -406,7 +406,7 @@ void test_fs_mkdirTree() {
406406 assert (ex .name == = "ErrnoError" && ex .errno == = 2 /* EACCES */ );
407407 );
408408
409- chdir ("test1" );
409+ chdir ("/ test1" );
410410 EM_ASM (
411411 FS .mkdirTree ("foo/bar" ); // Relative path
412412 );
@@ -448,22 +448,37 @@ void test_fs_utime() {
448448 remove ("utimetest" );
449449}
450450
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+
451463int main () {
452- test_fs_open ();
464+ #ifdef ABS_PATH_OK
453465 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 ();
454472 test_fs_readFile ();
455473 test_fs_rename ();
456- test_fs_readlink ();
457474 test_fs_read ();
458- test_fs_rmdir ();
459- test_fs_close ();
460475 test_fs_mknod ();
461476 test_fs_truncate ();
462477#if WASMFS
463478 // TODO: Fix legacy API FS.mmap bug involving emscripten_builtin_memalign
464479 test_fs_mmap ();
465480#endif
466- test_fs_mkdirTree ();
481+
467482 test_fs_utime ();
468483
469484 puts ("success" );
Original file line number Diff line number Diff line change @@ -5756,7 +5756,7 @@ def test_fs_writeFile(self):
57565756 self .set_setting ("FORCE_FILESYSTEM" )
57575757 self .do_run_in_out_file_test ('fs/test_writeFile.cpp' )
57585758
5759- @also_with_wasmfs
5759+ @with_all_fs
57605760 def test_fs_js_api (self ):
57615761 self .set_setting ("FORCE_FILESYSTEM" )
57625762 self .do_runf ('fs/test_fs_js_api.c' , 'success' )
You can’t perform that action at this time.
0 commit comments