summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Asselstine <mark.asselstine@windriver.com>2018-10-11 20:28:32 +0000
committerBruce Ashfield <bruce.ashfield@windriver.com>2018-10-12 10:30:43 -0400
commit39fd98a285699c32cf61fe3609e41e341319b06a (patch)
tree8acea1967428956c6b3d0c9fab1383f276ef2ad0
parent6013c088a2f9357ac940aa89d0bee476e8d8b366 (diff)
downloadmeta-virtualization-39fd98a285699c32cf61fe3609e41e341319b06a.tar.gz
lxc: use compiled tests instead of copying source building on target
The tests are already built when we do_compile so we only need to copy them to the ptest path and create a wrapper script to run them. This has the added benefit of reducing the size of the lxc package. We have to manipulate the test sources some to remove gpg validation and a few other minor changes, none of which actually change what is being tested (notes are provided in the associated commit logs). The following are the ptest results currently acheived: BEGIN: /usr/lib/lxc/ptest # Starting LXC ptest ### ./tests/lxc-test-apparmor SKIPPED ./tests/lxc-test-attach FAIL ./tests/lxc-test-automount PASS ./tests/lxc-test-autostart FAIL ./tests/lxc-test-cgpath PASS ./tests/lxc-test-cloneconfig PASS ./tests/lxc-test-clonetest PASS ./tests/lxc-test-concurrent PASS ./tests/lxc-test-console FAIL ./tests/lxc-test-containertests PASS ./tests/lxc-test-createconfig PASS ./tests/lxc-test-createtest FAIL ./tests/lxc-test-destroytest FAIL ./tests/lxc-test-device-add-remove PASS ./tests/lxc-test-get_item PASS ./tests/lxc-test-getkeys PASS ./tests/lxc-test-list PASS ./tests/lxc-test-locktests PASS ./tests/lxc-test-lxcpath PASS ./tests/lxc-test-may-control PASS ./tests/lxc-test-reboot PASS ./tests/lxc-test-saveconfig PASS ./tests/lxc-test-shutdowntest SKIPPED ./tests/lxc-test-snapshot PASS ./tests/lxc-test-startone PASS ./tests/lxc-test-utils PASS Results: PASSED = 19 FAILED = 5 SKIPPED = 2 (for details check individual test log in ./logs directory) ### LXC ptest complete ### Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> Signed-off-by: Sinan Kaya <okaya@kernel.org> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r--recipes-containers/lxc/files/automake-ensure-VPATH-builds-correctly.patch26
-rw-r--r--recipes-containers/lxc/files/run-ptest57
-rw-r--r--recipes-containers/lxc/files/runtest.patch32
-rw-r--r--recipes-containers/lxc/files/template-make-busybox-template-compatible-with-core-.patch60
-rw-r--r--recipes-containers/lxc/files/tests-add-no-validate-when-using-download-template.patch74
-rw-r--r--recipes-containers/lxc/files/tests-our-init-is-not-busybox.patch32
-rw-r--r--recipes-containers/lxc/lxc_2.0.8.bb13
7 files changed, 228 insertions, 66 deletions
diff --git a/recipes-containers/lxc/files/automake-ensure-VPATH-builds-correctly.patch b/recipes-containers/lxc/files/automake-ensure-VPATH-builds-correctly.patch
deleted file mode 100644
index 61c0e293..00000000
--- a/recipes-containers/lxc/files/automake-ensure-VPATH-builds-correctly.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1From fe23085d9a40d6d78387d9ce8ddb65785fe8d6e5 Mon Sep 17 00:00:00 2001
2From: Bogdan Purcareata <bogdan.purcareata@freescale.com>
3Date: Thu, 2 Oct 2014 18:31:50 -0400
4Subject: [PATCH] automake: ensure VPATH builds correctly
5
6Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
7---
8 src/tests/Makefile.am | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
12index d74c10d..6225f78 100644
13--- a/src/tests/Makefile.am
14+++ b/src/tests/Makefile.am
15@@ -66,7 +66,7 @@ buildtest-TESTS: $(TESTS)
16 install-ptest:
17 install -d $(TEST_DIR)
18 install -D ../lxc/.libs/liblxc.so $(TEST_DIR)/../lxc/liblxc.so
19- install -D ../../config/test-driver $(TEST_DIR)/../../config/test-driver
20+ install -D $(top_srcdir)/config/test-driver $(TEST_DIR)/../../config/test-driver
21 cp Makefile $(TEST_DIR)
22 @(for file in $(TESTS); do install $$file $(TEST_DIR); done;)
23 sed -i 's|^Makefile:|_Makefile:|' $(TEST_DIR)/Makefile
24--
251.7.10.4
26
diff --git a/recipes-containers/lxc/files/run-ptest b/recipes-containers/lxc/files/run-ptest
index 23a6256b..e9855449 100644
--- a/recipes-containers/lxc/files/run-ptest
+++ b/recipes-containers/lxc/files/run-ptest
@@ -1,4 +1,57 @@
1#!/bin/sh 1#!/bin/bash
2 2
3make -C src/tests -k check-TESTS 3# Network interfaces come up and down and can be quite noisy
4# and since we are often on the console when running ptests
5# let's just quiet things some
6dmesg -n 1
4 7
8# Blacklisted test will be skipped
9blacklist=""
10# Not applicable
11blacklist="$blacklist lxc-test-apparmor"
12# These currently hang so skip them until someone fixes them up
13blacklist="$blacklist lxc-test-shutdowntest"
14blacklist="$blacklist lxc-test-state-server"
15
16passed=0
17failed=0
18skipped=0
19
20# Create logs dir and clear old logs if any
21mkdir logs 2> /dev/null
22rm -f logs/*
23
24echo "### Starting LXC ptest ###"
25
26for test in ./tests/*
27do
28 if [[ ! $blacklist = *$(basename $test)* ]]
29 then
30 $test >logs/$(basename $test).log 2>&1
31 else
32 echo "$test SKIPPED"
33 skipped=$((skipped+1))
34 continue
35 fi
36
37 if [ $? -eq 0 ]
38 then
39 echo "$test PASS"
40 passed=$((passed+1))
41 else
42 echo "$test FAIL"
43 failed=$((failed+1))
44 fi
45done
46
47echo ""
48echo "Results:"
49echo " PASSED = $passed"
50echo " FAILED = $failed"
51echo " SKIPPED = $skipped"
52echo "(for details check individual test log in ./logs directory)"
53echo ""
54echo "### LXC ptest complete ###"
55
56# restore dmesg to console
57dmesg -n 6
diff --git a/recipes-containers/lxc/files/runtest.patch b/recipes-containers/lxc/files/runtest.patch
deleted file mode 100644
index 6572265f..00000000
--- a/recipes-containers/lxc/files/runtest.patch
+++ /dev/null
@@ -1,32 +0,0 @@
1Add install-ptest rule.
2
3Signed-off-by: Mihaela Sendrea <mihaela.sendrea@enea.com>
4Upstream-status: Pending
5
6diff -uNr a/src/tests/Makefile.am b/src/tests/Makefile.am
7--- a/src/tests/Makefile.am 2014-04-07 16:25:59.246238815 +0300
8+++ b/src/tests/Makefile.am 2014-04-10 18:09:43.195772467 +0300
9@@ -54,6 +54,23 @@
10
11 endif
12
13+TESTS = lxc-test-containertests lxc-test-locktests \
14+ lxc-test-getkeys lxc-test-lxcpath lxc-test-cgpath lxc-test-console \
15+ lxc-test-snapshot lxc-test-concurrent lxc-test-may-control \
16+ lxc-test-reboot lxc-test-list lxc-test-attach lxc-test-device-add-remove
17+
18+buildtest-TESTS: $(TESTS)
19+
20+install-ptest:
21+ install -d $(TEST_DIR)
22+ install -D ../lxc/.libs/liblxc.so $(TEST_DIR)/../lxc/liblxc.so
23+ install -D ../../config/test-driver $(TEST_DIR)/../../config/test-driver
24+ cp Makefile $(TEST_DIR)
25+ @(for file in $(TESTS); do install $$file $(TEST_DIR); done;)
26+ sed -i 's|^Makefile:|_Makefile:|' $(TEST_DIR)/Makefile
27+ sed -i 's|^all-am:|_all-am:|' $(TEST_DIR)/Makefile
28+ sed -i -e 's|^\(.*\.log:\) \(.*EXEEXT.*\)|\1|g' $(TEST_DIR)/Makefile
29+
30 EXTRA_DIST = \
31 cgpath.c \
32 clonetest.c \
diff --git a/recipes-containers/lxc/files/template-make-busybox-template-compatible-with-core-.patch b/recipes-containers/lxc/files/template-make-busybox-template-compatible-with-core-.patch
new file mode 100644
index 00000000..1d472d31
--- /dev/null
+++ b/recipes-containers/lxc/files/template-make-busybox-template-compatible-with-core-.patch
@@ -0,0 +1,60 @@
1From f64f39f54fa33c729c76626d337107f21def8f0b Mon Sep 17 00:00:00 2001
2From: Mark Asselstine <mark.asselstine@windriver.com>
3Date: Thu, 31 May 2018 11:44:44 -0400
4Subject: [PATCH 1/3] template: make busybox template compatible with
5 core-image-minimal
6
7The busybox template makes a lot of assumptions about how the busybox
8binary found on the host was configured. Building core-image-minimal
9"out of the box" does not configure busybox's 'passwd' or 'init'
10applets so we need to work around this.
11
12Chances are if you attempt to use the busybox template with a host
13which is note core-image-minimal it will fail but we are making these
14changes here to at least have the template work with
15core-image-minimal to be able to demonstrate that it can work as well
16as to have it available for the ptests.
17
18Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
19Signed-off-by: Sinan Kaya <okaya@kernel.org>
20---
21 templates/lxc-busybox.in | 16 +++++++++++++---
22 1 file changed, 13 insertions(+), 3 deletions(-)
23
24diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
25index c266668..25e4cbf 100644
26--- a/templates/lxc-busybox.in
27+++ b/templates/lxc-busybox.in
28@@ -310,6 +310,19 @@ configure_busybox()
29 return 1
30 fi
31
32+ # copy host passwd
33+ if ! cp "$(which passwd)" "${rootfs}/bin"; then
34+ echo "ERROR: Failed to copy passwd binary"
35+ return 1
36+ fi
37+
38+ # copy bash binary as the container init
39+ if ! cp "$(which bash)" "${rootfs}/sbin/init"; then
40+ echo "ERROR: Failed to copy bash binary"
41+ return 1
42+ fi
43+
44+
45 # symlink busybox for the commands it supports
46 # it would be nice to just use "chroot $rootfs busybox --install -s /bin"
47 # but that only works right in a chroot with busybox >= 1.19.0
48@@ -319,9 +332,6 @@ configure_busybox()
49 xargs -n1 ln -s busybox
50 popd > /dev/null
51
52- # relink /sbin/init
53- ln $rootfs/bin/busybox $rootfs/sbin/init
54-
55 # /etc/fstab must exist for "mount -a"
56 touch $rootfs/etc/fstab
57
58--
592.19.0
60
diff --git a/recipes-containers/lxc/files/tests-add-no-validate-when-using-download-template.patch b/recipes-containers/lxc/files/tests-add-no-validate-when-using-download-template.patch
new file mode 100644
index 00000000..4ca0b33d
--- /dev/null
+++ b/recipes-containers/lxc/files/tests-add-no-validate-when-using-download-template.patch
@@ -0,0 +1,74 @@
1From 11d930d622d20c1cf4db19a6ac6e0ee68173a3dc Mon Sep 17 00:00:00 2001
2From: Mark Asselstine <mark.asselstine@windriver.com>
3Date: Thu, 31 May 2018 15:14:26 -0400
4Subject: [PATCH 3/3] tests: add '--no-validate' when using download template
5
6We are usually running the ptests with core-image-minimal which has no
7mechanism to validate the downloads. Validation isn't really of
8interest to this test at any rate so simply add '--no-validate' to
9avoid failing due to no GPG validation.
10
11Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
12Signed-off-by: Sinan Kaya <okaya@kernel.org>
13---
14 src/tests/lxc-test-apparmor-mount | 2 +-
15 src/tests/lxc-test-autostart | 2 +-
16 src/tests/lxc-test-unpriv | 2 +-
17 src/tests/lxc-test-usernic.in | 2 +-
18 4 files changed, 4 insertions(+), 4 deletions(-)
19
20diff --git a/src/tests/lxc-test-apparmor-mount b/src/tests/lxc-test-apparmor-mount
21index bb9b1fc..a727092 100755
22--- a/src/tests/lxc-test-apparmor-mount
23+++ b/src/tests/lxc-test-apparmor-mount
24@@ -156,7 +156,7 @@ if [ -f /etc/lsb-release ]; then
25 done
26 fi
27
28-run_cmd lxc-create -t download -n $cname -- -d ubuntu -r $release -a $ARCH
29+run_cmd lxc-create -t download -n $cname -- --no-validate -d ubuntu -r $release -a $ARCH
30
31 echo "test default confined container"
32 run_cmd lxc-start -n $cname -d
33diff --git a/src/tests/lxc-test-autostart b/src/tests/lxc-test-autostart
34index 61dbdf1..921dfae 100755
35--- a/src/tests/lxc-test-autostart
36+++ b/src/tests/lxc-test-autostart
37@@ -55,7 +55,7 @@ if [ -f /etc/lsb-release ]; then
38 done
39 fi
40
41-lxc-create -t download -n $CONTAINER_NAME -- -d ubuntu -r $release -a $ARCH
42+lxc-create -t download -n $CONTAINER_NAME -B dir -- --no-validate -d ubuntu -r $release -a $ARCH
43 CONTAINER_PATH=$(dirname $(lxc-info -n $CONTAINER_NAME -c lxc.rootfs -H))
44 cp $CONTAINER_PATH/config $CONTAINER_PATH/config.bak
45
46diff --git a/src/tests/lxc-test-unpriv b/src/tests/lxc-test-unpriv
47index 8486fbd..dfa9b43 100755
48--- a/src/tests/lxc-test-unpriv
49+++ b/src/tests/lxc-test-unpriv
50@@ -172,7 +172,7 @@ run_cmd mkdir -p $HDIR/.cache/lxc
51 cp -R /var/cache/lxc/download $HDIR/.cache/lxc && \
52 chown -R $TUSER: $HDIR/.cache/lxc
53
54-run_cmd lxc-create -t download -n c1 -- -d ubuntu -r $release -a $ARCH
55+run_cmd lxc-create -t download -n c1 -- --no-validate -d ubuntu -r $release -a $ARCH
56
57 # Make sure we can start it - twice
58
59diff --git a/src/tests/lxc-test-usernic.in b/src/tests/lxc-test-usernic.in
60index 0b99baa..2a407c6 100755
61--- a/src/tests/lxc-test-usernic.in
62+++ b/src/tests/lxc-test-usernic.in
63@@ -145,7 +145,7 @@ if [ -f /etc/lsb-release ]; then
64 fi
65
66 # Create three containers
67-run_cmd "lxc-create -t download -n b1 -- -d ubuntu -r $release -a $ARCH"
68+run_cmd "lxc-create -t download -n b1 -- --no-validate -d ubuntu -r $release -a $ARCH"
69 run_cmd "lxc-start -n b1 -d"
70 p1=$(run_cmd "lxc-info -n b1 -p -H")
71
72--
732.19.0
74
diff --git a/recipes-containers/lxc/files/tests-our-init-is-not-busybox.patch b/recipes-containers/lxc/files/tests-our-init-is-not-busybox.patch
new file mode 100644
index 00000000..2a0113e9
--- /dev/null
+++ b/recipes-containers/lxc/files/tests-our-init-is-not-busybox.patch
@@ -0,0 +1,32 @@
1From 9c973bfaab26426d8dcda8329f93a9af77415d76 Mon Sep 17 00:00:00 2001
2From: Mark Asselstine <mark.asselstine@windriver.com>
3Date: Thu, 31 May 2018 15:00:34 -0400
4Subject: [PATCH 2/3] tests: our init is not busybox
5
6Since we are using 'bash' as the init (see our updates to the busybox
7template) we can't compare '/sbin/init' and 'busybox'. Actually we are
8really only interested in the fact 'cmp' is being run and not the
9result, so simplify by comparing '/sbin/init' to itself.
10
11Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
12Signed-off-by: Sinan Kaya <okaya@kernel.org>
13---
14 src/tests/attach.c | 2 +-
15 1 file changed, 1 insertion(+), 1 deletion(-)
16
17diff --git a/src/tests/attach.c b/src/tests/attach.c
18index af03862..03c247a 100644
19--- a/src/tests/attach.c
20+++ b/src/tests/attach.c
21@@ -248,7 +248,7 @@ static int test_attach_cmd(struct lxc_container *ct)
22 {
23 int ret;
24 pid_t pid;
25- char *argv[] = {"cmp", "-s", "/sbin/init", "/bin/busybox", NULL};
26+ char *argv[] = {"cmp", "-s", "/sbin/init", "/sbin/init", NULL};
27 lxc_attach_command_t command = {"cmp", argv};
28 lxc_attach_options_t attach_options = LXC_ATTACH_OPTIONS_DEFAULT;
29
30--
312.19.0
32
diff --git a/recipes-containers/lxc/lxc_2.0.8.bb b/recipes-containers/lxc/lxc_2.0.8.bb
index facad2eb..13f3e772 100644
--- a/recipes-containers/lxc/lxc_2.0.8.bb
+++ b/recipes-containers/lxc/lxc_2.0.8.bb
@@ -28,18 +28,19 @@ RDEPENDS_${PN} = " \
28 28
29RDEPENDS_${PN}_append_libc-glibc = " glibc-utils" 29RDEPENDS_${PN}_append_libc-glibc = " glibc-utils"
30 30
31RDEPENDS_${PN}-ptest += "file make gmp nettle gnutls bash" 31RDEPENDS_${PN}-ptest += "file make gmp nettle gnutls bash libgcc"
32 32
33SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ 33SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \
34 file://lxc-1.0.0-disable-udhcp-from-busybox-template.patch \ 34 file://lxc-1.0.0-disable-udhcp-from-busybox-template.patch \
35 file://runtest.patch \
36 file://run-ptest \ 35 file://run-ptest \
37 file://automake-ensure-VPATH-builds-correctly.patch \
38 file://lxc-fix-B-S.patch \ 36 file://lxc-fix-B-S.patch \
39 file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \ 37 file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \
40 file://logs-optionally-use-base-filenames-to-report-src-fil.patch \ 38 file://logs-optionally-use-base-filenames-to-report-src-fil.patch \
41 file://cgroups-work-around-issue-in-gcc-7.patch \ 39 file://cgroups-work-around-issue-in-gcc-7.patch \
42 file://templates-actually-create-DOWNLOAD_TEMP-directory.patch \ 40 file://templates-actually-create-DOWNLOAD_TEMP-directory.patch \
41 file://template-make-busybox-template-compatible-with-core-.patch \
42 file://tests-our-init-is-not-busybox.patch \
43 file://tests-add-no-validate-when-using-download-template.patch \
43 file://dnsmasq.conf \ 44 file://dnsmasq.conf \
44 " 45 "
45 46
@@ -111,8 +112,6 @@ FILES_${PN}-setup += "/lib/systemd/system"
111FILES_${PN}-setup += "/usr/lib/systemd/system" 112FILES_${PN}-setup += "/usr/lib/systemd/system"
112FILES_${PN}-setup += "/etc/init.d" 113FILES_${PN}-setup += "/etc/init.d"
113 114
114PRIVATE_LIBS_${PN}-ptest = "liblxc.so.1"
115
116CACHED_CONFIGUREVARS += " \ 115CACHED_CONFIGUREVARS += " \
117 ac_cv_path_PYTHON='${STAGING_BINDIR_NATIVE}/python3-native/python3' \ 116 ac_cv_path_PYTHON='${STAGING_BINDIR_NATIVE}/python3-native/python3' \
118 am_cv_python_pyexecdir='${exec_prefix}/${libdir}/python3.5/site-packages' \ 117 am_cv_python_pyexecdir='${exec_prefix}/${libdir}/python3.5/site-packages' \
@@ -151,7 +150,9 @@ do_install_append() {
151EXTRA_OEMAKE += "TEST_DIR=${D}${PTEST_PATH}/src/tests" 150EXTRA_OEMAKE += "TEST_DIR=${D}${PTEST_PATH}/src/tests"
152 151
153do_install_ptest() { 152do_install_ptest() {
154 oe_runmake -C src/tests install-ptest 153 # Move tests to the "ptest directory"
154 install -d ${D}/${PTEST_PATH}/tests
155 mv ${D}/usr/bin/lxc-test-* ${D}/${PTEST_PATH}/tests/.
155} 156}
156 157
157pkg_postinst_${PN}() { 158pkg_postinst_${PN}() {