blob: 61c4096a93c95f301457eaffbd4e8f16d986c65d (
plain)
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
106
107
108
|
#!/bin/sh
if dpkg --print-architecture | grep s390; then
echo "Skipping rfkill tests on s390 (LP: #1855009)"
exit 77
fi
if dpkg --print-architecture | grep i386; then
echo "Skipping rfkill tests on i386 (LP: #1855183)"
exit 77
fi
set -e
echo "+++ Building / adding fake-rfkill.ko"
make -f debian/tests/Makefile fake-rfkill
# poor man's dependency resolver
DEPS=$(modinfo debian/tests/fake-rfkill.ko | sed -n '/depends:/ {s/^.*://; s/[[:space:]]*$//; p}')
[ -z "$DEPS" ] || modprobe "$DEPS"
insmod debian/tests/fake-rfkill.ko
fake_id=$(rfkill list | grep fake | awk -F: '{ print $1; }')
echo "+++ fake-rfkill.ko is device $fake_id"
echo
echo "--- Testing killswitch bringup to match NM state: when URFKILL doesn't run"
echo "+++ stopping urfkill"
# ignore failure, only here, because urfkill probably isn't running yet.
service urfkill stop || true
echo "+++ unblocking device $fake_id"
rfkill unblock $fake_id
echo "+++ stopping network-manager"
service NetworkManager stop || true
echo "+++ blocking device $fake_id"
rfkill block $fake_id
echo "+++ starting network-manager"
service NetworkManager start
echo "+++ Waiting for the devices to settle"
sleep 30
echo -n "=== NetworkManager state should now be \"enabled\": "
LC_MESSAGES=C nmcli radio wifi
LC_MESSAGES=C nmcli radio wifi | grep -qc enabled
echo
echo -n "=== NM saved state: "
grep WirelessEnabled /var/lib/NetworkManager/NetworkManager.state
grep -qc WirelessEnabled=true /var/lib/NetworkManager/NetworkManager.state
echo
echo
echo "--- Testing killswitch bringup when URFKILL is running: follow URfkill signals"
echo "+++ starting urfkill"
service urfkill start
sleep 15
echo "+++ blocking device $fake_id"
rfkill block $fake_id
rfkill list
echo "+++ Waiting for the devices to settle"
sleep 30
echo -n "=== NetworkManager state should now be \"disabled\": "
LC_MESSAGES=C nmcli radio wifi
LC_MESSAGES=C nmcli radio wifi | grep -qc disabled
echo
echo -n "=== NM saved state: "
grep WirelessEnabled /var/lib/NetworkManager/NetworkManager.state
#grep -qc WirelessEnabled=false /var/lib/NetworkManager/NetworkManager.state
echo
echo
echo "+++ Asking urfkill to unblock device $fake_id"
dbus-send --print-reply --system --dest=org.freedesktop.URfkill /org/freedesktop/URfkill org.freedesktop.URfkill.BlockIdx uint32:$fake_id boolean:false
sleep 5
echo -n "=== NetworkManager state should now be \"enabled\": "
LC_MESSAGES=C nmcli radio wifi
LC_MESSAGES=C nmcli radio wifi | grep -qc enabled
echo
echo "+++ Asking urfkill to block device $fake_id again"
dbus-send --print-reply --system --dest=org.freedesktop.URfkill /org/freedesktop/URfkill org.freedesktop.URfkill.BlockIdx uint32:$fake_id boolean:true
sleep 5
echo -n "=== NetworkManager state should now be \"disabled\": "
LC_MESSAGES=C nmcli radio wifi
LC_MESSAGES=C nmcli radio wifi | grep -qc disabled
echo
echo
echo "--- Removing fake-rfkill, aggregate state should get back to enabled"
rmmod fake-rfkill
sleep 5
echo -n "=== Checking that the fake device $fake_id has disappeared: "
rfkill list | ( ! grep -qc fake || exit 1 ) && echo yes || echo no
echo -n "=== NetworkManager state should now be \"enabled\": "
LC_MESSAGES=C nmcli radio wifi
LC_MESSAGES=C nmcli radio wifi | grep -qc enabled
echo
#cleanup
make -f debian/tests/Makefile clean-rfkill
echo OK
exit 0
|