...

Source file src/github.com/prometheus/procfs/sysfs/class_watchdog_test.go

Documentation: github.com/prometheus/procfs/sysfs

     1  // Copyright 2023 The Prometheus Authors
     2  // Licensed under the Apache License, Version 2.0 (the "License");
     3  // you may not use this file except in compliance with the License.
     4  // You may obtain a copy of the License at
     5  //
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software
     9  // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  //go:build linux
    15  // +build linux
    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