Windows: Updates Windows Vendoring

Updates windows dependent libraries for vendoing.
This commit is contained in:
Nathan Gieseker
2019-01-23 18:43:18 -08:00
parent a686cc4bd8
commit 9a429d8d25
839 changed files with 282895 additions and 774 deletions

View File

@@ -0,0 +1,68 @@
package runhcs
import (
"os"
"path/filepath"
"sync/atomic"
"testing"
)
func resetRunhcsPath() {
runhcsPath = atomic.Value{}
}
func TestGetCommandPath_NoLookPath(t *testing.T) {
resetRunhcsPath()
path := getCommandPath()
if path != "runhcs.exe" {
t.Fatalf("expected path 'runhcs.exe' got '%s'", path)
}
pathi := runhcsPath.Load()
if pathi == nil {
t.Fatal("cache state should be set after first query")
}
if path != pathi.(string) {
t.Fatalf("expected: '%s' in cache got '%s'", path, pathi.(string))
}
}
func TestGetCommandPath_WithLookPath(t *testing.T) {
resetRunhcsPath()
wd, err := os.Getwd()
if err != nil {
t.Fatalf("failed to get cwd with err: %v", err)
}
fakePath := filepath.Join(wd, "runhcs.exe")
f, err := os.Create(fakePath)
if err != nil {
t.Fatalf("failed to create fake runhcs.exe in path with err: %v", err)
}
f.Close()
defer os.Remove(fakePath)
path := getCommandPath()
if path != fakePath {
t.Fatalf("expected fake path '%s' got '%s'", fakePath, path)
}
pathi := runhcsPath.Load()
if pathi == nil {
t.Fatal("cache state should be set after first query")
}
if path != pathi.(string) {
t.Fatalf("expected: '%s' in cache got '%s'", fakePath, pathi.(string))
}
}
func TestGetCommandPath_WithCache(t *testing.T) {
resetRunhcsPath()
value := "this is a test"
runhcsPath.Store(value)
path := getCommandPath()
if path != value {
t.Fatalf("expected fake cached path: '%s' got '%s'", value, path)
}
}