Apply the timeout multiplier to all the tests. am: 1ccdf7cd3b am: e7172249d5 am: 63f3c45d10

Original change: https://android-review.googlesource.com/c/platform/system/logging/+/2863766

Change-Id: I54e0dcb28ab860eef627032fdb401696776c3ffd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/liblog/tests/liblog_benchmark.cpp b/liblog/tests/liblog_benchmark.cpp
index 8a7dae6..6dc5da6 100644
--- a/liblog/tests/liblog_benchmark.cpp
+++ b/liblog/tests/liblog_benchmark.cpp
@@ -35,6 +35,8 @@
 #include <log/log_read.h>
 #include <private/android_logger.h>
 
+#include "test_utils.h"
+
 size_t convertPrintable(char*, const char*, size_t);
 
 BENCHMARK_MAIN();
@@ -636,7 +638,7 @@
   return l;
 }
 
-static const int alarm_time = 3;
+static const int alarm_time = getAlarmSeconds(3);
 
 /*
  *	Measure the time it takes for the logd posting call to acquire the
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index 501f25d..cde5a5b 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -46,6 +46,8 @@
 #include <private/android_filesystem_config.h>
 #include <private/android_logger.h>
 
+#include "test_utils.h"
+
 using android::base::make_scope_guard;
 
 // #define ENABLE_FLAKY_TESTS
@@ -70,12 +72,6 @@
   void operator()(struct logger_list* list) { android_logger_list_close(list); }
 };
 
-// Devices can set a system property indicating a slower device, giving a
-// multiplier to use for timeouts.  If the device has set this property, we use it.
-static unsigned int getAlarmSeconds(unsigned int seconds) {
-  return seconds * android::base::GetIntProperty("ro.hw_timeout_multiplier", 1);
-}
-
 // This function is meant to be used for most log tests, it does the following:
 // 1) Open the log_buffer with a blocking reader
 // 2) Write the messages via write_messages
diff --git a/liblog/tests/log_wrap_test.cpp b/liblog/tests/log_wrap_test.cpp
index 891ceb7..1373c2a 100644
--- a/liblog/tests/log_wrap_test.cpp
+++ b/liblog/tests/log_wrap_test.cpp
@@ -28,6 +28,8 @@
 #include <log/log_read.h>
 #include <log/log_time.h>
 
+#include "test_utils.h"
+
 #ifdef __ANDROID__
 static void read_with_wrap() {
   // Read the last line in the log to get a starting timestamp. We're assuming
@@ -68,7 +70,7 @@
   struct sigaction ignore = {.sa_handler = [](int) { _exit(0); }};
   struct sigaction old_sigaction;
   sigaction(SIGALRM, &ignore, &old_sigaction);
-  alarm(10);
+  alarm(getAlarmSeconds(5));
 
   android::base::Timer timer;
   read_with_wrap();
diff --git a/liblog/tests/test_utils.h b/liblog/tests/test_utils.h
new file mode 100644
index 0000000..ee1668a
--- /dev/null
+++ b/liblog/tests/test_utils.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <android-base/properties.h>
+
+// Devices can set a system property indicating a slower device, giving a
+// multiplier to use for timeouts.  If the device has set this property, we use it.
+static unsigned int getAlarmSeconds(unsigned int seconds) {
+  return seconds * android::base::GetIntProperty("ro.hw_timeout_multiplier", 1);
+}