forked from kmonad/kmonad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nixos-test.nix
105 lines (92 loc) · 2.37 KB
/
nixos-test.nix
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# To run this test:
#
# $ nix flake check
#
# To run this test with debugging output:
#
# $ nix flake check --print-build-logs
#
# To run the tests and interact with the VM:
#
# $ nix build .#checks.x86_64-linux.default.driverInteractive
# $ result/bin/nixos-test-driver
#
{ pkgs, module }:
let
config = pkgs.runCommand "kmonad-config" { } ''
${pkgs.gnused}/bin/sed -E \
'/^\(defcfg/,/^\)/d' \
${../keymap/tutorial.kbd} > $out
'';
qemu-keyboard = "/dev/input/by-path/pci-0000:00:0a.0-event-kbd";
users = { ... }: {
users.users.jdoe = {
createHome = true;
isNormalUser = true;
password = "password";
group = "users";
};
};
in
pkgs.nixosTest {
name = "kmonad-test";
nodes = {
tutorial = { ... }: {
imports = [
module
users
];
services.kmonad = {
enable = true;
keyboards.qemu = {
device = qemu-keyboard;
config = builtins.readFile ../keymap/tutorial.kbd;
};
};
};
defcfgGenerated = { ... }: {
imports = [
module
users
];
services.kmonad = {
enable = true;
keyboards.qemu = {
device = qemu-keyboard;
config = builtins.readFile (toString config);
defcfg = {
enable = true;
compose.key = null;
fallthrough = true;
};
};
};
};
};
testScript =
let node = name: ''
with subtest("Verify KMonad started"):
${name}.wait_for_unit("kmonad-qemu.service")
${name}.wait_until_succeeds("pgrep kmonad")
with subtest("Log In"):
${name}.wait_until_tty_matches(1, "login: ")
${name}.send_chars("jdoe\n")
${name}.wait_until_tty_matches(1, "Password: ")
${name}.send_chars("password\n")
${name}.wait_until_tty_matches(1, "$")
with subtest("Test Tutorial Numbers Layer"):
${name}.send_chars("echo ")
${name}.send_key("meta_l-k") # Should send "5"
${name}.send_key("meta_l-l") # Should send "6"
${name}.send_chars(" > /tmp/keys\n")
${name}.wait_until_succeeds("test -e /tmp/keys")
${name}.succeed("test \"$(cat /tmp/keys)\" -eq 56")
'';
in
''
with subtest("Start nodes"):
start_all()
''
+ node "tutorial"
+ node "defcfgGenerated";
}