github.com/robhaswell/grandperspective-scan@v0.1.0/test/go-go1.7.1/src/cmd/go/go_unix_test.go (about)

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build darwin dragonfly freebsd linux netbsd openbsd solaris
     6  
     7  package main_test
     8  
     9  import (
    10  	"os"
    11  	"syscall"
    12  	"testing"
    13  )
    14  
    15  func TestGoBuildUmask(t *testing.T) {
    16  	// Do not use tg.parallel; avoid other tests seeing umask manipulation.
    17  	mask := syscall.Umask(0077) // prohibit low bits
    18  	defer syscall.Umask(mask)
    19  	tg := testgo(t)
    20  	defer tg.cleanup()
    21  	tg.tempFile("x.go", `package main; func main() {}`)
    22  	tg.creatingTemp("x")
    23  	tg.run("build", tg.path("x.go"))
    24  	fi, err := os.Stat("x")
    25  	if err != nil {
    26  		t.Fatal(err)
    27  	}
    28  	if mode := fi.Mode(); mode&0077 != 0 {
    29  		t.Fatalf("wrote x with mode=%v, wanted no 0077 bits", mode)
    30  	}
    31  }