Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2014 The Go Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style |
| 4 | # license that can be found in the LICENSE file. |
| 5 | |
| 6 | # For testing Native Client on builders or locally. |
| 7 | # Builds a test file system and embeds it into package syscall |
| 8 | # in every generated binary. |
| 9 | # |
Shenghou Ma | 3ad9df0 | 2014-06-10 20:20:49 -0400 | [diff] [blame] | 10 | # Assumes that sel_ldr binaries and go_nacl_$GOARCH_exec scripts are in $PATH; |
| 11 | # see ../misc/nacl/README. |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 12 | |
| 13 | set -e |
| 14 | ulimit -c 0 |
| 15 | |
Shenghou Ma | 99e2a56 | 2014-07-10 15:15:41 -0400 | [diff] [blame] | 16 | # guess GOARCH if not set |
| 17 | naclGOARCH=$GOARCH |
| 18 | if [ -z "$naclGOARCH" ]; then |
| 19 | case "$(uname -m)" in |
| 20 | x86_64) |
| 21 | naclGOARCH=amd64p32 |
| 22 | ;; |
| 23 | armv7l) # NativeClient on ARM only supports ARMv7A. |
| 24 | naclGOARCH=arm |
| 25 | ;; |
| 26 | i?86) |
| 27 | naclGOARCH=386 |
| 28 | ;; |
| 29 | esac |
| 30 | fi |
| 31 | |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 32 | # Check GOARCH. |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 33 | case "$naclGOARCH" in |
| 34 | amd64p32) |
| 35 | if ! which sel_ldr_x86_64 >/dev/null; then |
| 36 | echo 'cannot find sel_ldr_x86_64' 1>&2 |
| 37 | exit 1 |
| 38 | fi |
| 39 | ;; |
| 40 | 386) |
| 41 | if ! which sel_ldr_x86_32 >/dev/null; then |
| 42 | echo 'cannot find sel_ldr_x86_32' 1>&2 |
| 43 | exit 1 |
| 44 | fi |
| 45 | ;; |
Shenghou Ma | 99e2a56 | 2014-07-10 15:15:41 -0400 | [diff] [blame] | 46 | arm) |
| 47 | if ! which sel_ldr_arm >/dev/null; then |
| 48 | echo 'cannot find sel_ldr_arm' 1>&2 |
| 49 | exit 1 |
| 50 | fi |
| 51 | ;; |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 52 | *) |
| 53 | echo 'unsupported $GOARCH for nacl: '"$naclGOARCH" 1>&2 |
| 54 | exit 1 |
| 55 | esac |
| 56 | |
Shenghou Ma | 3ad9df0 | 2014-06-10 20:20:49 -0400 | [diff] [blame] | 57 | if ! which go_nacl_${naclGOARCH}_exec >/dev/null; then |
| 58 | echo "cannot find go_nacl_${naclGOARCH}_exec, see ../misc/nacl/README." 1>&2 |
| 59 | exit 1 |
| 60 | fi |
| 61 | |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 62 | unset GOOS GOARCH |
| 63 | if [ ! -f make.bash ]; then |
Dave Cheney | e6fbce3 | 2015-02-06 11:44:09 +1100 | [diff] [blame] | 64 | echo 'nacltest.bash must be run from $GOROOT/src' 1>&2 |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 65 | exit 1 |
| 66 | fi |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 67 | |
Shenghou Ma | 54d0b5a | 2014-07-10 15:36:48 -0400 | [diff] [blame] | 68 | # the builder might have set GOROOT_FINAL. |
| 69 | export GOROOT=$(pwd)/.. |
| 70 | |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 71 | # Build zip file embedded in package syscall. |
Shenghou Ma | 16d8b41 | 2015-03-24 02:23:22 -0400 | [diff] [blame] | 72 | echo "##### Building fake file system zip for nacl" |
Russ Cox | de4964a | 2014-09-08 00:22:40 -0400 | [diff] [blame] | 73 | rm -f syscall/fstest_nacl.go |
Shenghou Ma | 16d8b41 | 2015-03-24 02:23:22 -0400 | [diff] [blame] | 74 | GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4} |
| 75 | gobin=$GOROOT_BOOTSTRAP/bin |
| 76 | GOROOT=$GOROOT_BOOTSTRAP $gobin/go run ../misc/nacl/mkzip.go -p syscall -r .. ../misc/nacl/testzip.proto syscall/fstest_nacl.go |
Russ Cox | 0c2a727 | 2014-05-20 12:10:19 -0400 | [diff] [blame] | 77 | |
| 78 | # Run standard build and tests. |
| 79 | export PATH=$(pwd)/../misc/nacl:$PATH |
Shenghou Ma | 16d8b41 | 2015-03-24 02:23:22 -0400 | [diff] [blame] | 80 | GOOS=nacl GOARCH=$naclGOARCH ./all.bash |
Shenghou Ma | fbb4c74 | 2015-05-01 21:56:28 -0400 | [diff] [blame] | 81 | |
| 82 | rm -f syscall/fstest_nacl.go |