Add set_clean_up_trap() in jenkins-common.sh and run it at the beginning of the jenkins.sh files. Move the common clean up code from the end of every jenkins.sh file into clean_up_common(), which gets called by the trap. Add a custom clean_up() function to those jenkins.sh files that need additional clean up.
Replace explicit container stop commands (for containers attached to the docker network) with one call to network_clean() in clean_up_common(). It kills all containers attached to the docker network.
The motivation for this change is the upcoming optional build of initrd and kernel during ttcn3-ggsn-test/jenkins.sh. After building these, a short smoke test will be performed to make sure we can boot the kernel and initrd, before continuing to run the entire testsuite against it. If building or the smoke test fails, we must do a proper clean up of the network and fix permissions.
Abort the script and trigger the clean up script, whenever any of the commands below to prepare the testsuite are failing. This saves time with figuring out why suddenly all or most tests are failing, and avoids running the entire testsuite on jenkins if it's obviously not going to work.
jenkins-common: put fix_perms() in clean_up_common
Don't call fix_perms from collect_logs anymore, it looks like it was only added there to avoid adding it at the end of each jenkins.sh. Now that we have clean_up_common, put it there.
Make it possible to run ttcn3-ggsn-test against osmo-ggsn with the GTP kernel module. This feature is enabled by environment variables explained in ttcn3-ggsn-test/jenkins.sh, and can either use the pre-built kernel from Debian, or build a kernel from source.
The kernel runs inside QEMU inside the usual osmo-ggsn-master docker image.
Thanks to Pau for providing the kernel config and kernel-test scripts that this patch is based on! I ended up modifying them quite a bit to fit the docker use case, and to build the initrd (so we can use the stock debian kernel).