@@ -162,6 +162,7 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
162162 }
163163
164164 if err := initialApplier .Apply (preparing ); err != nil {
165+ testutil .Unmount (t , preparing )
165166 t .Fatalf ("failure reason: %+v" , err )
166167 }
167168 // unmount before commit
@@ -199,10 +200,12 @@ func checkSnapshotterBasic(ctx context.Context, t *testing.T, snapshotter snapsh
199200 }
200201
201202 if err := fstest .CheckDirectoryEqualWithApplier (next , initialApplier ); err != nil {
203+ testutil .Unmount (t , next )
202204 t .Fatalf ("failure reason: %+v" , err )
203205 }
204206
205207 if err := diffApplier .Apply (next ); err != nil {
208+ testutil .Unmount (t , next )
206209 t .Fatalf ("failure reason: %+v" , err )
207210 }
208211 // unmount before commit
@@ -386,11 +389,12 @@ func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter
386389 if err != nil {
387390 t .Fatal (err )
388391 }
389- defer testutil .Unmount (t , preparing )
390392
391393 if err = os .WriteFile (filepath .Join (preparing , "foo" ), []byte ("foo\n " ), 0777 ); err != nil {
394+ testutil .Unmount (t , preparing )
392395 t .Fatal (err )
393396 }
397+ testutil .Unmount (t , preparing )
394398
395399 snapA := filepath .Join (work , "snapA" )
396400 if err = snapshotter .Commit (ctx , snapA , preparing , opt ); err != nil {
@@ -401,11 +405,12 @@ func checkSnapshotterTransitivity(ctx context.Context, t *testing.T, snapshotter
401405 if err != nil {
402406 t .Fatal (err )
403407 }
404- defer testutil .Unmount (t , next )
405408
406409 if err = os .WriteFile (filepath .Join (next , "foo" ), []byte ("foo bar\n " ), 0777 ); err != nil {
410+ testutil .Unmount (t , next )
407411 t .Fatal (err )
408412 }
413+ testutil .Unmount (t , next )
409414
410415 snapB := filepath .Join (work , "snapB" )
411416 if err = snapshotter .Commit (ctx , snapB , next , opt ); err != nil {
@@ -440,7 +445,7 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter
440445 if err != nil {
441446 t .Fatal (err )
442447 }
443- defer testutil .Unmount (t , preparing )
448+ testutil .Unmount (t , preparing )
444449
445450 snapA := filepath .Join (work , "snapA" )
446451 if err = snapshotter .Commit (ctx , snapA , preparing , opt ); err != nil {
@@ -517,6 +522,7 @@ func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshot
517522 if err != nil {
518523 t .Fatal (err )
519524 }
525+ testutil .Unmount (t , base )
520526
521527 committedBase := filepath .Join (work , "committed-base" )
522528 if err = snapshotter .Commit (ctx , committedBase , base , opt ); err != nil {
@@ -555,7 +561,6 @@ func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshot
555561 if err != nil {
556562 t .Fatal (err )
557563 }
558- testutil .Unmount (t , base )
559564 err = snapshotter .Remove (ctx , committedBase )
560565 if err != nil {
561566 t .Fatal (err )
@@ -817,6 +822,7 @@ func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter
817822 if err := os .WriteFile (testfile , []byte ("testcontent" ), 0777 ); err != nil {
818823 t .Logf ("write to %q failed with %v (EROFS is expected but can be other error code)" , testfile , err )
819824 } else {
825+ testutil .Unmount (t , viewMountPoint )
820826 t .Fatalf ("write to %q should fail (EROFS) but did not fail" , testfile )
821827 }
822828 testutil .Unmount (t , viewMountPoint )
0 commit comments