Skip to content

Commit f34483b

Browse files
committed
nixosTests: handleTest -> runTest, batch 1
Reference: #386873
1 parent 131462b commit f34483b

538 files changed

Lines changed: 35985 additions & 37060 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

nixos/tests/all-tests.nix

Lines changed: 540 additions & 540 deletions
Large diffs are not rendered by default.

nixos/tests/ax25.nix

Lines changed: 122 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,128 @@
1-
import ./make-test-python.nix (
2-
{ pkgs, lib, ... }:
3-
let
4-
5-
baud = 57600;
6-
tty = "/dev/ttyACM0";
7-
port = "tnc0";
8-
socatPort = 1234;
9-
10-
createAX25Node = nodeId: {
11-
12-
boot.kernelPackages = pkgs.linuxPackages_ham;
13-
boot.kernelModules = [ "ax25" ];
1+
{ pkgs, lib, ... }:
2+
3+
let
4+
baud = 57600;
5+
tty = "/dev/ttyACM0";
6+
port = "tnc0";
7+
socatPort = 1234;
8+
9+
createAX25Node = nodeId: {
10+
boot.kernelPackages = pkgs.linuxPackages_ham;
11+
boot.kernelModules = [ "ax25" ];
12+
13+
networking.firewall.allowedTCPPorts = [ socatPort ];
14+
15+
environment.systemPackages = with pkgs; [
16+
libax25
17+
ax25-tools
18+
ax25-apps
19+
socat
20+
];
21+
22+
services.ax25.axports."${port}" = {
23+
inherit baud tty;
24+
enable = true;
25+
callsign = "NOCALL-${toString nodeId}";
26+
description = "mocked tnc";
27+
};
1428

15-
networking.firewall.allowedTCPPorts = [ socatPort ];
29+
services.ax25.axlisten = {
30+
enable = true;
31+
};
1632

17-
environment.systemPackages = with pkgs; [
18-
libax25
19-
ax25-tools
20-
ax25-apps
21-
socat
33+
# All mocks radios will connect back to socat-broker on node 1 in order to get
34+
# all messages that are "broadcasted over the ether"
35+
systemd.services.ax25-mock-hardware = {
36+
description = "mock AX.25 TNC and Radio";
37+
wantedBy = [ "default.target" ];
38+
before = [
39+
"ax25-kissattach-${port}.service"
40+
"axlisten.service"
2241
];
23-
24-
services.ax25.axports."${port}" = {
25-
inherit baud tty;
26-
enable = true;
27-
callsign = "NOCALL-${toString nodeId}";
28-
description = "mocked tnc";
29-
};
30-
31-
services.ax25.axlisten = {
32-
enable = true;
33-
};
34-
35-
# All mocks radios will connect back to socat-broker on node 1 in order to get
36-
# all messages that are "broadcasted over the ether"
37-
systemd.services.ax25-mock-hardware = {
38-
description = "mock AX.25 TNC and Radio";
39-
wantedBy = [ "default.target" ];
40-
before = [
41-
"ax25-kissattach-${port}.service"
42-
"axlisten.service"
43-
];
44-
after = [ "network.target" ];
45-
serviceConfig = {
46-
Type = "exec";
47-
ExecStart = "${pkgs.socat}/bin/socat -d -d tcp:192.168.1.1:${toString socatPort} pty,link=${tty},b${toString baud},raw";
48-
};
42+
after = [ "network.target" ];
43+
serviceConfig = {
44+
Type = "exec";
45+
ExecStart = "${pkgs.socat}/bin/socat -d -d tcp:192.168.1.1:${toString socatPort} pty,link=${tty},b${toString baud},raw";
4946
};
5047
};
51-
in
52-
{
53-
name = "ax25Simple";
54-
nodes = {
55-
node1 = lib.mkMerge [
56-
(createAX25Node 1)
57-
# mimicking radios on the same frequency
58-
{
59-
systemd.services.ax25-mock-ether = {
60-
description = "mock radio ether";
61-
wantedBy = [ "default.target" ];
62-
requires = [ "network.target" ];
63-
before = [ "ax25-mock-hardware.service" ];
64-
# broken needs access to "ss" or "netstat"
65-
path = [ pkgs.iproute2 ];
66-
serviceConfig = {
67-
Type = "exec";
68-
ExecStart = "${pkgs.socat}/bin/socat-broker.sh tcp4-listen:${toString socatPort}";
69-
};
70-
postStart = "${pkgs.coreutils}/bin/sleep 2";
48+
};
49+
in
50+
{
51+
name = "ax25Simple";
52+
nodes = {
53+
node1 = lib.mkMerge [
54+
(createAX25Node 1)
55+
# mimicking radios on the same frequency
56+
{
57+
systemd.services.ax25-mock-ether = {
58+
description = "mock radio ether";
59+
wantedBy = [ "default.target" ];
60+
requires = [ "network.target" ];
61+
before = [ "ax25-mock-hardware.service" ];
62+
# broken needs access to "ss" or "netstat"
63+
path = [ pkgs.iproute2 ];
64+
serviceConfig = {
65+
Type = "exec";
66+
ExecStart = "${pkgs.socat}/bin/socat-broker.sh tcp4-listen:${toString socatPort}";
7167
};
72-
}
73-
];
74-
node2 = createAX25Node 2;
75-
node3 = createAX25Node 3;
76-
};
77-
testScript =
78-
{ ... }:
79-
''
80-
def wait_for_machine(m):
81-
m.succeed("lsmod | grep ax25")
82-
m.wait_for_unit("ax25-axports.target")
83-
m.wait_for_unit("axlisten.service")
84-
m.fail("journalctl -o cat -u axlisten.service | grep -i \"no AX.25 port data configured\"")
85-
86-
# start the first node since the socat-broker needs to be running
87-
node1.start()
88-
node1.wait_for_unit("ax25-mock-ether.service")
89-
wait_for_machine(node1)
90-
91-
node2.start()
92-
node3.start()
93-
wait_for_machine(node2)
94-
wait_for_machine(node3)
95-
96-
# Node 1 -> Node 2
97-
node1.succeed("echo hello | ax25_call ${port} NOCALL-1 NOCALL-2")
98-
node2.sleep(1)
99-
node2.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-1 to NOCALL-2 ctl I00\" | grep hello")
100-
101-
# Node 1 -> Node 3
102-
node1.succeed("echo hello | ax25_call ${port} NOCALL-1 NOCALL-3")
103-
node3.sleep(1)
104-
node3.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-1 to NOCALL-3 ctl I00\" | grep hello")
105-
106-
# Node 2 -> Node 1
107-
# must sleep due to previous ax25_call lingering
108-
node2.sleep(5)
109-
node2.succeed("echo hello | ax25_call ${port} NOCALL-2 NOCALL-1")
110-
node1.sleep(1)
111-
node1.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-2 to NOCALL-1 ctl I00\" | grep hello")
112-
113-
# Node 2 -> Node 3
114-
node2.succeed("echo hello | ax25_call ${port} NOCALL-2 NOCALL-3")
115-
node3.sleep(1)
116-
node3.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-2 to NOCALL-3 ctl I00\" | grep hello")
117-
118-
# Node 3 -> Node 1
119-
# must sleep due to previous ax25_call lingering
120-
node3.sleep(5)
121-
node3.succeed("echo hello | ax25_call ${port} NOCALL-3 NOCALL-1")
122-
node1.sleep(1)
123-
node1.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-3 to NOCALL-1 ctl I00\" | grep hello")
124-
125-
# Node 3 -> Node 2
126-
node3.succeed("echo hello | ax25_call ${port} NOCALL-3 NOCALL-2")
127-
node2.sleep(1)
128-
node2.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-3 to NOCALL-2 ctl I00\" | grep hello")
129-
'';
130-
}
131-
)
68+
postStart = "${pkgs.coreutils}/bin/sleep 2";
69+
};
70+
}
71+
];
72+
node2 = createAX25Node 2;
73+
node3 = createAX25Node 3;
74+
};
75+
testScript =
76+
{ ... }:
77+
''
78+
def wait_for_machine(m):
79+
m.succeed("lsmod | grep ax25")
80+
m.wait_for_unit("ax25-axports.target")
81+
m.wait_for_unit("axlisten.service")
82+
m.fail("journalctl -o cat -u axlisten.service | grep -i \"no AX.25 port data configured\"")
83+
84+
# start the first node since the socat-broker needs to be running
85+
node1.start()
86+
node1.wait_for_unit("ax25-mock-ether.service")
87+
wait_for_machine(node1)
88+
89+
node2.start()
90+
node3.start()
91+
wait_for_machine(node2)
92+
wait_for_machine(node3)
93+
94+
# Node 1 -> Node 2
95+
node1.succeed("echo hello | ax25_call ${port} NOCALL-1 NOCALL-2")
96+
node2.sleep(1)
97+
node2.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-1 to NOCALL-2 ctl I00\" | grep hello")
98+
99+
# Node 1 -> Node 3
100+
node1.succeed("echo hello | ax25_call ${port} NOCALL-1 NOCALL-3")
101+
node3.sleep(1)
102+
node3.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-1 to NOCALL-3 ctl I00\" | grep hello")
103+
104+
# Node 2 -> Node 1
105+
# must sleep due to previous ax25_call lingering
106+
node2.sleep(5)
107+
node2.succeed("echo hello | ax25_call ${port} NOCALL-2 NOCALL-1")
108+
node1.sleep(1)
109+
node1.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-2 to NOCALL-1 ctl I00\" | grep hello")
110+
111+
# Node 2 -> Node 3
112+
node2.succeed("echo hello | ax25_call ${port} NOCALL-2 NOCALL-3")
113+
node3.sleep(1)
114+
node3.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-2 to NOCALL-3 ctl I00\" | grep hello")
115+
116+
# Node 3 -> Node 1
117+
# must sleep due to previous ax25_call lingering
118+
node3.sleep(5)
119+
node3.succeed("echo hello | ax25_call ${port} NOCALL-3 NOCALL-1")
120+
node1.sleep(1)
121+
node1.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-3 to NOCALL-1 ctl I00\" | grep hello")
122+
123+
# Node 3 -> Node 2
124+
node3.succeed("echo hello | ax25_call ${port} NOCALL-3 NOCALL-2")
125+
node2.sleep(1)
126+
node2.succeed("journalctl -o cat -u axlisten.service | grep -A1 \"NOCALL-3 to NOCALL-2 ctl I00\" | grep hello")
127+
'';
128+
}

