forked from NeowayLabs/drm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drm_test.go
57 lines (50 loc) · 1.34 KB
/
drm_test.go
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
package drm_test
import (
"testing"
"github.com/NeowayLabs/drm"
"github.com/NeowayLabs/drm/mode"
)
func TestDRIOpen(t *testing.T) {
file, err := drm.OpenCard(0)
if err != nil {
t.Fatal(err)
}
file.Close()
}
func TestAvailableCard(t *testing.T) {
v, err := drm.Available()
if err != nil {
t.Fatal(err)
}
if v.Major == 0 && v.Minor == 0 && v.Patch == 0 {
t.Fatalf("failed to get driver version: %#v", v)
}
if v.Major != cardInfo.version.Major && v.Minor != cardInfo.version.Minor &&
v.Patch != cardInfo.version.Patch {
t.Logf("Unknow driver version: %d.%d.%d", v.Major, v.Minor, v.Patch)
}
t.Logf("Driver name: %s", v.Name)
t.Logf("Driver version: %d.%d.%d", v.Major, v.Minor, v.Patch)
t.Logf("Driver date: %s", v.Date)
t.Logf("Driver description: %s", v.Desc)
}
func TestModeRes(t *testing.T) {
file, err := drm.OpenCard(0)
if err != nil {
t.Fatal(err)
}
defer file.Close()
mres, err := mode.GetResources(file)
if err != nil {
t.Error(err)
return
}
t.Logf("Number of framebuffers: %d", mres.CountFbs)
t.Logf("Number of CRTCs: %d", mres.CountCrtcs)
t.Logf("Number of connectors: %d", mres.CountConnectors)
t.Logf("Number of encoders: %d", mres.CountEncoders)
t.Logf("Framebuffers ids: %v", mres.Fbs)
t.Logf("CRTC ids: %v", mres.Crtcs)
t.Logf("Connector ids: %v", mres.Connectors)
t.Logf("Encoder ids: %v", mres.Encoders)
}