aboutsummaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
authorSergio Andres Rodriguez Orama <sorama@google.com>2024-06-20 16:06:24 -0400
committerSergio Andres Rodriguez Orama <sorama@google.com>2024-06-20 16:12:47 -0400
commit574251acd571cd740cbee9339c8f9bd52f992171 (patch)
treee99489d65eff8126050698f9d178516077a6eac2 /host
parent7256207ed2c4894cb9da960d0d1947473efeed70 (diff)
downloadcuttlefish-574251acd571cd740cbee9339c8f9bd52f992171.tar.gz
Collect netsimd logs with `cvd host_bugreport`.
Bug: 341905936 Test: cvd host_bugreport Change-Id: I23bf96bc46d79b78adbe7e87483d8ba5dbcbd8d5
Diffstat (limited to 'host')
-rw-r--r--host/commands/host_bugreport/main.cc24
1 files changed, 24 insertions, 0 deletions
diff --git a/host/commands/host_bugreport/main.cc b/host/commands/host_bugreport/main.cc
index 071e08698..fc68c41eb 100644
--- a/host/commands/host_bugreport/main.cc
+++ b/host/commands/host_bugreport/main.cc
@@ -48,6 +48,28 @@ void SaveFile(ZipWriter& writer, const std::string& zip_path,
}
}
+Result<void> AddNetsimdLogs(ZipWriter& writer) {
+ // The temp directory name depends on whether the `USER` environment variable
+ // is defined.
+ // https://source.corp.google.com/h/googleplex-android/platform/superproject/main/+/main:tools/netsim/rust/common/src/system/mod.rs;l=37-57;drc=360ddb57df49472a40275b125bb56af2a65395c7
+ std::string user = StringFromEnv("USER", "");
+ std::string dir = user.empty() ? "/tmp/android/netsimd"
+ : fmt::format("/tmp/android-{}/netsimd", user);
+ if (!DirectoryExists(dir)) {
+ LOG(INFO) << "netsimd logs directory: `" << dir << "` does not exist.";
+ return {};
+ }
+ auto names =
+ CF_EXPECTF(DirectoryContents(dir), "Cannot read from {} directory.", dir);
+ for (const auto& name : names) {
+ if (name == "." || name == "..") {
+ continue;
+ }
+ SaveFile(writer, "netsimd/" + name, dir + "/" + name);
+ }
+ return {};
+}
+
Result<void> CvdHostBugreportMain(int argc, char** argv) {
::android::base::InitLogging(argv, android::base::StderrLogger);
google::ParseCommandLineFlags(&argc, &argv, true);
@@ -108,6 +130,8 @@ Result<void> CvdHostBugreportMain(int argc, char** argv) {
}
}
+ CF_EXPECT(AddNetsimdLogs(writer));
+
writer.Finish();
LOG(INFO) << "Saved to \"" << FLAGS_output << "\"";