summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Asselstine <mark.asselstine@windriver.com>2018-05-31 17:08:06 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2018-06-03 23:26:52 -0400
commit1a5853f87cfc0b16d992ed222bbb0ff6066b2617 (patch)
tree69f38ba542fd85dd9fe1e3067510aaadf7da8295
parentb6bccf42d1042ee52800d307cffb39191b0f35f3 (diff)
downloadmeta-virtualization-1a5853f87cfc0b16d992ed222bbb0ff6066b2617.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: ### Starting LXC ptest ### ./tests/lxc-test-api-reboot FAIL ./tests/lxc-test-apparmor SKIPPED ./tests/lxc-test-attach PASS ./tests/lxc-test-automount PASS ./tests/lxc-test-autostart PASS ./tests/lxc-test-cgpath PASS ./tests/lxc-test-cloneconfig PASS ./tests/lxc-test-clonetest PASS ./tests/lxc-test-concurrent PASS ./tests/lxc-test-config-jump-table PASS ./tests/lxc-test-console PASS ./tests/lxc-test-console-log PASS ./tests/lxc-test-containertests PASS ./tests/lxc-test-createconfig PASS ./tests/lxc-test-createtest PASS ./tests/lxc-test-criu-check-feature PASS ./tests/lxc-test-destroytest PASS ./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-no-new-privs PASS ./tests/lxc-test-parse-config-file PASS ./tests/lxc-test-raw-clone PASS ./tests/lxc-test-reboot PASS ./tests/lxc-test-rootfs PASS ./tests/lxc-test-saveconfig PASS ./tests/lxc-test-share-ns PASS ./tests/lxc-test-shortlived PASS ./tests/lxc-test-shutdowntest SKIPPED ./tests/lxc-test-snapshot PASS ./tests/lxc-test-startone PASS ./tests/lxc-test-state-server SKIPPED ./tests/lxc-test-utils PASS Results: PASSED = 33 FAILED = 1 SKIPPED = 3 (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>
-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-.patch59
-rw-r--r--recipes-containers/lxc/files/tests-add-no-validate-when-using-download-template.patch87
-rw-r--r--recipes-containers/lxc/files/tests-our-init-is-not-busybox.patch31
-rw-r--r--recipes-containers/lxc/lxc_3.0.0.bb13
7 files changed, 239 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..1c6022b7
--- /dev/null
+++ b/recipes-containers/lxc/files/template-make-busybox-template-compatible-with-core-.patch
@@ -0,0 +1,59 @@
1From 0990db9b9723589606104d42ac2cf865b78e50a1 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] 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>
19---
20 templates/lxc-busybox.in | 16 +++++++++++++---
21 1 file changed, 13 insertions(+), 3 deletions(-)
22
23diff --git a/templates/lxc-busybox.in b/templates/lxc-busybox.in
24index 7d00bf5..5a99103 100644
25--- a/templates/lxc-busybox.in
26+++ b/templates/lxc-busybox.in
27@@ -181,6 +181,19 @@ configure_busybox()
28 return 1
29 fi
30
31+ # copy host passwd
32+ if ! cp "$(which passwd)" "${rootfs}/bin"; then
33+ echo "ERROR: Failed to copy passwd binary"
34+ return 1
35+ fi
36+
37+ # copy bash binary as the container init
38+ if ! cp "$(which bash)" "${rootfs}/sbin/init"; then
39+ echo "ERROR: Failed to copy bash binary"
40+ return 1
41+ fi
42+
43+
44 # symlink busybox for the commands it supports
45 # it would be nice to just use "chroot $rootfs busybox --install -s /bin"
46 # but that only works right in a chroot with busybox >= 1.19.0
47@@ -191,9 +204,6 @@ configure_busybox()
48 xargs -n1 ln -s busybox
49 )
50
51- # relink /sbin/init
52- ln "${rootfs}/bin/busybox" "${rootfs}/sbin/init"
53-
54 # /etc/fstab must exist for "mount -a"
55 touch "${rootfs}/etc/fstab"
56
57--
582.7.4
59
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..81fd15d6
--- /dev/null
+++ b/recipes-containers/lxc/files/tests-add-no-validate-when-using-download-template.patch
@@ -0,0 +1,87 @@
1From 0dad69a3bd306cc701c8bd4df4ea47f0ec5f9150 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] 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>
12---
13 src/tests/lxc-test-apparmor-mount | 2 +-
14 src/tests/lxc-test-autostart | 2 +-
15 src/tests/lxc-test-no-new-privs | 2 +-
16 src/tests/lxc-test-unpriv | 2 +-
17 src/tests/lxc-test-usernic.in | 2 +-
18 5 files changed, 5 insertions(+), 5 deletions(-)
19
20diff --git a/src/tests/lxc-test-apparmor-mount b/src/tests/lxc-test-apparmor-mount
21index ddcee8a..d3d2c49 100755
22--- a/src/tests/lxc-test-apparmor-mount
23+++ b/src/tests/lxc-test-apparmor-mount
24@@ -157,7 +157,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 e5b651b..d15b79b 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 -B dir -- -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.path -H) | sed -e 's/dir://')
44 cp $CONTAINER_PATH/config $CONTAINER_PATH/config.bak
45
46diff --git a/src/tests/lxc-test-no-new-privs b/src/tests/lxc-test-no-new-privs
47index 8642992..e72bdf0 100755
48--- a/src/tests/lxc-test-no-new-privs
49+++ b/src/tests/lxc-test-no-new-privs
50@@ -47,7 +47,7 @@ if type dpkg >/dev/null 2>&1; then
51 ARCH=$(dpkg --print-architecture)
52 fi
53
54-lxc-create -t download -n c1 -- -d ubuntu -r xenial -a $ARCH
55+lxc-create -t download -n c1 -- --no-validate -d ubuntu -r xenial -a $ARCH
56 echo "lxc.no_new_privs = 1" >> /var/lib/lxc/c1/config
57
58 lxc-start -n c1
59diff --git a/src/tests/lxc-test-unpriv b/src/tests/lxc-test-unpriv
60index 16ff12d..0958d48 100755
61--- a/src/tests/lxc-test-unpriv
62+++ b/src/tests/lxc-test-unpriv
63@@ -173,7 +173,7 @@ run_cmd mkdir -p $HDIR/.cache/lxc
64 cp -R /var/cache/lxc/download $HDIR/.cache/lxc && \
65 chown -R $TUSER: $HDIR/.cache/lxc
66
67-run_cmd lxc-create -t download -n c1 -- -d ubuntu -r $release -a $ARCH
68+run_cmd lxc-create -t download -n c1 -- --no-validate -d ubuntu -r $release -a $ARCH
69
70 # Make sure we can start it - twice
71
72diff --git a/src/tests/lxc-test-usernic.in b/src/tests/lxc-test-usernic.in
73index 3e35008..f489286 100755
74--- a/src/tests/lxc-test-usernic.in
75+++ b/src/tests/lxc-test-usernic.in
76@@ -146,7 +146,7 @@ if [ -f /etc/lsb-release ]; then
77 fi
78
79 # Create three containers
80-run_cmd "lxc-create -t download -n b1 -- -d ubuntu -r $release -a $ARCH"
81+run_cmd "lxc-create -t download -n b1 -- --no-validate -d ubuntu -r $release -a $ARCH"
82 run_cmd "lxc-start -n b1 -d"
83 p1=$(run_cmd "lxc-info -n b1 -p -H")
84
85--
862.7.4
87
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..4c9bf652
--- /dev/null
+++ b/recipes-containers/lxc/files/tests-our-init-is-not-busybox.patch
@@ -0,0 +1,31 @@
1From b53169dc4c53f9ef64f8cb06dd9af97182577698 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] 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>
12---
13 src/tests/attach.c | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/src/tests/attach.c b/src/tests/attach.c
17index 2c77127..1c182d6 100644
18--- a/src/tests/attach.c
19+++ b/src/tests/attach.c
20@@ -251,7 +251,7 @@ static int test_attach_cmd(struct lxc_container *ct)
21 {
22 int ret;
23 pid_t pid;
24- char *argv[] = {"cmp", "-s", "/sbin/init", "/bin/busybox", NULL};
25+ char *argv[] = {"cmp", "-s", "/sbin/init", "/sbin/init", NULL};
26 lxc_attach_command_t command = {"cmp", argv};
27 lxc_attach_options_t attach_options = LXC_ATTACH_OPTIONS_DEFAULT;
28
29--
302.7.4
31
diff --git a/recipes-containers/lxc/lxc_3.0.0.bb b/recipes-containers/lxc/lxc_3.0.0.bb
index 762a3125..4f7526bd 100644
--- a/recipes-containers/lxc/lxc_3.0.0.bb
+++ b/recipes-containers/lxc/lxc_3.0.0.bb
@@ -29,19 +29,20 @@ RDEPENDS_${PN} = " \
29 29
30RDEPENDS_${PN}_append_libc-glibc = " glibc-utils" 30RDEPENDS_${PN}_append_libc-glibc = " glibc-utils"
31 31
32RDEPENDS_${PN}-ptest += "file make gmp nettle gnutls bash" 32RDEPENDS_${PN}-ptest += "file make gmp nettle gnutls bash libgcc"
33 33
34RDEPENDS_${PN}-networking += "iptables" 34RDEPENDS_${PN}-networking += "iptables"
35 35
36SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ 36SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \
37 file://lxc-1.0.0-disable-udhcp-from-busybox-template.patch \ 37 file://lxc-1.0.0-disable-udhcp-from-busybox-template.patch \
38 file://runtest.patch \
39 file://run-ptest \ 38 file://run-ptest \
40 file://automake-ensure-VPATH-builds-correctly.patch \
41 file://lxc-fix-B-S.patch \ 39 file://lxc-fix-B-S.patch \
42 file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \ 40 file://lxc-doc-upgrade-to-use-docbook-3.1-DTD.patch \
43 file://logs-optionally-use-base-filenames-to-report-src-fil.patch \ 41 file://logs-optionally-use-base-filenames-to-report-src-fil.patch \
44 file://templates-actually-create-DOWNLOAD_TEMP-directory.patch \ 42 file://templates-actually-create-DOWNLOAD_TEMP-directory.patch \
43 file://template-make-busybox-template-compatible-with-core-.patch \
44 file://tests-our-init-is-not-busybox.patch \
45 file://tests-add-no-validate-when-using-download-template.patch \
45 file://dnsmasq.conf \ 46 file://dnsmasq.conf \
46 file://lxc-net \ 47 file://lxc-net \
47 " 48 "
@@ -116,8 +117,6 @@ FILES_${PN}-networking += " \
116 ${sysconfdir}/default/lxc-net \ 117 ${sysconfdir}/default/lxc-net \
117" 118"
118 119
119PRIVATE_LIBS_${PN}-ptest = "liblxc.so.1"
120
121CACHED_CONFIGUREVARS += " \ 120CACHED_CONFIGUREVARS += " \
122 ac_cv_path_PYTHON='${STAGING_BINDIR_NATIVE}/python3-native/python3' \ 121 ac_cv_path_PYTHON='${STAGING_BINDIR_NATIVE}/python3-native/python3' \
123 am_cv_python_pyexecdir='${exec_prefix}/${libdir}/python3.5/site-packages' \ 122 am_cv_python_pyexecdir='${exec_prefix}/${libdir}/python3.5/site-packages' \
@@ -159,7 +158,9 @@ do_install_append() {
159EXTRA_OEMAKE += "TEST_DIR=${D}${PTEST_PATH}/src/tests" 158EXTRA_OEMAKE += "TEST_DIR=${D}${PTEST_PATH}/src/tests"
160 159
161do_install_ptest() { 160do_install_ptest() {
162 oe_runmake -C src/tests install-ptest 161 # Move tests to the "ptest directory"
162 install -d ${D}/${PTEST_PATH}/tests
163 mv ${D}/usr/bin/lxc-test-* ${D}/${PTEST_PATH}/tests/.
163} 164}
164 165
165pkg_postinst_${PN}() { 166pkg_postinst_${PN}() {