Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Fix unit tests so all tests pass #1580

Merged
merged 11 commits into from
Aug 2, 2022

Conversation

robertwu1
Copy link
Collaborator

@robertwu1 robertwu1 commented Jul 27, 2022

Fixes #1501
Fixes #933
Fixes #1103
Fixes #772
Fixes #346
Fixes #232

In the last couple of Android releases, file permissions have become very tight. Before, we were moving the binary to a specific location, giving execute privileges to it, and running it directly in Java. This method is clearly risky and is blocked.

In order to upgrade the UnitTestRunner app, the following was done.

  1. In run_tests.sh, the test binary is put under ${TEST_RUNNER_DIR}/app/src/main/jniLibs.
  2. For Android O and over, building AndroidTestRunner moves this binary from ${TEST_RUNNER_DIR}/app/src/main/jniLibs and moves it to /data/app/~~WaKVjcw3K51emFW_rzq8ng==/com.google.oboe.tests.unittestrunner-0A3aNOPlAJ-9TpG86JRNfQ==/lib/arm64/libtestOboe.so
  3. For Android O and over, UnitTestRunner now can execute the binary from the new spot (getApplicationInfo().nativeLibraryDir).

The old method is still used for Android N and below.

A couple of other quality of life changes were added in this PR:

  1. Cleaned up warnings in MainActivity.java. This adds some StringBuilder and some lambdas.
  2. Only print logs in ${TEST_RUNNER_PACKAGE_NAME}.MainActivity and OboeAudio instead of all logcats at the end of ./run_tests.sh.
  3. Removed empty assets folder in favor of creating jniLibs and assets dynamically. This is the .gitignore change.
  4. Clean up build files on every build. When testing on different devices, old build devices makes the compile fail.
  5. Loosen requirements on tests so emulators can pass.

All the Android emulators and real phones I tested with pass with the changes.

One of the test failures is actually a code failure in OpenSL ES. I have opened #1582 to fix this.

@robertwu1 robertwu1 requested a review from philburk July 27, 2022 18:07
@robertwu1 robertwu1 changed the title Tests: Update UnitTestRunner to Android T Tests: Fix unit tests so all tests pass Jul 30, 2022
Copy link
Collaborator

@philburk philburk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

tests/testStreamFramesProcessed.cpp Show resolved Hide resolved
tests/testReturnStop.cpp Outdated Show resolved Hide resolved
tests/testStreamOpen.cpp Outdated Show resolved Hide resolved
@robertwu1 robertwu1 merged commit 007bada into main Aug 2, 2022
@robertwu1 robertwu1 deleted the robertwu/unittestrunnertoandroid33 branch August 2, 2022 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment