• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17UNIT_TEST_DIR="jemalloc_unittests"
18
19UNIT_TESTS=( \
20  "atomic" \
21  "bitmap" \
22  "ckh" \
23  "decay" \
24  "hash" \
25  "junk" \
26  "junk_alloc" \
27  "junk_free" \
28  "lg_chunk" \
29  "mallctl" \
30  "math" \
31  "mq" \
32  "mtx" \
33  "nstime" \
34  "prng" \
35  "prof_accum" \
36  "prof_active" \
37  "prof_gdump" \
38  "prof_idump" \
39  "prof_reset" \
40  "prof_thread_name" \
41  "ql" \
42  "qr" \
43  "quarantine" \
44  "rb" \
45  "rtree" \
46  "run_quantize" \
47  "SFMT" \
48  "size_classes" \
49  "smoothstep" \
50  "stats" \
51  "ticker" \
52  "tsd" \
53  "util" \
54  "zero" \
55)
56
57INTEGRATION_TEST_DIR="jemalloc_integrationtests"
58
59INTEGRATION_TESTS=( \
60  "aligned_alloc" \
61  "allocated" \
62  "chunk" \
63  "MALLOCX_ARENA" \
64  "mallocx" \
65  "overflow" \
66  "posix_memalign" \
67  "rallocx" \
68  "sdallocx" \
69  "thread_arena" \
70  "thread_tcache_enabled" \
71  "xallocx" \
72)
73
74TEST_DIRECTORIES=( "/data/nativetest" "/data/nativetest64" )
75FAILING_TESTS=()
76
77function run_tests () {
78  local test_type=$1
79  shift
80  local test_dir=$1
81  shift
82  local test_list=$*
83  if [[ -d "${test_dir}" ]]; then
84    for test in ${test_list[@]}; do
85      echo "Running ${test_type} ${test}"
86      ${test_dir}/$test
87      local exit_val=$?
88      # 0 means all tests passed.
89      # 1 means all tests passed but some tests were skipped.
90      # 2 means at least one failure.
91      if [[ ${exit_val} -ne 0 ]] && [[ ${exit_val} -ne 1 ]]; then
92        echo "*** $test failed: ${exit_val}"
93        FAILING_TESTS+=("${test}")
94        EXIT_CODE=$((EXIT_CODE+1))
95      fi
96    done
97  fi
98}
99
100EXIT_CODE=0
101for test_dir in ${TEST_DIRECTORIES[@]}; do
102  if [[ -d "${test_dir}" ]]; then
103    run_tests "unit" "${test_dir}/${UNIT_TEST_DIR}" ${UNIT_TESTS[@]}
104    run_tests "integration" "${test_dir}/${INTEGRATION_TEST_DIR}" ${INTEGRATION_TESTS[@]}
105  fi
106done
107if [[ ${EXIT_CODE} -eq 0 ]]; then
108  echo "All tests passed"
109else
110  echo "List of failing tests:"
111  for fail in ${FAILING_TESTS[@]}; do
112    echo "  $fail"
113  done
114fi
115exit ${EXIT_CODE}
116