-
Notifications
You must be signed in to change notification settings - Fork 4
/
watchdogdev_test.py
executable file
·124 lines (100 loc) · 2.59 KB
/
watchdogdev_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
from __future__ import print_function
from watchdogdev import *
def test():
wd = watchdog('/dev/watchdog')
print('fileno:', wd.fileno())
wd.close()
wd = watchdog('/dev/watchdog')
print('options:', wd.options)
assert(wd.options == None)
print('firmware_version:', wd.firmware_version)
assert(wd.firmware_version == None)
print('identity:', wd.identity)
assert(wd.identity == None)
print()
wd.close()
wd = watchdog('/dev/watchdog')
wd.get_support()
print('options:', wd.options)
for name in list(globals()):
if not name.startswith('WDIOF_'):
continue
value = globals()[name]
print('%s:' % name, wd.options & value == value)
print()
print('firmware_version:', wd.firmware_version)
print('identity:', wd.identity)
print()
wd.close()
wd = watchdog('/dev/watchdog')
print('keep_alive:', end=' ')
try:
print(wd.keep_alive())
except IOError as e:
print(e)
print('get_status:', end=' ')
try:
print(wd.get_status())
except IOError as e:
print(e)
print('get_boot_status:', end=' ')
try:
print(wd.get_boot_status())
except IOError as e:
print(e)
print('get_temp:', end=' ')
try:
print(wd.get_temp())
except IOError as e:
print(e)
timeout = 60
print('get_timeout:', end=' ')
try:
timeout = wd.get_timeout()
print(timeout)
except IOError as e:
print(e)
print('get_pretimeout:', end=' ')
try:
print(wd.get_pretimeout())
except IOError as e:
print(e)
print('get_time_left:', end=' ')
try:
print(wd.get_time_left())
except IOError as e:
print(e)
print('set_options:', end=' ')
try:
for i in range(0, 65536):
wd.set_options(i)
assert(wd.get_options == i)
print('OK')
except IOError as e:
print(e)
print('set_timeout:', end=' ')
try:
for i in range(1, 65536):
wd.set_timeout(i)
assert(wd.get_timeout() == i)
wd.set_timeout(timeout)
print('OK')
except IOError as e:
print(e)
print('set_pretimeout:', end=' ')
try:
for i in range(1, 65536):
wd.set_pretimeout(i)
assert(wd.get_pretimeout == i)
wd.set_pretimeout(0)
print('OK')
except IOError as e:
print(e)
print('magic_close:', end=' ')
try:
wd.magic_close()
print('OK')
except IOError as e:
print(e)
if __name__ == '__main__':
test()