nixos/tests/benchexec.nix

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,62 @@
1-
import ./make-test-python.nix (
2-
{ pkgs, lib, ... }:
3-
let
4-
user = "alice";
5-
in
6-
{
7-
name = "benchexec";
1+
{ pkgs, lib, ... }:
2+
let
3+
user = "alice";
4+
in
5+
{
6+
name = "benchexec";
87

9-
nodes.benchexec = {
10-
imports = [ ./common/user-account.nix ];
8+
nodes.benchexec = {
9+
imports = [ ./common/user-account.nix ];
1110

12-
programs.benchexec = {
13-
enable = true;
14-
users = [ user ];
15-
};
11+
programs.benchexec = {
12+
enable = true;
13+
users = [ user ];
1614
};
15+
};
1716

18-
testScript =
19-
{ ... }:
20-
let
21-
runexec = lib.getExe' pkgs.benchexec "runexec";
22-
echo = builtins.toString pkgs.benchexec;
23-
test = lib.getExe (
24-
pkgs.writeShellApplication rec {
25-
name = "test";
26-
meta.mainProgram = name;
27-
text = "echo '${echo}'";
28-
}
29-
);
30-
wd = "/tmp";
31-
stdout = "${wd}/runexec.out";
32-
stderr = "${wd}/runexec.err";
33-
in
34-
''
35-
start_all()
36-
machine.wait_for_unit("multi-user.target")
37-
benchexec.succeed(''''\
38-
systemd-run \
39-
--property='StandardOutput=file:${stdout}' \
40-
--property='StandardError=file:${stderr}' \
41-
--unit=runexec --wait --user --machine='${user}@' \
42-
--working-directory ${wd} \
43-
'${runexec}' \
44-
--debug \
45-
--read-only-dir / \
46-
--hidden-dir /home \
47-
'${test}' \
48-
'''')
49-
benchexec.succeed("grep -s '${echo}' ${wd}/output.log")
50-
benchexec.succeed("test \"$(grep -Ec '((start|wall|cpu)time|memory)=' ${stdout})\" = 4")
51-
benchexec.succeed("! grep -E '(WARNING|ERROR)' ${stderr}")
52-
'';
53-
54-
interactive.nodes.benchexec.services.kmscon = {
55-
enable = true;
56-
fonts = [
57-
{
58-
name = "Fira Code";
59-
package = pkgs.fira-code;
17+
testScript =
18+
{ ... }:
19+
let
20+
runexec = lib.getExe' pkgs.benchexec "runexec";
21+
echo = builtins.toString pkgs.benchexec;
22+
test = lib.getExe (
23+
pkgs.writeShellApplication rec {
24+
name = "test";
25+
meta.mainProgram = name;
26+
text = "echo '${echo}'";
6027
}
61-
];
62-
};
63-
}
64-
)
28+
);
29+
wd = "/tmp";
30+
stdout = "${wd}/runexec.out";
31+
stderr = "${wd}/runexec.err";
32+
in
33+
''
34+
start_all()
35+
machine.wait_for_unit("multi-user.target")
36+
benchexec.succeed(''''\
37+
systemd-run \
38+
--property='StandardOutput=file:${stdout}' \
39+
--property='StandardError=file:${stderr}' \
40+
--unit=runexec --wait --user --machine='${user}@' \
41+
--working-directory ${wd} \
42+
'${runexec}' \
43+
--debug \
44+
--read-only-dir / \
45+
--hidden-dir /home \
46+
'${test}' \
47+
'''')
48+
benchexec.succeed("grep -s '${echo}' ${wd}/output.log")
49+
benchexec.succeed("test \"$(grep -Ec '((start|wall|cpu)time|memory)=' ${stdout})\" = 4")
50+
benchexec.succeed("! grep -E '(WARNING|ERROR)' ${stderr}")
51+
'';
52+
53+
interactive.nodes.benchexec.services.kmscon = {
54+
enable = true;
55+
fonts = [
56+
{
57+
name = "Fira Code";
58+
package = pkgs.fira-code;
59+
}
60+
];
61+
};
62+
}

0 commit comments

Comments
 (0)