Mercurial > hg > octave-shane > gnulib-hg
annotate tests/test-get-rusage-data.c @ 17530:8981b79e1271
error: make the module depend on vfprintf-posix
* modules/error (Depends-on): Add vfprintf-posix, since error
calls vfprintf unconditionally, via error_tail.
author | Jim Meyering <meyering@fb.com> |
---|---|
date | Sat, 12 Oct 2013 19:28:40 -0700 |
parents | e542fd46ad6f |
children | 344018b6e5d7 |
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. |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16346
diff
changeset
|
2 Copyright (C) 2011-2013 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 |
3a0a66848038
Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
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 |
3a0a66848038
Tests for module 'get-rusage-data'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 #if !((defined __APPLE__ && defined __MACH__) || defined __OpenBSD__ || (defined _WIN32 || defined __WIN32__) || defined __CYGWIN__) |
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 } |