Skip to content

Commit

Permalink
CoreCLR runtime tests + Mono on the x64 iOS simulator (#43954)
Browse files Browse the repository at this point in the history
This creates another `runtime-staging` lane, named "Build iOSSimulator x64
Release AllSubsets_Mono_RuntimeTests", that will eventually run the runtime
test suite against Mono's non-LLVM JIT on the iOS simulator on amd64 hosts.
Failing tests are added to the exclusion lists in issues.targets.

The tests aren't set to run yet, because they currently take a very long time
to execute.

`AppleAppBuilder` no longer requires a `MainLibraryFileName`. If omitted, one
must be supplied when the app bundle is launched via an environment variable
named `MONO_APPLE_APP_ENTRY_POINT_LIB_NAME`. The generated apps also accept
another environment variable named `MONO_APPLE_APP_ASSEMBLY_LOAD_PREFIX`, which
is a hack used to allow assembly lookup to proceed in a nested app-relative
subdirectory before falling back to the root of the app bundle. This is
necessary because app bundles contain multiple individual test assemblies, and
these assemblies sometimes have dependencies with names that collide with the
dependencies of other test assemblies inside the bundle.
  • Loading branch information
imhameed authored Aug 3, 2021
1 parent a35aff7 commit da803ac
Show file tree
Hide file tree
Showing 13 changed files with 471 additions and 64 deletions.
10 changes: 7 additions & 3 deletions eng/pipelines/coreclr/templates/helix-queues-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ jobs:
runtimeFlavorDisplayName: ${{ parameters.runtimeFlavorDisplayName }}
helixQueues:

# iOS/tvOS simulator x64/x86
- ${{ if in(parameters.platform, 'iOSSimulator_x64', 'tvOSSimulator_x64') }}:
- OSX.1015.Amd64.Open

# Android arm64
- ${{ if in(parameters.platform, 'Android_arm64') }}:
- Windows.10.Amd64.Android.Open

# Android x64
- ${{ if in(parameters.platform, 'Android_x64') }}:
- Ubuntu.1804.Amd64.Android.Open

# Browser wasm
- ${{ if eq(parameters.platform, 'Browser_wasm') }}:
- Ubuntu.1804.Amd64.Open

# Linux arm
- ${{ if eq(parameters.platform, 'Linux_arm') }}:
- ${{ if eq(variables['System.TeamProject'], 'public') }}:
Expand Down
42 changes: 42 additions & 0 deletions eng/pipelines/runtime-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,48 @@ jobs:
creator: dotnet-bot
testRunNamePrefixSuffix: Mono_$(_BuildConfig)

#
# Build the whole product using Mono and run runtime tests with the JIT.
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
buildConfig: Release
runtimeFlavor: mono
platforms:
- iOSSimulator_x64
variables:
- ${{ if and(eq(variables['System.TeamProject'], 'public'), eq(variables['Build.Reason'], 'PullRequest')) }}:
- name: _HelixSource
value: pr/dotnet/runtime/$(Build.SourceBranch)
- ${{ if and(eq(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest')) }}:
- name: _HelixSource
value: ci/dotnet/runtime/$(Build.SourceBranch)
- name: timeoutPerTestInMinutes
value: 60
- name: timeoutPerTestCollectionInMinutes
value: 180
jobParameters:
testGroup: innerloop
nameSuffix: AllSubsets_Mono_RuntimeTests
buildArgs: -s mono+libs -c $(_BuildConfig)
timeoutInMinutes: 240
condition: >-
or(
eq(dependencies.evaluate_paths.outputs['SetPathVars_runtimetests.containsChange'], true),
eq(dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'], true),
eq(variables['isFullMatrix'], true))
# Test execution is temporarily disabled because test apps no longer launch
# and the test suite times out after two hours, even if xharness cannot
# successfully launch any tests. Re-enable once these issues have been fixed.
#
# extra steps, run tests
# extraStepsTemplate: /eng/pipelines/common/templates/runtimes/android-runtime-and-send-to-helix.yml
# extraStepsParameters:
# creator: dotnet-bot
# testRunNamePrefixSuffix: Mono_$(_BuildConfig)

#
# Build the whole product using Mono for Android and run runtime tests with Android devices
#
Expand Down
13 changes: 9 additions & 4 deletions src/tasks/AppleAppBuilder/AppleAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ public string TargetOS
public string MonoRuntimeHeaders { get; set; } = ""!;

/// <summary>
/// This library will be used as an entry-point (e.g. TestRunner.dll)
/// This library will be used as an entry point (e.g. TestRunner.dll). Can
/// be empty. If empty, the entry point of the app must be specified in an
/// environment variable named "MONO_APPLE_APP_ENTRY_POINT_LIB_NAME" when
/// running the resulting app.
/// </summary>
[Required]
public string MainLibraryFileName { get; set; } = ""!;

/// <summary>
Expand Down Expand Up @@ -155,9 +157,12 @@ public override bool Execute()
{
bool isDevice = (TargetOS == TargetNames.iOS || TargetOS == TargetNames.tvOS);

if (!File.Exists(Path.Combine(AppDir, MainLibraryFileName)))
if (!string.IsNullOrEmpty(MainLibraryFileName))
{
throw new ArgumentException($"MainLibraryFileName='{MainLibraryFileName}' was not found in AppDir='{AppDir}'");
if (!File.Exists(Path.Combine(AppDir, MainLibraryFileName)))
{
throw new ArgumentException($"MainLibraryFileName='{MainLibraryFileName}' was not found in AppDir='{AppDir}'");
}
}

if (ProjectName.Contains(' '))
Expand Down
61 changes: 44 additions & 17 deletions src/tasks/AppleAppBuilder/Templates/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,33 @@
munmap (handle, size);
}

static MonoAssembly*
static const char *assembly_load_prefix = NULL;

static MonoAssembly *
load_assembly_aux (const char *filename, const char *culture, const char *bundle)
{
char path [1024];
int res;
if (culture && strcmp (culture, ""))
res = snprintf (path, sizeof (path) - 1, "%s/%s/%s", bundle, culture, filename);
else
res = snprintf (path, sizeof (path) - 1, "%s/%s", bundle, filename);
assert (res > 0);

struct stat buffer;
if (stat (path, &buffer) == 0) {
MonoAssembly *assembly = mono_assembly_open (path, NULL);
assert (assembly);
return assembly;
}
return NULL;
}

static MonoAssembly *
load_assembly (const char *name, const char *culture)
{
const char *bundle = get_bundle_path ();
char filename [1024];
char path [1024];
int res;

os_log_info (OS_LOG_DEFAULT, "assembly_preload_hook: %{public}s %{public}s %{public}s\n", name, culture, bundle);

Expand All @@ -105,19 +125,14 @@
strlcat (filename, ".dll", sizeof (filename));
}

if (culture && strcmp (culture, ""))
res = snprintf (path, sizeof (path) - 1, "%s/%s/%s", bundle, culture, filename);
else
res = snprintf (path, sizeof (path) - 1, "%s/%s", bundle, filename);
assert (res > 0);

struct stat buffer;
if (stat (path, &buffer) == 0) {
MonoAssembly *assembly = mono_assembly_open (path, NULL);
assert (assembly);
return assembly;
if (assembly_load_prefix [0] != '\0') {
char prefix_bundle [1024];
int res = snprintf (prefix_bundle, sizeof (prefix_bundle) - 1, "%s/%s", bundle, assembly_load_prefix);
assert (res > 0);
MonoAssembly *ret = load_assembly_aux (filename, culture, prefix_bundle);
if (ret) return ret;
}
return NULL;
return load_assembly_aux (filename, culture, bundle);
}

static MonoAssembly*
Expand Down Expand Up @@ -260,7 +275,7 @@

// TODO: set TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS and NATIVE_DLL_SEARCH_DIRECTORIES
const char *appctx_keys [] = {
"RUNTIME_IDENTIFIER",
"RUNTIME_IDENTIFIER",
"APP_CONTEXT_BASE_DIRECTORY",
#if !defined(INVARIANT_GLOBALIZATION)
"ICU_DAT_FILE_PATH"
Expand Down Expand Up @@ -291,6 +306,19 @@
free (file_path);
}

const char* executable = "%EntryPointLibName%";
if (executable [0] == '\0') {
executable = getenv ("MONO_APPLE_APP_ENTRY_POINT_LIB_NAME");
}
if (executable == NULL) {
executable = "";
}

assembly_load_prefix = getenv ("MONO_APPLE_APP_ASSEMBLY_LOAD_PREFIX");
if (assembly_load_prefix == NULL) {
assembly_load_prefix = "";
}

monovm_initialize (sizeof (appctx_keys) / sizeof (appctx_keys [0]), appctx_keys, appctx_values);

#if (FORCE_INTERPRETER && !FORCE_AOT)
Expand Down Expand Up @@ -334,7 +362,6 @@
MONO_EXIT_GC_UNSAFE;
#endif

const char* executable = "%EntryPointLibName%";
MonoAssembly *assembly = load_assembly (executable, NULL);
assert (assembly);
os_log_info (OS_LOG_DEFAULT, "Executable: %{public}s", executable);
Expand Down
Loading

0 comments on commit da803ac

Please sign in to comment.