blob: 049aad2ff29f1f0391a9d59e7a0bf2663e465d28 [file] [log] [blame]
Russ Cox0c2a7272014-05-20 12:10:19 -04001#!/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 Ma3ad9df02014-06-10 20:20:49 -040010# Assumes that sel_ldr binaries and go_nacl_$GOARCH_exec scripts are in $PATH;
11# see ../misc/nacl/README.
Russ Cox0c2a7272014-05-20 12:10:19 -040012
13set -e
14ulimit -c 0
15
Shenghou Ma99e2a562014-07-10 15:15:41 -040016# guess GOARCH if not set
17naclGOARCH=$GOARCH
18if [ -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
30fi
31
Russ Cox0c2a7272014-05-20 12:10:19 -040032# Check GOARCH.
Russ Cox0c2a7272014-05-20 12:10:19 -040033case "$naclGOARCH" in
34amd64p32)
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 ;;
40386)
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 Ma99e2a562014-07-10 15:15:41 -040046arm)
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 Cox0c2a7272014-05-20 12:10:19 -040052*)
53 echo 'unsupported $GOARCH for nacl: '"$naclGOARCH" 1>&2
54 exit 1
55esac
56
Shenghou Ma3ad9df02014-06-10 20:20:49 -040057if ! 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
60fi
61
Russ Cox0c2a7272014-05-20 12:10:19 -040062unset GOOS GOARCH
63if [ ! -f make.bash ]; then
Dave Cheneye6fbce32015-02-06 11:44:09 +110064 echo 'nacltest.bash must be run from $GOROOT/src' 1>&2
Russ Cox0c2a7272014-05-20 12:10:19 -040065 exit 1
66fi
Russ Cox0c2a7272014-05-20 12:10:19 -040067
Shenghou Ma54d0b5a2014-07-10 15:36:48 -040068# the builder might have set GOROOT_FINAL.
69export GOROOT=$(pwd)/..
70
Russ Cox0c2a7272014-05-20 12:10:19 -040071# Build zip file embedded in package syscall.
Shenghou Ma16d8b412015-03-24 02:23:22 -040072echo "##### Building fake file system zip for nacl"
Russ Coxde4964a2014-09-08 00:22:40 -040073rm -f syscall/fstest_nacl.go
Shenghou Ma16d8b412015-03-24 02:23:22 -040074GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4}
75gobin=$GOROOT_BOOTSTRAP/bin
76GOROOT=$GOROOT_BOOTSTRAP $gobin/go run ../misc/nacl/mkzip.go -p syscall -r .. ../misc/nacl/testzip.proto syscall/fstest_nacl.go
Russ Cox0c2a7272014-05-20 12:10:19 -040077
78# Run standard build and tests.
79export PATH=$(pwd)/../misc/nacl:$PATH
Shenghou Ma16d8b412015-03-24 02:23:22 -040080GOOS=nacl GOARCH=$naclGOARCH ./all.bash
Shenghou Mafbb4c742015-05-01 21:56:28 -040081
82rm -f syscall/fstest_nacl.go