[femu] Update run_vdl_test.sh to correctly fail if a test fails.

Skipped failing tests.

Example run: https://ci.chromium.org/swarming/task/525794618bd3f810?server=chromium-swarm.appspot.com

Bug: https://github.com/flutter/flutter/issues/78277

Change-Id: I856771d9eee2045d60c467f6ead1e83fd93a903e
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/11104
Commit-Queue: Yuan Zhi <yuanzhi@google.com>
Reviewed-by: Godofredo Contreras <godofredoc@google.com>
Reviewed-by: David Worsham <dworsham@google.com>
diff --git a/recipes/femu_test.expected/start_femu_with_vdl.json b/recipes/femu_test.expected/start_femu_with_vdl.json
index 5839f83..70fc054 100644
--- a/recipes/femu_test.expected/start_femu_with_vdl.json
+++ b/recipes/femu_test.expected/start_femu_with_vdl.json
@@ -556,7 +556,7 @@
       "-root",
       "[CACHE]/builder/vdl",
       "-ensure-file",
-      "fuchsia/vdl/${platform} g3-revision:vdl_fuchsia_20201002_RC00",
+      "fuchsia/vdl/${platform} g3-revision:vdl_fuchsia_20210316_RC00",
       "-max-threads",
       "0",
       "-json-output",
diff --git a/recipes/femu_test.py b/recipes/femu_test.py
index 9f4c3d0..b6f0566 100644
--- a/recipes/femu_test.py
+++ b/recipes/femu_test.py
@@ -103,7 +103,7 @@
     )
 
   def addVDLFiles():
-    vdl_version = api.properties.get('vdl_version', 'g3-revision:vdl_fuchsia_20201002_RC00')
+    vdl_version = api.properties.get('vdl_version', 'g3-revision:vdl_fuchsia_20210316_RC00')
     api.vdl.set_vdl_cipd_tag(tag=str(vdl_version))
     add(api.vdl.vdl_path, 'device_launcher')
     add(api.vdl.aemu_dir, 'aemu')
@@ -182,9 +182,29 @@
       'fml_tests':
           '--gtest_filter=-MessageLoop.TimeSensistiveTest_*:FileTest.CanTruncateAndWrite:FileTest.CreateDirectoryStructure',
       'shell_tests':
-          '--gtest_filter=-ShellTest.ReportTimingsIsCalledLaterInReleaseMode:ShellTest.ReportTimingsIsCalledSoonerInNonReleaseMode',
+          (
+              '--gtest_filter=-'
+              'ShellTest.ReportTimingsIsCalledLaterInReleaseMode:'
+              'ShellTest.ReportTimingsIsCalledSoonerInNonReleaseMode:'
+              'ShellTest.CacheSkSLWorks:'
+              'ShellTest.FrameRasterizedCallbackIsCalled:'
+              'ShellTest.ExternalEmbedderNoThreadMerger:'
+              'ShellTest.OnPlatformViewDestroyWithoutRasterThreadMerger:'
+              'ShellTest.ReportTimingsIsCalledImmediatelyAfterTheFirstFrame:'
+              'ShellTest.DisallowedDartVMFlag:'
+              'ShellTest.SetResourceCacheSize:'
+              'ShellTest.SetResourceCacheSizeEarly:'
+              'ShellTest.SetResourceCacheSizeNotifiesDart:'
+              'ShellTest.Screenshot:'
+              'ShellTest.RasterizerScreenshot:'
+              'ShellTest.DiscardLayerTreeOnResize:'
+              'SkpWarmupTest.Basic:'
+              'SkpWarmupTest.Image:'
+              'FuchsiaShellTest.LocaltimesVaryOnTimezoneChanges'),
       'flutter_runner_scenic_tests':
           '--gtest_filter=-SessionConnectionTest.*:CalculateNextLatchPointTest.*',
+      'flutter_runner_tests':
+          '--gtest_filter=-EngineTest.SkpWarmup',
   }
   flutter_tests, root_dir, isolated_hash = IsolateSymlink(api)
   cmd = ['./run_vdl_test.sh']
diff --git a/recipes/femu_test.resources/run_vdl_test.sh b/recipes/femu_test.resources/run_vdl_test.sh
index 11c8cc7..e8d7117 100644
--- a/recipes/femu_test.resources/run_vdl_test.sh
+++ b/recipes/femu_test.resources/run_vdl_test.sh
@@ -107,34 +107,50 @@
 readonly PORT_MAP="hostfwd=tcp::${SSH_PORT}-:22"
 readonly VDL_PROTO=$(mktemp -p "${PWD}")
 
-# Make sure --action=kill gets called even if --action=start errored.
 set +e
 
+shutdown() {
+  # Make sure --action=kill gets called even if --action=start errored.
+  # Stop the emulator
+  log "Stopping virtual device."
+  "./${VDL_LOCATION}" \
+    --action=kill \
+    --ga=true \
+    --launched_virtual_device_proto="${VDL_PROTO}"
+
+  VDL_STOP_EXIT_CODE=$?
+
+  if [[ ${VDL_STOP_EXIT_CODE} == 0 ]]; then
+    log "Stopped virtual device."
+  else
+    log "Stopping virutal device errored, this is usually fine. Exit code ${VDL_STOP_EXIT_CODE}"
+  fi
+}
+trap shutdown EXIT
+
 log "Launching virtual device using VDL."
 "./${VDL_LOCATION}" "${VDL_ARGS[@]}" \
   --action=start \
   --ga=true \
+  --event_action="flutter_infra" \
   --host_port_map="${PORT_MAP}" \
   --output_launched_device_proto="${VDL_PROTO}" > "${EMULATOR_LOG}" \
   --grpc_port="${GRPC_PORT}"
 
 _LAUNCH_EXIT_CODE=$?
-_TEST_EXIT_CODE=0
+err_codes=()
 
 if [[ ${_LAUNCH_EXIT_CODE} == 0 ]]; then
   log "Successfully launched virtual device proto ${VDL_PROTO}"
   ssh_to_guest "log_listener" >"${SYSLOG}" 2>&1 &
 
-  # Debug info to makesure fvm resizing worked.
-  ssh_to_guest lsblk
-
   for target in "${RUN_TESTS[@]}"; do
     ssh_to_guest "run-test-component fuchsia-pkg://fuchsia.com/${target}#meta/${target}.cmx ${TEST_ARGS}"
     _EXIT_CODE=$?
     if [[ ${_EXIT_CODE} == 0 ]]; then
       log "${target} Passed"
     else
-      _TEST_EXIT_CODE=${_EXIT_CODE}
+      err_codes+=(${_EXIT_CODE})
       log "${target} Failed with exit code ${_EXIT_CODE}"
     fi
   done
@@ -142,20 +158,8 @@
   log "Failed to launch virtual device. Exit code ${_LAUNCH_EXIT_CODE}"
 fi
 
-# Stop the emulator
-log "Stopping virtual device."
-
-"./${VDL_LOCATION}" \
-  --action=kill \
-  --ga=true \
-  --launched_virtual_device_proto="${VDL_PROTO}"
-
-VDL_STOP_EXIT_CODE=$?
-
-if [[ ${VDL_STOP_EXIT_CODE} == 0 ]]; then
-  log "Stopped virtual device."
-else
-  log "Failed to stop virtual device. Exit code ${VDL_STOP_EXIT_CODE}"
+if [[ ${err_codes[@]} ]]; then
+  log "Has test fails" 
+  exit 1
 fi
-
-exit ${_LAUNCH_EXIT_CODE} && ${_TEST_EXIT_CODE} && ${VDL_STOP_EXIT_CODE}
+exit 0