@@ -537,3 +537,63 @@ code = '''
537537 }
538538 lfs_unmount(&lfs) => 0;
539539'''
540+
541+ [cases .test_files_ishandleopen ]
542+ code = '''
543+ lfs_t lfs;
544+ lfs_format(&lfs, cfg) => 0;
545+ lfs_mount(&lfs, cfg) => 0;
546+ lfs_file_t file;
547+
548+ lfs_file_ishandleopen(&lfs, &file) => LFS_ERR_BADF;
549+
550+ lfs_file_open(&lfs, &file, "hello", LFS_O_CREAT | LFS_O_WRONLY) => 0;
551+
552+ lfs_file_ishandleopen(&lfs, &file) => 0;
553+
554+ lfs_file_close(&lfs, &file) => 0;
555+
556+ lfs_file_ishandleopen(&lfs, &file) => LFS_ERR_BADF;
557+
558+ lfs_unmount(&lfs) => 0;
559+ '''
560+
561+ [cases .test_files_movehandle ]
562+ defines.idx = [0 , 1 , 2 ]
563+ code = '''
564+ lfs_t lfs;
565+ lfs_format(&lfs, cfg) => 0;
566+ lfs_mount(&lfs, cfg) => 0;
567+ lfs_file_t file[3];
568+ lfs_file_open(&lfs, &file[0], "a", LFS_O_CREAT | LFS_O_WRONLY) => 0;
569+ lfs_file_open(&lfs, &file[1], "b", LFS_O_CREAT | LFS_O_WRONLY) => 0;
570+ lfs_file_open(&lfs, &file[2], "c", LFS_O_CREAT | LFS_O_WRONLY) => 0;
571+
572+ lfs_file_t file_new;
573+ lfs_file_movehandle(&lfs, &file[idx], &file_new) => 0;
574+
575+ for(int i = 0; i < 3; i++)
576+ {
577+ if(i == idx) {
578+ continue;
579+ }
580+
581+ lfs_file_ishandleopen(&lfs, &file[i]) => 0;
582+ }
583+ lfs_file_ishandleopen(&lfs, &file_new) => 0;
584+
585+ for(int i = 0; i < 3; i++)
586+ {
587+ if(i == idx) {
588+ continue;
589+ }
590+
591+ lfs_file_close(&lfs, &file[i]) => 0;
592+ lfs_file_ishandleopen(&lfs, &file[i]) => LFS_ERR_BADF;
593+ }
594+
595+ lfs_file_close(&lfs, &file_new) => 0;
596+ lfs_file_ishandleopen(&lfs, &file_new) => LFS_ERR_BADF;
597+
598+ lfs_unmount(&lfs) => 0;
599+ '''
0 commit comments