]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo: re-enable some tests
authorRuss Cox <rsc@golang.org>
Wed, 7 Mar 2012 04:27:30 +0000 (23:27 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 7 Mar 2012 04:27:30 +0000 (23:27 -0500)
The testso directory still needs to be enabled.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5731048

20 files changed:
misc/cgo/gmp/Makefile [deleted file]
misc/cgo/gmp/fib.go
misc/cgo/gmp/pi.go
misc/cgo/life/Makefile [deleted file]
misc/cgo/life/main.go
misc/cgo/life/test.bash
misc/cgo/stdio/Makefile [deleted file]
misc/cgo/stdio/chain.go
misc/cgo/stdio/fib.go
misc/cgo/stdio/file.go
misc/cgo/stdio/hello.go
misc/cgo/stdio/test.bash
misc/cgo/test/basic.go
misc/cgo/test/callback.go
misc/cgo/test/callback_c.c
misc/cgo/test/issue1328.go
misc/cgo/test/issue1560.go
src/cmd/dist/build.c
src/pkg/go/build/build.go
src/run.bash

diff --git a/misc/cgo/gmp/Makefile b/misc/cgo/gmp/Makefile
deleted file mode 100644 (file)
index d9390c1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2009 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.
-
-include ../../../src/Make.inc
-
-TARG=gmp
-
-# Can have plain GOFILES too, but this example doesn't.
-
-CGOFILES=\
-       gmp.go
-
-CGO_LDFLAGS=-lgmp
-
-# To add flags necessary for locating the library or its include files,
-# set CGO_CFLAGS or CGO_LDFLAGS.  For example, to use an
-# alternate installation of the library:
-#      CGO_CFLAGS=-I/home/rsc/gmp32/include
-#      CGO_LDFLAGS+=-L/home/rsc/gmp32/lib
-# Note the += on the second line.
-
-CLEANFILES+=pi fib
-
-include ../../../src/Make.pkg
-
-# Simple test programs
-
-# Computes 1000 digits of pi; single-threaded.
-pi: install pi.go
-       $(GC) $(GCFLAGS) $(GCIMPORTS) pi.go
-       $(LD) -o $@ pi.$O
-
-# Computes 200 Fibonacci numbers; multi-threaded.
-fib: install fib.go
-       $(GC) $(GCFLAGS) $(GCIMPORTS) fib.go
-       $(LD) -o $@ fib.$O
-
index 3eda39e178439f0bece684159700ef3a34959a93..18434beaf35871d163a697c0f734dac6d5961d2a 100644 (file)
@@ -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 ignore
+
 // Compute Fibonacci numbers with two goroutines
 // that pass integers back and forth.  No actual
 // concurrency, just threads and synchronization
@@ -10,7 +12,7 @@
 package main
 
 import (
-       big "gmp"
+       big "."
        "runtime"
 )
 
index 3e40624cfab0b6340e88b284ed7bc132d3032f14..019861e592f296305aaab86ade813002cc6981a0 100644 (file)
@@ -1,3 +1,5 @@
+// +build ignore
+
 /*
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
@@ -38,8 +40,8 @@ POSSIBILITY OF SUCH DAMAGE.
 package main
 
 import (
+       big "."
        "fmt"
-       big "gmp"
        "runtime"
 )
 
diff --git a/misc/cgo/life/Makefile b/misc/cgo/life/Makefile
deleted file mode 100644 (file)
index 1568a67..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright 2010 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.
-
-include ../../../src/Make.inc
-
-TARG=life
-
-CGOFILES=\
-       life.go\
-
-CGO_OFILES=\
-       c-life.o\
-
-ifeq ($(GOOS),windows)
-ifeq ($(GOARCH),amd64)
-CGO_OFILES+=\
-       lib64_libmingwex_a-wassert.o\
-       lib64_libmingw32_a-mingw_helpers.o\
-
-lib64_libmingwex_a-wassert.o:
-       ar -x /mingw/x86_64-w64-mingw32/lib/libmingwex.a lib64_libmingwex_a-wassert.o
-
-lib64_libmingw32_a-mingw_helpers.o:
-       ar -x /mingw/x86_64-w64-mingw32/lib/libmingw32.a  lib64_libmingw32_a-mingw_helpers.o
-endif
-endif
-
-CLEANFILES+=life
-
-include ../../../src/Make.pkg
-
-life: install main.go
-       $(GC) $(GCFLAGS) $(GCIMPORTS) main.go
-       $(LD) -o $@ main.$O
index 9cfed434be0f024238ef28113230530620996170..47ae0e18c53f0ba143857b16c174bc32fbf56bca 100644 (file)
@@ -2,14 +2,16 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build ignore
+
 // Run the game of life in C using Go for parallelization.
 
 package main
 
 import (
+       "."
        "flag"
        "fmt"
-       "life"
 )
 
 const MAXDIM = 100
index 5c5fba1a9762d3b200c0679725e752a2245ca53a..bb483522c168d6eb0717fa8e56b526edcb22e3e8 100755 (executable)
@@ -4,8 +4,11 @@
 # license that can be found in the LICENSE file.
 
 set -e
-gomake life
+go build -o life main.go
+
 echo '*' life >run.out
 ./life >>run.out
 diff run.out golden.out
-gomake clean
+
+rm -f life
+
diff --git a/misc/cgo/stdio/Makefile b/misc/cgo/stdio/Makefile
deleted file mode 100644 (file)
index 586132b..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2009 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.
-
-include ../../../src/Make.inc
-
-TARG=stdio
-CGOFILES=\
-       file.go\
-
-CLEANFILES+=hello fib chain run.out
-
-include ../../../src/Make.pkg
-
-%: install %.go
-       $(GC) $(GCFLAGS) $(GCIMPORTS) $*.go
-       $(LD) -o $@ $*.$O
index c188b2dd92c4684792f3e7e4fa4ebf30431c8d49..1cf0b1fe5f4c26e6e6242b8f8cc08d64dee1c2ce 100644 (file)
@@ -2,13 +2,15 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build ignore
+
 // Pass numbers along a chain of threads.
 
 package main
 
 import (
+       "../stdio"
        "runtime"
-       "stdio"
        "strconv"
 )
 
index 431d9cefee7c7df1e39faf0ed890d9f6d5acc011..6d3ccfd5275c0fb9583b3b80c99d73a76a35e63e 100644 (file)
@@ -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 ignore
+
 // Compute Fibonacci numbers with two goroutines
 // that pass integers back and forth.  No actual
 // concurrency, just threads and synchronization
@@ -10,8 +12,8 @@
 package main
 
 import (
+       "../stdio"
        "runtime"
-       "stdio"
        "strconv"
 )
 
index ab1e88436c94901241d190e8cd43047a1677a301..6e7d479ad98f18345798da6ee4c9fcaf24aa48d8 100644 (file)
@@ -28,7 +28,7 @@ var Stderr = (*File)(C.stderr)
 
 // Test reference to library symbol.
 // Stdout and stderr are too special to be a reliable test.
-var myerr = C.sys_errlist
+//var  = C.environ
 
 func (f *File) WriteString(s string) {
        p := C.CString(s)
index 58fc6d574b366620b2bda9ad91c5e02f70aac97d..4ab3c7447f335e303c2b673007c5e353ac850c8a 100644 (file)
@@ -2,9 +2,11 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build ignore
+
 package main
 
-import "stdio"
+import "../stdio"
 
 func main() {
        stdio.Stdout.WriteString(stdio.Greeting + "\n")
index 82e3f7b45bf6ece426723d9904ce7fcd7d52441b..21829fa31ff8f68798637ee016f9d288df441b29 100755 (executable)
@@ -4,7 +4,10 @@
 # license that can be found in the LICENSE file.
 
 set -e
-gomake hello fib chain
+go build hello.go
+go build fib.go
+go build chain.go
+
 echo '*' hello >run.out
 ./hello >>run.out
 echo '*' fib >>run.out
@@ -12,4 +15,6 @@ echo '*' fib >>run.out
 echo '*' chain >>run.out
 ./chain >>run.out
 diff run.out golden.out
-gomake clean
+
+rm -f hello fib chain
+
index cd6d88168630a212c8ad2e1c35c4a9af53c01959..70ec5e43ace398aefd9cf9c923e3bd17adb60702 100644 (file)
@@ -55,7 +55,7 @@ int add(int x, int y) {
 */
 import "C"
 import (
-       "os"
+       "syscall"
        "testing"
        "unsafe"
 )
@@ -110,7 +110,7 @@ func testErrno(t *testing.T) {
                C.fclose(f)
                t.Fatalf("C.fopen: should fail")
        }
-       if err != os.ENOENT {
+       if err != syscall.ENOENT {
                t.Fatalf("C.fopen: unexpected error: %v", err)
        }
 }
index ef852561b7de914d5a7aa3a5d52c1e190057ca42..e6a1462b3e7fdbb01d24765aebcfdaf8f778a95c 100644 (file)
@@ -6,14 +6,12 @@ package cgotest
 
 /*
 void callback(void *f);
-void callGoFoo(void) {
-       extern void goFoo(void);
-       goFoo();
-}
+void callGoFoo(void);
 */
 import "C"
 
 import (
+       "./backdoor"
        "runtime"
        "testing"
        "unsafe"
@@ -43,7 +41,7 @@ func testCallbackGC(t *testing.T) {
        nestedCall(runtime.GC)
 }
 
-func lockedOSThread() bool // in runtime.c
+var lockedOSThread = backdoor.LockedOSThread
 
 func testCallbackPanic(t *testing.T) {
        // Make sure panic during callback unwinds properly.
index c296d70e0577d6639da359b956ecf22ea839b175..47f07301bfebaa872e783c9fd18c88d261741c02 100644 (file)
@@ -15,3 +15,23 @@ callback(void *f)
        goCallback(f);
         data[sizeof(data)-1] = 0;
 }
+
+void
+callGoFoo(void)
+{
+       extern void goFoo(void);
+       goFoo();
+}
+
+void
+IntoC(void)
+{
+       BackIntoGo();
+}
+
+void
+twoSleep(int n)
+{
+       BackgroundSleep(n);
+       sleep(n);
+}
index e01207dd9b0472966dea1232df46b7aa5d10003d..e1796d6f723751ef3b3c7d71ebff69ae0755102f 100644 (file)
@@ -7,7 +7,7 @@ package cgotest
 import "testing"
 
 // extern void BackIntoGo(void);
-// void IntoC() { BackIntoGo(); }
+// void IntoC(void);
 import "C"
 
 //export BackIntoGo
index 833b14ae62dcd00c4a7e7a41792d8e169ad72446..3faa966e708c314eec2b26ba3d1eff454571824a 100644 (file)
@@ -10,10 +10,7 @@ package cgotest
 unsigned int sleep(unsigned int seconds);
 
 extern void BackgroundSleep(int);
-void twoSleep(int n) {
-       BackgroundSleep(n);
-       sleep(n);
-}
+void twoSleep(int);
 */
 import "C"
 
index acd7347aa89753f743c79173e20d080a4585e56d..6bcc0f5327142c0b60323e50e8d264d1ab4b8f6b 100644 (file)
@@ -52,6 +52,19 @@ static char *okgoos[] = {
        "windows",
 };
 
+// The known cgo-enabled combinations.
+// This list is also known to ../../pkg/go/build/build.go.
+static char *okcgo[] = {
+       "darwin/386",
+       "darwin/amd64",
+       "linux/386",
+       "linux/amd64",
+       "freebsd/386",
+       "freebsd/amd64",
+       "windows/386",
+       "windows/amd64",
+};
+
 static void rmworkdir(void);
 
 // find reports the first index of p in l[0:n], or else -1.
@@ -1308,6 +1321,11 @@ cmdenv(int argc, char **argv)
        xprintf(format, "GOTOOLDIR", tooldir);
        xprintf(format, "GOCHAR", gochar);
 
+       if(find(bprintf(&b, "%s/%s", goos, goarch), okcgo, nelem(okcgo)))
+               xprintf(format, "CGO_ENABLED", "1");
+       else
+               xprintf(format, "CGO_ENABLED", "0");
+
        if(pflag) {
                sep = ":";
                if(streq(gohostos, "windows"))
index d986f8039fe480c500eee69e52a97d9a59ae28eb..7f7bd185479997e0ff41489eb62888374924e4d1 100644 (file)
@@ -210,6 +210,7 @@ func (ctxt *Context) SrcDirs() []string {
 // if set, or else the compiled code's GOARCH, GOOS, and GOROOT.
 var Default Context = defaultContext()
 
+// This list is also known to ../../../cmd/dist/build.c.
 var cgoEnabled = map[string]bool{
        "darwin/386":    true,
        "darwin/amd64":  true,
index 7b1854865ef34102060687d80e8808fd567e4c02..b5ffaa9974d9b2584cc8702c2e0d4c76688b1309 100755 (executable)
@@ -35,32 +35,26 @@ go test sync -short -timeout=120s -cpu=10
 
 xcd() {
        echo
-       echo --- cd $1
+       echo '#' $1
        builtin cd "$GOROOT"/src/$1
 }
 
 BROKEN=true
 
-$BROKEN ||
 [ "$CGO_ENABLED" != 1 ] ||
 [ "$GOHOSTOS" == windows ] ||
 (xcd ../misc/cgo/stdio
-"$GOMAKE" clean
 ./test.bash
 ) || exit $?
 
-$BROKEN ||
 [ "$CGO_ENABLED" != 1 ] ||
 (xcd ../misc/cgo/life
-"$GOMAKE" clean
 ./test.bash
 ) || exit $?
 
-$BROKEN ||
 [ "$CGO_ENABLED" != 1 ] ||
 (xcd ../misc/cgo/test
-"$GOMAKE" clean
-gotest
+go test
 ) || exit $?
 
 $BROKEN ||