]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
e96d6be7 LP |
2 | /*** |
3 | This file is part of systemd. | |
4 | ||
5 | Copyright 2012 Lennart Poettering | |
6 | ||
7 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
8 | under the terms of the GNU Lesser General Public License as published by |
9 | the Free Software Foundation; either version 2.1 of the License, or | |
e96d6be7 LP |
10 | (at your option) any later version. |
11 | ||
12 | systemd is distributed in the hope that it will be useful, but | |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 15 | Lesser General Public License for more details. |
e96d6be7 | 16 | |
5430f7f2 | 17 | You should have received a copy of the GNU Lesser General Public License |
e96d6be7 LP |
18 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
19 | ***/ | |
20 | ||
dccca82b | 21 | #include <string.h> |
e96d6be7 | 22 | #include <unistd.h> |
e96d6be7 | 23 | |
da1e72f4 | 24 | #include "env-util.h" |
e96d6be7 | 25 | #include "log.h" |
cf0fbc49 | 26 | #include "watchdog.h" |
e96d6be7 LP |
27 | |
28 | int main(int argc, char *argv[]) { | |
da1e72f4 ZJS |
29 | usec_t t; |
30 | unsigned i, count; | |
e96d6be7 | 31 | int r; |
da1e72f4 | 32 | bool slow; |
e96d6be7 LP |
33 | |
34 | log_set_max_level(LOG_DEBUG); | |
35 | log_parse_environment(); | |
36 | ||
da1e72f4 ZJS |
37 | r = getenv_bool("SYSTEMD_SLOW_TESTS"); |
38 | slow = r >= 0 ? r : SYSTEMD_SLOW_TESTS_DEFAULT; | |
39 | ||
40 | t = slow ? 10 * USEC_PER_SEC : 1 * USEC_PER_SEC; | |
41 | count = slow ? 5 : 3; | |
42 | ||
e96d6be7 LP |
43 | r = watchdog_set_timeout(&t); |
44 | if (r < 0) | |
da927ba9 | 45 | log_warning_errno(r, "Failed to open watchdog: %m"); |
da1e72f4 ZJS |
46 | if (r == -EPERM) |
47 | t = 0; | |
e96d6be7 | 48 | |
da1e72f4 | 49 | for (i = 0; i < count; i++) { |
e96d6be7 LP |
50 | log_info("Pinging..."); |
51 | r = watchdog_ping(); | |
52 | if (r < 0) | |
da927ba9 | 53 | log_warning_errno(r, "Failed to ping watchdog: %m"); |
e96d6be7 LP |
54 | |
55 | usleep(t/2); | |
56 | } | |
57 | ||
58 | watchdog_close(true); | |
59 | return 0; | |
60 | } |