From 0f2ae9b98b9fa814731f92b22678536b60a295b3 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Tue, 31 Jan 2023 08:09:52 -0800 Subject: [PATCH] Fix temp dir creation Signed-off-by: Gabriel Adrian Samfira --- internal/winapi/zsyscall_windows.go | 14 +++++++------- test/functional/uvm_mem_backingtype_test.go | 1 + test/functional/uvm_memory_test.go | 1 + test/functional/uvm_properties_test.go | 1 + test/functional/uvm_scsi_test.go | 1 - test/functional/uvm_vsmb_test.go | 1 + test/internal/scratch.go | 2 +- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/internal/winapi/zsyscall_windows.go b/internal/winapi/zsyscall_windows.go index 9fe21209ca..dc19142087 100644 --- a/internal/winapi/zsyscall_windows.go +++ b/internal/winapi/zsyscall_windows.go @@ -83,9 +83,9 @@ var ( procNtQuerySystemInformation = modntdll.NewProc("NtQuerySystemInformation") procNtSetInformationFile = modntdll.NewProc("NtSetInformationFile") procRtlNtStatusToDosError = modntdll.NewProc("RtlNtStatusToDosError") + procORCloseHive = modoffreg.NewProc("ORCloseHive") procORCreateHive = modoffreg.NewProc("ORCreateHive") procORSaveHive = modoffreg.NewProc("ORSaveHive") - procORCloseHive = modoffreg.NewProc("ORCloseHive") ) func LogonUser(username *uint16, domain *uint16, password *uint16, logonType uint32, logonProvider uint32, token *windows.Token) (err error) { @@ -381,24 +381,24 @@ func RtlNtStatusToDosError(status uint32) (winerr error) { return } -func ORCreateHive(key *syscall.Handle) (regerrno error) { - r0, _, _ := syscall.Syscall(procORCreateHive.Addr(), 1, uintptr(unsafe.Pointer(key)), 0, 0) +func ORCloseHive(key *syscall.Handle) (regerrno error) { + r0, _, _ := syscall.Syscall(procORCloseHive.Addr(), 1, uintptr(unsafe.Pointer(key)), 0, 0) if r0 != 0 { regerrno = syscall.Errno(r0) } return } -func ORSaveHive(key syscall.Handle, file *uint16, OsMajorVersion uint32, OsMinorVersion uint32) (regerrno error) { - r0, _, _ := syscall.Syscall6(procORSaveHive.Addr(), 4, uintptr(key), uintptr(unsafe.Pointer(file)), uintptr(OsMajorVersion), uintptr(OsMinorVersion), 0, 0) +func ORCreateHive(key *syscall.Handle) (regerrno error) { + r0, _, _ := syscall.Syscall(procORCreateHive.Addr(), 1, uintptr(unsafe.Pointer(key)), 0, 0) if r0 != 0 { regerrno = syscall.Errno(r0) } return } -func ORCloseHive(key *syscall.Handle) (regerrno error) { - r0, _, _ := syscall.Syscall(procORCloseHive.Addr(), 1, uintptr(unsafe.Pointer(key)), 0, 0) +func ORSaveHive(key syscall.Handle, file *uint16, OsMajorVersion uint32, OsMinorVersion uint32) (regerrno error) { + r0, _, _ := syscall.Syscall6(procORSaveHive.Addr(), 4, uintptr(key), uintptr(unsafe.Pointer(file)), uintptr(OsMajorVersion), uintptr(OsMinorVersion), 0, 0) if r0 != 0 { regerrno = syscall.Errno(r0) } diff --git a/test/functional/uvm_mem_backingtype_test.go b/test/functional/uvm_mem_backingtype_test.go index f097640056..50eab781c1 100644 --- a/test/functional/uvm_mem_backingtype_test.go +++ b/test/functional/uvm_mem_backingtype_test.go @@ -7,6 +7,7 @@ package functional import ( "context" "io" + "os" "testing" "github.com/Microsoft/hcsshim/internal/uvm" diff --git a/test/functional/uvm_memory_test.go b/test/functional/uvm_memory_test.go index 4398a7f51d..cee55348ae 100644 --- a/test/functional/uvm_memory_test.go +++ b/test/functional/uvm_memory_test.go @@ -4,6 +4,7 @@ package functional import ( "context" + "os" "testing" "time" diff --git a/test/functional/uvm_properties_test.go b/test/functional/uvm_properties_test.go index d114d15983..aabd6ab508 100644 --- a/test/functional/uvm_properties_test.go +++ b/test/functional/uvm_properties_test.go @@ -6,6 +6,7 @@ package functional import ( "context" + "os" "testing" "github.com/Microsoft/hcsshim/osversion" diff --git a/test/functional/uvm_scsi_test.go b/test/functional/uvm_scsi_test.go index 2af0b419bf..b9dae75e1c 100644 --- a/test/functional/uvm_scsi_test.go +++ b/test/functional/uvm_scsi_test.go @@ -51,7 +51,6 @@ func TestSCSIAddRemoveWCOW(t *testing.T) { u, layers, uvmScratchDir := tuvm.CreateWCOWUVM(context.Background(), t, t.Name(), "mcr.microsoft.com/windows/nanoserver:1903") defer os.RemoveAll(uvmScratchDir) defer u.Close() - layers := testutilities.CreateWCOWBlankBaseLayer(context.Background(), t) defer os.RemoveAll(layers[0]) testSCSIAddRemoveSingle(t, u, `c:\`, "windows", layers) diff --git a/test/functional/uvm_vsmb_test.go b/test/functional/uvm_vsmb_test.go index 19e7931463..b51a40a8a6 100644 --- a/test/functional/uvm_vsmb_test.go +++ b/test/functional/uvm_vsmb_test.go @@ -7,6 +7,7 @@ package functional import ( "context" "errors" + "os" "testing" "github.com/Microsoft/hcsshim/internal/hcs" diff --git a/test/internal/scratch.go b/test/internal/scratch.go index d5bf566610..48dbe29360 100644 --- a/test/internal/scratch.go +++ b/test/internal/scratch.go @@ -32,7 +32,7 @@ func init() { // can be used as the base of a WCOW RW layer when it's not going to be the container's // scratch mount. func CreateWCOWBlankBaseLayer(ctx context.Context, t *testing.T) []string { - tempDir := CreateTempDir(t) + tempDir := t.TempDir() if err := wclayer.ConvertToBaseLayer(context.Background(), tempDir); err != nil { t.Fatalf("Failed ConvertToBaseLayer: %s", err) }