1 #!/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="jemalloc5_unittests" 18 19 UNIT_TESTS=( \ 20 "a0" \ 21 "arena_reset" \ 22 "atomic" \ 23 "background_thread" \ 24 "background_thread_enable" \ 25 "base" \ 26 "bitmap" \ 27 "ckh" \ 28 "div" \ 29 "emitter" \ 30 "extent_quantize" \ 31 "fork" \ 32 "hash" \ 33 "hooks" \ 34 "junk" \ 35 "junk_alloc" \ 36 "junk_free" \ 37 "log" \ 38 "mallctl" \ 39 "malloc_io" \ 40 "math" \ 41 "mq" \ 42 "mtx" \ 43 "pack" \ 44 "pages" \ 45 "prng" \ 46 "prof_accum" \ 47 "prof_active" \ 48 "prof_gdump" \ 49 "prof_idump" \ 50 "prof_reset" \ 51 "prof_thread_name" \ 52 "ql" \ 53 "qr" \ 54 "rb" \ 55 "retained" \ 56 "rtree" \ 57 "SFMT" \ 58 "size_classes" \ 59 "slab" \ 60 "smoothstep" \ 61 "spin" \ 62 "stats" \ 63 "stats_print" \ 64 "ticker" \ 65 "nstime" \ 66 "tsd" \ 67 "witness" \ 68 ) 69 70 # These tests have bit-rotted and are not working properly. 71 # "decay" \ 72 # "zero" \ 73 74 INTEGRATION_TEST_DIR="jemalloc5_integrationtests" 75 76 INTEGRATION_TESTS=( \ 77 "aligned_alloc" \ 78 "allocated" \ 79 "extent" \ 80 "mallocx" \ 81 "MALLOCX_ARENA" \ 82 "overflow" \ 83 "posix_memalign" \ 84 "rallocx" \ 85 "sdallocx" \ 86 "thread_arena" \ 87 "xallocx" \ 88 "basic" \ 89 ) 90 91 STRESS_TEST_DIR="jemalloc5_stresstests" 92 93 STRESS_TESTS=( \ 94 "microbench" \ 95 ) 96 97 TEST_DIRECTORIES=( "nativetest" "nativetest64" ) 98 FAILING_TESTS=() 99 100 function run_tests () { 101 local test_type=$1 102 shift 103 local test_dir=$1 104 shift 105 local test_list=$* 106 if [[ -d "${test_dir}" ]]; then 107 for test in ${test_list[@]}; do 108 echo "Running ${test_type} ${test}" 109 ${test_dir}/$test 110 local exit_val=$? 111 # 0 means all tests passed. 112 # 1 means all tests passed but some tests were skipped. 113 # 2 means at least one failure. 114 if [[ ${exit_val} -ne 0 ]] && [[ ${exit_val} -ne 1 ]]; then 115 echo "*** $test failed: ${exit_val}" 116 FAILING_TESTS+=("${test_dir}/${test}") 117 EXIT_CODE=$((EXIT_CODE+1)) 118 fi 119 done 120 fi 121 } 122 123 if [[ "" == "$1" ]]; then 124 directory="/data" 125 else 126 directory=$1; 127 fi 128 129 echo "Looking in $directory"; 130 131 EXIT_CODE=0 132 for test_dir in ${TEST_DIRECTORIES[@]}; do 133 test_dir="${directory}/${test_dir}" 134 if [[ -d "${test_dir}" ]]; then 135 run_tests "unit" "${test_dir}/${UNIT_TEST_DIR}" ${UNIT_TESTS[@]} 136 run_tests "integration" "${test_dir}/${INTEGRATION_TEST_DIR}" ${INTEGRATION_TESTS[@]} 137 run_tests "stress" "${test_dir}/${STRESS_TEST_DIR}" ${STRESS_TESTS[@]} 138 fi 139 done 140 if [[ ${EXIT_CODE} -eq 0 ]]; then 141 echo "All tests passed" 142 else 143 echo "List of failing tests:" 144 for fail in ${FAILING_TESTS[@]}; do 145 echo " $fail" 146 done 147 fi 148 exit ${EXIT_CODE} 149