github.com/avfs/avfs@v0.33.1-0.20240303173310-c6ba67c33eb7/test/testbuild/testbuild.go (about) 1 // 2 // Copyright 2022 The AVFS authors 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 package main 18 19 import ( 20 "io" 21 "log" 22 "os" 23 "time" 24 25 "github.com/avfs/avfs" 26 "github.com/avfs/avfs/vfs/osfs" 27 ) 28 29 // This code is used by gox to generate an executable for all operating systems (see mage/magefile.go). 30 // It should use all functions that depend on OS specific syscalls to make sure every system can be built. 31 func main() { 32 vfs := osfs.New() 33 34 tmpDir, err := vfs.MkdirTemp("", "gox") 35 if err != nil { 36 log.Fatal(err) 37 } 38 39 u := &avfs.DummyUser{} 40 tmpFile := vfs.Join(tmpDir, "file") 41 42 _, _ = vfs.Abs(tmpDir) 43 _ = vfs.Base(tmpDir) 44 _ = vfs.Chdir(tmpDir) 45 _ = vfs.Chmod(tmpDir, avfs.DefaultDirPerm) 46 _ = vfs.Chown(tmpDir, 0, 0) 47 _ = vfs.Chroot(tmpDir) 48 _ = vfs.Chtimes(tmpDir, time.Now(), time.Now()) 49 _ = vfs.Clean(tmpDir) 50 _, _ = vfs.Create(tmpFile) 51 _, _ = vfs.CreateTemp(tmpDir, "") 52 _ = vfs.Dir(tmpDir) 53 _, _ = vfs.EvalSymlinks(tmpDir) 54 _ = vfs.Features() 55 _ = vfs.FromSlash(tmpDir) 56 _, _ = vfs.Getwd() 57 _, _ = vfs.Glob("") 58 _ = vfs.HasFeature(avfs.FeatSymlink) 59 _ = vfs.Idm() 60 _ = vfs.IsAbs(tmpDir) 61 _ = vfs.IsPathSeparator('a') 62 _ = vfs.Join("", "") 63 _ = vfs.Lchown(tmpDir, 0, 0) 64 _ = vfs.Link(tmpDir, tmpDir) 65 _, _ = vfs.Lstat(tmpDir) 66 _, _ = vfs.Match("", "") 67 _ = vfs.Mkdir(tmpDir, avfs.DefaultDirPerm) 68 _ = vfs.MkdirAll(tmpDir, avfs.DefaultDirPerm) 69 _, _ = vfs.MkdirTemp(tmpDir, "") 70 _ = vfs.Name() 71 f, _ := vfs.Open(tmpDir) 72 _, _ = vfs.OpenFile(tmpDir, os.O_RDONLY, avfs.DefaultDirPerm) 73 _ = vfs.OSType() 74 _ = vfs.PathSeparator() 75 _, _ = vfs.ReadDir(tmpDir) 76 _, _ = vfs.ReadFile(tmpDir) 77 _, _ = vfs.Readlink(tmpDir) 78 _, _ = vfs.Rel(tmpDir, tmpDir) 79 _ = vfs.Remove(tmpDir) 80 _ = vfs.RemoveAll(tmpDir) 81 _ = vfs.Rename(tmpDir, tmpDir) 82 _, _ = vfs.Split(tmpDir) 83 info, _ := vfs.Stat(tmpFile) 84 _ = vfs.SetUMask(0) 85 _ = vfs.SetUser(u) 86 _ = vfs.SetUserByName("") 87 _, _ = vfs.Sub("") 88 _ = vfs.TempDir() 89 _ = vfs.ToSlash(tmpDir) 90 _ = vfs.ToSysStat(info) 91 _ = vfs.Truncate(tmpFile, 0) 92 _ = vfs.Type() 93 _ = vfs.User() 94 _ = vfs.UMask() 95 _ = vfs.WalkDir(tmpDir, nil) 96 _ = vfs.WriteFile(tmpFile, nil, avfs.DefaultFilePerm) 97 98 _ = f.Chdir() 99 _ = f.Chmod(0) 100 _ = f.Chown(0, 0) 101 _ = f.Close() 102 _ = f.Fd() 103 _ = f.Name() 104 _, _ = f.Read(nil) 105 _, _ = f.ReadAt(nil, 0) 106 _, _ = f.ReadDir(0) 107 _, _ = f.Readdirnames(0) 108 _, _ = f.Seek(0, io.SeekStart) 109 _, _ = f.Stat() 110 _ = f.Sync() 111 _, _ = f.Write(nil) 112 _, _ = f.WriteAt(nil, 0) 113 _, _ = f.WriteString("") 114 }