Skip to content

Commit

Permalink
Update Android instrumentation runner to be closer to upstream (#43775)
Browse files Browse the repository at this point in the history
The upstream instrumentation runners don't use runOnMainSync() in the onStart() method, update our runner to do the same and add a bit more logging.

Also fixed a small typo in configure.cmake that I happened to notice.
  • Loading branch information
akoeplinger committed Oct 23, 2020
1 parent 0d4448a commit 0e402bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/libraries/Native/Unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ check_c_source_compiles(
HAVE_MKSTEMP)

if (NOT HAVE_MKSTEMPS AND NOT HAVE_MKSTEMP)
message(FATAL_ERROR "Cannot find mkstemp nor mkstemp on this platform.")
message(FATAL_ERROR "Cannot find mkstemps nor mkstemp on this platform.")
endif()

check_c_source_compiles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.os.Looper;
import android.util.Log;
import android.view.View;
import android.app.Activity;
Expand All @@ -32,6 +33,7 @@ public class MonoRunner extends Instrumentation
}

static String entryPointLibName = "%EntryPointLibName%";
static Bundle result = new Bundle();

@Override
public void onCreate(Bundle arguments) {
Expand Down Expand Up @@ -62,33 +64,32 @@ public static int initialize(String entryPointLibName, Context context) {
// unzip libs and test files to filesDir
unzipAssets(context, filesDir, "assets.zip");

Log.i("DOTNET", "initRuntime, entryPointLibName=" + entryPointLibName);
Log.i("DOTNET", "MonoRunner initialize, entryPointLibName=" + entryPointLibName);
return initRuntime(filesDir, cacheDir, docsDir, entryPointLibName);
}

@Override
public void onStart() {
super.onStart();
Looper.prepare();

if (entryPointLibName == "") {
Log.e("DOTNET", "Missing entryPointLibName argument, pass '-e entryPointLibName <name.dll>' to adb to specify which program to run.");
finish(1, null);
return;
}
int retcode = initialize(entryPointLibName, getContext());
runOnMainSync(new Runnable() {
public void run() {
Bundle result = new Bundle();
result.putInt("return-code", retcode);

// Xharness cli expects "test-results-path" with test results
File testResults = new File(getDocsDir(getContext()) + "/testResults.xml");
if (testResults.exists()) {
result.putString("test-results-path", testResults.getAbsolutePath());
}
finish(retcode, result);
}
});

Log.i("DOTNET", "MonoRunner finished, return-code=" + retcode);
result.putInt("return-code", retcode);

// Xharness cli expects "test-results-path" with test results
File testResults = new File(getDocsDir(getContext()) + "/testResults.xml");
if (testResults.exists()) {
Log.i("DOTNET", "MonoRunner finished, test-results-path=" + testResults.getAbsolutePath());
result.putString("test-results-path", testResults.getAbsolutePath());
}

finish(retcode, result);
}

static void unzipAssets(Context context, String toPath, String zipName) {
Expand Down

0 comments on commit 0e402bc

Please sign in to comment.