...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package sysfs
18
19 import (
20 "testing"
21
22 "github.com/google/go-cmp/cmp"
23 )
24
25 func TestWatchdogClass(t *testing.T) {
26 fs, err := NewFS(sysTestFixtures)
27 if err != nil {
28 t.Fatal(err)
29 }
30
31 got, err := fs.WatchdogClass()
32 if err != nil {
33 t.Fatal(err)
34 }
35
36 var (
37 bootstatus int64 = 1
38 fwVersion int64 = 2
39 nowayout int64
40 timeleft int64 = 300
41 timeout int64 = 60
42 pretimeout int64 = 120
43 accessCs0 int64
44
45 options = "0x8380"
46 identity = "Software Watchdog"
47 state = "active"
48 status = "0x8000"
49 pretimeoutGovernor = "noop"
50 )
51
52 want := WatchdogClass{
53 "watchdog0": {
54 Name: "watchdog0",
55 Bootstatus: &bootstatus,
56 Options: &options,
57 FwVersion: &fwVersion,
58 Identity: &identity,
59 Nowayout: &nowayout,
60 State: &state,
61 Status: &status,
62 Timeleft: &timeleft,
63 Timeout: &timeout,
64 Pretimeout: &pretimeout,
65 PretimeoutGovernor: &pretimeoutGovernor,
66 AccessCs0: &accessCs0,
67 },
68 "watchdog1": {
69 Name: "watchdog1",
70 },
71 }
72
73 if diff := cmp.Diff(want, got); diff != "" {
74 t.Fatalf("unexpected watchdog class (-want +got):\n%s", diff)
75 }
76 }
77
View as plain text