usleep tests: Avoid failure due to known Cygwin 3.5.3 bug.
[gnulib.git] / tests / test-get-rusage-as.c
blobe1e92f842e6ede061c5b9cb9ea59fe66d5c8ea12
1 /* Test of getter for RLIMIT_AS.
2 Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 #include <config.h>
19 #include "resource-ext.h"
21 #include <stdio.h>
22 #include <stdlib.h>
24 #include "qemu.h"
25 #include "macros.h"
27 void *memchunk1;
28 void *memchunk2;
30 int
31 main ()
33 uintptr_t value1, value2, value3;
35 value1 = get_rusage_as ();
37 memchunk1 = malloc (0x88);
39 value2 = get_rusage_as ();
41 memchunk2 = malloc (0x281237);
43 value3 = get_rusage_as ();
45 if (value1 == 0 && value2 == 0 && value3 == 0)
47 fprintf (stderr, "Skipping test: no way to determine address space size\n");
48 return 77;
50 else if (is_running_under_qemu_user ())
52 fprintf (stderr, "Skipping test: running under QEMU\n");
53 return 77;
55 else
57 /* The address space size is positive. */
58 ASSERT (value1 > 0);
60 /* Allocating memory should not decrease the address space size. */
61 ASSERT (value2 >= value1);
62 ASSERT (value3 >= value2);
64 /* Allocating 2.5 MB of memory should increase the address space size. */
65 #ifdef _AIX
66 /* Except on AIX in 32-bit mode, where a single interval is used for
67 malloc and for the stack. malloc() blocks are taken from the bottom
68 of this interval. The stack sits at its top. */
69 if (sizeof (void *) > 4)
70 #endif
71 ASSERT (value3 > value1);
73 return test_exit_status;