aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2014-12-04 19:39:53 -0800
committerChristopher Ferris <cferris@google.com>2014-12-04 19:43:12 -0800
commit9528f3c08a68a8e591f02fd8cac9e7245ed086d2 (patch)
treeae070212b11f2256c885cef3298ade907a0fe06b
parent2174ea369225abb9a7c2573333e665c591f80432 (diff)
downloadjemalloc-9528f3c08a68a8e591f02fd8cac9e7245ed086d2.tar.gz
Add new unit test and rewrite run script.
Change-Id: I22a36d3369a39f7c0228d8a836ffd0b7c23071a5
-rw-r--r--Android.mk1
-rwxr-xr-xandroid/test/run_integration.sh16
-rwxr-xr-xandroid/test/run_jemalloc_tests.sh97
-rwxr-xr-xandroid/test/run_unit.sh24
4 files changed, 98 insertions, 40 deletions
diff --git a/Android.mk b/Android.mk
index 5acd474..cdcbc61 100644
--- a/Android.mk
+++ b/Android.mk
@@ -155,6 +155,7 @@ include $(BUILD_STATIC_LIBRARY)
# jemalloc unit tests
#-----------------------------------------------------------------------
unit_tests := \
+ test/unit/atomic.c \
test/unit/bitmap.c \
test/unit/ckh.c \
test/unit/hash.c \
diff --git a/android/test/run_integration.sh b/android/test/run_integration.sh
deleted file mode 100755
index 65a5ff0..0000000
--- a/android/test/run_integration.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/system/bin/sh
-
-set -e
-
-test_dir=/data/nativetest/jemalloc_integrationtests
-
-$test_dir/aligned_alloc
-$test_dir/allocated
-$test_dir/chunk
-$test_dir/mallocx
-$test_dir/MALLOCX_ARENA
-$test_dir/posix_memalign
-$test_dir/rallocx
-$test_dir/thread_arena
-$test_dir/thread_tcache_enabled
-$test_dir/xallocx
diff --git a/android/test/run_jemalloc_tests.sh b/android/test/run_jemalloc_tests.sh
new file mode 100755
index 0000000..3c9ed9c
--- /dev/null
+++ b/android/test/run_jemalloc_tests.sh
@@ -0,0 +1,97 @@
+#!/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=( \
+ "atomic" \
+ "bitmap" \
+ "ckh" \
+ "hash" \
+ "junk" \
+ "mallctl" \
+ "math" \
+ "mq" \
+ "mtx" \
+ "ql" \
+ "qr" \
+ "quarantine" \
+ "rb" \
+ "rtree" \
+ "SFMT" \
+ "stats" \
+ "tsd" \
+ "util" \
+ "zero" \
+)
+
+INTEGRATION_TEST_DIR="jemalloc_integrationtests"
+
+INTEGRATION_TESTS=( \
+ "aligned_alloc" \
+ "allocated" \
+ "chunk" \
+ "mallocx" \
+ "MALLOCX_ARENA" \
+ "posix_memalign" \
+ "rallocx" \
+ "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}
diff --git a/android/test/run_unit.sh b/android/test/run_unit.sh
deleted file mode 100755
index fe121af..0000000
--- a/android/test/run_unit.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/system/bin/sh
-
-set -e
-
-test_dir=/data/nativetest/jemalloc_unittests
-
-$test_dir/bitmap
-$test_dir/ckh
-$test_dir/hash
-$test_dir/junk
-$test_dir/mallctl
-$test_dir/math
-$test_dir/mq
-$test_dir/mtx
-$test_dir/ql
-$test_dir/qr
-$test_dir/quarantine
-$test_dir/rb
-$test_dir/rtree
-$test_dir/SFMT
-$test_dir/stats
-$test_dir/tsd
-$test_dir/util
-$test_dir/zero