diff --git a/tests/unit_tests/test_target/base_config.yaml b/tests/unit_tests/test_target/base_config.yaml index 40d2e68c9..2d9d823b3 100644 --- a/tests/unit_tests/test_target/base_config.yaml +++ b/tests/unit_tests/test_target/base_config.yaml @@ -45,6 +45,7 @@ patches: - ./patches/tests/syscalls_logger.yaml - ./patches/tests/lifeguard.yaml - ./patches/tests/nvram.yaml + - ./patches/tests/net_external.yaml # - ./patches/tests/uboot_env_cmp.yaml diff --git a/tests/unit_tests/test_target/patches/tests/net_external.yaml b/tests/unit_tests/test_target/patches/tests/net_external.yaml new file mode 100644 index 000000000..fa240390a --- /dev/null +++ b/tests/unit_tests/test_target/patches/tests/net_external.yaml @@ -0,0 +1,51 @@ +core: + network: true + +plugins: + verifier: + conditions: + net_external: + type: file_contains + file: console.log + string: "/tests/zzznet_external.sh PASS" + + +static_files: + #zzz here to ensure it runs last + /tests/zzznet_external.sh: + type: inline_file + contents: | + #!/igloo/utils/sh + set -ex + + /igloo/utils/busybox sleep 5 + + /igloo/utils/busybox ip addr flush dev eth0 + /igloo/utils/busybox ip route flush table main + + /igloo/utils/busybox ip link set eth0 down + /igloo/utils/busybox ip link set eth0 up + + # If iptables is available, reset firewall rules completely + if /igloo/utils/busybox which iptables >/dev/null 2>&1; then + /igloo/utils/busybox iptables -F + /igloo/utils/busybox iptables -X + /igloo/utils/busybox iptables -t nat -F + /igloo/utils/busybox iptables -t nat -X + /igloo/utils/busybox iptables -P INPUT ACCEPT + /igloo/utils/busybox iptables -P FORWARD ACCEPT + /igloo/utils/busybox iptables -P OUTPUT ACCEPT + fi + /igloo/utils/busybox ip addr add 10.0.2.15/24 dev eth0 + /igloo/utils/busybox ip route add default via 10.0.2.2 + + /igloo/utils/busybox ping -c 3 8.8.8.8 + + if [ $? -ne 0 ]; then + echo "FAILED to ping external IP" + exit 1 + else + echo "PASSED ping to external IP" + exit 0 + fi + mode: 73 \ No newline at end of file