From feb637f92dad76bd7d17c4727244ee67cc4a17f6 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Sat, 4 Feb 2023 02:39:30 -0800 Subject: [PATCH] Fix layer comparison and enable read-only checks fstest.CheckDirectoryEqual checks if any files in the diff matches a list of known metadataFiles. This only happens if we specify the initial layer as the first parameter and the mutated layer as the second. This also enables the read-only view checks, as the bind filter allows us to mount a layer as ro. Signed-off-by: Gabriel Adrian Samfira --- snapshots/testsuite/testsuite.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/snapshots/testsuite/testsuite.go b/snapshots/testsuite/testsuite.go index cdfa0e7ae..9586ba500 100644 --- a/snapshots/testsuite/testsuite.go +++ b/snapshots/testsuite/testsuite.go @@ -796,10 +796,6 @@ func checkRemove(ctx context.Context, t *testing.T, snapshotter snapshots.Snapsh // checkSnapshotterViewReadonly ensures a KindView snapshot to be mounted as a read-only filesystem. // This function is called only when WithTestViewReadonly is true. func checkSnapshotterViewReadonly(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) { - if runtime.GOOS == "windows" { - t.Skip("Read-only protection on views is not supported on WCOW") - } - preparing := filepath.Join(work, "preparing") if _, err := snapshotter.Prepare(ctx, preparing, "", opt); err != nil { t.Fatal(err) @@ -943,7 +939,7 @@ func check128LayersMount(name string) func(ctx context.Context, t *testing.T, sn t.Log("mount", preparing) - if err := fstest.CheckDirectoryEqual(preparing, flat); err != nil { + if err := fstest.CheckDirectoryEqual(flat, preparing); err != nil { testutil.Unmount(t, preparing) t.Fatalf("[layer %d] preparing doesn't equal to flat before apply: %+v", i, err) } @@ -958,7 +954,7 @@ func check128LayersMount(name string) func(ctx context.Context, t *testing.T, sn t.Fatalf("[layer %d] failed to apply on preparing dir: %+v", i, err) } - if err := fstest.CheckDirectoryEqual(preparing, flat); err != nil { + if err := fstest.CheckDirectoryEqual(flat, preparing); err != nil { testutil.Unmount(t, preparing) t.Fatalf("[layer %d] preparing doesn't equal to flat after apply: %+v", i, err) } @@ -987,7 +983,7 @@ func check128LayersMount(name string) func(ctx context.Context, t *testing.T, sn } defer testutil.Unmount(t, view) - if err := fstest.CheckDirectoryEqual(view, flat); err != nil { + if err := fstest.CheckDirectoryEqual(flat, view); err != nil { t.Fatalf("fullview should equal to flat: %+v", err) } }