"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: bring open_tests.go generator back into line with the generated tests
Nick Craig-Wood07908f3f54cb
diff --git a/vfs/make_open_tests.go b/vfs/make_open_tests.goindex 9d3f4a684..d610b87e0 100644--- a/vfs/make_open_tests.go+++ b/vfs/make_open_tests.go@@ -1,6 +1,11 @@-// This makes the open test suite+// This makes the open test suite. It tries to open a file (existing+// or not existing) with all possible file modes and writes a test+// matrix.//-// Run with go run make_open_tests.go | gofmt > open_test.go+// The behaviour is as run on Linux, with the small modification that+// O_TRUNC with O_RDONLY does **not** truncate the file.+//+// Run with go generate (defined in vfs.go)////+build none@@ -26,6 +31,8 @@ func whichError(err error) string {return "nil"case io.EOF:return "io.EOF"+ case os.ErrInvalid:+ return "EINVAL"}s := err.Error()switch {@@ -40,6 +47,8 @@ func whichError(err error) string {return ""}+const accessModeMask = (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)+// test Opening, reading and writing the file handle with the flags givenfunc test(fileName string, flags int, mode string) {// first try with file not existing@@ -123,6 +132,19 @@ func test(fileName string, flags int, mode string) {log.Fatalf("failed to remove: %v", err)}+ // http://pubs.opengroup.org/onlinepubs/7908799/xsh/open.html+ // The result of using O_TRUNC with O_RDONLY is undefined.+ // Linux seems to truncate the file, but we prefer to return EINVAL+ if (flags&accessModeMask) == os.O_RDONLY && flags&os.O_TRUNC != 0 {+ openNonExistentErr = os.ErrInvalid // EINVAL+ readNonExistentErr = nil+ writeNonExistentErr = nil+ openExistingErr = os.ErrInvalid // EINVAL+ readExistingErr = nil+ writeExistingErr = nil+ contents = "hello"+ }+// output the structfmt.Printf(`{flags: %s,@@ -147,7 +169,7 @@ func test(fileName string, flags int, mode string) {}func main() {- fmt.Printf(`// data generated by go run make_open_tests.go | gofmt > open_test.go+ fmt.Printf(`// AUTO GENERATED by make_open_tests.go - DO NOT EDIT - use go generate to rebuildpackage vfsdiff --git a/vfs/open_test.go b/vfs/open_test.goindex 22f661606..ad7fce7dc 100644--- a/vfs/open_test.go+++ b/vfs/open_test.go@@ -1,4 +1,4 @@-// data generated by go run make_open_tests.go | gofmt > open_test.go+// AUTO GENERATED by make_open_tests.go - DO NOT EDIT - use go generate to rebuildpackage vfsdiff --git a/vfs/vfs.go b/vfs/vfs.goindex 2fa71db69..fa2947237 100644--- a/vfs/vfs.go+++ b/vfs/vfs.go@@ -16,6 +16,9 @@// error conditions have ocurred. It may also return general errors// it receives. It tries to use os Error values (eg os.ErrExist)// where possible.++//go:generate sh -c "go run make_open_tests.go | gofmt > open_test.go"+package vfsimport (