2
0
mirror of synced 2025-02-23 06:48:15 +00:00
mobile/cmd/gomobile/build_test.go
David Crawshaw 405d6233b3 cmd/gomobile: parameterize tests on NumCPU
Builders only have p=4.

Change-Id: I3e5d57579d26cb26f4ce29817a7bbdd8c34ad2ae
Reviewed-on: https://go-review.googlesource.com/12742
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-07-28 13:18:05 +00:00

51 lines
1.3 KiB
Go

// Copyright 2015 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.
package main
import (
"bytes"
"os"
"path/filepath"
"testing"
"text/template"
)
func TestAndroidBuild(t *testing.T) {
buf := new(bytes.Buffer)
defer func() {
xout = os.Stderr
buildN = false
buildX = false
}()
xout = buf
buildN = true
buildX = true
buildO = "basic.apk"
buildTarget = "android"
gopath = filepath.SplitList(os.Getenv("GOPATH"))[0]
if goos == "windows" {
os.Setenv("HOMEDRIVE", "C:")
}
cmdBuild.flag.Parse([]string{"golang.org/x/mobile/example/basic"})
err := runBuild(cmdBuild)
if err != nil {
t.Log(buf.String())
t.Fatal(err)
}
diff, err := diffOutput(buf.String(), androidBuildTmpl)
if err != nil {
t.Fatalf("computing diff failed: %v", err)
}
if diff != "" {
t.Errorf("unexpected output:\n%s", diff)
}
}
var androidBuildTmpl = template.Must(template.New("output").Parse(`GOMOBILE={{.GOPATH}}/pkg/gomobile
WORK=$WORK
GOOS=android GOARCH=arm GOARM=7 CC=$GOMOBILE/android-{{.NDK}}/arm/bin/arm-linux-androideabi-gcc{{.EXE}} CXX=$GOMOBILE/android-{{.NDK}}/arm/bin/arm-linux-androideabi-g++{{.EXE}} CGO_ENABLED=1 go build -p={{.NumCPU}} -pkgdir=$GOMOBILE/pkg_android_arm -tags="" -x -buildmode=c-shared -o $WORK/libbasic.so golang.org/x/mobile/example/basic
`))