[compiler-rt] 417f5bc - [NFC][sanitizer_common] Fix getpw_getgr.cpp test for large groups (#193625)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 22 16:49:10 PDT 2026
Author: Vitaly Buka
Date: 2026-04-22T23:49:05Z
New Revision: 417f5bc952962437bcd031e412d757f156d4fa64
URL: https://github.com/llvm/llvm-project/commit/417f5bc952962437bcd031e412d757f156d4fa64
DIFF: https://github.com/llvm/llvm-project/commit/417f5bc952962437bcd031e412d757f156d4fa64.diff
LOG: [NFC][sanitizer_common] Fix getpw_getgr.cpp test for large groups (#193625)
On my desktop buffer needs to be about 1MB.
Added:
Modified:
compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
Removed:
################################################################################
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
index 848774a8909bd..ad16da10a3b14 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
@@ -1,12 +1,15 @@
// RUN: %clangxx %s -o %t && %run %t
#include <assert.h>
+#include <errno.h>
#include <grp.h>
#include <memory>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <string>
+#include <unistd.h>
std::unique_ptr<char []> any_group;
const int N = 123456;
@@ -63,8 +66,16 @@ template <class T, class Fn, class... Args>
void test_r(Fn f, Args... args) {
T gr;
T *result;
- char buff[10000];
- assert(!f(args..., &gr, buff, sizeof(buff), &result));
+ std::string buff;
+
+ int r;
+ do {
+ buff.resize(1000 + buff.size() * 2);
+ r = f(args..., &gr, buff.data(), buff.size(), &result);
+ } while (r == ERANGE);
+
+ assert(!r);
+
Check(&gr);
Check(result);
}
More information about the llvm-commits
mailing list