mirror of
https://github.com/golang/go
synced 2024-11-26 00:57:56 -07:00
build: make nacl pass
Add nacl.bash, the NaCl version of all.bash. It's a separate script because it builds a variant of package syscall with a large zip file embedded in it, containing all the input files needed for tests. Disable various tests new since the last round, mostly the ones using os/exec. Fixes #7945. LGTM=dave R=golang-codereviews, remyoudompheng, dave, bradfitz CC=golang-codereviews https://golang.org/cl/100590044
This commit is contained in:
parent
f374dd30a0
commit
0c2a727477
220
misc/nacl/mkzip.go
Normal file
220
misc/nacl/mkzip.go
Normal file
@ -0,0 +1,220 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Mkzip creates a zip file from a 'proto' file describing the contents.
|
||||
//
|
||||
// The proto file is inspired by the Plan 9 mkfs prototype file format.
|
||||
// It describes a file tree, one directory per line, with leading tab
|
||||
// indentation marking the tree structure. Each line contains a leading
|
||||
// name field giving the name of the file to copy into the zip file,
|
||||
// and then a sequence of optional key=value attributes to control
|
||||
// the copy. The only known attribute is src=foo, meaning copy the
|
||||
// actual data for the file (or directory) from an alternate location.
|
||||
package main
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func usage() {
|
||||
fmt.Fprintf(os.Stderr, "usage: mkzip [-r root] src.proto out.zip\n")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
func sysfatal(format string, args ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, "mkzip: %s\n", fmt.Sprintf(format, args...))
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
var (
|
||||
root = flag.String("r", ".", "interpret source paths relative to this directory")
|
||||
gopackage = flag.String("p", "", "write Go source file in this package")
|
||||
)
|
||||
|
||||
type stack struct {
|
||||
name string
|
||||
src string
|
||||
depth int
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.SetFlags(0)
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
|
||||
args := flag.Args()
|
||||
if len(args) != 2 {
|
||||
usage()
|
||||
}
|
||||
|
||||
rf, err := os.Open(args[0])
|
||||
if err != nil {
|
||||
sysfatal("%v", err)
|
||||
}
|
||||
r := bufio.NewScanner(rf)
|
||||
|
||||
zf, err := os.Create(args[1])
|
||||
if err != nil {
|
||||
sysfatal("%v", err)
|
||||
}
|
||||
|
||||
var w io.Writer = zf
|
||||
if *gopackage != "" {
|
||||
fmt.Fprintf(zf, "package %s\n\nfunc init() {\n\tunzip(\"", *gopackage)
|
||||
gw := &goWriter{b: bufio.NewWriter(w)}
|
||||
defer func() {
|
||||
if err := gw.Close(); err != nil {
|
||||
sysfatal("finishing Go output: %v", err)
|
||||
}
|
||||
}()
|
||||
w = gw
|
||||
}
|
||||
z := zip.NewWriter(w)
|
||||
|
||||
lineno := 0
|
||||
|
||||
addfile := func(info os.FileInfo, dst string, src string) {
|
||||
zh, err := zip.FileInfoHeader(info)
|
||||
if err != nil {
|
||||
sysfatal("%s:%d: %s: %v", args[0], lineno, src, err)
|
||||
}
|
||||
zh.Name = dst
|
||||
zh.Method = zip.Deflate
|
||||
if info.IsDir() && !strings.HasSuffix(dst, "/") {
|
||||
zh.Name += "/"
|
||||
}
|
||||
w, err := z.CreateHeader(zh)
|
||||
if err != nil {
|
||||
sysfatal("%s:%d: %s: %v", args[0], lineno, src, err)
|
||||
}
|
||||
if info.IsDir() {
|
||||
return
|
||||
}
|
||||
r, err := os.Open(src)
|
||||
if err != nil {
|
||||
sysfatal("%s:%d: %s: %v", args[0], lineno, src, err)
|
||||
}
|
||||
defer r.Close()
|
||||
if _, err := io.Copy(w, r); err != nil {
|
||||
sysfatal("%s:%d: %s: %v", args[0], lineno, src, err)
|
||||
}
|
||||
}
|
||||
|
||||
var stk []stack
|
||||
|
||||
for r.Scan() {
|
||||
line := r.Text()
|
||||
lineno++
|
||||
s := strings.TrimLeft(line, "\t")
|
||||
prefix, line := line[:len(line)-len(s)], s
|
||||
if i := strings.Index(line, "#"); i >= 0 {
|
||||
line = line[:i]
|
||||
}
|
||||
f := strings.Fields(line)
|
||||
if len(f) == 0 {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(line, " ") {
|
||||
sysfatal("%s:%d: must use tabs for indentation", args[0], lineno)
|
||||
}
|
||||
depth := len(prefix)
|
||||
for len(stk) > 0 && depth <= stk[len(stk)-1].depth {
|
||||
stk = stk[:len(stk)-1]
|
||||
}
|
||||
parent := ""
|
||||
psrc := *root
|
||||
if len(stk) > 0 {
|
||||
parent = stk[len(stk)-1].name
|
||||
psrc = stk[len(stk)-1].src
|
||||
}
|
||||
if strings.Contains(f[0], "/") {
|
||||
sysfatal("%s:%d: destination name cannot contain slash", args[0], lineno)
|
||||
}
|
||||
name := path.Join(parent, f[0])
|
||||
src := filepath.Join(psrc, f[0])
|
||||
for _, attr := range f[1:] {
|
||||
i := strings.Index(attr, "=")
|
||||
if i < 0 {
|
||||
sysfatal("%s:%d: malformed attribute %q", args[0], lineno, attr)
|
||||
}
|
||||
key, val := attr[:i], attr[i+1:]
|
||||
switch key {
|
||||
case "src":
|
||||
src = val
|
||||
default:
|
||||
sysfatal("%s:%d: unknown attribute %q", args[0], lineno, attr)
|
||||
}
|
||||
}
|
||||
|
||||
stk = append(stk, stack{name: name, src: src, depth: depth})
|
||||
|
||||
if f[0] == "*" || f[0] == "+" {
|
||||
if f[0] == "*" {
|
||||
dir, err := ioutil.ReadDir(psrc)
|
||||
if err != nil {
|
||||
sysfatal("%s:%d: %v", args[0], lineno, err)
|
||||
}
|
||||
for _, d := range dir {
|
||||
addfile(d, path.Join(parent, d.Name()), filepath.Join(psrc, d.Name()))
|
||||
}
|
||||
} else {
|
||||
err := filepath.Walk(psrc, func(src string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if src == psrc {
|
||||
return nil
|
||||
}
|
||||
if psrc == "." {
|
||||
psrc = ""
|
||||
}
|
||||
name := path.Join(parent, filepath.ToSlash(src[len(psrc):]))
|
||||
addfile(info, name, src)
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
sysfatal("%s:%d: %v", args[0], lineno, err)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
fi, err := os.Stat(src)
|
||||
if err != nil {
|
||||
sysfatal("%s:%d: %v", args[0], lineno, err)
|
||||
}
|
||||
addfile(fi, name, src)
|
||||
}
|
||||
|
||||
if err := z.Close(); err != nil {
|
||||
sysfatal("finishing zip file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
type goWriter struct {
|
||||
b *bufio.Writer
|
||||
}
|
||||
|
||||
func (w *goWriter) Write(b []byte) (int, error) {
|
||||
for _, c := range b {
|
||||
fmt.Fprintf(w.b, "\\x%02x", c)
|
||||
}
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
func (w *goWriter) Close() error {
|
||||
fmt.Fprintf(w.b, "\")\n}\n")
|
||||
w.b.Flush()
|
||||
return nil
|
||||
}
|
0
misc/nacl/testdata/bin/placeholder
vendored
Normal file
0
misc/nacl/testdata/bin/placeholder
vendored
Normal file
0
misc/nacl/testdata/empty
vendored
Normal file
0
misc/nacl/testdata/empty
vendored
Normal file
8
misc/nacl/testdata/group
vendored
Normal file
8
misc/nacl/testdata/group
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
nobody:*:-2:
|
||||
nogroup:*:-1:
|
||||
wheel:*:0:root
|
||||
daemon:*:1:root
|
||||
kmem:*:2:root
|
||||
sys:*:3:root
|
||||
tty:*:4:root
|
||||
operator:*:5:root
|
1
misc/nacl/testdata/hosts
vendored
Normal file
1
misc/nacl/testdata/hosts
vendored
Normal file
@ -0,0 +1 @@
|
||||
127.0.0.1 localhost
|
1596
misc/nacl/testdata/mime.types
vendored
Normal file
1596
misc/nacl/testdata/mime.types
vendored
Normal file
File diff suppressed because it is too large
Load Diff
116
misc/nacl/testzip.proto
Normal file
116
misc/nacl/testzip.proto
Normal file
@ -0,0 +1,116 @@
|
||||
etc src=/etc
|
||||
mime.types src=../misc/nacl/testdata/mime.types
|
||||
resolv.conf src=../misc/nacl/testdata/empty
|
||||
group src=../misc/nacl/testdata/group
|
||||
passwd src=../misc/nacl/testdata/empty
|
||||
hosts src=../misc/nacl/testdata/hosts
|
||||
services
|
||||
usr src=../misc/nacl/testdata
|
||||
bin
|
||||
go src=..
|
||||
src
|
||||
cmd
|
||||
gofmt
|
||||
testdata
|
||||
+
|
||||
link
|
||||
testdata
|
||||
+
|
||||
pkg
|
||||
archive
|
||||
tar
|
||||
testdata
|
||||
+
|
||||
zip
|
||||
testdata
|
||||
+
|
||||
compress
|
||||
bzip2
|
||||
testdata
|
||||
+
|
||||
flate
|
||||
gzip
|
||||
testdata
|
||||
+
|
||||
lzw
|
||||
testdata
|
||||
+
|
||||
zlib
|
||||
crypto
|
||||
rsa
|
||||
testdata
|
||||
+
|
||||
tls
|
||||
testdata
|
||||
+
|
||||
debug
|
||||
dwarf
|
||||
testdata
|
||||
+
|
||||
elf
|
||||
testdata
|
||||
+
|
||||
macho
|
||||
testdata
|
||||
+
|
||||
pe
|
||||
testdata
|
||||
+
|
||||
plan9obj
|
||||
testdata
|
||||
+
|
||||
go
|
||||
build
|
||||
+
|
||||
doc
|
||||
testdata
|
||||
+
|
||||
format
|
||||
+
|
||||
parser
|
||||
+
|
||||
printer
|
||||
+
|
||||
image
|
||||
testdata
|
||||
+
|
||||
draw
|
||||
gif
|
||||
jpeg
|
||||
png
|
||||
testdata
|
||||
+
|
||||
io
|
||||
+
|
||||
mime
|
||||
testdata
|
||||
+
|
||||
multipart
|
||||
testdata
|
||||
+
|
||||
net
|
||||
http
|
||||
+
|
||||
testdata
|
||||
+
|
||||
os
|
||||
+
|
||||
path
|
||||
filepath
|
||||
+
|
||||
regexp
|
||||
testdata
|
||||
+
|
||||
strconv
|
||||
testdata
|
||||
+
|
||||
text
|
||||
template
|
||||
testdata
|
||||
+
|
||||
lib
|
||||
time
|
||||
zoneinfo.zip
|
||||
|
||||
test
|
||||
+
|
@ -9,7 +9,7 @@ if [ ! -f make.bash ]; then
|
||||
exit 1
|
||||
fi
|
||||
OLDPATH="$PATH"
|
||||
. ./make.bash --no-banner
|
||||
. ./make.bash "$@" --no-banner
|
||||
bash run.bash --no-rebuild
|
||||
PATH="$OLDPATH"
|
||||
$GOTOOLDIR/dist banner # print build info
|
||||
|
@ -92,6 +92,10 @@ func testAddr2Line(t *testing.T, exepath, addr string) {
|
||||
|
||||
// This is line 93. The test depends on that.
|
||||
func TestAddr2Line(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
syms := loadSyms(t)
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "TestAddr2Line")
|
||||
|
@ -55,6 +55,10 @@ func checkSymbols(t *testing.T, nmoutput []byte) {
|
||||
}
|
||||
|
||||
func TestNM(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "TestNM")
|
||||
if err != nil {
|
||||
t.Fatal("TempDir failed: ", err)
|
||||
|
@ -19,6 +19,10 @@ import (
|
||||
)
|
||||
|
||||
func loadSyms(t *testing.T) map[string]string {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
cmd := exec.Command("go", "tool", "nm", os.Args[0])
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
@ -40,6 +44,10 @@ func loadSyms(t *testing.T) map[string]string {
|
||||
}
|
||||
|
||||
func runObjDump(t *testing.T, exe, startaddr, endaddr string) (path, lineno string) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
cmd := exec.Command(exe, os.Args[0], startaddr, endaddr)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
@ -67,7 +75,7 @@ func runObjDump(t *testing.T, exe, startaddr, endaddr string) (path, lineno stri
|
||||
return f[0], f[1]
|
||||
}
|
||||
|
||||
func testObjDump(t *testing.T, exe, startaddr, endaddr string) {
|
||||
func testObjDump(t *testing.T, exe, startaddr, endaddr string, line int) {
|
||||
srcPath, srcLineNo := runObjDump(t, exe, startaddr, endaddr)
|
||||
fi1, err := os.Stat("objdump_test.go")
|
||||
if err != nil {
|
||||
@ -80,13 +88,13 @@ func testObjDump(t *testing.T, exe, startaddr, endaddr string) {
|
||||
if !os.SameFile(fi1, fi2) {
|
||||
t.Fatalf("objdump_test.go and %s are not same file", srcPath)
|
||||
}
|
||||
if srcLineNo != "89" {
|
||||
t.Fatalf("line number = %v; want 89", srcLineNo)
|
||||
if srcLineNo != fmt.Sprint(line) {
|
||||
t.Fatalf("line number = %v; want %d", srcLineNo, line)
|
||||
}
|
||||
}
|
||||
|
||||
// This is line 88. The test depends on that.
|
||||
func TestObjDump(t *testing.T) {
|
||||
_, _, line, _ := runtime.Caller(0)
|
||||
syms := loadSyms(t)
|
||||
|
||||
tmp, exe := buildObjdump(t)
|
||||
@ -98,11 +106,15 @@ func TestObjDump(t *testing.T) {
|
||||
t.Fatalf("invalid start address %v: %v", startaddr, err)
|
||||
}
|
||||
endaddr := fmt.Sprintf("%x", addr+10)
|
||||
testObjDump(t, exe, startaddr, endaddr)
|
||||
testObjDump(t, exe, "0x"+startaddr, "0x"+endaddr)
|
||||
testObjDump(t, exe, startaddr, endaddr, line-1)
|
||||
testObjDump(t, exe, "0x"+startaddr, "0x"+endaddr, line-1)
|
||||
}
|
||||
|
||||
func buildObjdump(t *testing.T) (tmp, exe string) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
tmp, err := ioutil.TempDir("", "TestObjDump")
|
||||
if err != nil {
|
||||
t.Fatal("TempDir failed: ", err)
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
@ -185,6 +186,10 @@ func TestExtract(t *testing.T) {
|
||||
|
||||
// Test that pack-created archives can be understood by the tools.
|
||||
func TestHello(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
dir := tmpDir(t)
|
||||
defer os.RemoveAll(dir)
|
||||
hello := filepath.Join(dir, "hello.go")
|
||||
@ -217,6 +222,10 @@ func TestHello(t *testing.T) {
|
||||
|
||||
// Test that pack works with very long lines in PKGDEF.
|
||||
func TestLargeDefs(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
dir := tmpDir(t)
|
||||
defer os.RemoveAll(dir)
|
||||
large := filepath.Join(dir, "large.go")
|
||||
|
@ -153,6 +153,7 @@ echo "# Building compilers and Go bootstrap tool for host, $GOHOSTOS/$GOHOSTARCH
|
||||
buildall="-a"
|
||||
if [ "$1" = "--no-clean" ]; then
|
||||
buildall=""
|
||||
shift
|
||||
fi
|
||||
./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap
|
||||
# Delay move of dist tool to now, because bootstrap may clear tool directory.
|
||||
|
50
src/nacltest.bash
Normal file
50
src/nacltest.bash
Normal file
@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2014 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
# For testing Native Client on builders or locally.
|
||||
# Builds a test file system and embeds it into package syscall
|
||||
# in every generated binary.
|
||||
#
|
||||
# Assumes that sel_ldr binaries are in $PATH; see ../misc/nacl/README.
|
||||
|
||||
set -e
|
||||
ulimit -c 0
|
||||
|
||||
# Check GOARCH.
|
||||
naclGOARCH=${GOARCH:-386}
|
||||
case "$naclGOARCH" in
|
||||
amd64p32)
|
||||
if ! which sel_ldr_x86_64 >/dev/null; then
|
||||
echo 'cannot find sel_ldr_x86_64' 1>&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
386)
|
||||
if ! which sel_ldr_x86_32 >/dev/null; then
|
||||
echo 'cannot find sel_ldr_x86_32' 1>&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo 'unsupported $GOARCH for nacl: '"$naclGOARCH" 1>&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
# Run host build to get toolchain for running zip generator.
|
||||
unset GOOS GOARCH
|
||||
if [ ! -f make.bash ]; then
|
||||
echo 'nacl.bash must be run from $GOROOT/src' 1>&2
|
||||
exit 1
|
||||
fi
|
||||
GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH ./make.bash
|
||||
|
||||
# Build zip file embedded in package syscall.
|
||||
gobin=${GOBIN:-$(pwd)/../bin}
|
||||
rm -f pkg/syscall/fstest_nacl.go
|
||||
GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH $gobin/go run ../misc/nacl/mkzip.go -p syscall -r .. ../misc/nacl/testzip.proto pkg/syscall/fstest_nacl.go
|
||||
|
||||
# Run standard build and tests.
|
||||
export PATH=$(pwd)/../misc/nacl:$PATH
|
||||
GOOS=nacl GOARCH=$naclGOARCH ./all.bash --no-clean
|
@ -22,6 +22,7 @@ import (
|
||||
"net"
|
||||
"os/exec"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@ -727,6 +728,10 @@ func TestParsePEMCRL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImports(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
if err := exec.Command("go", "run", "x509_test_import.go").Run(); err != nil {
|
||||
t.Errorf("failed to run x509_test_import.go: %s", err)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@ -23,6 +24,10 @@ import (
|
||||
// This test is a CGI host (testing host.go) that runs its own binary
|
||||
// as a child process testing the other half of CGI (child.go).
|
||||
func TestHostingOurselves(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
h := &Handler{
|
||||
Path: os.Args[0],
|
||||
Root: "/test.go",
|
||||
@ -87,6 +92,10 @@ func (w *limitWriter) Write(p []byte) (n int, err error) {
|
||||
// If there's an error copying the child's output to the parent, test
|
||||
// that we kill the child.
|
||||
func TestKillChildAfterCopyError(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
defer func() { testHookStartProcess = nil }()
|
||||
proc := make(chan *os.Process, 1)
|
||||
testHookStartProcess = func(p *os.Process) {
|
||||
@ -130,6 +139,10 @@ func TestKillChildAfterCopyError(t *testing.T) {
|
||||
// Test that a child handler writing only headers works.
|
||||
// golang.org/issue/7196
|
||||
func TestChildOnlyHeaders(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
h := &Handler{
|
||||
Path: os.Args[0],
|
||||
Root: "/test.go",
|
||||
|
@ -40,7 +40,7 @@ func packetConnTestData(t *testing.T, net string, i int) ([]byte, func()) {
|
||||
return b, nil
|
||||
case "unixgram":
|
||||
switch runtime.GOOS {
|
||||
case "plan9", "windows":
|
||||
case "nacl", "plan9", "windows":
|
||||
return nil, func() {
|
||||
t.Logf("skipping %q test on %q", net, runtime.GOOS)
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ func TestIPConnSpecificMethods(t *testing.T) {
|
||||
|
||||
func TestUnixListenerSpecificMethods(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "plan9", "windows":
|
||||
case "nacl", "plan9", "windows":
|
||||
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||
}
|
||||
|
||||
@ -278,7 +278,7 @@ func TestUnixListenerSpecificMethods(t *testing.T) {
|
||||
|
||||
func TestUnixConnSpecificMethods(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "plan9", "windows":
|
||||
case "nacl", "plan9", "windows":
|
||||
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
func skipServerTest(net, unixsotype, addr string, ipv6, ipv4map, linuxOnly bool) bool {
|
||||
switch runtime.GOOS {
|
||||
case "linux":
|
||||
case "plan9", "windows":
|
||||
case "nacl", "plan9", "windows":
|
||||
// "unix" sockets are not supported on Windows and Plan 9.
|
||||
if net == unixsotype {
|
||||
return true
|
||||
|
@ -120,6 +120,9 @@ func TestReadTimeout(t *testing.T) {
|
||||
t.Fatalf("Read: expected err %v, got %v", errClosing, err)
|
||||
}
|
||||
default:
|
||||
if err == io.EOF && runtime.GOOS == "nacl" { // close enough; golang.org/issue/8044
|
||||
break
|
||||
}
|
||||
if err != errClosing {
|
||||
t.Fatalf("Read: expected err %v, got %v", errClosing, err)
|
||||
}
|
||||
@ -708,7 +711,7 @@ func TestProlongTimeout(t *testing.T) {
|
||||
|
||||
func TestDeadlineRace(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "plan9":
|
||||
case "nacl", "plan9":
|
||||
t.Skipf("skipping test on %q", runtime.GOOS)
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !plan9,!windows
|
||||
// +build !nacl,!plan9,!windows
|
||||
|
||||
package net
|
||||
|
||||
|
@ -27,7 +27,10 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func helperCommand(s ...string) *exec.Cmd {
|
||||
func helperCommand(t *testing.T, s ...string) *exec.Cmd {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
cs := []string{"-test.run=TestHelperProcess", "--"}
|
||||
cs = append(cs, s...)
|
||||
cmd := exec.Command(os.Args[0], cs...)
|
||||
@ -36,7 +39,7 @@ func helperCommand(s ...string) *exec.Cmd {
|
||||
}
|
||||
|
||||
func TestEcho(t *testing.T) {
|
||||
bs, err := helperCommand("echo", "foo bar", "baz").Output()
|
||||
bs, err := helperCommand(t, "echo", "foo bar", "baz").Output()
|
||||
if err != nil {
|
||||
t.Errorf("echo: %v", err)
|
||||
}
|
||||
@ -75,7 +78,7 @@ func TestCommandRelativeName(t *testing.T) {
|
||||
func TestCatStdin(t *testing.T) {
|
||||
// Cat, testing stdin and stdout.
|
||||
input := "Input string\nLine 2"
|
||||
p := helperCommand("cat")
|
||||
p := helperCommand(t, "cat")
|
||||
p.Stdin = strings.NewReader(input)
|
||||
bs, err := p.Output()
|
||||
if err != nil {
|
||||
@ -89,7 +92,7 @@ func TestCatStdin(t *testing.T) {
|
||||
|
||||
func TestCatGoodAndBadFile(t *testing.T) {
|
||||
// Testing combined output and error values.
|
||||
bs, err := helperCommand("cat", "/bogus/file.foo", "exec_test.go").CombinedOutput()
|
||||
bs, err := helperCommand(t, "cat", "/bogus/file.foo", "exec_test.go").CombinedOutput()
|
||||
if _, ok := err.(*exec.ExitError); !ok {
|
||||
t.Errorf("expected *exec.ExitError from cat combined; got %T: %v", err, err)
|
||||
}
|
||||
@ -117,7 +120,7 @@ func TestNoExistBinary(t *testing.T) {
|
||||
|
||||
func TestExitStatus(t *testing.T) {
|
||||
// Test that exit values are returned correctly
|
||||
cmd := helperCommand("exit", "42")
|
||||
cmd := helperCommand(t, "exit", "42")
|
||||
err := cmd.Run()
|
||||
want := "exit status 42"
|
||||
switch runtime.GOOS {
|
||||
@ -140,7 +143,7 @@ func TestPipes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
// Cat, testing stdin and stdout.
|
||||
c := helperCommand("pipetest")
|
||||
c := helperCommand(t, "pipetest")
|
||||
stdin, err := c.StdinPipe()
|
||||
check("StdinPipe", err)
|
||||
stdout, err := c.StdoutPipe()
|
||||
@ -193,7 +196,7 @@ func TestStdinClose(t *testing.T) {
|
||||
t.Fatalf("%s: %v", what, err)
|
||||
}
|
||||
}
|
||||
cmd := helperCommand("stdinClose")
|
||||
cmd := helperCommand(t, "stdinClose")
|
||||
stdin, err := cmd.StdinPipe()
|
||||
check("StdinPipe", err)
|
||||
// Check that we can access methods of the underlying os.File.`
|
||||
@ -313,7 +316,7 @@ func TestExtraFilesFDShuffle(t *testing.T) {
|
||||
// Moving this test case around within the overall tests may
|
||||
// affect the FDs obtained and hence the checks to catch these cases.
|
||||
npipes := 2
|
||||
c := helperCommand("extraFilesAndPipes", strconv.Itoa(npipes+1))
|
||||
c := helperCommand(t, "extraFilesAndPipes", strconv.Itoa(npipes+1))
|
||||
rd, wr, _ := os.Pipe()
|
||||
defer rd.Close()
|
||||
if rd.Fd() != 3 {
|
||||
@ -440,7 +443,7 @@ func TestExtraFiles(t *testing.T) {
|
||||
t.Fatalf("Seek: %v", err)
|
||||
}
|
||||
|
||||
c := helperCommand("read3")
|
||||
c := helperCommand(t, "read3")
|
||||
var stdout, stderr bytes.Buffer
|
||||
c.Stdout = &stdout
|
||||
c.Stderr = &stderr
|
||||
@ -483,10 +486,10 @@ func TestExtraFilesRace(t *testing.T) {
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
la := listen()
|
||||
ca := helperCommand("describefiles")
|
||||
ca := helperCommand(t, "describefiles")
|
||||
ca.ExtraFiles = []*os.File{listenerFile(la)}
|
||||
lb := listen()
|
||||
cb := helperCommand("describefiles")
|
||||
cb := helperCommand(t, "describefiles")
|
||||
cb.ExtraFiles = []*os.File{listenerFile(lb)}
|
||||
ares := make(chan string)
|
||||
bres := make(chan string)
|
||||
|
@ -496,10 +496,10 @@ func TestHardLink(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSymLink(t *testing.T) {
|
||||
// Symlinks are not supported under windows or Plan 9.
|
||||
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
|
||||
return
|
||||
func TestSymlink(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "windows", "plan9", "nacl":
|
||||
t.Skipf("skipping on %s", runtime.GOOS)
|
||||
}
|
||||
from, to := "symlinktestfrom", "symlinktestto"
|
||||
Remove(from) // Just in case.
|
||||
@ -559,9 +559,9 @@ func TestSymLink(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLongSymlink(t *testing.T) {
|
||||
// Symlinks are not supported under windows or Plan 9.
|
||||
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
|
||||
return
|
||||
switch runtime.GOOS {
|
||||
case "windows", "plan9", "nacl":
|
||||
t.Skipf("skipping on %s", runtime.GOOS)
|
||||
}
|
||||
s := "0123456789abcdef"
|
||||
// Long, but not too long: a common limit is 255.
|
||||
@ -630,6 +630,10 @@ func exec(t *testing.T, dir, cmd string, args []string, expect string) {
|
||||
}
|
||||
|
||||
func TestStartProcess(t *testing.T) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
var dir, cmd string
|
||||
var args []string
|
||||
if runtime.GOOS == "windows" {
|
||||
@ -703,8 +707,10 @@ func TestFTruncate(t *testing.T) {
|
||||
checkSize(t, f, 1024)
|
||||
f.Truncate(0)
|
||||
checkSize(t, f, 0)
|
||||
f.Write([]byte("surprise!"))
|
||||
checkSize(t, f, 13+9) // wrote at offset past where hello, world was.
|
||||
_, err := f.Write([]byte("surprise!"))
|
||||
if err == nil {
|
||||
checkSize(t, f, 13+9) // wrote at offset past where hello, world was.
|
||||
}
|
||||
}
|
||||
|
||||
func TestTruncate(t *testing.T) {
|
||||
@ -721,8 +727,10 @@ func TestTruncate(t *testing.T) {
|
||||
checkSize(t, f, 1024)
|
||||
Truncate(f.Name(), 0)
|
||||
checkSize(t, f, 0)
|
||||
f.Write([]byte("surprise!"))
|
||||
checkSize(t, f, 13+9) // wrote at offset past where hello, world was.
|
||||
_, err := f.Write([]byte("surprise!"))
|
||||
if err == nil {
|
||||
checkSize(t, f, 13+9) // wrote at offset past where hello, world was.
|
||||
}
|
||||
}
|
||||
|
||||
// Use TempDir() to make sure we're on a local file system,
|
||||
@ -757,13 +765,13 @@ func TestChtimes(t *testing.T) {
|
||||
}
|
||||
postStat := st
|
||||
|
||||
/* Plan 9:
|
||||
/* Plan 9, NaCl:
|
||||
Mtime is the time of the last change of content. Similarly, atime is set whenever the
|
||||
contents are accessed; also, it is set whenever mtime is set.
|
||||
*/
|
||||
pat := Atime(postStat)
|
||||
pmt := postStat.ModTime()
|
||||
if !pat.Before(at) && runtime.GOOS != "plan9" {
|
||||
if !pat.Before(at) && runtime.GOOS != "plan9" && runtime.GOOS != "nacl" {
|
||||
t.Errorf("AccessTime didn't go backwards; was=%d, after=%d", at, pat)
|
||||
}
|
||||
|
||||
@ -965,8 +973,9 @@ func run(t *testing.T, cmd []string) string {
|
||||
func TestHostname(t *testing.T) {
|
||||
// There is no other way to fetch hostname on windows, but via winapi.
|
||||
// On Plan 9 it is can be taken from #c/sysname as Hostname() does.
|
||||
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
|
||||
return
|
||||
switch runtime.GOOS {
|
||||
case "windows", "plan9", "nacl":
|
||||
t.Skipf("skipping on %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
// Check internal Hostname() against the output of /bin/hostname.
|
||||
@ -1225,6 +1234,10 @@ func TestReadAtEOF(t *testing.T) {
|
||||
}
|
||||
|
||||
func testKillProcess(t *testing.T, processKiller func(p *Process)) {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
dir, err := ioutil.TempDir("", "go-build")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create temp directory: %v", err)
|
||||
|
@ -167,8 +167,9 @@ func TestRemoveAll(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMkdirAllWithSymlink(t *testing.T) {
|
||||
if runtime.GOOS == "windows" || runtime.GOOS == "plan9" {
|
||||
t.Skip("Skipping test: symlinks don't exist under Windows/Plan 9")
|
||||
switch runtime.GOOS {
|
||||
case "nacl", "plan9", "windows":
|
||||
t.Skipf("skipping on %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "TestMkdirAllWithSymlink-")
|
||||
|
@ -167,11 +167,10 @@ var globSymlinkTests = []struct {
|
||||
|
||||
func TestGlobSymlink(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "windows", "plan9":
|
||||
// The tests below are Unix specific so we skip plan9, which does not
|
||||
// support symlinks, and windows.
|
||||
t.Skipf("skipping test on %v", runtime.GOOS)
|
||||
case "nacl", "plan9", "windows":
|
||||
t.Skipf("skipping on %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "globsymlink")
|
||||
if err != nil {
|
||||
t.Fatal("creating temp dir:", err)
|
||||
|
@ -691,8 +691,9 @@ func simpleJoin(dir, path string) string {
|
||||
}
|
||||
|
||||
func TestEvalSymlinks(t *testing.T) {
|
||||
if runtime.GOOS == "plan9" {
|
||||
t.Skip("Skipping test: symlinks don't exist under Plan 9")
|
||||
switch runtime.GOOS {
|
||||
case "nacl", "plan9":
|
||||
t.Skipf("skipping on %s", runtime.GOOS)
|
||||
}
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "evalsymlink")
|
||||
|
@ -302,7 +302,7 @@ TEXT reflect·call(SB), NOSPLIT, $0-20
|
||||
JMP AX
|
||||
|
||||
#define CALLFN(NAME,MAXSIZE) \
|
||||
TEXT runtime·NAME(SB), WRAPPER, $MAXSIZE-12; \
|
||||
TEXT runtime·NAME(SB), WRAPPER, $MAXSIZE-16; \
|
||||
/* copy arguments to stack */ \
|
||||
MOVL argptr+4(FP), SI; \
|
||||
MOVL argsize+8(FP), CX; \
|
||||
@ -315,7 +315,11 @@ TEXT runtime·NAME(SB), WRAPPER, $MAXSIZE-12; \
|
||||
/* copy return values back */ \
|
||||
MOVL argptr+4(FP), DI; \
|
||||
MOVL argsize+8(FP), CX; \
|
||||
MOVL retoffset+12(FP), BX; \
|
||||
MOVL SP, SI; \
|
||||
ADDL BX, DI; \
|
||||
ADDL BX, SI; \
|
||||
SUBL BX, CX; \
|
||||
REP;MOVSB; \
|
||||
RET
|
||||
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"text/template"
|
||||
@ -31,6 +32,10 @@ func testEnv(cmd *exec.Cmd) *exec.Cmd {
|
||||
}
|
||||
|
||||
func executeTest(t *testing.T, templ string, data interface{}) string {
|
||||
if runtime.GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
checkStaleRuntime(t)
|
||||
|
||||
st := template.Must(template.New("crashSource").Parse(templ))
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !nacl
|
||||
|
||||
package pprof_test
|
||||
|
||||
import (
|
||||
|
@ -95,6 +95,10 @@ func BenchmarkDeferMany(b *testing.B) {
|
||||
// The value reported will include the padding between runtime.gogo and the
|
||||
// next function in memory. That's fine.
|
||||
func TestRuntimeGogoBytes(t *testing.T) {
|
||||
if GOOS == "nacl" {
|
||||
t.Skip("skipping on nacl")
|
||||
}
|
||||
|
||||
dir, err := ioutil.TempDir("", "go-build")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temp directory: %v", err)
|
||||
@ -183,6 +187,10 @@ func TestSetPanicOnFault(t *testing.T) {
|
||||
}
|
||||
|
||||
func testSetPanicOnFault(t *testing.T, addr uintptr) {
|
||||
if GOOS == "nacl" {
|
||||
t.Skip("nacl doesn't seem to fault on high addresses")
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err == nil {
|
||||
t.Fatalf("did not find error in recover")
|
||||
|
21
src/run.bash
21
src/run.bash
@ -34,7 +34,7 @@ fi
|
||||
|
||||
# allow all.bash to avoid double-build of everything
|
||||
rebuild=true
|
||||
if [ "$1" = "--no-rebuild" ]; then
|
||||
if [ "$1" == "--no-rebuild" ]; then
|
||||
shift
|
||||
else
|
||||
echo '# Building packages and commands.'
|
||||
@ -178,15 +178,18 @@ go run main.go || exit 1
|
||||
./test.bash || exit 1
|
||||
) || exit $?
|
||||
|
||||
[ "$GOOS" == nacl ] ||
|
||||
(xcd ../doc/progs
|
||||
time ./run || exit 1
|
||||
) || exit $?
|
||||
|
||||
[ "$GOOS" == nacl ] ||
|
||||
[ "$GOARCH" == arm ] || # uses network, fails under QEMU
|
||||
(xcd ../doc/articles/wiki
|
||||
./test.bash || exit 1
|
||||
) || exit $?
|
||||
|
||||
[ "$GOOS" == nacl ] ||
|
||||
(xcd ../doc/codewalk
|
||||
time ./run || exit 1
|
||||
) || exit $?
|
||||
@ -196,6 +199,7 @@ echo '#' ../misc/goplay
|
||||
go build ../misc/goplay
|
||||
rm -f goplay
|
||||
|
||||
[ "$GOOS" == nacl ] ||
|
||||
[ "$GOARCH" == arm ] ||
|
||||
(xcd ../test/bench/shootout
|
||||
time ./timing.sh -test || exit 1
|
||||
@ -210,12 +214,17 @@ go test ../test/bench/go1 || exit 1
|
||||
|
||||
(xcd ../test
|
||||
unset GOMAXPROCS
|
||||
time go run run.go || exit 1
|
||||
GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH go build -o runtest run.go || exit 1
|
||||
time ./runtest || exit 1
|
||||
rm -f runtest
|
||||
) || exit $?
|
||||
|
||||
[ "$GOOS" == nacl ] ||
|
||||
(
|
||||
echo
|
||||
echo '# Checking API compatibility.'
|
||||
time go run $GOROOT/src/cmd/api/run.go || exit 1
|
||||
) || exit $?
|
||||
|
||||
echo
|
||||
echo '# Checking API compatibility.'
|
||||
time go run $GOROOT/src/cmd/api/run.go
|
||||
|
||||
echo
|
||||
echo ALL TESTS PASSED
|
||||
|
@ -1,5 +1,7 @@
|
||||
// run
|
||||
|
||||
// +build !nacl
|
||||
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
@ -36,7 +38,7 @@ func main() {
|
||||
}
|
||||
|
||||
runtime.ReadMemStats(memstats)
|
||||
obj := memstats.HeapObjects - st.HeapObjects
|
||||
obj := int64(memstats.HeapObjects - st.HeapObjects)
|
||||
if obj > N/5 {
|
||||
fmt.Println("too many objects left:", obj)
|
||||
os.Exit(1)
|
||||
|
@ -1,5 +1,7 @@
|
||||
// run
|
||||
|
||||
// +build !nacl
|
||||
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
@ -273,7 +275,6 @@ TestCases:
|
||||
|
||||
ioutil.WriteFile(filepath.Join(dir, "asm.s"), buf.Bytes(), 0666)
|
||||
|
||||
|
||||
cmd := exec.Command("go", "build")
|
||||
cmd.Dir = dir
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
Loading…
Reference in New Issue
Block a user