Change test 149 to run for 10 seconds
Run for a fixed 10 seconds to prevent timeouts on overloaded
machines.
Bug: 28988206
Change-Id: Ia40b8e61445ca0a6331668dc605401d1f69e4d17
diff --git a/test/149-suspend-all-stress/suspend_all.cc b/test/149-suspend-all-stress/suspend_all.cc
index 5d2be08..dfd944a 100644
--- a/test/149-suspend-all-stress/suspend_all.cc
+++ b/test/149-suspend-all-stress/suspend_all.cc
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include "base/time_utils.h"
#include "jni.h"
#include "runtime.h"
#include "thread_list.h"
@@ -22,7 +23,6 @@
extern "C" JNIEXPORT void JNICALL Java_Main_suspendAndResume(JNIEnv*, jclass) {
static constexpr size_t kInitialSleepUS = 100 * 1000; // 100ms.
- static constexpr size_t kIterations = 250;
usleep(kInitialSleepUS); // Leave some time for threads to get in here before we start suspending.
enum Operation {
kOPSuspendAll,
@@ -31,8 +31,11 @@
// Total number of operations.
kOPNumber,
};
- for (size_t i = 0; i < kIterations; ++i) {
- switch (static_cast<Operation>(i % kOPNumber)) {
+ const uint64_t start_time = NanoTime();
+ size_t iterations = 0;
+ // Run for a fixed period of 10 seconds.
+ while (NanoTime() - start_time < MsToNs(10 * 1000)) {
+ switch (static_cast<Operation>(iterations % kOPNumber)) {
case kOPSuspendAll: {
ScopedSuspendAll ssa(__FUNCTION__);
usleep(500);
@@ -52,7 +55,9 @@
case kOPNumber:
break;
}
+ ++iterations;
}
+ LOG(INFO) << "Did " << iterations << " iterations";
}
} // namespace art