Skip to content

Commit 62ebf08

Browse files
committed
tests: test APK
Signed-off-by: Paul Spooren <mail@aparcar.org>
1 parent 35c0600 commit 62ebf08

3 files changed

Lines changed: 71 additions & 10 deletions

File tree

.github/workflows/snapshots.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
PYTHONUNBUFFERED: "1"
1212
PYTEST_ADDOPTS: "--color=yes"
1313
UPSTREAM_URL: "https://downloads.openwrt.org/snapshots/targets"
14+
LG_FEATURE_APK: "true"
1415

1516
concurrency:
1617
group: ${{ github.workflow }}-${{ github.ref }}
@@ -144,6 +145,8 @@ jobs:
144145
test-qemu:
145146
name: QEMU ${{ matrix.target }}
146147
runs-on: ubuntu-latest
148+
env:
149+
LG_FEATURE_ONLINE: "true"
147150
strategy:
148151
fail-fast: false
149152
matrix:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies = [
88
"allure-pytest>=2.14.3",
99
"labgrid>=25.0",
1010
"pytest>=8.4.1",
11+
"pytest-check>=2.5.3",
1112
"pytest-harvest>=1.10.5",
1213
]
1314

tests/test_apk.py

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,72 @@
1+
import os
2+
13
import pytest
24

35

4-
@pytest.mark.lg_feature("apk")
5-
def test_apk_procd_installed(ssh_command):
6-
assert "procd" in "\n".join(ssh_command.run_check("apk list"))
6+
@pytest.mark.skipif(
7+
os.getenv("LG_FEATURE_APK") is None, reason="LG_FEATURE_APK not defined"
8+
)
9+
class TestApk:
10+
def test_apk_procd_installed(self, ssh_command):
11+
assert "procd" in "\n".join(ssh_command.run_check("apk list"))
12+
13+
@pytest.mark.skipif(
14+
os.getenv("LG_TEST_ONLINE") is None, reason="LG_TEST_ONLINE not defined"
15+
)
16+
def test_apk_add_ucert(self, ssh_command):
17+
try:
18+
ssh_command.run_check("apk add ucert")
19+
assert "ucert" in "\n".join(ssh_command.run_check("apk list | grep ucert"))
20+
finally:
21+
ssh_command.run("apk del ucert")
722

23+
def test_apk_audit(self, ssh_command, check):
24+
changes = ssh_command.run_check("apk audit")
25+
expected_changes = [
26+
"A etc/urandom.seed",
27+
"A etc/board.json",
28+
"A etc/apk/arch",
29+
"A etc/apk/repositories.d/customfeeds.list",
30+
"A etc/apk/repositories.d/distfeeds.list",
31+
"A etc/apk/world",
32+
"U etc/config/dhcp",
33+
"A etc/config/network",
34+
"A etc/config/system",
35+
"A etc/dropbear/dropbear_rsa_host_key",
36+
"A etc/dropbear/dropbear_ed25519_host_key",
37+
"U etc/group",
38+
"U etc/passwd",
39+
"A etc/rc.d/K10gpio_switch",
40+
"A etc/rc.d/K50dropbear",
41+
"A etc/rc.d/K85odhcpd",
42+
"A etc/rc.d/K89log",
43+
"A etc/rc.d/K90boot",
44+
"A etc/rc.d/K90network",
45+
"A etc/rc.d/K90sysfixtime",
46+
"A etc/rc.d/K90umount",
47+
"A etc/rc.d/S00sysfixtime",
48+
"A etc/rc.d/S00urngd",
49+
"A etc/rc.d/S10boot",
50+
"A etc/rc.d/S10system",
51+
"A etc/rc.d/S11sysctl",
52+
"A etc/rc.d/S12log",
53+
"A etc/rc.d/S19dnsmasq",
54+
"A etc/rc.d/S19dropbear",
55+
"A etc/rc.d/S19firewall",
56+
"A etc/rc.d/S20network",
57+
"A etc/rc.d/S25packet_steering",
58+
"A etc/rc.d/S35odhcpd",
59+
"A etc/rc.d/S50cron",
60+
"A etc/rc.d/S94gpio_switch",
61+
"A etc/rc.d/S95done",
62+
"A etc/rc.d/S96led",
63+
"A etc/rc.d/S98sysntpd",
64+
"A etc/rc.d/S99urandom_seed",
65+
"U etc/shadow",
66+
]
867

9-
@pytest.mark.lg_feature(["online", "apk"])
10-
def test_apk_add_ucert(ssh_command):
11-
try:
12-
ssh_command.run_check("apk add ucert")
13-
assert "ucert" in "\n".join(ssh_command.run_check("apk list | grep ucert"))
14-
finally:
15-
ssh_command.run("apk del ucert")
68+
for expected in expected_changes:
69+
with check:
70+
assert expected in changes, (
71+
f"Expected change '{expected}' not found in audit output"
72+
)

0 commit comments

Comments
 (0)