aboutsummaryrefslogtreecommitdiff
path: root/host
diff options
context:
space:
mode:
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 << "\"";