blob: e413778f5ca7f15baf23e25c9a66e3f9d37df961 [file] [log] [blame]
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -07001# Run all tests
2
3PROGDIR=`dirname $0`
4PROGDIR=`cd $PROGDIR && pwd`
David 'Digit' Turnerf4790e62010-07-29 18:07:56 -07005
6# Assume that we are under tests/
7# and that the samples will be under samples/ and platforms/android-N/samples/
8#
9ROOTDIR=`dirname $PROGDIR`
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -070010#
11# Sanity checks:
12#
13if [ -z "$NDK" ] ; then
14 echo "ERROR: Please define NDK in your environment to point to the root of your NDK install."
15 exit 1
16fi
17
18if [ ! -d "$NDK" ] ; then
19 echo "ERROR: Your NDK variable does not point to a directory: $NDK"
20 exit 2
21fi
22
23if [ ! -f "$NDK/ndk-build" -o ! -f "$NDK/build/core/ndk-common.sh" ] ; then
24 echo "ERROR: Your NDK variable does not point to a valid NDK directory: $NDK"
25 exit 3
26fi
27
David 'Digit' Turnerf4790e62010-07-29 18:07:56 -070028if [ ! -d "$NDK/platforms" -o ! -d "$NDK/samples" ] ; then
29 echo "ERROR: Your NDK directory does not have 'platforms' or 'samples' directories."
30 echo "Please run $NDK/build/tools/build-platforms.sh first !"
31 exit 3
32fi
33
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -070034#
35# Parse options
36#
37JOBS=
38while [ -n "$1" ]; do
39 opt="$1"
40 optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
41 case "$opt" in
42 --help|-h|-\?)
43 OPTION_HELP=yes
44 ;;
45 --verbose)
46 VERBOSE=yes
47 ;;
48 -j*)
49 JOBS="$opt"
50 shift
51 ;;
52 --jobs=*)
53 JOBS="-j$optarg"
54 ;;
55 -*) # unknown options
56 echo "ERROR: Unknown option '$opt', use --help for list of valid ones."
57 exit 1
58 ;;
59 *) # Simply record parameter
60 if [ -z "$PARAMETERS" ] ; then
61 PARAMETERS="$opt"
62 else
63 PARAMETERS="$PARAMETERS $opt"
64 fi
65 ;;
66 esac
67 shift
68done
69
70if [ "$OPTION_HELP" = "yes" ] ; then
71 echo "Usage: $PROGNAME [options]"
72 echo ""
73 echo "Run all NDK automated tests at once."
74 echo ""
75 echo "Valid options:"
76 echo ""
77 echo " --help|-h|-? Print this help"
78 echo " --verbose Enable verbose mode"
79 echo " -j<N> --jobs=<N> Launch parallel builds"
80 echo ""
81 exit 0
82fi
83
84#
85# Create log file
86#
87MYLOG=/tmp/ndk-tests.log
88mkdir -p `dirname $MYLOG`
89rm -f $MYLOG
90echo "NDK automated tests log file" > $MYLOG
91
David 'Digit' Turner6d0ef0d2010-07-16 14:31:30 -070092if [ "$VERBOSE" = "yes" ] ; then
93run ()
94{
95 $NDK/ndk-build -B $JOBS 2>&1
96}
97else
98run ()
99{
100 $NDK/ndk-build -B $JOBS >> $MYLOG 2>&1
101}
102fi
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -0700103
David 'Digit' Turnerf4790e62010-07-29 18:07:56 -0700104# Find sample directories
105SAMPLE_DIRS=`cd $ROOTDIR && ls -d samples/*`
106SAMPLE_DIRS="$SAMPLE_DIRS "`cd $ROOTDIR && ls -d platforms/android-*/samples/*`
107
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -0700108#
109# Rebuild all samples first
David 'Digit' Turnerf4790e62010-07-29 18:07:56 -0700110# $1: sample name
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -0700111#
112build_sample ()
113{
David 'Digit' Turnerf4790e62010-07-29 18:07:56 -0700114 echo "Building NDK sample: `basename $1`"
115 SAMPLEDIR=$ROOTDIR/$1
116 cd $SAMPLEDIR
David 'Digit' Turner6d0ef0d2010-07-16 14:31:30 -0700117 run $NDK/ndk-build -B $JOBS
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -0700118 if [ $? != 0 ] ; then
David 'Digit' Turnerf4790e62010-07-29 18:07:56 -0700119 echo "!!! BUILD FAILURE [$1]!!! See $MYLOG for details or use --verbose option!"
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -0700120 exit 1
121 fi
122}
123
David 'Digit' Turnerf4790e62010-07-29 18:07:56 -0700124for DIR in $SAMPLE_DIRS; do
125 build_sample $DIR
David 'Digit' Turnerd74329c2010-07-15 16:20:59 -0700126done