summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2023-01-25 15:36:26 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2023-01-25 14:47:22 +0000
commit6424b345be8c083e253aefa14a9f06328f949813 (patch)
tree9c27a8777ae831819ae21df9b2002e0bc1d73e1d
parente3a6f3f0115ab533558dd69d8cfa2b194f8403e8 (diff)
downloadalpine-conf-6424b345be8c083e253aefa14a9f06328f949813.zip
setup-interfaces: add tests for auto
-rw-r--r--setup-interfaces.in2
-rwxr-xr-xtests/setup_interfaces_test26
2 files changed, 26 insertions, 2 deletions
diff --git a/setup-interfaces.in b/setup-interfaces.in
index 33e9219..a5cc9ed 100644
--- a/setup-interfaces.in
+++ b/setup-interfaces.in
@@ -550,7 +550,7 @@ prompt_for_interfaces() {
auto_setup() {
local iface
for iface in $(available_ifaces); do
- if [ "$(cat "$ROOT"/sys/class/net/$iface/operstate)" = "up" ]; then
+ if [ "$(cat "$ROOT"/sys/class/net/$iface/operstate 2>/dev/null)" = "up" ]; then
break
fi
done
diff --git a/tests/setup_interfaces_test b/tests/setup_interfaces_test
index 35dce72..4a611ab 100755
--- a/tests/setup_interfaces_test
+++ b/tests/setup_interfaces_test
@@ -12,7 +12,10 @@ init_tests \
setup_interfaces_interactive_br0 \
setup_interfaces_interactive_bond0 \
setup_interfaces_interactive_wlan0_psk \
- setup_interfaces_interactive_wlan0_open
+ setup_interfaces_interactive_wlan0_open \
+ setup_interfaces_auto \
+ setup_interfaces_auto_none \
+ setup_interfaces_auto_restart
setup_interfaces_usage_body() {
test_usage setup-interfaces
@@ -233,3 +236,24 @@ setup_interfaces_interactive_wlan0_open_body() {
-o match:"Ip address for wlan0" \
setup-interfaces <answers
}
+
+setup_interfaces_auto_body() {
+ init_env
+ create_fake_ifaces lo eth0
+ atf_check -s exit:0 \
+ setup-interfaces -a
+}
+
+setup_interfaces_auto_none_body() {
+ init_env
+ atf_check -s exit:0 \
+ setup-interfaces -a
+}
+
+setup_interfaces_auto_restart_body() {
+ init_env
+ create_fake_ifaces lo eth0
+ atf_check -s exit:0 \
+ setup-interfaces -a -r
+ atf_check -o match:"status: started" rc-service networking status
+}