diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-07-05 17:32:15 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-07-05 17:32:15 +0200 |
commit | 9d4574d45d2544b94d28244441ea8042da090fbb (patch) | |
tree | 8791aaa90f4c023b56816cd3f3d00fb12a312e46 | |
parent | 812bd55f014dc68d70586dcf6d046b296927372b (diff) | |
download | alpine-conf-9d4574d45d2544b94d28244441ea8042da090fbb.zip |
tests: setup-interfaces: add simple test for dhcp
-rwxr-xr-x | tests/setup_interfaces_test | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/setup_interfaces_test b/tests/setup_interfaces_test index e486083..fc652c1 100755 --- a/tests/setup_interfaces_test +++ b/tests/setup_interfaces_test @@ -2,9 +2,35 @@ . $(atf_get_srcdir)/test_env.sh init_tests \ - setup_interfaces_usage + setup_interfaces_usage \ + setup_interfaces_interactive_dhcp setup_interfaces_usage_body() { test_usage setup-interfaces } +create_fake_ifaces() { + local n=1 + for i; do + mkdir -p sys/class/net/$i + echo $n > sys/class/net/$i/ifindex + echo down >sys/class/net/$i/operstate + n=$((n+1)) + done +} + +setup_interfaces_interactive_dhcp_body() { + init_env + create_fake_ifaces lo eth0 + ( + # Which one do you want to initialize? (or '?' or 'done') [eth0] + echo eth0 + # Ip address for eth0? (or 'dhcp', 'none', '?') [dhcp] + echo dhcp + # Do you want to do any manual network configuration? (y/n) [n] + echo n + )>answers + atf_check -s exit:0 \ + -o match:"Available interfaces are: eth0" \ + setup-interfaces <answers +} |