message: Update test expectations to be robust to the presence of other "/host:CUPTI" XLines.
diff: @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
  limitations under the License.
  ==============================================================================*/
  +#include <array>
  #include <map>
  #include <memory>
  #include <string>
  @@ -382,10 +383,12 @@ TEST_F(DeviceTracerTest, CudaRuntimeResource) {
  ASSERT_NE(cupti_host_plane, nullptr);
  XPlaneVisitor host_plane = CreateTfXPlaneVisitor(cupti_host_plane);
  - EXPECT_EQ(host_plane.NumLines(), 1);
  + // Expect at least one XLine for CUPTI activity events. There may be an
  + // additional line for CuptiTracerEventType Overhead.
  + EXPECT_GE(host_plane.NumLines(), 1);
  // These follow the order in which they were invoked above.
  - const StatType expected_stat_type[] = {
  + const std::array<StatType, 4> expected_event_stat_type = {
  kMemallocDetails,
  kMemsetDetails,
  kMemcpyDetails,
  @@ -398,17 +401,20 @@ TEST_F(DeviceTracerTest, CudaRuntimeResource) {
  VLOG(3) << "Line " << line.Id() << "\n";
  line.ForEachEvent([&](const tensorflow::profiler::XEventVisitor& event) {
  VLOG(3) << " Event " << *event.Type() << "\n";
  +
  absl::optional<XStatVisitor> stat =
  - event.GetStat(expected_stat_type[event_idx]);
  - EXPECT_TRUE(stat.has_value());
  + event.GetStat(expected_event_stat_type[event_idx]);
  + // The stat may not exist if we're looking at the wrong line.
  + if (stat.has_value()) {
  + event_idx += 1;
  VLOG(3) << " Stat name=" << stat->Name() << " type=" << *stat->Type()
  << " " << stat->ToString() << "\n";
  - event_idx += 1;
  + }
  });
  });
  - // One host side event for each API call.
  - EXPECT_EQ(event_idx, 4);
  + // Expect that all stats show up. One host side event for each API call.
  + EXPECT_EQ(event_idx, expected_event_stat_type.size());
  const XPlane* cupti_device_plane = FindPlaneWithName(space, GpuPlaneName(0));
  ASSERT_NE(cupti_device_plane, nullptr);
  