Skip to content

Commit

Permalink
add gtest/opencl-stub for memory calls test
Browse files Browse the repository at this point in the history
  • Loading branch information
gaohaoyuan committed Jan 12, 2025
1 parent e30757b commit 7bc66e0
Show file tree
Hide file tree
Showing 30 changed files with 13,499 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://github.com/google/googletest.git
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ target_link_libraries(alloc_hook PRIVATE helper)
# 安装到 out/lib 目录
install(TARGETS alloc_hook DESTINATION ${CMAKE_INSTALL_PREFIX}/out/lib)

if (TARGET gtest)
message(STATUS "gtest is already defined")
else()
set(GOOGLETEST_VERSION 1.15.2)
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/googletest/googletest)
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/opencl_stub)
add_subdirectory(test)
endif()

# copy database compile_commands.json to PROJECT_SOURCE_DIR
add_custom_target(
copy_database_compile_commands_mem_trace ALL
Expand Down
24 changes: 23 additions & 1 deletion build_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ BUILD_ARCH="arm64-v8a"
if [ -n "$1" ]; then
BUILD_ARCH=$1
fi
USER="alloc_test"

SRC_DIR=$(readlink -f "`dirname $0`")
cd ${SRC_DIR}
Expand Down Expand Up @@ -56,12 +57,33 @@ function cmake_para_gen(){
function build_sdk(){
rm -rf build
rm -rf out
mkdir build
mkdir -p out/lib
mkdir build && cd build
mkdir -p out/bin

pushd .
cd build
cmake ${CMAKE_PARA} ..
ninja install -v
popd
}

function test_func(){
adb shell rm -rf /data/local/tmp/trace
adb shell mkdir -p /data/local/tmp/trace
adb shell rm -rf /data/local/tmp/${USER}
adb shell mkdir -p /data/local/tmp/${USER}

current_dir=$(pwd)
adb push --sync ${current_dir}/out/lib/* /data/local/tmp/${USER}
adb push --sync ${current_dir}/out/bin/* /data/local/tmp/${USER}

adb exec-out "cd /data/local/tmp/${USER}; \
unset LD_PRELOAD; \
export LD_LIBRARY_PATH=.; \
chmod 777 ./alloc_hook_test; \
LD_PRELOAD=liballoc_hook.so ./alloc_hook_test"
}
cmake_para_gen
build_sdk
test_func
9 changes: 9 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_subdirectory(gl_test)
file(GLOB_RECURSE DIR_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/util/*.cpp"
)
add_executable(alloc_hook_test ${DIR_SRCS})

target_link_libraries(alloc_hook_test gtest log opencl-stub gles3jni)
install(TARGETS alloc_hook_test DESTINATION ${CMAKE_INSTALL_PREFIX}/out/bin)
Loading

0 comments on commit 7bc66e0

Please sign in to comment.