• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# This script runs tests for the Go toolchain on target devices.
4# It can be used for both ChromeOS and Android targets.
5#
6# Many of the test drivers that come from upstream do not support
7# cross-compiling and running the tests remotely. The patches in
8# the ./patch/ directory must be applied to the upstream sources
9# to add this support.
10#
11# Usage: test_go [-v] [-vv] [-full] <target>...
12#   -v: enable verbose test output from compiler tests.
13#   -v: enable verbose test output from standard library tests.
14#   -full: run all standard library tests (without the -short flag).
15
16verbose_run_test=""
17verbose_go_test=""
18testflags="-short"
19while [[ "$1" == -* ]]
20do
21	case "$1" in
22		-v) verbose_run_test="-v" ;;
23		-vv) verbose_go_test="-v" ;;
24		-full) testflags="-timeout=2h" ;;
25		*) echo "unrecognized flag: $1" ;;
26	esac
27	shift
28done
29
30go_local build -o runtest test/run.go
31runtest="${PWD}/runtest"
32
33function run_test()
34	{
35	GOOS="$(go_${target} env GOOS)" GOARCH="$(go_${target} env GOARCH)" ${runtest} -n=1 ${verbose_run_test} -show_skips -summary -target="${target}" "$@"
36	}
37
38function go_test()
39	{
40	go_${target} test -p=1 ${verbose_go_test} -exec="go_${target}_exec" ${testflags} "$@"
41	}
42
43function go_test_target()
44	{
45	go_local test -p=1 ${verbose_go_test} ${testflags} "$@" -target="${target}"
46	}
47
48for target in "$@"
49do
50	echo
51	echo "## ${target}"
52
53	echo
54	echo "# test"
55	(cd test && run_test)
56
57	echo
58	echo "# std"
59	go_test std
60
61	echo
62	echo "# GOMAXPROCS=2 -cpu=1,2,4 runtime"
63	GOMAXPROCS=2 go_test -cpu=1,2,4 runtime
64
65	echo
66	echo "# -cpu=10 sync"
67	go_test -cpu=10 sync
68
69	echo
70	echo "# runtime crypto/x509 -target=${target}"
71	go_test_target runtime crypto/x509
72
73	echo
74	echo "# misc/cgo/{stdio,life}"
75	run_test misc/cgo/{stdio,life}
76
77	echo
78	echo "# misc/cgo/{test,testtls,nocgo}"
79	GOTRACEBACK=2 go_test ./misc/cgo/{test,testtls,nocgo}
80
81	echo
82	echo "# misc/cgo/testcshared"
83	(cd misc/cgo/testcshared && target="${target}" ./test.bash)
84
85	echo
86	echo "# misc/cgo/testsigfwd"
87	(cd misc/cgo/testsigfwd && go_${target} run -exec="go_${target}_exec" main.go)
88done
89