Mercurial > hg > octave-nkf > gnulib-hg
annotate tests/test-sleep.c @ 17848:ab58d4870664
version-etc: new year
* doc/gnulib.texi:
* lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date.
* all files: Run 'make update-copyright'.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 01 Jan 2015 01:38:23 +0000 |
parents | 344018b6e5d7 |
children |
rev | line source |
---|---|
8787 | 1 /* Test of sleep() function. |
17848 | 2 Copyright (C) 2007-2015 Free Software Foundation, Inc. |
8787 | 3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8787
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
8787 | 5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8787
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8787
diff
changeset
|
7 (at your option) any later version. |
8787 | 8 |
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. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8787
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
8787 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ | |
18 | |
19 #include <config.h> | |
20 | |
21 #include <unistd.h> | |
22 | |
12489 | 23 #include "signature.h" |
24 SIGNATURE_CHECK (sleep, unsigned int, (unsigned int)); | |
25 | |
12326 | 26 #include <signal.h> |
8787 | 27 |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12489
diff
changeset
|
28 #include "macros.h" |
8787 | 29 |
12326 | 30 #if HAVE_DECL_ALARM |
31 static void | |
32 handle_alarm (int sig) | |
33 { | |
34 if (sig != SIGALRM) | |
35 _exit (1); | |
36 } | |
37 #endif | |
38 | |
8787 | 39 int |
12481 | 40 main (void) |
8787 | 41 { |
42 ASSERT (sleep (1) <= 1); | |
43 | |
44 ASSERT (sleep (0) == 0); | |
45 | |
12326 | 46 #if HAVE_DECL_ALARM |
47 { | |
48 const unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days. */ | |
49 unsigned int remaining; | |
50 signal (SIGALRM, handle_alarm); | |
51 alarm (1); | |
52 remaining = sleep (pentecost); | |
53 ASSERT (pentecost - 10 < remaining && remaining <= pentecost); | |
54 } | |
55 #endif | |
56 | |
8787 | 57 return 0; |
58 } |