Reduce VeryLargeMemory test memory allocation in engine_io_test.cc
An upcoming LLVM update is due to make this test fail under msan, since msan touches most of the memory allocated for the mjData arena. This causes an OOM failure on memory-limited testing infrastructure. An 8G allocation is sufficient to catch errors that arise from the use of 32-bit integers to handle sizes. PiperOrigin-RevId: 640504620 Change-Id: Ia1949b04a1428f01e1075e26b421facb3babedb6
This commit is contained in:
committed by
Copybara-Service
parent
a56b9c8bbd
commit
40755e165d
@@ -701,30 +701,30 @@ TEST_F(EngineIoTest, LargeMemory) {
|
||||
TEST_F(EngineIoTest, VeryLargeMemory) {
|
||||
constexpr char xml[] = R"(
|
||||
<mujoco>
|
||||
<size memory="64G"/>
|
||||
<size memory="8G"/>
|
||||
</mujoco>
|
||||
)";
|
||||
|
||||
std::array<char, 1024> error;
|
||||
mjModel* model = LoadModelFromString(xml, error.data(), error.size());
|
||||
if (!model) {
|
||||
// in some test environments, 64GB is too large
|
||||
// in some test environments, 8GB is too large
|
||||
EXPECT_THAT(error.data(), HasSubstr("Could not allocate memory"));
|
||||
} else {
|
||||
ASSERT_THAT(model, NotNull()) << "Failed to load model: " << error.data();
|
||||
mjData* data = mj_makeData(model);
|
||||
ASSERT_THAT(data, NotNull());
|
||||
|
||||
// allocate 63G of mjtNums
|
||||
// allocate 7G of mjtNums
|
||||
mj_markStack(data);
|
||||
size_t num = 63000000000 / sizeof(mjtNum);
|
||||
size_t num = 7516192768ull / sizeof(mjtNum);
|
||||
mjtNum* testNum = mj_stackAllocNum(data, num);
|
||||
testNum[num-1] = 1;
|
||||
mj_freeStack(data);
|
||||
|
||||
// allocate 63G of bytes
|
||||
// allocate 7G of bytes
|
||||
mj_markStack(data);
|
||||
num = 63000000000;
|
||||
num = 7516192768ull;
|
||||
char* testByte = (char*) mj_stackAllocByte(data, num, alignof(char));
|
||||
testByte[num-1] = 1;
|
||||
mj_freeStack(data);
|
||||
|
||||
Reference in New Issue
Block a user