mirror of
https://github.com/rwinkhart/go-winio.git
synced 2026-08-28 21:06:52 -04:00
* Bug: Close hvsock handle on listen error; fix tests Close the socket created in `github.com/Microsoft/go-winio/pkg/ListenHvsock` if either the `Bind` or `Listen` calls fail. Go changed `filepath.VolumeName` code, resulting in different behavior in `github.com/Microsoft/go-winio/pkg/fs.GetFileSystemType`. Update test accordingly. Also add more debug logs to `pkg\fs\resolve_test.go`. Also, move add skip for fuzzing on WS2019 or older to `FuzzHvSockRxTx` code directly, instead of in ci.yml. See: https://go-review.googlesource.com/c/go/+/540277 Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com> * PR: unskip TestResolvePath Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com> --------- Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package fs
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetFSTypeOfKnownDrive(t *testing.T) {
|
|
fsType, err := GetFileSystemType("C:\\")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if fsType == "" {
|
|
t.Fatal("No filesystem type name returned")
|
|
}
|
|
}
|
|
|
|
func TestGetFSTypeOfInvalidPath(t *testing.T) {
|
|
// [filepath.VolumeName] doesn't mandate that the drive letters matches [a-zA-Z].
|
|
// Instead, use non-character drive.
|
|
_, err := GetFileSystemType(`No:\`)
|
|
if !errors.Is(err, ErrInvalidPath) {
|
|
t.Fatalf("Expected `ErrInvalidPath`, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestGetFSTypeOfValidButAbsentDrive(t *testing.T) {
|
|
drive := ""
|
|
for _, letter := range "abcdefghijklmnopqrstuvwxyz" {
|
|
possibleDrive := string(letter) + ":\\"
|
|
if _, err := os.Stat(possibleDrive); os.IsNotExist(err) {
|
|
drive = possibleDrive
|
|
break
|
|
}
|
|
}
|
|
if drive == "" {
|
|
t.Skip("Every possible drive exists")
|
|
}
|
|
|
|
_, err := GetFileSystemType(drive)
|
|
if err == nil {
|
|
t.Fatalf("GetFileSystemType %s unexpectedly succeeded", drive)
|
|
}
|
|
if !os.IsNotExist(err) {
|
|
t.Fatalf("GetFileSystemType %s failed with %v, expected 'ErrNotExist' or similar", drive, err)
|
|
}
|
|
}
|