v0.5.1 657f658

device_test.go RawHistoryFolder

1//go:build linux
2
3package vkdevice
4
5import (
6	"encoding/binary"
7	"os"
8	"testing"
9
10	"golang.org/x/sys/unix"
11)
12
13func TestDeviceIdentity(t *testing.T) {
14	for _, tc := range []struct{ major, minor uint32 }{{0, 0}, {226, 128}, {226, 0}, {4095, 1 << 20}, {2, 255}} {
15		// Linux makedev as used by x/sys/unix and stat on /dev/dri.
16		raw := unix.Mkdev(tc.major, tc.minor)
17		b := make([]byte, 8)
18		binary.NativeEndian.PutUint64(b, raw)
19		got, err := DecodeDevice(b)
20		if err != nil || got != (Identity{tc.major, tc.minor}) || got != DeviceIdentity(raw) {
21			t.Fatalf("dev_t %d:%d -> %+v: %v", tc.major, tc.minor, got, err)
22		}
23	}
24	if _, err := DecodeDevice([]byte{1}); err == nil {
25		t.Fatal("accepted truncated dev_t")
26	}
27}
28
29func TestNoCrossGPUFallback(t *testing.T) {
30	main := Identity{226, 128}
31	if Matches(main, Identity{226, 0}, Identity{226, 129}, true, true) {
32		t.Fatal("matched different GPU")
33	}
34	if !Matches(main, main, Identity{226, 129}, true, true) {
35		t.Fatal("did not match primary")
36	}
37	if !Matches(main, Identity{226, 0}, main, true, true) {
38		t.Fatal("did not match render")
39	}
40	if Matches(main, main, main, false, false) {
41		t.Fatal("matched device without DRM capability")
42	}
43}
44
45func TestVulkanDeviceHardware(t *testing.T) {
46	path := os.Getenv("NEFERGUI_RENDER_NODE")
47	if path == "" {
48		t.Skip("opt in with NEFERGUI_RENDER_NODE=/dev/dri/renderD... (matching compositor main_device)")
49	}
50	var stat unix.Stat_t
51	if err := unix.Stat(path, &stat); err != nil {
52		t.Fatal(err)
53	}
54	d, err := Open(DeviceIdentity(uint64(stat.Rdev)))
55	if err != nil {
56		t.Fatal(err)
57	}
58	defer d.Close()
59	t.Logf("selected main_device %d:%d -> Vulkan render node %d:%d queue family %d", unix.Major(uint64(stat.Rdev)), unix.Minor(uint64(stat.Rdev)), d.Render.Major, d.Render.Minor, d.QueueFamily)
60	if d.Render != DeviceIdentity(uint64(stat.Rdev)) {
61		t.Fatalf("render node mismatch: %+v", d.Render)
62	}
63}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 12

↑↓ moveenter openesc close