github.com/hongwozai/go-src-1.4.3@v0.0.0-20191127132709-dc3fce3dbccb/test/sinit_run.go (about) 1 // +build !nacl 2 // run 3 4 // Copyright 2014 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 // Run the sinit test. 9 10 package main 11 12 import ( 13 "bytes" 14 "fmt" 15 "go/build" 16 "os" 17 "os/exec" 18 ) 19 20 func main() { 21 letter, err := build.ArchChar(build.Default.GOARCH) 22 if err != nil { 23 fmt.Println(err) 24 os.Exit(1) 25 } 26 27 cmd := exec.Command("go", "tool", letter+"g", "-S", "sinit.go") 28 out, err := cmd.CombinedOutput() 29 if err != nil { 30 fmt.Println(string(out)) 31 fmt.Println(err) 32 os.Exit(1) 33 } 34 os.Remove("sinit." + letter) 35 36 if bytes.Contains(out, []byte("initdone")) { 37 fmt.Println("sinit generated an init function") 38 os.Exit(1) 39 } 40 }