1 /* Test of getting load average.
2 Copyright (C) 2011 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 <http://www.gnu.org/licenses/>. */
21 #include "signature.h"
22 SIGNATURE_CHECK (getloadavg, int, (double [], int));
29 check_avg (int minutes, double avg, int printit)
32 printf ("%d-minute: %f ", minutes, avg);
33 if (avg < 0 || avg != avg)
37 /* This program can also be used as a manual test, by invoking it with
38 an argument; it then prints the load average. If the argument is
39 nonzero, the manual test repeats forever, sleeping for the stated
40 interval between each iteration. */
42 main (int argc, char **argv)
47 naptime = atoi (argv[1]);
52 int loads = getloadavg (avg, 3);
55 if (! (errno == ENOSYS || errno == ENOTSUP))
57 perror ("Skipping test; load average not supported");
61 check_avg (1, avg[0], argc > 1);
63 check_avg (5, avg[1], argc > 1);
65 check_avg (15, avg[1], argc > 1);
66 if (loads > 0 && argc > 1)