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 # 10 # Assumes that sel_ldr binaries and go_nacl_$GOARCH_exec scripts are in $PATH; 11 # see ../misc/nacl/README. 12 13 set -e 14 ulimit -c 0 15 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 32 # Check GOARCH. 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 ;; 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 ;; 52 *) 53 echo 'unsupported $GOARCH for nacl: '"$naclGOARCH" 1>&2 54 exit 1 55 esac 56 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 62 unset GOOS GOARCH 63 if [ ! -f make.bash ]; then 64 echo 'nacltest.bash must be run from $GOROOT/src' 1>&2 65 exit 1 66 fi 67 68 # the builder might have set GOROOT_FINAL. 69 export GOROOT=$(pwd)/.. 70 71 # Build zip file embedded in package syscall. 72 echo "##### Building fake file system zip for nacl" 73 rm -f syscall/fstest_nacl.go 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 77 78 # Run standard build and tests. 79 export PATH=$(pwd)/../misc/nacl:$PATH 80 GOOS=nacl GOARCH=$naclGOARCH ./all.bash 81 82 rm -f syscall/fstest_nacl.go 83