shellcheck / shellcheck (push) Failing after 14s
archinstall's "Copy ISO network configuration", which a user who connected with iwctl may pick, turns on iwd and systemd-networkd. CoreDesktop then turns on NetworkManager too, and after a restart two services fight over the Wi-Fi card. system/wifi.sh disables iwd and systemd-networkd, without stopping them, when NetworkManager is enabled and isn't set to use iwd itself. install.sh runs it, and a migration runs it on existing machines. The README tells users to choose NetworkManager in archinstall. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
1.9 KiB
Bash
63 lines
1.9 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
# system/wifi.sh with fake systemctl, sudo and NetworkManager. $ENABLED lists
|
|
# the enabled units; $NM_CONFIG is what NetworkManager --print-config prints.
|
|
|
|
setup() {
|
|
common_setup
|
|
export ENABLED="NetworkManager.service iwd.service systemd-networkd.service"
|
|
export NM_CONFIG=$'[device]\n# wifi.backend=wpa_supplicant'
|
|
stub systemctl '[ "$1" = is-enabled ] || exit 0
|
|
[[ " $ENABLED " == *" ${!#} "* ]]'
|
|
stub sudo '"$@"'
|
|
stub NetworkManager 'echo "$NM_CONFIG"'
|
|
}
|
|
|
|
@test "wifi.sh turns off iwd and systemd-networkd alongside NetworkManager" {
|
|
run bash "$REPO/system/wifi.sh"
|
|
[ "$status" -eq 0 ]
|
|
called systemctl disable iwd.service
|
|
called systemctl disable systemd-networkd.service systemd-networkd.socket systemd-networkd-wait-online.service
|
|
[[ "$output" == *"GNOME's top-right menu"* ]]
|
|
}
|
|
|
|
@test "wifi.sh leaves systemd-networkd alone when it's off" {
|
|
ENABLED="NetworkManager.service iwd.service"
|
|
run bash "$REPO/system/wifi.sh"
|
|
[ "$status" -eq 0 ]
|
|
called systemctl disable iwd.service
|
|
uncalled systemctl disable systemd-networkd.service systemd-networkd.socket systemd-networkd-wait-online.service
|
|
}
|
|
|
|
@test "wifi.sh does nothing without iwd" {
|
|
ENABLED="NetworkManager.service systemd-networkd.service"
|
|
run bash "$REPO/system/wifi.sh"
|
|
[ "$status" -eq 0 ]
|
|
[ -z "$output" ]
|
|
not_called sudo
|
|
}
|
|
|
|
@test "wifi.sh does nothing when NetworkManager is off" {
|
|
ENABLED="iwd.service systemd-networkd.service"
|
|
run bash "$REPO/system/wifi.sh"
|
|
[ "$status" -eq 0 ]
|
|
[ -z "$output" ]
|
|
not_called sudo
|
|
}
|
|
|
|
@test "wifi.sh leaves iwd to NetworkManager set up to use it" {
|
|
NM_CONFIG=$'[device]\nwifi.backend=iwd'
|
|
run bash "$REPO/system/wifi.sh"
|
|
[ "$status" -eq 0 ]
|
|
[ -z "$output" ]
|
|
not_called sudo
|
|
}
|
|
|
|
@test "wifi.sh fails when it can't turn iwd off" {
|
|
stub sudo 'exit 1'
|
|
run bash "$REPO/system/wifi.sh"
|
|
[ "$status" -eq 1 ]
|
|
}
|