annotate tests/test-get-rusage-data.c @ 40196:e63f5d3edab5

relocatable-prog: Update documentation. * doc/relocatable-maint.texi (Supporting Relocation): Update to match the recent changes.
author Bruno Haible <bruno@clisp.org>
date Sun, 24 Feb 2019 01:49:15 +0100
parents b06060465f09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14229
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of getter for RLIMIT_DATA.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19595
diff changeset
2 Copyright (C) 2011-2019 Free Software Foundation, Inc.
14229
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18925
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
14229
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include "resource-ext.h"
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include <stdio.h>
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include <stdlib.h>
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include "macros.h"
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25
16346
aef1ea36022d get-rusage-as, get-rusage-data tests: Avoid test failure with gcc-4.7.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
26 void *memchunk1;
aef1ea36022d get-rusage-as, get-rusage-data tests: Avoid test failure with gcc-4.7.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
27 void *memchunk2;
aef1ea36022d get-rusage-as, get-rusage-data tests: Avoid test failure with gcc-4.7.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
28
14229
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 int
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 main ()
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 {
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 uintptr_t value1, value2, value3;
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 value1 = get_rusage_data ();
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35
16346
aef1ea36022d get-rusage-as, get-rusage-data tests: Avoid test failure with gcc-4.7.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
36 memchunk1 = malloc (0x88);
14229
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 value2 = get_rusage_data ();
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39
16346
aef1ea36022d get-rusage-as, get-rusage-data tests: Avoid test failure with gcc-4.7.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
40 memchunk2 = malloc (0x281237);
14229
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 value3 = get_rusage_data ();
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 if (value1 == 0 && value2 == 0 && value3 == 0)
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 {
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 fprintf (stderr, "Skipping test: no way to determine data segment size\n");
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 return 77;
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 }
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 else
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 {
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 /* The data segment size is positive, except possibly at the beginning. */
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 ASSERT (value2 > 0);
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 /* Allocating memory should not decrease the data segment size. */
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 ASSERT (value2 >= value1);
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 ASSERT (value3 >= value2);
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57
19595
beb2ad957aca Simplify code. Drop support for Borland C++ on Windows.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
58 #if !(__GLIBC__ == 2 || (defined __APPLE__ && defined __MACH__) || defined __DragonFly__ || defined __OpenBSD__ || defined _WIN32 || defined __CYGWIN__)
14229
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 /* Allocating 2.5 MB of memory should increase the data segment size. */
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 ASSERT (value3 > value1);
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 #endif
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 return 0;
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 }
3a0a66848038 Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 }