pw_rpc: Build integration test binaries by default

- For host toolchains, build the integration tests by default, but do
  not execute them. As before, these can be executed by running the
  integration_tests GN target.
- Fix a few clang-tidy issues in integration test binaries.

Change-Id: I4404b351c3bf0588afedb34d5fd2ec0f7d6be346
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126253
Reviewed-by: Erik Gilling <konkers@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/BUILD.gn b/BUILD.gn
index acd6fd1..78f1c4d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -418,10 +418,21 @@
     # Add target-specific images.
     deps += pw_TARGET_APPLICATIONS
 
-    # Add the pw_tool target to be built on host.
+    # Add host-only targets to the build.
     if (defined(pw_toolchain_SCOPE.is_host_toolchain) &&
         pw_toolchain_SCOPE.is_host_toolchain) {
       deps += [ "$dir_pw_tool" ]
+
+      # TODO(b/240982565): Build integration tests on Windows and macOS when
+      #     SocketStream supports those platforms.
+      if (host_os == "linux") {
+        # Build the integration test binaries, but don't run them by default.
+        deps += [
+          "$dir_pw_rpc:client_integration_test",
+          "$dir_pw_rpc:test_rpc_server",
+          "$dir_pw_unit_test:test_rpc_server",
+        ]
+      }
     }
   }
 
diff --git a/pw_rpc/nanopb/client_integration_test.cc b/pw_rpc/nanopb/client_integration_test.cc
index 07d3ca9..6163ba7 100644
--- a/pw_rpc/nanopb/client_integration_test.cc
+++ b/pw_rpc/nanopb/client_integration_test.cc
@@ -114,6 +114,7 @@
     pw::rpc::NanopbClientReaderWriter<pw_rpc_Payload, pw_rpc_Payload> new_call =
         std::move(call);
 
+    // NOLINTNEXTLINE(bugprone-use-after-move)
     EXPECT_EQ(Status::FailedPrecondition(), call.Write(Payload("Dello")));
 
     ASSERT_EQ(OkStatus(), new_call.Write(Payload("Dello")));
@@ -121,6 +122,7 @@
 
     call = std::move(new_call);
 
+    // NOLINTNEXTLINE(bugprone-use-after-move)
     EXPECT_EQ(Status::FailedPrecondition(), new_call.Write(Payload("Dello")));
 
     ASSERT_EQ(OkStatus(), call.Write(Payload("???")));
diff --git a/pw_rpc/public/pw_rpc/integration_test_socket_client.h b/pw_rpc/public/pw_rpc/integration_test_socket_client.h
index 2d4ba0d..f884787 100644
--- a/pw_rpc/public/pw_rpc/integration_test_socket_client.h
+++ b/pw_rpc/public/pw_rpc/integration_test_socket_client.h
@@ -148,7 +148,7 @@
       return;
     }
 
-    if (!read.ok() || read->size() == 0u) {
+    if (!read.ok() || read->empty()) {
       continue;
     }
 
diff --git a/pw_rpc/pwpb/client_integration_test.cc b/pw_rpc/pwpb/client_integration_test.cc
index e0d55bf..af5bfc7 100644
--- a/pw_rpc/pwpb/client_integration_test.cc
+++ b/pw_rpc/pwpb/client_integration_test.cc
@@ -117,6 +117,7 @@
                                     pw::rpc::Payload::Message>
         new_call = std::move(call);
 
+    // NOLINTNEXTLINE(bugprone-use-after-move)
     EXPECT_EQ(Status::FailedPrecondition(), call.Write(Payload("Dello")));
 
     ASSERT_EQ(OkStatus(), new_call.Write(Payload("Dello")));
@@ -124,6 +125,7 @@
 
     call = std::move(new_call);
 
+    // NOLINTNEXTLINE(bugprone-use-after-move)
     EXPECT_EQ(Status::FailedPrecondition(), new_call.Write(Payload("Dello")));
 
     ASSERT_EQ(OkStatus(), call.Write(Payload("???")));
diff --git a/targets/host/system_rpc_server.cc b/targets/host/system_rpc_server.cc
index 6de5567..f3d870f 100644
--- a/targets/host/system_rpc_server.cc
+++ b/targets/host/system_rpc_server.cc
@@ -53,7 +53,7 @@
 void Init() {
   log_basic::SetOutput([](std::string_view log) {
     std::fprintf(stderr, "%.*s\n", static_cast<int>(log.size()), log.data());
-    hdlc::WriteUIFrame(1, as_bytes(span(log)), socket_stream)
+    hdlc::WriteUIFrame(1, as_bytes(span<const char>(log)), socket_stream)
         .IgnoreError();  // TODO(b/242598609): Handle Status properly
   });