1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:50:05 -07:00

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

Change-Id: I4278abca9d2a8f25149fa8935a93d32e7d04a43a
Reviewed-on: https://go-review.googlesource.com/9050
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
David Crawshaw 2015-04-17 16:42:16 -04:00
parent 4d01922e46
commit c5befcf0a7
3 changed files with 19 additions and 3 deletions

View File

@ -8,6 +8,7 @@
extern signed char DidInitRun();
extern signed char DidMainRun();
extern int32_t FromPkg();
extern void CheckArgs();
int main(void) {
int32_t res;
@ -28,5 +29,7 @@ int main(void) {
return 2;
}
CheckArgs();
return 0;
}

View File

@ -5,9 +5,13 @@
package main
import (
_ "p"
"fmt"
"os"
"reflect"
"syscall"
"time"
_ "p"
)
import "C"
@ -40,3 +44,12 @@ func DidInitRun() bool {
//export DidMainRun
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)
}
}

View File

@ -22,10 +22,10 @@ fi
GOPATH=$(pwd) go build -buildmode=c-archive src/libgo/libgo.go
$(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a
$bin
$bin arg1 arg2
rm libgo.a testp
GOPATH=$(pwd) go build -buildmode=c-archive -o libgo.a libgo
$(go env CC) $(go env GOGCCFLAGS) $ccargs -o testp main.c libgo.a
$bin
$bin arg1 arg2
rm libgo.a testp