1 # Run all tests 2 3 PROGDIR=`dirname $0` 4 PROGDIR=`cd $PROGDIR && pwd` 5 6 # Assume that we are under tests/ 7 # and that the samples will be under samples/ and platforms/android-N/samples/ 8 # 9 ROOTDIR=`dirname $PROGDIR` 10 # 11 # Sanity checks: 12 # 13 if [ -z "$NDK" ] ; then 14 echo "ERROR: Please define NDK in your environment to point to the root of your NDK install." 15 exit 1 16 fi 17 18 if [ ! -d "$NDK" ] ; then 19 echo "ERROR: Your NDK variable does not point to a directory: $NDK" 20 exit 2 21 fi 22 23 if [ ! -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 26 fi 27 28 if [ ! -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 32 fi 33 34 # 35 # Parse options 36 # 37 JOBS= 38 while [ -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 68 done 69 70 if [ "$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 82 fi 83 84 # 85 # Create log file 86 # 87 MYLOG=/tmp/ndk-tests.log 88 mkdir -p `dirname $MYLOG` 89 rm -f $MYLOG 90 echo "NDK automated tests log file" > $MYLOG 91 92 if [ "$VERBOSE" = "yes" ] ; then 93 run () 94 { 95 $NDK/ndk-build -B $JOBS 2>&1 96 } 97 else 98 run () 99 { 100 $NDK/ndk-build -B $JOBS >> $MYLOG 2>&1 101 } 102 fi 103 104 # Find sample directories 105 SAMPLE_DIRS=`cd $ROOTDIR && ls -d samples/*` 106 SAMPLE_DIRS="$SAMPLE_DIRS "`cd $ROOTDIR && ls -d platforms/android-*/samples/*` 107 108 # 109 # Rebuild all samples first 110 # $1: sample name 111 # 112 build_sample () 113 { 114 echo "Building NDK sample: `basename $1`" 115 SAMPLEDIR=$ROOTDIR/$1 116 cd $SAMPLEDIR 117 run $NDK/ndk-build -B $JOBS 118 if [ $? != 0 ] ; then 119 echo "!!! BUILD FAILURE [$1]!!! See $MYLOG for details or use --verbose option!" 120 exit 1 121 fi 122 } 123 124 for DIR in $SAMPLE_DIRS; do 125 build_sample $DIR 126 done 127