...

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

Documentation: github.com/prometheus/procfs/sysfs

     1  // Copyright 2018 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  	"reflect"
    21  	"testing"
    22  
    23  	"github.com/prometheus/procfs/internal/util"
    24  )
    25  
    26  func TestClassThermalZoneStats(t *testing.T) {
    27  	fs, err := NewFS(sysTestFixtures)
    28  	if err != nil {
    29  		t.Fatal(err)
    30  	}
    31  
    32  	thermalTest, err := fs.ClassThermalZoneStats()
    33  	if err != nil {
    34  		t.Fatal(err)
    35  	}
    36  
    37  	enabled := util.ParseBool("enabled")
    38  	passive := uint64(0)
    39  
    40  	classThermalZoneStats := []ClassThermalZoneStats{
    41  		{
    42  			Name:    "0",
    43  			Type:    "bcm2835_thermal",
    44  			Policy:  "step_wise",
    45  			Temp:    49925,
    46  			Mode:    nil,
    47  			Passive: nil,
    48  		},
    49  		{
    50  			Name:    "1",
    51  			Type:    "acpitz",
    52  			Policy:  "step_wise",
    53  			Temp:    -44000,
    54  			Mode:    enabled,
    55  			Passive: &passive,
    56  		},
    57  	}
    58  
    59  	if !reflect.DeepEqual(classThermalZoneStats, thermalTest) {
    60  		t.Errorf("Result not correct: want %v, have %v", classThermalZoneStats, thermalTest)
    61  	}
    62  }
    63  

View as plain text