Update all tests & roll Bazel SDK.

Squash of commits fxrev.dev/668923, fxrev.dev/669647, and
fxrev.dev/669649.

Change-Id: Ic9cf230dfceb7c6caa43c24c0d9818651a07e215
Reviewed-on: https://fuchsia-review.googlesource.com/c/sdk-samples/getting-started/+/672644
Reviewed-by: Kyo Lee <kyol@google.com>
Reviewed-by: Renato Mangini Dias <mangini@google.com>
diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel
index e4d149e..326cd26 100644
--- a/WORKSPACE.bazel
+++ b/WORKSPACE.bazel
@@ -3,17 +3,19 @@
 # found in the LICENSE file.
 
 load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
-
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
 http_archive(
-   name = "bazel_skylib",
-   urls = [
-       "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
-       "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
-   ],
-   sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
+    name = "bazel_skylib",
+    sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
+    urls = [
+        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
+        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
+    ],
 )
+
 load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
+
 bazel_skylib_workspace()
 
 load("@bazel_skylib//lib:versions.bzl", "versions")
@@ -22,13 +24,13 @@
 
 git_repository(
     name = "rules_fuchsia",
+    commit = "702a1c7b5930fc07d257e0543b8c3f661564d752",
+    patch_cmds = [
+        "rm -R tools",
+        "mv bazel_rules_fuchsia/* .",
+    ],
     remote = "https://fuchsia.googlesource.com/sdk-integration",
-
-    # branch = "sandbox/training_1",
-    commit = "3dbe6ec5f41ae68e14a7f78a7af8cc4779491632",
-    shallow_since = "1649982637 +0000",
-
-    patch_cmds = ["rm -R tools", "mv bazel_rules_fuchsia/* ."],
+    shallow_since = "1650929135 +0000",
 )
 
 load(
@@ -53,11 +55,11 @@
 
 fuchsia_clang_repository(
     name = "fuchsia_clang",
-    cipd_tag = "git_revision:c9e46219f38da5c3fbfe41012173dc893516826e",
+    cipd_tag = "git_revision:ec2de7490813a7593dad59f210c7ec41f1a29002",
     sdk_root_label = "@fuchsia_sdk",
     sha256 = {
-        "linux": "573ebb62fc5cd9d2357be630cc079fa97b028cd99e2e87132dcd8be31c425984",
-        "mac": "fb9e478d18f35d0a9bb186138a85cf7ef5f9078fbf432fc3ad8f0660b233b3b4",
+        "linux": "1a4ee70190a4e39c2804baa26c9aa58231a1ea67e16a5c5adc1dde2d7bada728",
+        "mac": "a5c681756e4f3db058ff451758962f9544f5993af38975c944eb82309222ce4f",
     },
 )
 
@@ -66,4 +68,3 @@
     name = "com_google_googletest",
     path = "third_party/googletest",
 )
-
diff --git a/src/echo/BUILD.bazel b/src/echo/BUILD.bazel
index 89f76f6..1a22a64 100644
--- a/src/echo/BUILD.bazel
+++ b/src/echo/BUILD.bazel
@@ -6,10 +6,12 @@
 load(
     "@rules_fuchsia//fuchsia:defs.bzl",
     "fuchsia_cc_binary",
+    "fuchsia_cc_test",
     "fuchsia_component",
     "fuchsia_component_manifest",
     "fuchsia_package",
-    "fuchsia_test_component",
+    "fuchsia_test_package",
+    "if_fuchsia",
 )
 #[END imports]
 
@@ -32,10 +34,9 @@
     src = "meta/echo.cml",
     component_name = "echo",
     includes = [
-      "@fuchsia_sdk//pkg/syslog:client",
-      "@fuchsia_sdk//pkg/syslog:elf_stdio",
+        "@fuchsia_sdk//pkg/syslog:client",
+        "@fuchsia_sdk//pkg/syslog:elf_stdio",
     ],
