Improve starter_test stability
If the timing was wrong, we'd query the process name *immediately* after
the fork(), and then never fix it. Instead:
(a) Update the name if it ever changes; and
(b) Make the test ensure that it gives time for a second reading to
happen before checking the process_info.
Additionally, there was a race condition in making the calls to
Cleanup() in the tests. Move that call into the same thread as
the rest of the starter work.
Change-Id: I6992ab64a4eae51e3a9b41b84cdb0a49bd0c8ad3
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/util/top.cc b/aos/util/top.cc
index 4882af7..8a0019d 100644
--- a/aos/util/top.cc
+++ b/aos/util/top.cc
@@ -195,6 +195,11 @@
process.start_time = start_time;
process.readings.Reset();
}
+ // If the process name has changed (e.g., if our first reading for a process
+ // name occurred before execvp was called), then update it.
+ if (process.name != proc_stat->name) {
+ process.name = proc_stat->name;
+ }
process.readings.Push(Reading{now, TotalProcessTime(*proc_stat),
RealMemoryUsage(*proc_stat)});