@@ -282,26 +282,40 @@ impl Harness {
282282 /// Compared to [compare_contents], this avoids doing a `readdir` before `lookup`, and so tests
283283 /// a different path through the inode code.
284284 pub async fn compare_single_path ( & self , idx : usize ) {
285- let inodes = self . reference . list_recursive ( ) ;
286- if inodes . is_empty ( ) {
285+ let ref_inodes = self . reference . list_recursive ( ) ;
286+ if ref_inodes . is_empty ( ) {
287287 return ;
288288 }
289- let ( path , node) = & inodes [ idx % inodes . len ( ) ] ;
289+ let ( path_components , node) = & ref_inodes [ idx % ref_inodes . len ( ) ] ;
290290
291291 let mut parent = FUSE_ROOT_INODE ;
292292 let mut seen_inos = HashSet :: from ( [ FUSE_ROOT_INODE ] ) ;
293- for name in path. iter ( ) . take ( path. len ( ) . saturating_sub ( 1 ) ) {
294- let lookup = self . fs . lookup ( parent, name. as_ref ( ) ) . await . unwrap ( ) ;
293+
294+ let ( leaf, ancestors) = path_components
295+ . split_last ( )
296+ . expect ( "there should always be at least one path component" ) ;
297+ for name in ancestors {
298+ let lookup = self
299+ . fs
300+ . lookup ( parent, name. as_ref ( ) )
301+ . await
302+ . expect ( "ancestor must exist in MP fs" ) ;
295303 assert_eq ! ( lookup. attr. kind, FileType :: Directory ) ;
304+ let ino = lookup. attr . ino ;
296305 assert ! (
297- seen_inos. insert( lookup . attr . ino) ,
298- "should not have seen ancestor before"
306+ seen_inos. insert( ino) ,
307+ "should not have seen ancestor ino {ino} in MP fs before"
299308 ) ;
300- parent = lookup . attr . ino ;
309+ parent = ino;
301310 }
302311
303- let lookup = self . fs . lookup ( parent, path. last ( ) . unwrap ( ) . as_ref ( ) ) . await . unwrap ( ) ;
304- assert ! ( seen_inos. insert( lookup. attr. ino) , "should not have seen inode before" ) ;
312+ let lookup = self
313+ . fs
314+ . lookup ( parent, leaf. as_ref ( ) )
315+ . await
316+ . expect ( "directory entry at path should exist in MP fs" ) ;
317+ let ino = lookup. attr . ino ;
318+ assert ! ( seen_inos. insert( ino) , "should not have seen ino {ino} before" ) ;
305319 match node {
306320 Node :: Directory { .. } => {
307321 assert_eq ! ( lookup. attr. kind, FileType :: Directory ) ;
@@ -643,8 +657,8 @@ impl Harness {
643657 ) -> BoxFuture < ' a , ( ) > {
644658 async move {
645659 let dir_handle = self . fs . opendir ( fs_dir, 0 ) . await . unwrap ( ) . fh ;
646- let children = ref_dir. children ( ) ;
647- let mut keys = children . keys ( ) . cloned ( ) . collect :: < HashSet < _ > > ( ) ;
660+ let ref_children = ref_dir. children ( ) ;
661+ let mut unvisited_ref_children = ref_children . keys ( ) . cloned ( ) . collect :: < HashSet < _ > > ( ) ;
648662
649663 let mut reply = DirectoryReply :: new ( self . readdir_limit ) ;
650664 self . fs . readdir ( fs_dir, dir_handle, 0 , & mut reply) . await . unwrap ( ) ;
@@ -686,7 +700,7 @@ impl Harness {
686700 let lkup = self . fs . lookup ( fs_dir, & reply. name ) . await . unwrap ( ) ;
687701 let attr = lkup. attr ;
688702
689- match children . get ( name) {
703+ match ref_children . get ( name) {
690704 Some ( node) => {
691705 let ref_kind = node. node_type ( ) . into ( ) ;
692706 assert_eq ! (
@@ -710,7 +724,7 @@ impl Harness {
710724 self . compare_contents_recursive ( fs_dir, reply. ino , node) . await ;
711725 }
712726 assert ! (
713- keys . remove( name) ,
727+ unvisited_ref_children . remove( name) ,
714728 "file name must be in the set of child names in the reference fs" ,
715729 ) ;
716730 }
@@ -722,8 +736,8 @@ impl Harness {
722736 }
723737
724738 assert ! (
725- keys . is_empty( ) ,
726- "reference contained elements not in the filesystem in dir inode {fs_dir}: {keys :?}"
739+ unvisited_ref_children . is_empty( ) ,
740+ "reference contained elements not in the filesystem in dir inode {fs_dir}: {unvisited_ref_children :?}"
727741 ) ;
728742
729743 self . fs . releasedir ( fs_dir, dir_handle, 0 ) . await . unwrap ( ) ;
@@ -733,10 +747,10 @@ impl Harness {
733747
734748 /// Compare the contents of a given reference file to the system under test (SUT),
735749 /// by opening and reading the file from the SUT.
736- async fn compare_file < ' a > ( & ' a self , fs_file : InodeNo , ref_file : & ' a MockObject ) {
737- let fh = match self . fs . open ( fs_file , OpenFlags :: empty ( ) , 0 ) . await {
750+ async fn compare_file < ' a > ( & ' a self , fs_ino : InodeNo , ref_file : & ' a MockObject ) {
751+ let fh = match self . fs . open ( fs_ino , OpenFlags :: empty ( ) , 0 ) . await {
738752 Ok ( ret) => ret. fh ,
739- Err ( e) => panic ! ( "failed to open ino {fs_file } for content comparison: {e:?}" ) ,
753+ Err ( e) => panic ! ( "failed to open ino {fs_ino } for content comparison: {e:?}" ) ,
740754 } ;
741755 let mut offset = 0 ;
742756 const MAX_READ_SIZE : usize = 128 * 1024 ;
@@ -747,7 +761,7 @@ impl Harness {
747761 assert_eq ! ( ref_bytes. len( ) , num_bytes, "number of bytes did not match" ) ;
748762 let bytes_from_read = self
749763 . fs
750- . read ( fs_file , fh, offset as i64 , num_bytes as u32 , 0 , None )
764+ . read ( fs_ino , fh, offset as i64 , num_bytes as u32 , 0 , None )
751765 . await
752766 . expect ( "read should succeed" ) ;
753767 assert_eq ! ( & ref_bytes[ ..] , & bytes_from_read, "read bytes did not match" ) ;
0 commit comments