vendor: remove dep and use vndr
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
16f44674a4
commit
148e72d81e
16131 changed files with 73815 additions and 4235138 deletions
94
vendor/github.com/containers/storage/pkg/system/chtimes_test.go
generated
vendored
94
vendor/github.com/containers/storage/pkg/system/chtimes_test.go
generated
vendored
|
@ -1,94 +0,0 @@
|
|||
package system
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// prepareTempFile creates a temporary file in a temporary directory.
|
||||
func prepareTempFile(t *testing.T) (string, string) {
|
||||
dir, err := ioutil.TempDir("", "docker-system-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
file := filepath.Join(dir, "exist")
|
||||
if err := ioutil.WriteFile(file, []byte("hello"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return file, dir
|
||||
}
|
||||
|
||||
// TestChtimes tests Chtimes on a tempfile. Test only mTime, because aTime is OS dependent
|
||||
func TestChtimes(t *testing.T) {
|
||||
file, dir := prepareTempFile(t)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
beforeUnixEpochTime := time.Unix(0, 0).Add(-100 * time.Second)
|
||||
unixEpochTime := time.Unix(0, 0)
|
||||
afterUnixEpochTime := time.Unix(100, 0)
|
||||
unixMaxTime := maxTime
|
||||
|
||||
// Test both aTime and mTime set to Unix Epoch
|
||||
Chtimes(file, unixEpochTime, unixEpochTime)
|
||||
|
||||
f, err := os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if f.ModTime() != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, f.ModTime())
|
||||
}
|
||||
|
||||
// Test aTime before Unix Epoch and mTime set to Unix Epoch
|
||||
Chtimes(file, beforeUnixEpochTime, unixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if f.ModTime() != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, f.ModTime())
|
||||
}
|
||||
|
||||
// Test aTime set to Unix Epoch and mTime before Unix Epoch
|
||||
Chtimes(file, unixEpochTime, beforeUnixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if f.ModTime() != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, f.ModTime())
|
||||
}
|
||||
|
||||
// Test both aTime and mTime set to after Unix Epoch (valid time)
|
||||
Chtimes(file, afterUnixEpochTime, afterUnixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if f.ModTime() != afterUnixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", afterUnixEpochTime, f.ModTime())
|
||||
}
|
||||
|
||||
// Test both aTime and mTime set to Unix max time
|
||||
Chtimes(file, unixMaxTime, unixMaxTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if f.ModTime().Truncate(time.Second) != unixMaxTime.Truncate(time.Second) {
|
||||
t.Fatalf("Expected: %s, got: %s", unixMaxTime.Truncate(time.Second), f.ModTime().Truncate(time.Second))
|
||||
}
|
||||
}
|
91
vendor/github.com/containers/storage/pkg/system/chtimes_unix_test.go
generated
vendored
91
vendor/github.com/containers/storage/pkg/system/chtimes_unix_test.go
generated
vendored
|
@ -1,91 +0,0 @@
|
|||
// +build !windows
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestChtimes tests Chtimes access time on a tempfile on Linux
|
||||
func TestChtimesLinux(t *testing.T) {
|
||||
file, dir := prepareTempFile(t)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
beforeUnixEpochTime := time.Unix(0, 0).Add(-100 * time.Second)
|
||||
unixEpochTime := time.Unix(0, 0)
|
||||
afterUnixEpochTime := time.Unix(100, 0)
|
||||
unixMaxTime := maxTime
|
||||
|
||||
// Test both aTime and mTime set to Unix Epoch
|
||||
Chtimes(file, unixEpochTime, unixEpochTime)
|
||||
|
||||
f, err := os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
stat := f.Sys().(*syscall.Stat_t)
|
||||
aTime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
|
||||
if aTime != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
|
||||
}
|
||||
|
||||
// Test aTime before Unix Epoch and mTime set to Unix Epoch
|
||||
Chtimes(file, beforeUnixEpochTime, unixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
stat = f.Sys().(*syscall.Stat_t)
|
||||
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
|
||||
if aTime != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
|
||||
}
|
||||
|
||||
// Test aTime set to Unix Epoch and mTime before Unix Epoch
|
||||
Chtimes(file, unixEpochTime, beforeUnixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
stat = f.Sys().(*syscall.Stat_t)
|
||||
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
|
||||
if aTime != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
|
||||
}
|
||||
|
||||
// Test both aTime and mTime set to after Unix Epoch (valid time)
|
||||
Chtimes(file, afterUnixEpochTime, afterUnixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
stat = f.Sys().(*syscall.Stat_t)
|
||||
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
|
||||
if aTime != afterUnixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", afterUnixEpochTime, aTime)
|
||||
}
|
||||
|
||||
// Test both aTime and mTime set to Unix max time
|
||||
Chtimes(file, unixMaxTime, unixMaxTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
stat = f.Sys().(*syscall.Stat_t)
|
||||
aTime = time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec))
|
||||
if aTime.Truncate(time.Second) != unixMaxTime.Truncate(time.Second) {
|
||||
t.Fatalf("Expected: %s, got: %s", unixMaxTime.Truncate(time.Second), aTime.Truncate(time.Second))
|
||||
}
|
||||
}
|
86
vendor/github.com/containers/storage/pkg/system/chtimes_windows_test.go
generated
vendored
86
vendor/github.com/containers/storage/pkg/system/chtimes_windows_test.go
generated
vendored
|
@ -1,86 +0,0 @@
|
|||
// +build windows
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestChtimes tests Chtimes access time on a tempfile on Windows
|
||||
func TestChtimesWindows(t *testing.T) {
|
||||
file, dir := prepareTempFile(t)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
beforeUnixEpochTime := time.Unix(0, 0).Add(-100 * time.Second)
|
||||
unixEpochTime := time.Unix(0, 0)
|
||||
afterUnixEpochTime := time.Unix(100, 0)
|
||||
unixMaxTime := maxTime
|
||||
|
||||
// Test both aTime and mTime set to Unix Epoch
|
||||
Chtimes(file, unixEpochTime, unixEpochTime)
|
||||
|
||||
f, err := os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
aTime := time.Unix(0, f.Sys().(*syscall.Win32FileAttributeData).LastAccessTime.Nanoseconds())
|
||||
if aTime != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
|
||||
}
|
||||
|
||||
// Test aTime before Unix Epoch and mTime set to Unix Epoch
|
||||
Chtimes(file, beforeUnixEpochTime, unixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
aTime = time.Unix(0, f.Sys().(*syscall.Win32FileAttributeData).LastAccessTime.Nanoseconds())
|
||||
if aTime != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
|
||||
}
|
||||
|
||||
// Test aTime set to Unix Epoch and mTime before Unix Epoch
|
||||
Chtimes(file, unixEpochTime, beforeUnixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
aTime = time.Unix(0, f.Sys().(*syscall.Win32FileAttributeData).LastAccessTime.Nanoseconds())
|
||||
if aTime != unixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", unixEpochTime, aTime)
|
||||
}
|
||||
|
||||
// Test both aTime and mTime set to after Unix Epoch (valid time)
|
||||
Chtimes(file, afterUnixEpochTime, afterUnixEpochTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
aTime = time.Unix(0, f.Sys().(*syscall.Win32FileAttributeData).LastAccessTime.Nanoseconds())
|
||||
if aTime != afterUnixEpochTime {
|
||||
t.Fatalf("Expected: %s, got: %s", afterUnixEpochTime, aTime)
|
||||
}
|
||||
|
||||
// Test both aTime and mTime set to Unix max time
|
||||
Chtimes(file, unixMaxTime, unixMaxTime)
|
||||
|
||||
f, err = os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
aTime = time.Unix(0, f.Sys().(*syscall.Win32FileAttributeData).LastAccessTime.Nanoseconds())
|
||||
if aTime.Truncate(time.Second) != unixMaxTime.Truncate(time.Second) {
|
||||
t.Fatalf("Expected: %s, got: %s", unixMaxTime.Truncate(time.Second), aTime.Truncate(time.Second))
|
||||
}
|
||||
}
|
30
vendor/github.com/containers/storage/pkg/system/lstat_unix_test.go
generated
vendored
30
vendor/github.com/containers/storage/pkg/system/lstat_unix_test.go
generated
vendored
|
@ -1,30 +0,0 @@
|
|||
// +build linux freebsd
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestLstat tests Lstat for existing and non existing files
|
||||
func TestLstat(t *testing.T) {
|
||||
file, invalid, _, dir := prepareFiles(t)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
statFile, err := Lstat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if statFile == nil {
|
||||
t.Fatal("returned empty stat for existing file")
|
||||
}
|
||||
|
||||
statInvalid, err := Lstat(invalid)
|
||||
if err == nil {
|
||||
t.Fatal("did not return error for non-existing file")
|
||||
}
|
||||
if statInvalid != nil {
|
||||
t.Fatal("returned non-nil stat for non-existing file")
|
||||
}
|
||||
}
|
40
vendor/github.com/containers/storage/pkg/system/meminfo_unix_test.go
generated
vendored
40
vendor/github.com/containers/storage/pkg/system/meminfo_unix_test.go
generated
vendored
|
@ -1,40 +0,0 @@
|
|||
// +build linux freebsd
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/go-units"
|
||||
)
|
||||
|
||||
// TestMemInfo tests parseMemInfo with a static meminfo string
|
||||
func TestMemInfo(t *testing.T) {
|
||||
const input = `
|
||||
MemTotal: 1 kB
|
||||
MemFree: 2 kB
|
||||
SwapTotal: 3 kB
|
||||
SwapFree: 4 kB
|
||||
Malformed1:
|
||||
Malformed2: 1
|
||||
Malformed3: 2 MB
|
||||
Malformed4: X kB
|
||||
`
|
||||
meminfo, err := parseMemInfo(strings.NewReader(input))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if meminfo.MemTotal != 1*units.KiB {
|
||||
t.Fatalf("Unexpected MemTotal: %d", meminfo.MemTotal)
|
||||
}
|
||||
if meminfo.MemFree != 2*units.KiB {
|
||||
t.Fatalf("Unexpected MemFree: %d", meminfo.MemFree)
|
||||
}
|
||||
if meminfo.SwapTotal != 3*units.KiB {
|
||||
t.Fatalf("Unexpected SwapTotal: %d", meminfo.SwapTotal)
|
||||
}
|
||||
if meminfo.SwapFree != 4*units.KiB {
|
||||
t.Fatalf("Unexpected SwapFree: %d", meminfo.SwapFree)
|
||||
}
|
||||
}
|
78
vendor/github.com/containers/storage/pkg/system/path_windows_test.go
generated
vendored
78
vendor/github.com/containers/storage/pkg/system/path_windows_test.go
generated
vendored
|
@ -1,78 +0,0 @@
|
|||
// +build windows
|
||||
|
||||
package system
|
||||
|
||||
import "testing"
|
||||
|
||||
// TestCheckSystemDriveAndRemoveDriveLetter tests CheckSystemDriveAndRemoveDriveLetter
|
||||
func TestCheckSystemDriveAndRemoveDriveLetter(t *testing.T) {
|
||||
// Fails if not C drive.
|
||||
path, err := CheckSystemDriveAndRemoveDriveLetter(`d:\`)
|
||||
if err == nil || (err != nil && err.Error() != "The specified path is not on the system drive (C:)") {
|
||||
t.Fatalf("Expected error for d:")
|
||||
}
|
||||
|
||||
// Single character is unchanged
|
||||
if path, err = CheckSystemDriveAndRemoveDriveLetter("z"); err != nil {
|
||||
t.Fatalf("Single character should pass")
|
||||
}
|
||||
if path != "z" {
|
||||
t.Fatalf("Single character should be unchanged")
|
||||
}
|
||||
|
||||
// Two characters without colon is unchanged
|
||||
if path, err = CheckSystemDriveAndRemoveDriveLetter("AB"); err != nil {
|
||||
t.Fatalf("2 characters without colon should pass")
|
||||
}
|
||||
if path != "AB" {
|
||||
t.Fatalf("2 characters without colon should be unchanged")
|
||||
}
|
||||
|
||||
// Abs path without drive letter
|
||||
if path, err = CheckSystemDriveAndRemoveDriveLetter(`\l`); err != nil {
|
||||
t.Fatalf("abs path no drive letter should pass")
|
||||
}
|
||||
if path != `\l` {
|
||||
t.Fatalf("abs path without drive letter should be unchanged")
|
||||
}
|
||||
|
||||
// Abs path without drive letter, linux style
|
||||
if path, err = CheckSystemDriveAndRemoveDriveLetter(`/l`); err != nil {
|
||||
t.Fatalf("abs path no drive letter linux style should pass")
|
||||
}
|
||||
if path != `\l` {
|
||||
t.Fatalf("abs path without drive letter linux failed %s", path)
|
||||
}
|
||||
|
||||
// Drive-colon should be stripped
|
||||
if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:\`); err != nil {
|
||||
t.Fatalf("An absolute path should pass")
|
||||
}
|
||||
if path != `\` {
|
||||
t.Fatalf(`An absolute path should have been shortened to \ %s`, path)
|
||||
}
|
||||
|
||||
// Verify with a linux-style path
|
||||
if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:/`); err != nil {
|
||||
t.Fatalf("An absolute path should pass")
|
||||
}
|
||||
if path != `\` {
|
||||
t.Fatalf(`A linux style absolute path should have been shortened to \ %s`, path)
|
||||
}
|
||||
|
||||
// Failure on c:
|
||||
if path, err = CheckSystemDriveAndRemoveDriveLetter(`c:`); err == nil {
|
||||
t.Fatalf("c: should fail")
|
||||
}
|
||||
if err.Error() != `No relative path specified in "c:"` {
|
||||
t.Fatalf(path, err)
|
||||
}
|
||||
|
||||
// Failure on d:
|
||||
if path, err = CheckSystemDriveAndRemoveDriveLetter(`d:`); err == nil {
|
||||
t.Fatalf("c: should fail")
|
||||
}
|
||||
if err.Error() != `No relative path specified in "d:"` {
|
||||
t.Fatalf(path, err)
|
||||
}
|
||||
}
|
39
vendor/github.com/containers/storage/pkg/system/stat_unix_test.go
generated
vendored
39
vendor/github.com/containers/storage/pkg/system/stat_unix_test.go
generated
vendored
|
@ -1,39 +0,0 @@
|
|||
// +build linux freebsd
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestFromStatT tests fromStatT for a tempfile
|
||||
func TestFromStatT(t *testing.T) {
|
||||
file, _, _, dir := prepareFiles(t)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
stat := &syscall.Stat_t{}
|
||||
err := syscall.Lstat(file, stat)
|
||||
|
||||
s, err := fromStatT(stat)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if stat.Mode != s.Mode() {
|
||||
t.Fatal("got invalid mode")
|
||||
}
|
||||
if stat.Uid != s.UID() {
|
||||
t.Fatal("got invalid uid")
|
||||
}
|
||||
if stat.Gid != s.GID() {
|
||||
t.Fatal("got invalid gid")
|
||||
}
|
||||
if stat.Rdev != s.Rdev() {
|
||||
t.Fatal("got invalid rdev")
|
||||
}
|
||||
if stat.Mtim != s.Mtim() {
|
||||
t.Fatal("got invalid mtim")
|
||||
}
|
||||
}
|
9
vendor/github.com/containers/storage/pkg/system/syscall_windows_test.go
generated
vendored
9
vendor/github.com/containers/storage/pkg/system/syscall_windows_test.go
generated
vendored
|
@ -1,9 +0,0 @@
|
|||
package system
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHasWin32KSupport(t *testing.T) {
|
||||
s := HasWin32KSupport() // make sure this doesn't panic
|
||||
|
||||
t.Logf("win32k: %v", s) // will be different on different platforms -- informative only
|
||||
}
|
68
vendor/github.com/containers/storage/pkg/system/utimes_unix_test.go
generated
vendored
68
vendor/github.com/containers/storage/pkg/system/utimes_unix_test.go
generated
vendored
|
@ -1,68 +0,0 @@
|
|||
// +build linux freebsd
|
||||
|
||||
package system
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// prepareFiles creates files for testing in the temp directory
|
||||
func prepareFiles(t *testing.T) (string, string, string, string) {
|
||||
dir, err := ioutil.TempDir("", "docker-system-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
file := filepath.Join(dir, "exist")
|
||||
if err := ioutil.WriteFile(file, []byte("hello"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
invalid := filepath.Join(dir, "doesnt-exist")
|
||||
|
||||
symlink := filepath.Join(dir, "symlink")
|
||||
if err := os.Symlink(file, symlink); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
return file, invalid, symlink, dir
|
||||
}
|
||||
|
||||
func TestLUtimesNano(t *testing.T) {
|
||||
file, invalid, symlink, dir := prepareFiles(t)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
before, err := os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ts := []syscall.Timespec{{0, 0}, {0, 0}}
|
||||
if err := LUtimesNano(symlink, ts); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
symlinkInfo, err := os.Lstat(symlink)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if before.ModTime().Unix() == symlinkInfo.ModTime().Unix() {
|
||||
t.Fatal("The modification time of the symlink should be different")
|
||||
}
|
||||
|
||||
fileInfo, err := os.Stat(file)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if before.ModTime().Unix() != fileInfo.ModTime().Unix() {
|
||||
t.Fatal("The modification time of the file should be same")
|
||||
}
|
||||
|
||||
if err := LUtimesNano(invalid, ts); err == nil {
|
||||
t.Fatal("Doesn't return an error on a non-existing file")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue