Merge pull request #788 from SonyMobile/narrower-mingw-workaround

tests: Narrow test_buffer_can_grow_to_max mingw allocation workaround at compile time
This commit is contained in:
Sebastian Pipping 2023-11-09 15:50:38 +01:00 committed by GitHub
commit df1e3d6f1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2875,15 +2875,16 @@ START_TEST(test_buffer_can_grow_to_max) {
"withreadabilityprettygreatithinkanywaysthisisprobablylongenoughbye><x a='"};
const int num_prefixes = sizeof(prefixes) / sizeof(prefixes[0]);
int maxbuf = INT_MAX / 2 + (INT_MAX & 1); // round up without overflow
if (sizeof(void *) < 8) {
// Looks like we have a 32-bit system. Can we make a big allocation?
void *big = malloc(maxbuf);
if (! big) {
// The big allocation failed. Let's be a little lenient.
maxbuf = maxbuf / 2;
}
free(big);
#if defined(__MINGW32__) && ! defined(__MINGW64__)
// workaround for mingw/wine32 on GitHub CI not being able to reach 1GiB
// Can we make a big allocation?
void *big = malloc(maxbuf);
if (! big) {
// The big allocation failed. Let's be a little lenient.
maxbuf = maxbuf / 2;
}
free(big);
#endif
for (int i = 0; i < num_prefixes; ++i) {
set_subtest("\"%s\"", prefixes[i]);