• 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	push_goroot ${target}
53
54	echo
55	echo "# test"
56	(cd test && run_test)
57
58	echo
59	echo "# std"
60	go_test std
61
62	echo
63	echo "# GOMAXPROCS=2 -cpu=1,2,4 runtime"
64	GOMAXPROCS=2 go_test -cpu=1,2,4 runtime
65
66	echo
67	echo "# -cpu=10 sync"
68	go_test -cpu=10 sync
69
70	echo
71	echo "# runtime crypto/x509 -target=${target}"
72	go_test_target runtime crypto/x509
73
74	echo
75	echo "# misc/cgo/{stdio,life}"
76	run_test misc/cgo/{stdio,life}
77
78	echo
79	echo "# misc/cgo/{test,testtls,nocgo}"
80	GOTRACEBACK=2 go_test ./misc/cgo/{test,testtls,nocgo}
81done
82