1 # Copyright 2013 The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # This file should be sourced from bash. Sets environment variables for 16 # running tests, and also checks that a number of dependences are present 17 # and that the unit tests for the modules passed (indicating that the setup 18 # is correct). 19 20 export CAMERA_ITS_TOP=$PWD 21 22 [[ "${BASH_SOURCE[0]}" != "${0}" ]] || \ 23 { echo ">> Script must be sourced with 'source $0'" >&2; exit 1; } 24 25 command -v adb >/dev/null 2>&1 || \ 26 echo ">> Require adb executable to be in path" >&2 27 28 command -v python >/dev/null 2>&1 || \ 29 echo ">> Require python executable to be in path" >&2 30 31 python -V 2>&1 | grep -q "Python 2.7" || \ 32 echo ">> Require python 2.7" >&2 33 34 for M in numpy PIL matplotlib scipy.stats scipy.spatial 35 do 36 python -c "import $M" >/dev/null 2>&1 || \ 37 echo ">> Require Python $M module" >&2 38 done 39 40 for N in 'PIL Image' 'matplotlib pylab' 41 do 42 IFS=' ' read module submodule <<< "$N" 43 python -c "from $module import $submodule" >/dev/null 2>&1 || \ 44 echo ">> Require Python $module module $submodule submodule" >&2 45 done 46 47 CV2_VER=$(python -c "\ 48 try: 49 import cv2 50 print cv2.__version__ 51 except: 52 print \"N/A\" 53 ") 54 55 echo $CV2_VER | grep -q -e "^2.4" -e "^3.2" || \ 56 echo ">> Require python opencv 2.4. or 3.2. Got $CV2_VER" >&2 57 58 export PYTHONPATH="$PWD/pymodules:$PYTHONPATH" 59 60 for M in device objects image caps dng target error 61 do 62 python "pymodules/its/$M.py" 2>&1 | grep -q "OK" || \ 63 echo ">> Unit test for $M failed" >&2 64 done 65 66 alias gpylint='gpylint --rcfile=$CAMERA_ITS_TOP"/build/scripts/gpylint_rcfile"' 67