osmith submitted this change.
ggsn: testenv: support running osmo-ggsn in QEMU
Run osmo-ggsn optionally in QEMU, to test the kernel GTP-U feature
with different kernels.
Related: OS#3208
Change-Id: I3f9db4325d5928c809cc99bc82d9cb82bf9e71eb
---
A ggsn_tests/osmo-ggsn/run.sh
M ggsn_tests/osmo-ggsn/testenv.sh
M ggsn_tests/testenv_osmo_ggsn_all.cfg
M ggsn_tests/testenv_osmo_ggsn_v4_only.cfg
M ggsn_tests/testenv_osmo_ggsn_v4v6_only.cfg
M ggsn_tests/testenv_osmo_ggsn_v6_only.cfg
6 files changed, 74 insertions(+), 6 deletions(-)
diff --git a/ggsn_tests/osmo-ggsn/run.sh b/ggsn_tests/osmo-ggsn/run.sh
new file mode 100755
index 0000000..ae77484
--- /dev/null
+++ b/ggsn_tests/osmo-ggsn/run.sh
@@ -0,0 +1,40 @@
+#!/bin/sh -ex
+if [ -z "$TESTENV_QEMU_KERNEL" ]; then
+ exec osmo-ggsn "$@"
+fi
+
+build_initrd() {
+ qemu_initrd_init
+
+ qemu_initrd_add_mod \
+ gtp \
+ tun
+
+ qemu_initrd_add_bin \
+ osmo-ggsn
+
+ qemu_initrd_add_file \
+ osmo-ggsn.cfg
+
+ # Enable dynamic_debug
+ qemu_initrd_add_cmd \
+ "mount -t debugfs none /sys/kernel/debug || true" \
+ "echo -n 'module gtp +p' > /sys/kernel/debug/dynamic_debug/control || true"
+
+ qemu_initrd_add_cmd \
+ "ip addr add 172.18.3.2/24 brd 172.18.3.255 dev eth0" \
+ "ip addr add 172.18.3.201/24 brd 172.18.3.255 dev eth0" \
+ "ip route add default via 172.18.3.1 dev eth0" \
+ "sysctl net.ipv4.ip_forward=1" \
+ "osmo-ggsn"
+
+ qemu_initrd_finish
+}
+
+. qemu_functions.sh
+
+if ! build_initrd >build_initrd.log 2>&1; then
+ qemu_initrd_exit_error "build_initrd.log"
+fi
+
+qemu_run
diff --git a/ggsn_tests/osmo-ggsn/testenv.sh b/ggsn_tests/osmo-ggsn/testenv.sh
index 4155d52..0c0bc37 100755
--- a/ggsn_tests/osmo-ggsn/testenv.sh
+++ b/ggsn_tests/osmo-ggsn/testenv.sh
@@ -22,6 +22,15 @@
esac
}
+check_usage_qemu() {
+ if [ -n "$TESTENV_QEMU_KERNEL" ] && [ "$CONFIG" = "all" ]; then
+ set +x
+ echo "ERROR: '--config osmo_ggsn_all' uses multiple APNs, which is currently not supported with kernel" \
+ "gtp-u! (OS#6106)"
+ exit 1
+ fi
+}
+
replace_ips() {
# Run osmo-ggsn on 172.18.3.x (testenv0 bridge) instead of
# 127.0.0.1 (lo), so it works when running osmo-ggsn in QEMU to test
@@ -37,6 +46,10 @@
> osmo-ggsn.cfg
replace_ips osmo-ggsn.cfg
+
+ if [ -n "$TESTENV_QEMU_KERNEL" ]; then
+ sed -i "s/gtpu-mode tun/gtpu-mode kernel-gtp/" osmo-ggsn.cfg
+ fi
}
adjust_ttcn3_config() {
@@ -49,7 +62,9 @@
}
setcap_osmo_ggsn() {
- sudo setcap CAP_NET_ADMIN=+eip $(which osmo-ggsn)
+ if [ -z "$TESTENV_QEMU_KERNEL" ]; then
+ sudo setcap CAP_NET_ADMIN=+eip $(which osmo-ggsn)
+ fi
}
rename_junit_xml_classname() {
@@ -64,10 +79,15 @@
# Add a bridge reachable through the GTP tunnel that can answer ICMP
# pings (for e.g. TC_pdp4_act_deact_gtpu_access). The bridge is also used to
# connect the SUT when it runs in QEMU.
-EXTRA_IPS="172.18.3.201 fd02:db8:3::201 172.18.3.2" add_remove_testenv0_bridge.sh
+if [ -n "$TESTENV_QEMU_KERNEL" ]; then
+ add_remove_testenv0_bridge.sh
+else
+ EXTRA_IPS="172.18.3.201 fd02:db8:3::201 172.18.3.2" add_remove_testenv0_bridge.sh
+fi
case "$TESTENV_CLEAN_REASON" in
prepare)
+ check_usage_qemu
adjust_osmo_ggsn_config
adjust_ttcn3_config
setcap_osmo_ggsn
diff --git a/ggsn_tests/testenv_osmo_ggsn_all.cfg b/ggsn_tests/testenv_osmo_ggsn_all.cfg
index 4c33b43..c389064 100644
--- a/ggsn_tests/testenv_osmo_ggsn_all.cfg
+++ b/ggsn_tests/testenv_osmo_ggsn_all.cfg
@@ -3,7 +3,9 @@
config=GGSN_Tests.cfg
[ggsn]
-program=osmo-ggsn
+qemu=optional
+program=osmo-ggsn/run.sh
+setup=qemu_wait.sh
make=osmo-ggsn
package=osmo-ggsn libosmocore-utils
copy=osmo-ggsn
diff --git a/ggsn_tests/testenv_osmo_ggsn_v4_only.cfg b/ggsn_tests/testenv_osmo_ggsn_v4_only.cfg
index 57e736f..604864d 100644
--- a/ggsn_tests/testenv_osmo_ggsn_v4_only.cfg
+++ b/ggsn_tests/testenv_osmo_ggsn_v4_only.cfg
@@ -3,7 +3,9 @@
config=GGSN_Tests.cfg
[ggsn]
-program=osmo-ggsn
+qemu=optional
+program=osmo-ggsn/run.sh
+setup=qemu_wait.sh
make=osmo-ggsn
package=osmo-ggsn libosmocore-utils
copy=osmo-ggsn
diff --git a/ggsn_tests/testenv_osmo_ggsn_v4v6_only.cfg b/ggsn_tests/testenv_osmo_ggsn_v4v6_only.cfg
index 6f0e11f..b037c0c 100644
--- a/ggsn_tests/testenv_osmo_ggsn_v4v6_only.cfg
+++ b/ggsn_tests/testenv_osmo_ggsn_v4v6_only.cfg
@@ -3,7 +3,9 @@
config=GGSN_Tests.cfg
[ggsn]
-program=osmo-ggsn
+qemu=optional
+program=osmo-ggsn/run.sh
+setup=qemu_wait.sh
make=osmo-ggsn
package=osmo-ggsn libosmocore-utils
copy=osmo-ggsn
diff --git a/ggsn_tests/testenv_osmo_ggsn_v6_only.cfg b/ggsn_tests/testenv_osmo_ggsn_v6_only.cfg
index 101538f..fdaa395 100644
--- a/ggsn_tests/testenv_osmo_ggsn_v6_only.cfg
+++ b/ggsn_tests/testenv_osmo_ggsn_v6_only.cfg
@@ -3,7 +3,9 @@
config=GGSN_Tests.cfg
[ggsn]
-program=osmo-ggsn
+qemu=optional
+program=osmo-ggsn/run.sh
+setup=qemu_wait.sh
make=osmo-ggsn
package=osmo-ggsn libosmocore-utils
copy=osmo-ggsn
To view, visit change 38344. To unsubscribe, or for help writing mail filters, visit settings.