[gardening] Don't run tests requiring dsymutil on platforms without it.

TEST=vm/dart/use_dwarf_stack_traces_flag and
     vm/dart/use_macho_reduce_padding_flag on AOT simulators/Windows.

Change-Id: I4be334a4b5f374fe2469c64f415ce8de174f5e8d
Cq-Include-Trybots: luci.dart.try:vm-aot-win-release-x64-try,vm-aot-linux-release-simarm_x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463261
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
diff --git a/runtime/tests/vm/dart/use_dwarf_stack_traces_flag_test.dart b/runtime/tests/vm/dart/use_dwarf_stack_traces_flag_test.dart
index 253b720..f9c6419 100644
--- a/runtime/tests/vm/dart/use_dwarf_stack_traces_flag_test.dart
+++ b/runtime/tests/vm/dart/use_dwarf_stack_traces_flag_test.dart
@@ -19,6 +19,12 @@
 import 'use_dwarf_stack_traces_flag_helper.dart';
 
 Future<void> main() async {
+  bool hasDsymutil = true;
+  if (Platform.isWindows || isSimulator) {
+    // Currently dsymutil isn't available in these cases, so don't run
+    // the corresponding test (but do in the future if it becomes available).
+    hasDsymutil = llvmTool('dsymutil') != null;
+  }
   await runTests(
     'dwarf-flag-test',
     path.join(
@@ -33,7 +39,7 @@
     [
       runElf,
       runMachODylib,
-      runMachODsym,
+      if (hasDsymutil) runMachODsym,
       // Don't run assembly on Windows since DLLs don't contain DWARF.
       if (!Platform.isWindows) runAssembly,
     ],
diff --git a/runtime/tests/vm/dart/use_macho_reduce_padding_flag_test.dart b/runtime/tests/vm/dart/use_macho_reduce_padding_flag_test.dart
index f1cc91a..156f156 100644
--- a/runtime/tests/vm/dart/use_macho_reduce_padding_flag_test.dart
+++ b/runtime/tests/vm/dart/use_macho_reduce_padding_flag_test.dart
@@ -24,6 +24,12 @@
     return; // SDK tree and dart_bootstrap not available on the test device.
   }
 
+  if (Platform.isWindows || isSimulator) {
+    // Currently dsymutil isn't available in these cases (but if it is
+    // in the future, go ahead and run them).
+    if (llvmTool('dsymutil') == null) return;
+  }
+
   // These are the tools we need to be available to run on a given platform:
   if (!await testExecutable(genSnapshot)) {
     throw "Cannot run test as $genSnapshot not available";