drop dependency on sys/resource.h
Biggest part of it is removal of SetTestResourceLimit. The reasoning behind it is, we don't do it on windows. Tests pass just fine. So, there is no reason to bother.
This commit is contained in:
parent
a4fe2d7cd0
commit
93380fc754
|
@ -205,7 +205,6 @@ check_include_file("poll.h" HAVE_POLL_H) # optional; for forking out to symboliz
|
|||
check_include_file("fcntl.h" HAVE_FCNTL_H) # for tcmalloc_unittest
|
||||
check_include_file("grp.h" HAVE_GRP_H) # for heapchecker_unittest
|
||||
check_include_file("pwd.h" HAVE_PWD_H) # for heapchecker_unittest
|
||||
check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H) # for SetTestResourceLimit
|
||||
check_include_file("sys/cdefs.h" HAVE_SYS_CDEFS_H) # Where glibc defines __THROW
|
||||
|
||||
check_include_file("sys/ucontext.h" HAVE_SYS_UCONTEXT_H)
|
||||
|
|
|
@ -113,9 +113,6 @@
|
|||
/* Define to 1 if you have the <sys/malloc.h> header file. */
|
||||
#cmakedefine HAVE_SYS_MALLOC_H
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#cmakedefine HAVE_SYS_RESOURCE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#cmakedefine HAVE_SYS_SOCKET_H
|
||||
|
||||
|
|
|
@ -270,7 +270,6 @@ AC_CHECK_HEADERS(poll.h) # optional; for forking out to symbolizer
|
|||
AC_CHECK_HEADERS(fcntl.h) # for tcmalloc_unittest
|
||||
AC_CHECK_HEADERS(grp.h) # for heapchecker_unittest
|
||||
AC_CHECK_HEADERS(pwd.h) # for heapchecker_unittest
|
||||
AC_CHECK_HEADERS(sys/resource.h) # for memalign_unittest.cc
|
||||
AC_CHECK_HEADERS(sys/cdefs.h) # Where glibc defines __THROW
|
||||
|
||||
AC_CHECK_HEADERS(sys/ucontext.h)
|
||||
|
|
|
@ -39,14 +39,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/time.h> // for struct timeval
|
||||
#include <sys/resource.h> // for getrusage
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include <sysinfoapi.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
@ -60,16 +53,9 @@
|
|||
using tcmalloc::TestingPortal;
|
||||
|
||||
static double GetCPUTime() {
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
struct rusage r;
|
||||
getrusage(RUSAGE_SELF, &r);
|
||||
struct timeval tv = r.ru_utime;
|
||||
return 1e-6 * tv.tv_usec + tv.tv_sec;
|
||||
#elif defined(_WIN32)
|
||||
return GetTickCount64() * 1e-3;
|
||||
#else
|
||||
# error No way to calculate time on your system
|
||||
#endif
|
||||
// Note, we do plain wall-clock time instead of cpu time, but this
|
||||
// is close enough for this file's purpose.
|
||||
return clock() / static_cast<double>(CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
static std::optional<size_t> GetSlackBytes() {
|
||||
|
|
|
@ -1174,8 +1174,6 @@ static int RunAllTests(int argc, char** argv) {
|
|||
// Optional argv[1] is the seed
|
||||
AllocatorState rnd(argc > 1 ? atoi(argv[1]) : 100);
|
||||
|
||||
SetTestResourceLimit();
|
||||
|
||||
#ifndef DEBUGALLOCATION
|
||||
TestNewOOMHandling();
|
||||
#endif
|
||||
|
|
|
@ -38,47 +38,11 @@
|
|||
#include "tests/testutil.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
// On FreeBSD, if you #include <sys/resource.h>, you have to get stdint first.
|
||||
#include <stdint.h>
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
// When compiled 64-bit and run on systems with swap several unittests will end
|
||||
// up trying to consume all of RAM+swap, and that can take quite some time. By
|
||||
// limiting the address-space size we get sufficient coverage without blowing
|
||||
// out job limits.
|
||||
void SetTestResourceLimit() {
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
// The actual resource we need to set varies depending on which flavour of
|
||||
// unix. On Linux we need RLIMIT_AS because that covers the use of mmap.
|
||||
// Otherwise hopefully RLIMIT_RSS is good enough. (Unfortunately 64-bit
|
||||
// and 32-bit headers disagree on the type of these constants!)
|
||||
#ifdef RLIMIT_AS
|
||||
#define USE_RESOURCE RLIMIT_AS
|
||||
#else
|
||||
#define USE_RESOURCE RLIMIT_RSS
|
||||
#endif
|
||||
|
||||
// Restrict the test to 1GiB, which should fit comfortably well on both
|
||||
// 32-bit and 64-bit hosts, and executes in ~1s.
|
||||
const rlim_t kMaxMem = 1<<30;
|
||||
|
||||
struct rlimit rlim;
|
||||
if (getrlimit(USE_RESOURCE, &rlim) == 0) {
|
||||
if (rlim.rlim_cur == RLIM_INFINITY || rlim.rlim_cur > kMaxMem) {
|
||||
rlim.rlim_cur = kMaxMem;
|
||||
setrlimit(USE_RESOURCE, &rlim); // ignore result
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_SYS_RESOURCE_H */
|
||||
}
|
||||
|
||||
|
||||
struct FunctionAndId {
|
||||
void (*ptr_to_function)(int);
|
||||
int id;
|
||||
|
|
|
@ -51,12 +51,6 @@ extern "C" void RunManyThreads(void (*fn)(), int count);
|
|||
// where idx is the index of the thread (which of the X threads this is).
|
||||
extern "C" void RunManyThreadsWithId(void (*fn)(int), int count);
|
||||
|
||||
// When compiled 64-bit and run on systems with swap several unittests will end
|
||||
// up trying to consume all of RAM+swap, and that can take quite some time. By
|
||||
// limiting the address-space size we get sufficient coverage without blowing
|
||||
// out job limits.
|
||||
void SetTestResourceLimit();
|
||||
|
||||
static void (* volatile noopt_helper)(void *) = [] (void* dummy) {};
|
||||
|
||||
// This function forces compiler to forget specific knowledge about
|
||||
|
|
|
@ -125,12 +125,6 @@
|
|||
/* Define to 1 if you have the <sys/cdefs.h> header file. */
|
||||
/* #undef HAVE_SYS_CDEFS_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
/* #undef HAVE_SYS_RESOURCE_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
/* #undef HAVE_SYS_SOCKET_H */
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue