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