-
 )
 
 fuchsia_component(
@@ -57,7 +58,7 @@
 #[END echo]
 
 #[START unittest]
-cc_test(
+fuchsia_cc_test(
     name = "echo_unittests",
     size = "small",
     srcs = [
@@ -66,40 +67,19 @@
         "echo_unittest.cc",
     ],
     visibility = ["//visibility:public"],
-    deps = [
-        "@com_google_googletest//:gtest_main",
+    deps = ["@com_google_googletest//:gtest_main"] + if_fuchsia([
         "@fuchsia_sdk//pkg/fdio",
         "@fuchsia_sdk//pkg/sys_cpp",
         "@fuchsia_sdk//pkg/syslog",
-    ],
+    ]),
 )
 
-filegroup(
-    name = "common_libs",
-    srcs = [
-        "@fuchsia_sdk//:arch/x64/sysroot/dist/lib/ld.so.1",
-    ],
-    visibility = ["//visibility:public"],
-)
-
-fuchsia_test_component(
-    name = "echo_unittest_component",
-    test_name = "echo_unittests",
-    visibility = ["//visibility:public"],
-    deps = [
-        ":common_libs",
-        ":echo_unittests",
-        "@fuchsia_clang//:dist",
-    ],
-)
-
-fuchsia_package(
+fuchsia_test_package(
     name = "test_pkg",
     package_name = "echo_unittests",
-    testonly = True,
     visibility = ["//visibility:public"],
     deps = [
-        ":echo_unittest_component",
+        ":echo_unittests",
     ],
 )
 #[END unittest]
diff --git a/src/hello_world/BUILD.bazel b/src/hello_world/BUILD.bazel
index cbf3e47..38eafeb 100644
--- a/src/hello_world/BUILD.bazel
+++ b/src/hello_world/BUILD.bazel
@@ -1,10 +1,16 @@
+# Copyright 2022 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
 load(
     "@rules_fuchsia//fuchsia:defs.bzl",
     "fuchsia_cc_binary",
+    "fuchsia_cc_test",
     "fuchsia_component",
     "fuchsia_component_manifest",
     "fuchsia_package",
-    "fuchsia_test_component",
+    "fuchsia_test_package",
+    "if_fuchsia",
 )
 
 fuchsia_cc_binary(
@@ -39,76 +45,32 @@
     ],
 )
 
-cc_test(
-    name = "host_test",
-    size = "small",
-    srcs = ["hello_test.cc"],
-)
-
-cc_test(
+fuchsia_cc_test(
     name = "hello_test",
     size = "small",
     srcs = ["hello_test.cc"],
-    deps = [
+    deps = if_fuchsia([
         "@fuchsia_sdk//pkg/fdio",
         "@fuchsia_sdk//pkg/syslog",
-    ],
+    ]),
 )
 
-cc_test(
-    name = "host_gtest",
-    size = "small",
-    srcs = ["hello_gtest.cc"],
-    deps = ["@com_google_googletest//:gtest_main"],
-)
-
-cc_test(
+fuchsia_cc_test(
     name = "hello_gtest",
     size = "small",
     srcs = ["hello_gtest.cc"],
-    deps = [
-        "@com_google_googletest//:gtest_main",
+    deps = ["@com_google_googletest//:gtest_main"] + if_fuchsia([
         "@fuchsia_sdk//pkg/fdio",
         "@fuchsia_sdk//pkg/syslog",
-    ],
+    ]),
 )
 
-filegroup(
-    name = "common_libs",
-    srcs = [
-        "@fuchsia_sdk//:arch/x64/sysroot/dist/lib/ld.so.1",
-    ],
-    visibility = ["//visibility:public"],
-)
-
-fuchsia_test_component(
-    name = "test_component",
-    is_gtest = False,
-    test_name = "hello_test",
-    deps = [
-        ":common_libs",
-        ":hello_test",
-        "@fuchsia_clang//:dist",
-    ],
-)
-
-fuchsia_test_component(
-    name = "gtest_component",
-    test_name = "hello_gtest",
-    deps = [
-        ":common_libs",
-        ":hello_gtest",
-        "@fuchsia_clang//:dist",
-    ],
-)
-
-fuchsia_package(
+fuchsia_test_package(
     name = "test_pkg",
     package_name = "hello_test",
-    testonly = True,
     visibility = ["//visibility:public"],
     deps = [
-        ":gtest_component",
-        ":test_component",
+        ":hello_gtest",
+        ":hello_test",
     ],
 )
diff --git a/src/hello_world/hello_gtest.cc b/src/hello_world/hello_gtest.cc
index 1285109..bec8255 100644
--- a/src/hello_world/hello_gtest.cc
+++ b/src/hello_world/hello_gtest.cc
@@ -4,9 +4,12 @@
 
 #include <gtest/gtest.h>
 
+#include <iostream>
+
 // Demonstrate some basic assertions.
-TEST(HelloTest, BasicAssertions)
-{
+TEST(HelloTest, BasicAssertions) {
+  std::cout << "Example stdout." << std::endl;
+
   // Expect two strings not to be equal.
   EXPECT_STRNE("hello", "world");
   // Expect equality.
diff --git a/src/hello_world/hello_test.cc b/src/hello_world/hello_test.cc
index 0fb23e3..9b0d5c9 100644
--- a/src/hello_world/hello_test.cc
+++ b/src/hello_world/hello_test.cc
@@ -2,10 +2,21 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <assert.h>
+
 #include <iostream>
 
-int main()
-{
-  std::cout << "Hello Test!" << std::endl;
+// Demonstrate some basic assertions.
+int main() {
+  std::cout << "Example stdout." << std::endl;
+
+  // Expect two strings not to be equal.
+  std::string a("hello");
+  std::string b("world");
+  assert(a != b);
+
+  // Expect equality.
+  assert(7 * 6 == 42);
+
   return 0;
 }
diff --git a/src/hello_world/meta/hello_world.cml b/src/hello_world/meta/hello_world.cml
index f9492f3..95a37db 100644
--- a/src/hello_world/meta/hello_world.cml
+++ b/src/hello_world/meta/hello_world.cml
@@ -1,3 +1,7 @@
+// Copyright 2022 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
 {
     include: [ "syslog/client.shard.cml" ],
 
diff --git a/src/routing/BUILD.bazel b/src/routing/BUILD.bazel
index 228af76..1af7c07 100644
--- a/src/routing/BUILD.bazel
+++ b/src/routing/BUILD.bazel
@@ -8,7 +8,7 @@
     "fuchsia_component",
     "fuchsia_component_manifest",
     "fuchsia_package",
-    "fuchsia_test_component",
+    "fuchsia_test_package",
 )
 # [END imports]
 
@@ -23,9 +23,6 @@
     name = "echo_realm",
     component_name = "echo_realm",
     manifest = ":manifest",
-    visibility = ["//visibility:public"],
-    deps = [
-    ],
 )
 # [END component]
 
@@ -40,10 +37,9 @@
     ],
 )
 
-fuchsia_package(
+fuchsia_test_package(
     name = "test_pkg",
     package_name = "echo_integration_test",
-    testonly = True,
     visibility = ["//visibility:public"],
     deps = [
         "//src/routing/cpp/echo_server:echo_server_component",
diff --git a/src/routing/fidl/BUILD.bazel b/src/routing/fidl/BUILD.bazel
index 9a7a5f8..eec7609 100644
--- a/src/routing/fidl/BUILD.bazel
+++ b/src/routing/fidl/BUILD.bazel
@@ -1,7 +1,6 @@
 # Copyright 2022 The Fuchsia Authors. All rights reserved.
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
-package(default_visibility = ["//visibility:public"])
 
 load(
     "@rules_fuchsia//fuchsia:defs.bzl",
@@ -9,19 +8,19 @@
     "fuchsia_fidl_library",
 )
 
+package(default_visibility = ["//visibility:public"])
+
 fuchsia_fidl_library(
     name = "fidl.examples.routing.echo",
     srcs = [
         "echo.fidl",
     ],
     library = "fidl.examples.routing.echo",
-    visibility = ["//visibility:public"],
 )
 
 fuchsia_fidl_hlcpp_library(
     name = "fidl.examples.routing.echo.fidl_cc",
     library = ":fidl.examples.routing.echo",
-    visibility = ["//visibility:public"],
     deps = [
         "@fuchsia_sdk//pkg/fidl_cpp",
     ],
diff --git a/src/routing/integration_tests/BUILD.bazel b/src/routing/integration_tests/BUILD.bazel
index 49411c1..1185e0b 100644
--- a/src/routing/integration_tests/BUILD.bazel
+++ b/src/routing/integration_tests/BUILD.bazel
@@ -5,21 +5,16 @@
 # [START imports]
 load(
     "@rules_fuchsia//fuchsia:defs.bzl",
-    "fuchsia_cc_binary",
-    "fuchsia_component",
+    "fuchsia_cc_test",
     "fuchsia_component_manifest",
-    "fuchsia_package",
     "fuchsia_test_component",
 )
-
-package(default_visibility = ["//visibility:public"])
 # [END imports]
 
-cc_test(
+fuchsia_cc_test(
     name = "echo_integration_test",
     size = "small",
     srcs = ["echo_integration_test.cc"],
-    visibility = ["//visibility:public"],
     deps = [
         "//src/routing/fidl:fidl.examples.routing.echo.fidl_cc",
         "@com_google_googletest//:gtest_main",
@@ -34,34 +29,20 @@
 )
 
 # [START component]
-filegroup(
-    name = "common_libs",
-    srcs = [
-        "@fuchsia_sdk//:arch/x64/sysroot/dist/lib/ld.so.1",
-    ],
-    visibility = ["//visibility:public"],
-)
-
 fuchsia_component_manifest(
     name = "test_manifest",
     src = "meta/echo_integration_test.cml",
     component_name = "echo_integration_test_component",
     includes = [
-        "@fuchsia_sdk//pkg/syslog:client",
         "@fuchsia_sdk//pkg/sys/testing:elf_test_runner",
+        "@fuchsia_sdk//pkg/syslog:client",
     ],
-    visibility = ["//visibility:public"],
 )
 
 fuchsia_test_component(
     name = "echo_integration_test_component",
     manifest = ":test_manifest",
-    test_name = "echo_integration_test",
     visibility = ["//visibility:public"],
-    deps = [
-        ":common_libs",
-        ":echo_integration_test",
-        "@fuchsia_clang//:dist",
-    ],
+    deps = [":echo_integration_test"],
 )
 # [END component]