@@ -196,6 +196,47 @@ jobs:
196196 - name : Check MSRV for core with Rust ${{ env.rust_minver }}
197197 run : cargo +${{ env.rust_minver }} check --locked --all-features --verbose
198198
199+ native-test-android :
200+ strategy :
201+ fail-fast : false
202+ runs-on : ' ubuntu-latest'
203+ steps :
204+ - name : Checkout repository
205+ uses : actions/checkout@v4
206+ - name : Restore cargo caches
207+ uses : Swatinem/rust-cache@v2
208+ - name : Install cross
209+ run : cargo install cross --git https://github.com/cross-rs/cross --verbose
210+ - name : Build example
211+ run : |
212+ cross build --target x86_64-linux-android --example native_android --features native,android_log,source-location --verbose
213+ mv ./target/x86_64-linux-android/debug/examples/native_android ./target/x86_64-linux-android/debug/examples/native_android_srcloc
214+ cross build --target x86_64-linux-android --example native_android --features native,android_log --verbose
215+ - name : Enable KVM
216+ run : |
217+ echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
218+ sudo udevadm control --reload-rules
219+ sudo udevadm trigger --name-match=kvm
220+ - name : Run emulator and test
221+ uses : reactivecircus/android-emulator-runner@v2
222+ with :
223+ api-level : 29
224+ arch : x86_64
225+ script : |
226+ adb root
227+ adb push ./target/x86_64-linux-android/debug/examples/native_android /data
228+ adb push ./target/x86_64-linux-android/debug/examples/native_android_srcloc /data
229+
230+ adb logcat -b all -c
231+ adb shell /data/native_android
232+ adb shell /data/native_android_srcloc
233+ adb logcat -s "spdlog-rs-example" -d > ./logcat.log
234+ cat ./logcat.log
235+ cat ./logcat.log | grep "I spdlog-rs-example: \[demo] info message from spdlog-rs's AndroidSink"
236+ cat ./logcat.log | grep "E spdlog-rs-example: \[demo] error message from spdlog-rs's AndroidSink { error_code=114514 }"
237+ cat ./logcat.log | grep -E "I spdlog-rs-example: \[demo] \[native_android, .+.rs:[0-9]+] info message from spdlog-rs's AndroidSink"
238+ cat ./logcat.log | grep -E "E spdlog-rs-example: \[demo] \[native_android, .+.rs:[0-9]+] error message from spdlog-rs's AndroidSink { error_code=114514 }"
239+
199240 bench :
200241 needs : [test, check]
201242 strategy :
0 commit comments