Commit c5befcf0 authored by David Crawshaw's avatar David Crawshaw

misc/cgo/testcarchive: check that os.Args is set

Change-Id: I4278abca9d2a8f25149fa8935a93d32e7d04a43a
Reviewed-on: https://go-review.googlesource.com/9050Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 4d01922e
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
extern signed char DidInitRun(); extern signed char DidInitRun();
extern signed char DidMainRun(); extern signed char DidMainRun();
extern int32_t FromPkg(); extern int32_t FromPkg();
extern void CheckArgs();
int main(void) { int main(void) {
int32_t res; int32_t res;
...@@ -28,5 +29,7 @@ int main(void) { ...@@ -28,5 +29,7 @@ int main(void) {
return 2; return 2;
} }
CheckArgs();
return 0; return 0;
} }
...@@ -5,9 +5,13 @@ ...@@ -5,9 +5,13 @@
package main package main
import ( import (
_ "p" "fmt"
"os"
"reflect"
"syscall" "syscall"
"time" "time"
_ "p"
) )
import "C" import "C"
...@@ -40,3 +44,12 @@ func DidInitRun() bool { ...@@ -40,3 +44,12 @@ func DidInitRun() bool {
//export DidMainRun //export DidMainRun
func DidMainRun() bool { return ranMain } func DidMainRun() bool { return ranMain }
//export CheckArgs
func CheckArgs() {
want := []string{"./testp", "arg1", "arg2"}
if !reflect.DeepEqual(want, os.Args) {
fmt.Printf("CheckArgs: want %v, got: %v\n", want, os.Args)
os.Exit(2)
}
}
...@@ -22,10 +22,10 @@ fi ...@@ -22,10 +22,10 @@ fi
GOPATH=$(pwd) go build -buildmode=c-archive src/libgo/libgo.go GOPATH=$(pwd) go build -buildmode=c-archive src/libgo/libgo.go
$(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a $(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a
$bin $bin arg1 arg2
rm libgo.a testp rm libgo.a testp
GOPATH=$(pwd) go build -buildmode=c-archive -o libgo.a libgo GOPATH=$(pwd) go build -buildmode=c-archive -o libgo.a libgo
$(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a $(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a
$bin $bin arg1 arg2
rm libgo.a testp rm libgo.a testp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment