commit 58e8e7030d3d6edf1a4a1c5507423621543db4ba Author: Kristof Provost Date: Fri Sep 28 17:53:40 2018 +0200 tests: Basic nested jail test With VIMAGE activated there was an issue with the detection of IP address clashes in jails. Attempt to provoke this by creating nested (non-vnet) jails. PR: 231773 diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index 24bad91a0fd..331fe647818 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -727,6 +727,8 @@ .. execve .. + jail + .. pipe .. .. diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index 0ab4a70a41b..8d9affdf216 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -62,6 +62,7 @@ WARNS?= 3 TESTS_SUBDIRS+= acct TESTS_SUBDIRS+= execve TESTS_SUBDIRS+= pipe +TESTS_SUBDIRS+= jail .include diff --git a/tests/sys/kern/jail/Makefile b/tests/sys/kern/jail/Makefile new file mode 100644 index 00000000000..b29cb017084 --- /dev/null +++ b/tests/sys/kern/jail/Makefile @@ -0,0 +1,9 @@ +# $FreeBSD$ + +PACKAGE= tests + +TESTSDIR= ${TESTSBASE}/sys/kern/jail + +ATF_TESTS_SH+= nested_jail + +.include diff --git a/tests/sys/kern/jail/nested_jail.sh b/tests/sys/kern/jail/nested_jail.sh new file mode 100644 index 00000000000..49105073386 --- /dev/null +++ b/tests/sys/kern/jail/nested_jail.sh @@ -0,0 +1,31 @@ +# $FreeBSD$ + +atf_test_case "basic" "cleanup" +basic_head() +{ + atf_set descr 'Basic nested jails test' + atf_set require.user root +} + +basic_body() +{ + # Create the first jail + jail -c name=basejail persist \ + ip4.addr=192.0.2.1 ip4.addr=192.0.2.2 \ + children.max=1 + + atf_check -s exit:0 -o ignore \ + jexec basejail \ + jail -c name=nestedjail persist ip4.addr=192.0.2.2 +} + +basic_cleanup() +{ + jail -r nestedjail + jail -r basejail +} + +atf_init_test_cases() +{ + atf_add_test_case "basic" +}