Files
sdk/runtime/tests/vm/dart/sanitizer_compatibility_test.dart
T
Siva Annamalai 74c5aa3a7a Revert ""[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory""
This reverts commit f81a402aa1.

Reason for revert: golem benchmarks are failing to run

TEST=ci

Original change's description:
> "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
>
> Fixed golem breakage by temporarily copying dartaotruntime to dart_precompiled_runtime
>
> This reverts commit 75e6a748f7.
>
> TEST=ci
>
> Original change's description:
> > Revert "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
> >
> > This reverts commit 1b331d05c2.
> >
> > Reason for revert: golem builds are failing
> >
> > Original change's description:
> > > [SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory
> > >
> > > TEST=ci
> > >
>
> Change-Id: Id0f383eabb496c06c0acebc639c8e3b056ba82d0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393781
> Commit-Queue: Siva Annamalai <asiva@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

Change-Id: Iec494940412aa31dbefdc5280e35ae99e8cecb26
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393764
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-11-06 05:37:46 +00:00

92 lines
3.0 KiB
Dart

// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Check for a proper error when a snapshot and a runtime don't agree on which
// sanitizer they are using.
import "dart:io";
import "package:expect/expect.dart";
import "use_flag_test_helper.dart";
String find(String haystack, List<String> needles) {
for (String needle in needles) {
if (haystack.contains(needle)) {
return needle;
}
}
throw "None of ${needles.join(' ')}";
}
void checkExists(String path) {
if (!File(path).existsSync()) {
throw "$path does not exist";
}
}
main() async {
var sanitizer = find(Platform.executable, ["MSAN", "TSAN"]);
var mode = find(Platform.executable, ["Debug", "Release", "Product"]);
var arch = find(Platform.executable, ["X64", "ARM64", "RISCV64"]);
var out = find(Platform.executable, ["out", "xcodebuild"]);
var targetFlag = {
"MSAN": "--target_memory_sanitizer",
"TSAN": "--target_thread_sanitizer"
}[sanitizer]!;
var nonePlatform = "$out/$mode$arch/vm_platform_strong.dill";
var noneGenSnapshot = "$out/$mode$arch/gen_snapshot";
var noneJitRuntime = "$out/$mode$arch/dart";
var noneAotRuntime = "$out/$mode$arch/dart_precompiled_runtime";
var sanitizerGenSnapshot = "$out/$mode$sanitizer$arch/gen_snapshot";
var sanitizerAotRuntime =
"$out/$mode$sanitizer$arch/dart_precompiled_runtime";
checkExists(noneGenSnapshot);
checkExists(noneJitRuntime);
checkExists(noneAotRuntime);
checkExists(sanitizerGenSnapshot);
checkExists(sanitizerAotRuntime);
await withTempDir('sanitizer-compatibility-test', (String tempDir) async {
var aotDill = "$tempDir/aot.dill";
var noneElf = "$tempDir/none.elf";
var sanitizerElf = "$tempDir/$sanitizer.elf";
var sanitizerElf2 = "$tempDir/${sanitizer}2.elf";
await run(noneJitRuntime, [
"pkg/vm/bin/gen_kernel.dart",
"--platform",
nonePlatform,
"--aot",
"-o",
aotDill,
"tests/language/unsorted/first_test.dart"
]);
await run(noneGenSnapshot,
["--snapshot-kind=app-aot-elf", "--elf=$noneElf", aotDill]);
await run(sanitizerGenSnapshot,
["--snapshot-kind=app-aot-elf", "--elf=$sanitizerElf", aotDill]);
await run(noneGenSnapshot, [
"--snapshot-kind=app-aot-elf",
"--elf=$sanitizerElf2",
targetFlag,
aotDill
]);
await run(noneAotRuntime, [noneElf]);
await run(sanitizerAotRuntime, [sanitizerElf]);
await run(sanitizerAotRuntime, [sanitizerElf2]);
var errorLines = await runError(noneAotRuntime, [sanitizerElf]);
Expect.contains("Snapshot not compatible", errorLines[0]);
errorLines = await runError(noneAotRuntime, [sanitizerElf2]);
Expect.contains("Snapshot not compatible", errorLines[0]);
errorLines = await runError(sanitizerAotRuntime, [noneElf]);
Expect.contains("Snapshot not compatible", errorLines[0]);
});
}