Home | History | Annotate | Download | only in test
      1 #!/system/bin/sh
      2 #
      3 # Copyright (C) 2014 The Android Open Source Project
      4 #
      5 # Licensed under the Apache License, Version 2.0 (the "License");
      6 # you may not use this file except in compliance with the License.
      7 # You may obtain a copy of the License at
      8 #
      9 #      http://www.apache.org/licenses/LICENSE-2.0
     10 #
     11 # Unless required by applicable law or agreed to in writing, software
     12 # distributed under the License is distributed on an "AS IS" BASIS,
     13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14 # See the License for the specific language governing permissions and
     15 # limitations under the License.
     16 
     17 UNIT_TEST_DIR="jemalloc_unittests"
     18 
     19 UNIT_TESTS=( \
     20   "a0" \
     21   "arena_reset" \
     22   "atomic" \
     23   "bitmap" \
     24   "ckh" \
     25   "decay" \
     26   "fork" \
     27   "hash" \
     28   "junk" \
     29   "junk_alloc" \
     30   "junk_free" \
     31   "lg_chunk" \
     32   "mallctl" \
     33   "math" \
     34   "mq" \
     35   "mtx" \
     36   "nstime" \
     37   "pack" \
     38   "pages" \
     39   "prng" \
     40   "prof_accum" \
     41   "prof_active" \
     42   "prof_gdump" \
     43   "prof_idump" \
     44   "prof_reset" \
     45   "prof_thread_name" \
     46   "ql" \
     47   "qr" \
     48   "quarantine" \
     49   "rb" \
     50   "rtree" \
     51   "run_quantize" \
     52   "SFMT" \
     53   "size_classes" \
     54   "smoothstep" \
     55   "stats" \
     56   "ticker" \
     57   "tsd" \
     58   "util" \
     59   "witness" \
     60   "zero" \
     61 )
     62 
     63 INTEGRATION_TEST_DIR="jemalloc_integrationtests"
     64 
     65 INTEGRATION_TESTS=( \
     66   "aligned_alloc" \
     67   "allocated" \
     68   "chunk" \
     69   "MALLOCX_ARENA" \
     70   "mallocx" \
     71   "overflow" \
     72   "posix_memalign" \
     73   "rallocx" \
     74   "sdallocx" \
     75   "thread_arena" \
     76   "thread_tcache_enabled" \
     77   "xallocx" \
     78 )
     79 
     80 TEST_DIRECTORIES=( "/data/nativetest" "/data/nativetest64" )
     81 FAILING_TESTS=()
     82 
     83 function run_tests () {
     84   local test_type=$1
     85   shift
     86   local test_dir=$1
     87   shift
     88   local test_list=$*
     89   if [[ -d "${test_dir}" ]]; then
     90     for test in ${test_list[@]}; do
     91       echo "Running ${test_type} ${test}"
     92       ${test_dir}/$test
     93       local exit_val=$?
     94       # 0 means all tests passed.
     95       # 1 means all tests passed but some tests were skipped.
     96       # 2 means at least one failure.
     97       if [[ ${exit_val} -ne 0 ]] && [[ ${exit_val} -ne 1 ]]; then
     98         echo "*** $test failed: ${exit_val}"
     99         FAILING_TESTS+=("${test}")
    100         EXIT_CODE=$((EXIT_CODE+1))
    101       fi
    102     done
    103   fi
    104 }
    105 
    106 EXIT_CODE=0
    107 for test_dir in ${TEST_DIRECTORIES[@]}; do
    108   if [[ -d "${test_dir}" ]]; then
    109     run_tests "unit" "${test_dir}/${UNIT_TEST_DIR}" ${UNIT_TESTS[@]}
    110     run_tests "integration" "${test_dir}/${INTEGRATION_TEST_DIR}" ${INTEGRATION_TESTS[@]}
    111   fi
    112 done
    113 if [[ ${EXIT_CODE} -eq 0 ]]; then
    114   echo "All tests passed"
    115 else
    116   echo "List of failing tests:"
    117   for fail in ${FAILING_TESTS[@]}; do
    118     echo "  $fail"
    119   done
    120 fi
    121 exit ${EXIT_CODE}
    122