Skip to content

Commit 7bc66e0

Browse files
author
gaohaoyuan
committed
add gtest/opencl-stub for memory calls test
1 parent e30757b commit 7bc66e0

30 files changed

+13499
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "third_party/googletest"]
2+
path = third_party/googletest
3+
url = https://github.com/google/googletest.git

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ target_link_libraries(alloc_hook PRIVATE helper)
3030
# 安装到 out/lib 目录
3131
install(TARGETS alloc_hook DESTINATION ${CMAKE_INSTALL_PREFIX}/out/lib)
3232

33+
if (TARGET gtest)
34+
message(STATUS "gtest is already defined")
35+
else()
36+
set(GOOGLETEST_VERSION 1.15.2)
37+
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/googletest/googletest)
38+
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/opencl_stub)
39+
add_subdirectory(test)
40+
endif()
41+
3342
# copy database compile_commands.json to PROJECT_SOURCE_DIR
3443
add_custom_target(
3544
copy_database_compile_commands_mem_trace ALL

build_android.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ BUILD_ARCH="arm64-v8a"
55
if [ -n "$1" ]; then
66
BUILD_ARCH=$1
77
fi
8+
USER="alloc_test"
89

910
SRC_DIR=$(readlink -f "`dirname $0`")
1011
cd ${SRC_DIR}
@@ -56,12 +57,33 @@ function cmake_para_gen(){
5657
function build_sdk(){
5758
rm -rf build
5859
rm -rf out
60+
mkdir build
5961
mkdir -p out/lib
60-
mkdir build && cd build
62+
mkdir -p out/bin
6163

64+
pushd .
65+
cd build
6266
cmake ${CMAKE_PARA} ..
6367
ninja install -v
68+
popd
6469
}
6570

71+
function test_func(){
72+
adb shell rm -rf /data/local/tmp/trace
73+
adb shell mkdir -p /data/local/tmp/trace
74+
adb shell rm -rf /data/local/tmp/${USER}
75+
adb shell mkdir -p /data/local/tmp/${USER}
76+
77+
current_dir=$(pwd)
78+
adb push --sync ${current_dir}/out/lib/* /data/local/tmp/${USER}
79+
adb push --sync ${current_dir}/out/bin/* /data/local/tmp/${USER}
80+
81+
adb exec-out "cd /data/local/tmp/${USER}; \
82+
unset LD_PRELOAD; \
83+
export LD_LIBRARY_PATH=.; \
84+
chmod 777 ./alloc_hook_test; \
85+
LD_PRELOAD=liballoc_hook.so ./alloc_hook_test"
86+
}
6687
cmake_para_gen
6788
build_sdk
89+
test_func

test/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
add_subdirectory(gl_test)
2+
file(GLOB_RECURSE DIR_SRCS
3+
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
4+
"${CMAKE_CURRENT_SOURCE_DIR}/util/*.cpp"
5+
)
6+
add_executable(alloc_hook_test ${DIR_SRCS})
7+
8+
target_link_libraries(alloc_hook_test gtest log opencl-stub gles3jni)
9+
install(TARGETS alloc_hook_test DESTINATION ${CMAKE_INSTALL_PREFIX}/out/bin)

0 commit comments

Comments
 (0)