aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/os/os_chmod_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/os_chmod_test.go')
-rw-r--r--src/os/os_chmod_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/os/os_chmod_test.go b/src/os/os_chmod_test.go
new file mode 100644
index 000000000..eef507c3d
--- /dev/null
+++ b/src/os/os_chmod_test.go
@@ -0,0 +1,27 @@
+// +build !baremetal,!js,!wasi
+
+// TODO: Move this into os_test.go (as upstream has it) when wasi supports chmod
+
+package os_test
+
+import (
+ . "os"
+ "runtime"
+ "testing"
+)
+
+func TestChmod(t *testing.T) {
+ f := newFile("TestChmod", t)
+ defer Remove(f.Name())
+ defer f.Close()
+ // Creation mode is read write
+
+ fm := FileMode(0456)
+ if runtime.GOOS == "windows" {
+ fm = FileMode(0444) // read-only file
+ }
+ if err := Chmod(f.Name(), fm); err != nil {
+ t.Fatalf("chmod %s %#o: %s", f.Name(), fm, err)
+ }
+ checkMode(t, f.Name(), fm)
+}