github.com/coreos/mantle@v0.13.0/system/mount_linux_test.go (about) 1 // Copyright 2015 CoreOS, Inc. 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 package system 16 17 import ( 18 "syscall" 19 "testing" 20 ) 21 22 func TestSplitFlags(t *testing.T) { 23 data := []struct { 24 opts string 25 flags uintptr 26 extra string 27 }{ 28 {"", 0, ""}, 29 {"nodev,nosuid,mode=755", syscall.MS_NOSUID | syscall.MS_NODEV, "mode=755"}, 30 {"mode=755,other", 0, "mode=755,other"}, 31 {"mode=755,nodev,other", syscall.MS_NODEV, "mode=755,other"}, 32 } 33 34 for _, d := range data { 35 f, e := splitFlags(d.opts) 36 if f != d.flags { 37 t.Errorf("bad flags for %q, got 0x%x wanted 0x%x", d.opts, f, d.flags) 38 } 39 if e != d.extra { 40 t.Errorf("bad extra for %q, got %q wanted %q", d.opts, e, d.extra) 41 } 42 } 43 }