github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/os/os_chmod_test.go (about)

     1  //go:build !baremetal && !js && !wasip1
     2  
     3  // Copyright 2009 The Go Authors. All rights reserved.
     4  // Use of this source code is governed by a BSD-style
     5  // license that can be found in the LICENSE file.
     6  
     7  // TODO: Move this back into os_test.go (as upstream has it) when wasi supports chmod
     8  
     9  package os_test
    10  
    11  import (
    12  	. "os"
    13  	"runtime"
    14  	"testing"
    15  )
    16  
    17  func TestChmod(t *testing.T) {
    18  	f := newFile("TestChmod", t)
    19  	defer Remove(f.Name())
    20  	defer f.Close()
    21  	// Creation mode is read write
    22  
    23  	fm := FileMode(0456)
    24  	if runtime.GOOS == "windows" {
    25  		fm = FileMode(0444) // read-only file
    26  	}
    27  	if err := Chmod(f.Name(), fm); err != nil {
    28  		t.Fatalf("chmod %s %#o: %s", f.Name(), fm, err)
    29  	}
    30  	checkMode(t, f.Name(), fm)
    31  }