From 011faecf3ac8ac5fb9479a456ad04e64ad1079ba Mon Sep 17 00:00:00 2001 From: Juerg Ritter Date: Sat, 8 Jun 2024 23:44:02 +0200 Subject: [PATCH] implement drm card test --- sysfs/class_drm_card_port.go | 1 + sysfs/class_drm_card_test.go | 51 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 sysfs/class_drm_card_test.go diff --git a/sysfs/class_drm_card_port.go b/sysfs/class_drm_card_port.go index df1755e82..e6d2a3e6a 100644 --- a/sysfs/class_drm_card_port.go +++ b/sysfs/class_drm_card_port.go @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build !windows // +build !windows package sysfs diff --git a/sysfs/class_drm_card_test.go b/sysfs/class_drm_card_test.go new file mode 100644 index 000000000..d0e48f7f7 --- /dev/null +++ b/sysfs/class_drm_card_test.go @@ -0,0 +1,51 @@ +// Copyright 2021 The Prometheus Authors +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build linux +// +build linux + +package sysfs + +import ( + "reflect" + "testing" +) + +func TestClassDRMCard(t *testing.T) { + fs, err := NewFS(sysTestFixtures) + if err != nil { + t.Fatal(err) + } + + drmCardTest, err := fs.ClassDrmCard() + if err != nil { + t.Fatal(err) + } + + classDrmCard := []ClassDrmCard{ + { + Name: "card0", + Enable: 1, + Driver: "amdgpu", + }, + { + Name: "card1", + Enable: 1, + Driver: "i915", + }, + } + + if !reflect.DeepEqual(classDrmCard, drmCardTest) { + t.Errorf("Result not correct: want %v, have %v", classDrmCard, drmCardTest) + } +}