Revert "strerror: incl enum name"
Revert submission 1833622-usable-strerror
Reason for revert: b/202330586
Bug: 202330586
Reverted Changes:
I4d8f617a0:Track strerror(3) change.
I8ea86220c:strerror: incl enum name
I407bd9f4d:strerror: incl enum name
Change-Id: I81ed563221a77827084711eadd7fb739aeba52a1
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index cf8cb0a..e38dd60 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -2461,7 +2461,7 @@
ASSERT_STREQ("<Unknown error -1>", buf);
errno = EINVAL;
snprintf(buf, sizeof(buf), "<%m>");
- ASSERT_MATCH(buf, "<Invalid argument.*>");
+ ASSERT_STREQ("<Invalid argument>", buf);
}
TEST(STDIO_TEST, printf_m_does_not_clobber_strerror) {
@@ -2484,7 +2484,7 @@
ASSERT_EQ(std::wstring(L"<Unknown error -1>"), buf);
errno = EINVAL;
swprintf(buf, sizeof(buf), L"<%m>");
- ASSERT_MATCH(buf, L"Invalid argument.*>");
+ ASSERT_EQ(std::wstring(L"<Invalid argument>"), buf);
}
TEST(STDIO_TEST, wprintf_m_does_not_clobber_strerror) {
@@ -2558,9 +2558,9 @@
TEST(STDIO_TEST, perror) {
ExecTestHelper eth;
- eth.Run([&]() { errno = EINVAL; perror("a b c"); exit(0); }, 0, "a b c: Invalid argument.*\n");
- eth.Run([&]() { errno = EINVAL; perror(nullptr); exit(0); }, 0, "Invalid argument.*\n");
- eth.Run([&]() { errno = EINVAL; perror(""); exit(0); }, 0, "Invalid argument.*\n");
+ eth.Run([&]() { errno = EINVAL; perror("a b c"); exit(0); }, 0, "a b c: Invalid argument\n");
+ eth.Run([&]() { errno = EINVAL; perror(nullptr); exit(0); }, 0, "Invalid argument\n");
+ eth.Run([&]() { errno = EINVAL; perror(""); exit(0); }, 0, "Invalid argument\n");
}
TEST(STDIO_TEST, puts) {
diff --git a/tests/string_posix_strerror_r_test.cpp b/tests/string_posix_strerror_r_test.cpp
index 808f963..e4becaa 100644
--- a/tests/string_posix_strerror_r_test.cpp
+++ b/tests/string_posix_strerror_r_test.cpp
@@ -15,8 +15,6 @@
*/
#include <errno.h>
-
-#include <android-base/test_utils.h>
#include <gtest/gtest.h>
// Defined in string_posix_strerror_r_wrapper.cpp as a wrapper around the posix
@@ -35,7 +33,7 @@
ASSERT_STREQ("Success", buf);
#endif
ASSERT_EQ(0, posix_strerror_r(1, buf, sizeof(buf)));
- ASSERT_MATCH(buf, "Operation not permitted.*");
+ ASSERT_STREQ("Operation not permitted", buf);
#if defined(__BIONIC__) || defined(ANDROID_HOST_MUSL)
// Invalid.
diff --git a/tests/string_test.cpp b/tests/string_test.cpp
index 1b0082f..8d3fb68 100644
--- a/tests/string_test.cpp
+++ b/tests/string_test.cpp
@@ -28,8 +28,6 @@
#include <algorithm>
#include <vector>
-#include <android-base/test_utils.h>
-
#include "buffer_tests.h"
#if defined(NOFORTIFY)
@@ -60,7 +58,7 @@
TEST(STRING_TEST, strerror) {
// Valid.
ASSERT_STREQ("Success", strerror(0));
- ASSERT_MATCH(strerror(1), "Operation not permitted.*");
+ ASSERT_STREQ("Operation not permitted", strerror(1));
// Invalid.
ASSERT_STREQ("Unknown error -1", strerror(-1));
@@ -108,9 +106,9 @@
#if defined(__BIONIC__)
ASSERT_STREQ("Success", buf);
#endif
- ASSERT_MATCH(strerror_r(1, buf, sizeof(buf)), "Operation not permitted.*");
+ ASSERT_STREQ("Operation not permitted", strerror_r(1, buf, sizeof(buf)));
#if defined(__BIONIC__)
- ASSERT_MATCH(buf, "Operation not permitted.*");
+ ASSERT_STREQ("Operation not permitted", buf);
#endif
// Invalid.
diff --git a/tests/utils.h b/tests/utils.h
index 90fb1d0..284140a 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -44,7 +44,6 @@
#include <android-base/macros.h>
#include <android-base/scopeguard.h>
#include <android-base/stringprintf.h>
-#include <android-base/test_utils.h>
#if defined(__LP64__)
#define PATH_TO_SYSTEM_LIB "/system/lib64/"
@@ -260,7 +259,9 @@
std::string error_msg("Test output:\n" + output_);
AssertChildExited(pid, expected_exit_status, &error_msg);
if (expected_output_regex != nullptr) {
- ASSERT_MATCH(output_, expected_output_regex);
+ if (!std::regex_search(output_, std::regex(expected_output_regex))) {
+ FAIL() << "regex " << expected_output_regex << " didn't match " << output_;
+ }
}
}