From 5cf5a6fc5eca5e05ab7cd189a19196e73c5408c4 Mon Sep 17 00:00:00 2001 From: Constantin Konstantinidis Date: Mon, 15 Jul 2019 06:32:40 +0200 Subject: os: return an error when the argument of Mkdir on Windows is os.DevNull Test added. Fixes #24556 Change-Id: I4d1cd4513142edeea1a983fbfde46c2fccecab2a Reviewed-on: https://go-review.googlesource.com/c/go/+/186139 Run-TryBot: Alex Brainman TryBot-Result: Gobot Gobot Reviewed-by: Alex Brainman --- src/os/os_windows_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/os/os_windows_test.go') diff --git a/src/os/os_windows_test.go b/src/os/os_windows_test.go index 326670cc9d..2693904e56 100644 --- a/src/os/os_windows_test.go +++ b/src/os/os_windows_test.go @@ -1168,3 +1168,19 @@ func TestWindowsReadlink(t *testing.T) { mklink(t, "relfilelink", "file") testReadlink(t, "relfilelink", "file") } + +// os.Mkdir(os.DevNull) fails. +func TestMkdirDevNull(t *testing.T) { + err := os.Mkdir(os.DevNull, 777) + oserr, ok := err.(*os.PathError) + if !ok { + t.Fatalf("error (%T) is not *os.PathError", err) + } + errno, ok := oserr.Err.(syscall.Errno) + if !ok { + t.Fatalf("error (%T) is not syscall.Errno", oserr) + } + if errno != syscall.ENOTDIR { + t.Fatalf("error %d is not syscall.ENOTDIR", errno) + } +} \ No newline at end of file -- cgit v1.3