Skip to content

Commit

Permalink
[aot] Switch aot tests to use a script in taichi-aot-demo (taichi-dev…
Browse files Browse the repository at this point in the history
…#6559)

Issue: #

### Brief Summary

Debug in CI since I don't have an android phone ...
  • Loading branch information
ailzhang authored Nov 10, 2022
1 parent a971496 commit 3c7d8f6
Showing 1 changed file with 24 additions and 40 deletions.
64 changes: 24 additions & 40 deletions .github/workflows/scripts/aot-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function build-and-smoke-test-android-aot-demo {
sudo chmod 0777 $HOME/.cache
python implicit_fem.py --aot
popd

mkdir -p $JNI_PATH
cp taichi/build/libtaichi_export_core.so $JNI_PATH
cd $ANDROID_APP_ROOT
Expand Down Expand Up @@ -105,60 +104,45 @@ function build-and-test-headless-demo {
popd

rm -rf taichi-aot-demo
git clone --recursive --depth=1 https://github.com/taichi-dev/taichi-aot-demo
git clone --recursive --depth=1 -b add_test_script https://github.com/taichi-dev/taichi-aot-demo
cd taichi-aot-demo
mkdir build
pushd build

. $(pwd)/ci/test_utils.sh

# Build demos
export TAICHI_C_API_INSTALL_DIR=$(find $TAICHI_REPO_DIR -name cmake-install -type d | head -n 1)/c_api
cmake $ANDROID_CMAKE_ARGS ..
make -j
build_demos "$ANDROID_CMAKE_ARGS"

export PATH=/android-sdk/platform-tools:$PATH
grab-android-bot
trap release-android-bot EXIT
adb connect $BOT

# clear temporary test folder
adb shell "rm -rf /data/local/tmp/*"
# Clear temporary test folder
adb shell "rm -rf /data/local/tmp/* && mkdir /data/local/tmp/build"

pushd headless
BINARIES=$(ls E*)
for b in $BINARIES; do
adb push $b /data/local/tmp
done
popd # headless
# Push all binaries and shaders to the phone
pushd ci
adb push ./*.sh /data/local/tmp
popd
adb push $TAICHI_C_API_INSTALL_DIR/lib/libtaichi_c_api.so /data/local/tmp

pushd 0_tutorial_cgraph
adb push E0_tutorial_cgraph /data/local/tmp
popd # 0_tutorial_cgraph

pushd 0_tutorial_kernel
adb push E0_tutorial_kernel /data/local/tmp
popd # 0_tutorial_kernel

popd # build

adb push ./build/headless /data/local/tmp/build
adb push ./build/tutorial /data/local/tmp/build
for dir in ?_*; do
adb push $dir /data/local/tmp
done

# Run 0_tutorial_cgraph
adb shell "cd /data/local/tmp && LD_LIBRARY_PATH=\$(pwd) ./E0_tutorial_cgraph"
# Run 0_tutorial_kernel
adb shell "cd /data/local/tmp && LD_LIBRARY_PATH=\$(pwd) ./E0_tutorial_kernel"
# Run demos
adb shell "cd /data/local/tmp && LD_LIBRARY_PATH=\$(pwd) ./run_demos.sh"

# Run demos with headless-truth
for b in $BINARIES; do
adb shell "cd /data/local/tmp && LD_LIBRARY_PATH=\$(pwd) ./$b"
adb pull /data/local/tmp/0001.bmp $b.bmp
done
# Pull output images and compare with groundtruth
rm -rf output
mkdir output

for b in $BINARIES; do
if [[ $(cmp -l $b.bmp ci/headless-truths/$b.bmp | wc -l) -gt 300 ]]; then
echo "Above threshold: $b"
exit 1
fi
done
adb shell "ls /data/local/tmp/output"

adb pull /data/local/tmp/output .
compare_to_groundtruth android
}

$1

0 comments on commit 3c7d8f6

Please sign in to comment.