github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/utils/mount/overlay2_test.go (about) 1 // Copyright © 2021 Alibaba Group Holding Ltd. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 //go:build linux 16 // +build linux 17 18 package mount 19 20 import "testing" 21 22 func TestOverlay2_Mount(t *testing.T) { 23 type args struct { 24 target string 25 upper string 26 layers []string 27 } 28 29 tests := []struct { 30 name string 31 args args 32 }{ 33 { 34 name: "merged layer files to merged1", 35 args: args{ 36 "../test/mount/overlay2/merged1", 37 "../test/mount/overlay2/upper", 38 []string{"../test/mount/overlay2/lower1", "../test/mount/overlay2/lower2", "../test/mount/overlay2/lower3"}, 39 }, 40 }, 41 { 42 name: "merged layer files to merged2", 43 args: args{ 44 "../test/mount/overlay2/merged2", 45 "../test/mount/overlay2/upper", 46 []string{"../test/mount/overlay2/lower1", "../test/mount/overlay2/lower2", "../test/mount/overlay2/lower3"}, 47 }, 48 }, 49 } 50 for _, tt := range tests { 51 d := &Overlay2{} 52 t.Run(tt.name, func(t *testing.T) { 53 if err := d.Mount(tt.args.target, tt.args.upper, tt.args.layers...); err != nil { 54 t.Errorf("err %s, %s", tt.name, err) 55 } else { 56 if err := unmount(tt.args.target, 0); err != nil { 57 t.Errorf("err unmount %s, %s", tt.args.target, err) 58 } 59 } 60 }) 61 } 62 } 63 func TestNewMountDriver(t *testing.T) { 64 if !supportsOverlay() { 65 t.Errorf("mountDriver isn't overlay") 66 } 67 }