[fusl] Build example apptests under fusl

R=viettrungluu@chromium.org

Review URL: https://codereview.chromium.org/1701193002 .
diff --git a/BUILD.gn b/BUILD.gn
index 18f558f..ffde2b7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -22,7 +22,10 @@
 
   if (is_linux) {
     deps += [
+      "//apps(//build/toolchain/fusl:fusl_${current_cpu})",
+      "//examples(//build/toolchain/fusl:fusl_${current_cpu})",
       "//fusl",
+      "//services(//build/toolchain/fusl:fusl_${current_cpu})",
 
       # We need this to run tests (especially on bots).
       "//third_party/mesa:osmesa",
diff --git a/mojo/devtools/common/mojo_test b/mojo/devtools/common/mojo_test
index d72bb82..59f5310 100755
--- a/mojo/devtools/common/mojo_test
+++ b/mojo/devtools/common/mojo_test
@@ -11,6 +11,7 @@
 import argparse
 import logging
 import sys
+import os.path
 
 from devtoolslib import apptest_dart
 from devtoolslib import apptest_gtest
@@ -80,7 +81,10 @@
     return 1
 
   target_os = "android" if script_args.android else "linux"
-  test_list_globals = {"target_os": target_os}
+  test_list_globals = {
+    "shell_path": config.shell_path,
+    "target_os": target_os,
+  }
   exec script_args.test_list_file in test_list_globals
   test_list = test_list_globals["tests"]
 
diff --git a/mojo/tools/data/fusl_apptests b/mojo/tools/data/fusl_apptests
new file mode 100644
index 0000000..4f15319
--- /dev/null
+++ b/mojo/tools/data/fusl_apptests
@@ -0,0 +1,88 @@
+# This file contains a list of fusl-backed Mojo apptests to run. For
+# description of the file format, see `mojo_test` in devtools.
+
+# TODO(kulakowski) Figure out how to deduplicate app tests. There's no
+# particular reason to run against both the host glibc and fusl.
+
+import os.path
+
+_ORIGIN = os.path.join(os.path.dirname(shell_path), "fusl_x64")
+_ORIGIN_ARG = "--origin=file://" + _ORIGIN
+
+tests = [
+  {
+    "test": "mojo:asset_bundle_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:authenticating_url_loader_interceptor_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:benchmark_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:clipboard_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:example_apptests",
+    # ExampleApplicationTest.CheckCommandLineArg checks --example_apptest_arg.
+    "shell-args": [ _ORIGIN_ARG ],
+    "test-args": ["--example_apptest_arg"],
+  },
+  {
+    "test": "mojo:example_apptests",
+    "name": "mojo:example_apptests (multiprocess)",
+    # ExampleApplicationTest.CheckCommandLineArg checks --example_apptest_arg.
+    "test-args": ["--example_apptest_arg"],
+    "shell-args": [
+      _ORIGIN_ARG,
+      "--enable-multiprocess"
+    ],
+  },
+  {
+    "test": "mojo:files_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:http_server_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:log_impl_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:moterm_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:prediction_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+    "test": "mojo:url_response_disk_cache_apptests",
+    "shell-args": [ _ORIGIN_ARG ],
+  },
+  {
+  "test": "mojo:example_apptests",
+    "name": "mojo:example_apptests (python_example_service)",
+    # ExampleApplicationTest.CheckCommandLineArg checks --example_apptest_arg.
+    "test-args": ["--example_apptest_arg"],
+    "shell-args": [
+      "--url-mappings=mojo:example_service=mojo:python_example_service",
+      _ORIGIN_ARG,
+    ],
+  },
+  {
+  "test": "mojo:mojo_url_redirector_apptests",
+    "test-args": ["--redirector_port=49152",
+                  "--app_location_files_port=49153"],
+    "shell-args": [
+      "--args-for=mojo:mojo_url_redirector 0.0.0.0:49152 http://localhost:49153",
+      _ORIGIN_ARG,
+    ],
+  }
+]
diff --git a/mojo/tools/get_test_list.py b/mojo/tools/get_test_list.py
index 73c7d3f..f8ea8ca 100755
--- a/mojo/tools/get_test_list.py
+++ b/mojo/tools/get_test_list.py
@@ -100,6 +100,12 @@
                  [os.path.join("mojo", "tools", "apptest_runner.py"),
                   os.path.join("mojo", "tools", "data", "apptests"),
                   build_dir] + verbose_flags)
+    # Fusl app tests (Linux excluding Android):
+    if (target_os == Config.OS_LINUX):
+      AddXvfbEntry("Fusl app tests",
+                   [os.path.join("mojo", "tools", "apptest_runner.py"),
+                    os.path.join("mojo", "tools", "data", "fusl_apptests"),
+                    build_dir] + verbose_flags)
     # Non-SFI NaCl app tests (Linux including Android, no asan):
     if config.sanitizer != Config.SANITIZER_ASAN:
       AddXvfbEntry("Non-SFI NaCl App tests",
diff --git a/services/icu_data/BUILD.gn b/services/icu_data/BUILD.gn
index bac2851..094f32c 100644
--- a/services/icu_data/BUILD.gn
+++ b/services/icu_data/BUILD.gn
@@ -7,7 +7,7 @@
 import("//mojo/tools/embed/rules.gni")
 
 embed_file("embed_icu_data") {
-  source = "$root_build_dir/icudtl.dat"
+  source = "$root_out_dir/icudtl.dat"
   namespace = "icu_data"
   variable = "kICUData"
 
@@ -22,11 +22,11 @@
   ]
 
   deps = [
+    ":embed_icu_data",
     "//base",
     "//mojo/application",
     "//mojo/common",
     "//mojo/environment:chromium",
     "//mojo/services/icu_data/interfaces",
-    ":embed_icu_data",
   ]
 }