tests: Introducing docker tests
cover tests: Introducing docker tests
v1: Since RFC, addressed comments from reviewers, and improved a lot of things.
Thanks to Daniel, Eric, Paolo, Stefan, for the feedback.
This series adds a new "docker" make target family to run tests in created docker containers.
To begin with, this can be a place to store standard env/command combinations to build and test QEMU.
Secondly, CI usually provides "docker" capability (such as travis [1]), where we define standard/repeatable test environments, and run tests in them. However, what tests to cover is better maintained in-tree, in order to keep in sync with the code development.
Lastly, this makes it very simple for developers to replicate such tests themselves.
[1]: https://docs.travis-ci.com/user/docker/
Fam Zheng (12):
tests: Add utilities for docker testing
Makefile: Rules for docker testing
docker: Add images
docker: Add test runner
docker: Add common.rc
docker: Add basic test
docker: Add clang test
docker: Add mingw test
docker: Add travis tool
docs: Add text for tests/docker in build-system.txt .gitignore: Ignore temporary dockerfile
MAINTAINERS: Add tests/docker
.gitignore | 1 + MAINTAINERS | 7 +++ Makefile | 4 +- docs/build-system.txt | 5 ++ tests/docker/Makefile.include | 88 ++++++++++++++++++++++++++++++++++ tests/docker/centos6.docker | 5 ++ tests/docker/common.rc | 28 +++++++++++ tests/docker/docker.py | 108 ++++++++++++++++++++++++++++++++++++++++++ tests/docker/docker_build | 42 ++++++++++++++++ tests/docker/docker_clean | 22 +++++++++ tests/docker/docker_run | 28 +++++++++++ tests/docker/fedora.docker | 7 +++ tests/docker/run | 23 +++++++++ tests/docker/test-basic.sh | 22 +++++++++ tests/docker/test-clang.sh | 26 ++++++++++ tests/docker/test-mingw.sh | 34 +++++++++++++ tests/docker/travis.py | 53 +++++++++++++++++++++ tests/docker/travis.sh | 20 ++++++++ tests/docker/ubuntu.docker | 9 ++++ 19 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 tests/docker/Makefile.include create mode 100644 tests/docker/centos6.docker create mode 100755 tests/docker/common.rc create mode 100755 tests/docker/docker.py create mode 100755 tests/docker/docker_build create mode 100755 tests/docker/docker_clean create mode 100755 tests/docker/docker_run create mode 100644 tests/docker/fedora.docker create mode 100755 tests/docker/run create mode 100755 tests/docker/test-basic.sh create mode 100755 tests/docker/test-clang.sh create mode 100755 tests/docker/test-mingw.sh create mode 100755 tests/docker/travis.py create mode 100755 tests/docker/travis.sh create mode 100644 tests/docker/ubuntu.docker
Signature · 1 line
2.4.3
PATCH 1/12 tests: Add utilities for docker testing
docker_run: A wrapper for "docker run" (or "sudo -n docker run" if necessary), which takes care of killing and removing the running container at SIGINT.
docker_clean: A tool to tear down all the containers including inactive ones that are started by docker_run.
docker_build: A tool to compare an image from given dockerfile and rebuild it if they're different.
--- tests/docker/docker.py | 108 ++++++++++++++++++++++++++++++++++++++++++++++ tests/docker/docker_build | 42 ++++++++++++++++++ tests/docker/docker_clean | 22 ++++++++++ tests/docker/docker_run | 28 ++++++++++++ 4 files changed, 200 insertions(+) create mode 100755 tests/docker/docker.py create mode 100755 tests/docker/docker_build create mode 100755 tests/docker/docker_clean create mode 100755 tests/docker/docker_run
tests/docker/docker.py new file +108 -0
@@ -0,0 +1,108 @@ +#!/usr/bin/env python2 -B +# +# Docker controlling module +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import os +import subprocess +import json +import hashlib +import atexit +import time +import uuid + +class ContainerTerminated(Exception): + pass + +class Docker(object): + def __init__(self): + self._command = self._guess_command() + self._instances = [] + atexit.register(self._kill_instances) + + def _do(self, cmd, quiet=True, **kwargs): + if quiet: + kwargs["stdout"] = subprocess.PIPE + return subprocess.call(self._command + cmd, **kwargs) + + def _do_kill_instances(self, only_known, only_active=True): + cmd = ["ps", "-q"] + if not only_active: + cmd.append("-a") + for i in self._output(cmd).split(): + r = self._output(["inspect", i]) + labels = json.loads(r)[0]["Config"]["Labels"] + active = json.loads(r)[0]["State"]["Running"] + if not labels: + continue + u = labels.get("com.qemu.instance.uuid", None) + if not u: + continue + if only_known and u not in self._instances: + continue + print "Terminating", i + if active: + self._do(["kill", i]) + self._do(["rm", i]) + + def clean(self): + self._do_kill_instances(False, False) + return 0 + + def _kill_instances(self): + return self._do_kill_instances(True) + + def _output(self, cmd, **kwargs): + return subprocess.check_output(self._command + cmd, + stderr=subprocess.STDOUT, + **kwargs) + + def _guess_command(self): + for c in [["docker"], ["sudo", "-n", "docker"]]: + if subprocess.call(c + ["images"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) == 0: + return c + raise Exception("Cannot find working docker command") + + def get_image_dockerfile_checksum(self, tag): + resp = self._output(["inspect", tag]) + t = json.loads(resp)[0] + return t["Config"].get("Labels", {}).get("com.qemu.dockerfile-checksum", "") + + def checksum(self, text): + return hashlib.sha1(text).hexdigest() + + def build_image(self, tag, dockerfile, df, quiet=True): + tmp = dockerfile + "\n" + \ + "LABEL com.qemu.dockerfile-checksum=%s" % self.checksum(dockerfile) + tmp_df = df + ".tmp" + f = open(tmp_df, "wb") + f.write(tmp) + f.close() + self._do(["build", "-t", tag, "-f", tmp_df, os.path.dirname(df)], + quiet=quiet) + os.unlink(tmp_df) + + def image_matches_dockerfile(self, tag, dockerfile): + try: + a = self.get_image_dockerfile_checksum(tag) + except: + return False + return a == self.checksum(dockerfile) + + def run(self, cmd, quiet, **kwargs): + label = uuid.uuid1().hex + self._instances.append(label) + r = self._do(["run", "--label", "com.qemu.instance.uuid=" + label] + cmd, quiet=quiet) + self._instances.remove(label) + return r +
tests/docker/docker_build new file +42 -0
42 lines not on this page · raw message
tests/docker/docker_clean new file +22 -0
@@ -0,0 +1,22 @@ +#!/usr/bin/env python2 +# +# Clean up uselsee containers. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import sys +import docker + +def main(): + docker.Docker().clean() + return 0 + +if __name__ == "__main__": + sys.exit(main())
tests/docker/docker_run new file +28 -0
@@ -0,0 +1,28 @@ +#!/usr/bin/env python2 +# +# Wrapper for "docker run" with automatical clean up if the execution is +# iterrupted. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import os +import sys +import argparse +import docker + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--quiet", action="store_true", + help="Run quietly unless an error occured") + args, argv = parser.parse_known_args() + return docker.Docker().run(argv, quiet=args.quiet) + +if __name__ == "__main__": + sys.exit(main())
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 01/12] tests: Add utilities for docker testing
Quoted 87 lines · Fam Zheng
docker_run: A wrapper for "docker run" (or "sudo -n docker run" if necessary), which takes care of killing and removing the running container at SIGINT.
docker_clean: A tool to tear down all the containers including inactive ones that are started bydocker_run.
docker_build: A tool to compare an image from given dockerfile and rebuild it if they're different.Signed-off-by Fam Zheng <[email protected]>--- tests/docker/docker.py | 108 ++++++++++++++++++++++++++++++++++++++++++++++ tests/docker/docker_build | 42 ++++++++++++++++++ tests/docker/docker_clean | 22 ++++++++++ tests/docker/docker_run | 28 ++++++++++++ 4 files changed, 200 insertions(+) create mode 100755 tests/docker/docker.py create mode 100755 tests/docker/docker_build create mode 100755 tests/docker/docker_clean create mode 100755 tests/docker/docker_runtests/docker/docker.py new file +59
-0@@ -0,0 +1,108 @@ +#!/usr/bin/env python2 -B +# +# Docker controlling module +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import os +import subprocess +import json +import hashlib +import atexit +import time +import uuid + +class ContainerTerminated(Exception): + pass + +class Docker(object): + def __init__(self): + self._command = self._guess_command() + self._instances = [] + atexit.register(self._kill_instances) + + def _do(self, cmd, quiet=True, **kwargs): + if quiet: + kwargs["stdout"] = subprocess.PIPE + return subprocess.call(self._command + cmd, **kwargs) + + def _do_kill_instances(self, only_known, only_active=True): + cmd = ["ps", "-q"] + if not only_active: + cmd.append("-a") + for i in self._output(cmd).split(): + r = self._output(["inspect", i]) + labels = json.loads(r)[0]["Config"]["Labels"] + active = json.loads(r)[0]["State"]["Running"] + if not labels: + continue + u = labels.get("com.qemu.instance.uuid", None) + if not u: + continue + if only_known and u not in self._instances: + continue + print "Terminating", i + if active: + self._do(["kill", i]) + self._do(["rm", i]) + + def clean(self): + self._do_kill_instances(False, False) + return 0 +
tests/docker/docker.py line 69
Quoted 10 lines
tests/docker/docker.py new file +10
-0+ def _kill_instances(self): + return self._do_kill_instances(True) + + def _output(self, cmd, **kwargs): + return subprocess.check_output(self._command + cmd, + stderr=subprocess.STDOUT, + **kwargs) + + def _guess_command(self): + for c in [["docker"], ["sudo", "-n", "docker"]]:
If the sudo version fails (Say, because a password prompt shows up) we get the unhelpful error "Cannot find working docker command."
Does your sudo not prompt you in your dev environment?
Quoted 150 lines
tests/docker/docker.py new file +39
-0+ if subprocess.call(c + ["images"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) == 0: + return c + raise Exception("Cannot find working docker command") + + def get_image_dockerfile_checksum(self, tag): + resp = self._output(["inspect", tag]) + t = json.loads(resp)[0] + return t["Config"].get("Labels", {}).get("com.qemu.dockerfile-checksum", "") + + def checksum(self, text): + return hashlib.sha1(text).hexdigest() + + def build_image(self, tag, dockerfile, df, quiet=True): + tmp = dockerfile + "\n" + \ + "LABEL com.qemu.dockerfile-checksum=%s" % self.checksum(dockerfile) + tmp_df = df + ".tmp" + f = open(tmp_df, "wb") + f.write(tmp) + f.close() + self._do(["build", "-t", tag, "-f", tmp_df, os.path.dirname(df)], + quiet=quiet) + os.unlink(tmp_df) + + def image_matches_dockerfile(self, tag, dockerfile): + try: + a = self.get_image_dockerfile_checksum(tag) + except: + return False + return a == self.checksum(dockerfile) + + def run(self, cmd, quiet, **kwargs): + label = uuid.uuid1().hex + self._instances.append(label) + r = self._do(["run", "--label", "com.qemu.instance.uuid=" + label] + cmd, quiet=quiet) + self._instances.remove(label) + return r +tests/docker/docker_build new file +42
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python2 +# +# Compare to Dockerfile and rebuild a docker image if necessary. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import sys +import docker +import argparse + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("tag", + help="Image Tag") + parser.add_argument("dockerfile", + help="Dockerfile name") + parser.add_argument("--verbose", "-v", action="store_true", + help="Print verbose information") + args = parser.parse_args() + + dockerfile = open(args.dockerfile, "rb").read() + tag = args.tag + + d = docker.Docker() + if d.image_matches_dockerfile(tag, dockerfile): + if args.verbose: + print "Image is up to date." + return 0 + + quiet = not args.verbose + d.build_image(tag, dockerfile, args.dockerfile, quiet=quiet) + return 0 + +if __name__ == "__main__": + sys.exit(main())tests/docker/docker_clean new file +22
-0@@ -0,0 +1,22 @@ +#!/usr/bin/env python2 +# +# Clean up uselsee containers. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import sys +import docker + +def main(): + docker.Docker().clean() + return 0 + +if __name__ == "__main__": + sys.exit(main())tests/docker/docker_run new file +28
-0@@ -0,0 +1,28 @@ +#!/usr/bin/env python2 +# +# Wrapper for "docker run" with automatical clean up if the execution is +# iterrupted. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import os +import sys +import argparse +import docker + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--quiet", action="store_true", + help="Run quietly unless an error occured") + args, argv = parser.parse_known_args() + return docker.Docker().run(argv, quiet=args.quiet) + +if __name__ == "__main__": + sys.exit(main())
Signature · 1 line
—js
Re: [Qemu-devel] [PATCH 01/12] tests: Add utilities for docker testing
Quoted 5 lines · John Snow
tests/docker/docker.py line 69
Quoted 2 lines
tests/docker/docker.py new file +2
-0+ def _guess_command(self): + for c in [["docker"], ["sudo", "-n", "docker"]]:If the sudo version fails (Say, because a password prompt shows up) we get the unhelpful error "Cannot find working docker command."
If you have previously "sudo $something" and typed in the password, this will work.
You can also specify passworless for docker only:
fam ALL=(ALL) NOPASSWD: /usr/bin/docker
Fam
Quoted 154 lines
Quoted 151 lines
tests/docker/docker.py new file +39
-0+ if subprocess.call(c + ["images"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) == 0: + return c + raise Exception("Cannot find working docker command") + + def get_image_dockerfile_checksum(self, tag): + resp = self._output(["inspect", tag]) + t = json.loads(resp)[0] + return t["Config"].get("Labels", {}).get("com.qemu.dockerfile-checksum", "") + + def checksum(self, text): + return hashlib.sha1(text).hexdigest() + + def build_image(self, tag, dockerfile, df, quiet=True): + tmp = dockerfile + "\n" + \ + "LABEL com.qemu.dockerfile-checksum=%s" % self.checksum(dockerfile) + tmp_df = df + ".tmp" + f = open(tmp_df, "wb") + f.write(tmp) + f.close() + self._do(["build", "-t", tag, "-f", tmp_df, os.path.dirname(df)], + quiet=quiet) + os.unlink(tmp_df) + + def image_matches_dockerfile(self, tag, dockerfile): + try: + a = self.get_image_dockerfile_checksum(tag) + except: + return False + return a == self.checksum(dockerfile) + + def run(self, cmd, quiet, **kwargs): + label = uuid.uuid1().hex + self._instances.append(label) + r = self._do(["run", "--label", "com.qemu.instance.uuid=" + label] + cmd, quiet=quiet) + self._instances.remove(label) + return r +tests/docker/docker_build new file +42
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python2 +# +# Compare to Dockerfile and rebuild a docker image if necessary. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import sys +import docker +import argparse + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("tag", + help="Image Tag") + parser.add_argument("dockerfile", + help="Dockerfile name") + parser.add_argument("--verbose", "-v", action="store_true", + help="Print verbose information") + args = parser.parse_args() + + dockerfile = open(args.dockerfile, "rb").read() + tag = args.tag + + d = docker.Docker() + if d.image_matches_dockerfile(tag, dockerfile): + if args.verbose: + print "Image is up to date." + return 0 + + quiet = not args.verbose + d.build_image(tag, dockerfile, args.dockerfile, quiet=quiet) + return 0 + +if __name__ == "__main__": + sys.exit(main())tests/docker/docker_clean new file +22
-0@@ -0,0 +1,22 @@ +#!/usr/bin/env python2 +# +# Clean up uselsee containers. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import sys +import docker + +def main(): + docker.Docker().clean() + return 0 + +if __name__ == "__main__": + sys.exit(main())tests/docker/docker_run new file +28
-0@@ -0,0 +1,28 @@ +#!/usr/bin/env python2 +# +# Wrapper for "docker run" with automatical clean up if the execution is +# iterrupted. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import os +import sys +import argparse +import docker + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--quiet", action="store_true", + help="Run quietly unless an error occured") + args, argv = parser.parse_known_args() + return docker.Docker().run(argv, quiet=args.quiet) + +if __name__ == "__main__": + sys.exit(main())Signature · 1 line
—js
Re: [Qemu-devel] [PATCH 01/12] tests: Add utilities for docker testing
Quoted 7 lines · Fam Zheng
Quoted 5 lines · John Snow
tests/docker/docker.py line 69
Quoted 2 lines
tests/docker/docker.py new file +2
-0+ def _guess_command(self): + for c in [["docker"], ["sudo", "-n", "docker"]]:If the sudo version fails (Say, because a password prompt shows up) we get the unhelpful error "Cannot find working docker command."
Quoted 9 lines
If you have previously "sudo $something" and typed in the password, this will work.
You can also specify passworless for docker only:
fam ALL=(ALL) NOPASSWD:
/usr/bin/dockerFam
Sure, but the failure here is not particularly obvious, because it makes it seem as if docker has failed instead of a sudo privilege situation.
--js
Quoted 154 lines
Quoted 154 lines
Quoted 151 lines
tests/docker/docker.py new file +39
-0+ if subprocess.call(c + ["images"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) == 0: + return c + raise Exception("Cannot find working docker command") + + def get_image_dockerfile_checksum(self, tag): + resp = self._output(["inspect", tag]) + t = json.loads(resp)[0] + return t["Config"].get("Labels", {}).get("com.qemu.dockerfile-checksum", "") + + def checksum(self, text): + return hashlib.sha1(text).hexdigest() + + def build_image(self, tag, dockerfile, df, quiet=True): + tmp = dockerfile + "\n" + \ + "LABEL com.qemu.dockerfile-checksum=%s" % self.checksum(dockerfile) + tmp_df = df + ".tmp" + f = open(tmp_df, "wb") + f.write(tmp) + f.close() + self._do(["build", "-t", tag, "-f", tmp_df, os.path.dirname(df)], + quiet=quiet) + os.unlink(tmp_df) + + def image_matches_dockerfile(self, tag, dockerfile): + try: + a = self.get_image_dockerfile_checksum(tag) + except: + return False + return a == self.checksum(dockerfile) + + def run(self, cmd, quiet, **kwargs): + label = uuid.uuid1().hex + self._instances.append(label) + r = self._do(["run", "--label", "com.qemu.instance.uuid=" + label] + cmd, quiet=quiet) + self._instances.remove(label) + return r +tests/docker/docker_build new file +42
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python2 +# +# Compare to Dockerfile and rebuild a docker image if necessary. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import sys +import docker +import argparse + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("tag", + help="Image Tag") + parser.add_argument("dockerfile", + help="Dockerfile name") + parser.add_argument("--verbose", "-v", action="store_true", + help="Print verbose information") + args = parser.parse_args() + + dockerfile = open(args.dockerfile, "rb").read() + tag = args.tag + + d = docker.Docker() + if d.image_matches_dockerfile(tag, dockerfile): + if args.verbose: + print "Image is up to date." + return 0 + + quiet = not args.verbose + d.build_image(tag, dockerfile, args.dockerfile, quiet=quiet) + return 0 + +if __name__ == "__main__": + sys.exit(main())tests/docker/docker_clean new file +22
-0@@ -0,0 +1,22 @@ +#!/usr/bin/env python2 +# +# Clean up uselsee containers. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import sys +import docker + +def main(): + docker.Docker().clean() + return 0 + +if __name__ == "__main__": + sys.exit(main())tests/docker/docker_run new file +28
-0@@ -0,0 +1,28 @@ +#!/usr/bin/env python2 +# +# Wrapper for "docker run" with automatical clean up if the execution is +# iterrupted. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import os +import sys +import argparse +import docker + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--quiet", action="store_true", + help="Run quietly unless an error occured") + args, argv = parser.parse_known_args() + return docker.Docker().run(argv, quiet=args.quiet) + +if __name__ == "__main__": + sys.exit(main())Signature · 1 line
—js
Re: [Qemu-devel] [PATCH 01/12] tests: Add utilities for docker testing
Quoted 2 lines · John Snow
Sure, but the failure here is not particularly obvious, because it makes it seem as if docker has failed instead of a sudo privilege situation.
Of course you're right, I'll improve the error message. Thanks!
Fam
PATCH 2/12 Makefile: Rules for docker testing
In reply to Fam ZhengThis adds a group of make targets to run docker tests, all are available in source tree without running ./configure.
The usage is shown by "make docker".
Besides the fixed ones, dynamic targets for building each image and running each test in each image are generated automatically by make, scanning $(SRC_PATH)/tests/docker/ files with specific patterns.
Alternative to manually list particular targets (docker-run-FOO@BAR) set, you can control which tests/images to run by filtering variables, TESTS= and IMAGES=, which are expressed in Makefile pattern syntax, "foo% %bar ...". For example:
$ make docker-run IMAGES="ubuntu fedora"
Unfortunately, it's impossible to propagate "-j $JOBS" into make in containers, however since each combination is made a first class target is the top Makefile, "make -j$N docker-run" still parallels the tests coarsely.
--- Makefile | 4 +- tests/docker/Makefile.include | 88 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/docker/Makefile.include
Makefile +3 -1
@@ -6,7 +6,7 @@ BUILD_DIR=$(CURDIR) # Before including a proper config-host.mak, assume we are in the source tree SRC_PATH=. -UNCHECKED_GOALS := %clean TAGS cscope ctags +UNCHECKED_GOALS := %clean TAGS cscope ctags docker docker-% # All following code might depend on configuration variables ifneq ($(wildcard config-host.mak),)
@@ -651,3 +651,5 @@ endif # Include automatically generated dependency files # Dependencies in Makefile.objs files come from our recursive subdir rules -include $(wildcard *.d tests/*.d) + +include $(SRC_PATH)/tests/docker/Makefile.include
tests/docker/Makefile.include new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 02/12] Makefile: Rules for docker testing
Quoted 9 lines · Fam Zheng
This adds a group of make targets to run docker tests, all are available in source tree without running ./configure.
The usage is shown by "make docker".
Besides the fixed ones, dynamic targets for building each image and running each test in each image are generated automatically by make, scanning $(SRC_PATH)/tests/docker/ files with specific patterns.
Quoted 6 lines
Alternative to manually list particular targets (docker-run-FOO@BAR) set, you can control which tests/images to run by filtering variables, TESTS= and IMAGES=, which are expressed in
Makefilepattern syntax, "foo% %bar ...". For example:$ make docker-run IMAGES="ubuntu fedora"
This could do with repeating in the docs so that you don't need to search commits for example invocations.
Quoted 88 lines
Unfortunately, it's impossible to propagate "-j $JOBS" into make in containers, however since each combination is made a first class target is the top
Makefile, "make -j$N docker-run" still parallels the tests coarsely.Signed-off-by Fam Zheng <[email protected]>--- Makefile | 4 +- tests/docker/Makefile.include | 88 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/docker/Makefile.includeMakefile +3
-1@@ -6,7 +6,7 @@ BUILD_DIR=$(CURDIR) # Before including a proper config-host.mak, assume we are in the source tree SRC_PATH=. -UNCHECKED_GOALS := %clean TAGS cscope ctags +UNCHECKED_GOALS := %clean TAGS cscope ctags docker docker-% # All following code might depend on configuration variables ifneq ($(wildcard config-host.mak),)@@ -651,3 +651,5 @@ endif # Include automatically generated dependency files # Dependencies in Makefile.objs files come from our recursive subdir rules -include $(wildcard *.d tests/*.d) + +include $(SRC_PATH)/tests/docker/Makefile.includetests/docker/Makefile.include new file +50
-0@@ -0,0 +1,88 @@ +# Makefile for Docker tests + +$(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak)) + +.PHONY: docker docker-build docker-run docker-clean + +DOCKER_SUFFIX = .docker + +DOCKER_IMAGES := $(patsubst %$(DOCKER_SUFFIX),%, $(shell \ + ls $(SRC_PATH)/tests/docker/ | grep '$(DOCKER_SUFFIX)$$')) + +DOCKER_SCRIPTS := $(shell ls $(SRC_PATH)/tests/docker/ | grep '\.sh$$') +DOCKER_TESTS := $(filter test-%, $(DOCKER_SCRIPTS)) +DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS)) + +TESTS ?= % +IMAGES ?= % + +$(foreach i,$(DOCKER_IMAGES), \ + $(eval docker-build: docker-build-$i) \ + $(foreach t,$(DOCKER_SCRIPTS), \ + $(eval docker-build-$i docker-run-$t@$i: IMAGE=$i) \ + $(eval docker-run-$t@$i: SCRIPT=$t) \ + $(eval docker-run-$t@$i: docker-build-$i) \ + $(if $(filter test-%,$t), \ + $(eval docker-run: docker-run-$t@$i) \ + $(eval docker-run-$t@: docker-run-$t@$i) \ + $(eval docker-run-@$i: docker-run-$t@$i)) \ +)) + +docker: + @echo 'Building QEMU and running tests or tools inside Docker containers' + @echo + @echo 'Available targets:' + @echo + @echo ' docker: Print this help.' + @echo ' docker-run: Run all image/test combinations.' + @echo ' You can override the test cases to run by providing' + @echo ' TESTS="foo bar" in the make command, and the image set' + @echo ' by providing IMAGES="baz qux".' + @echo ' docker-clean: Kill and remove residual docker testing containers.' + @echo ' docker-build: Build all images.' + @echo ' docker-build-IMG: Build image "IMG".' + @echo ' "IMG" is one of the listed image name."' + @echo ' docker-run-FOO@BAR: Run "FOO" in container "BAR".' + @echo ' "FOO" must be one of the listed test/tool name."' + @echo ' "BAR" must be one of the listed image name."' + @echo ' docker-run-FOO@: Run "FOO" in all containers.' + @echo ' "FOO" must be one of the listed test name."' + @echo ' docker-run-@BAR: Run all tests in container "BAR".'
tests/docker/Makefile.include line 60
Quoted 10 lines
tests/docker/Makefile.include new file +10
-0+ @echo ' "BAR" must be one of the listed image name."' + @echo + @echo 'Available images:' + @echo ' $(DOCKER_IMAGES)' + @echo + @echo 'Available tests:' + @echo ' $(DOCKER_TESTS)' + @echo + @echo 'Available tools:' + @echo ' $(DOCKER_TOOLS)'
I commend the addition of help ;-)
Perhaps replace FOO and BAR with TEST and IMAGE to cement the actual rather than the abstract in the readers mind.
Also I expected this to work:
$ make docker-run-basic@fedora Invalid target make: *** [docker-run-basic@fedora] Error 1
The help gives:
Available images:
centos6 fedora ubuntu
Available tests:
test-basic.sh test-clang.sh test-mingw.sh
Available tools:
travis.sh
The test and .sh seem superfluous to the user wanting to invoke things. We know they are tests and the implementation detail of the shell should be irrelevant to the user.
Quoted 18 lines
tests/docker/Makefile.include new file +18
-0+ +docker-build-%: + @if test -z "$(IMAGE)"; then echo "Invalid target"; exit 1; fi + $(if $(filter $(IMAGES),$(IMAGE)), $(call quiet-command,\ + $(SRC_PATH)/tests/docker/docker_build qemu:$(IMAGE) \ + $(SRC_PATH)/tests/docker/$(IMAGE).docker \ + $(if $V,-v,), " BUILD $(IMAGE)")) + +docker-run-%: + @if test -z "$(IMAGE)" || test -z "$(SCRIPT)"; \ + then echo "Invalid target"; exit 1; \ + fi + $(if $(filter $(TESTS),$(SCRIPT)),$(if $(filter $(IMAGES),$(IMAGE)), \ + $(call quiet-command,\ + $(SRC_PATH)/tests/docker/docker_run \ + --privileged -t --rm --net=none \ + -v $$(realpath $(SRC_PATH)):/var/tmp/qemu \ + -e QEMU_SRC=/var/tmp/qemu \
tests/docker/Makefile.include line 88
Quoted 10 lines
tests/docker/Makefile.include new file +10
-0+ -e V=$(V) \ + -v /var/tmp/qemu-docker-ccache:/var/tmp/ccache \ + -e CCACHE_DIR=/var/tmp/ccache \ + qemu:$(IMAGE) \ + /var/tmp/qemu/tests/docker/run \ + /var/tmp/qemu/tests/docker/$(SCRIPT); \ + , " RUN $(SCRIPT) in $(IMAGE)"))) + +docker-clean: + $(call quiet-command, $(SRC_PATH)/tests/docker/docker_clean)
Otherwise looking good. Thanks!
--
Alex Bennée
Re: [Qemu-devel] [PATCH 02/12] Makefile: Rules for docker testing
Quoted 17 lines · Alex Bennée
Quoted 14 lines · Fam Zheng
This adds a group of make targets to run docker tests, all are available in source tree without running ./configure.
The usage is shown by "make docker".
Besides the fixed ones, dynamic targets for building each image and running each test in each image are generated automatically by make, scanning $(SRC_PATH)/tests/docker/ files with specific patterns.
Alternative to manually list particular targets (docker-run-FOO@BAR) set, you can control which tests/images to run by filtering variables, TESTS= and IMAGES=, which are expressed in
Makefilepattern syntax, "foo% %bar ...". For example:
Quoted 4 lines
Quoted 1 line
$ make docker-run IMAGES="ubuntu fedora"This could do with repeating in the docs so that you don't need to search commits for example invocations.
Okay.
Quoted 102 lines
Quoted 89 lines
Unfortunately, it's impossible to propagate "-j $JOBS" into make in containers, however since each combination is made a first class target is the top
Makefile, "make -j$N docker-run" still parallels the tests coarsely.Signed-off-by Fam Zheng <[email protected]>--- Makefile | 4 +- tests/docker/Makefile.include | 88 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 tests/docker/Makefile.includeMakefile +3
-1@@ -6,7 +6,7 @@ BUILD_DIR=$(CURDIR) # Before including a proper config-host.mak, assume we are in the source tree SRC_PATH=. -UNCHECKED_GOALS := %clean TAGS cscope ctags +UNCHECKED_GOALS := %clean TAGS cscope ctags docker docker-% # All following code might depend on configuration variables ifneq ($(wildcard config-host.mak),)@@ -651,3 +651,5 @@ endif # Include automatically generated dependency files # Dependencies in Makefile.objs files come from our recursive subdir rules -include $(wildcard *.d tests/*.d) + +include $(SRC_PATH)/tests/docker/Makefile.includetests/docker/Makefile.include new file +50
-0@@ -0,0 +1,88 @@ +# Makefile for Docker tests + +$(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak)) + +.PHONY: docker docker-build docker-run docker-clean + +DOCKER_SUFFIX = .docker + +DOCKER_IMAGES := $(patsubst %$(DOCKER_SUFFIX),%, $(shell \ + ls $(SRC_PATH)/tests/docker/ | grep '$(DOCKER_SUFFIX)$$')) + +DOCKER_SCRIPTS := $(shell ls $(SRC_PATH)/tests/docker/ | grep '\.sh$$') +DOCKER_TESTS := $(filter test-%, $(DOCKER_SCRIPTS)) +DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS)) + +TESTS ?= % +IMAGES ?= % + +$(foreach i,$(DOCKER_IMAGES), \ + $(eval docker-build: docker-build-$i) \ + $(foreach t,$(DOCKER_SCRIPTS), \ + $(eval docker-build-$i docker-run-$t@$i: IMAGE=$i) \ + $(eval docker-run-$t@$i: SCRIPT=$t) \ + $(eval docker-run-$t@$i: docker-build-$i) \ + $(if $(filter test-%,$t), \ + $(eval docker-run: docker-run-$t@$i) \ + $(eval docker-run-$t@: docker-run-$t@$i) \ + $(eval docker-run-@$i: docker-run-$t@$i)) \ +)) + +docker: + @echo 'Building QEMU and running tests or tools inside Docker containers' + @echo + @echo 'Available targets:' + @echo + @echo ' docker: Print this help.' + @echo ' docker-run: Run all image/test combinations.' + @echo ' You can override the test cases to run by providing' + @echo ' TESTS="foo bar" in the make command, and the image set' + @echo ' by providing IMAGES="baz qux".' + @echo ' docker-clean: Kill and remove residual docker testing containers.' + @echo ' docker-build: Build all images.' + @echo ' docker-build-IMG: Build image "IMG".' + @echo ' "IMG" is one of the listed image name."' + @echo ' docker-run-FOO@BAR: Run "FOO" in container "BAR".' + @echo ' "FOO" must be one of the listed test/tool name."' + @echo ' "BAR" must be one of the listed image name."' + @echo ' docker-run-FOO@: Run "FOO" in all containers.' + @echo ' "FOO" must be one of the listed test name."' + @echo ' docker-run-@BAR: Run all tests in container "BAR".'tests/docker/Makefile.include line 60
Quoted 10 lines
tests/docker/Makefile.include new file +10
-0+ @echo ' "BAR" must be one of the listed image name."' + @echo + @echo 'Available images:' + @echo ' $(DOCKER_IMAGES)' + @echo + @echo 'Available tests:' + @echo ' $(DOCKER_TESTS)' + @echo + @echo 'Available tools:' + @echo ' $(DOCKER_TOOLS)'I commend the addition of help ;-)
Quoted 2 lines
Perhaps replace FOO and BAR with TEST and IMAGE to cement the actual rather than the abstract in the readers mind.
OK!
Quoted 15 lines
Also I expected this to work:
$ make docker-run-basic@fedora Invalid target make: *** [docker-run-basic@fedora] Error 1The help gives:
Available images:
centos6 fedora ubuntuAvailable tests:
test-basic.shtest-clang.shtest-mingw.sh
Quoted 6 lines
Available tools:
travis.shThe test and .sh seem superfluous to the user wanting to invoke things. We know they are tests and the implementation detail of the shell should be irrelevant to the user.
I want to distinguish tests from usual tools by prefix (test-). Tools shouldn't be invoked by "make docker-run".
I'll remove the .sh suffixes, and "s/docker-run-FOO/docker-FOO/". Then you just:
$ make docker-test-basic@fedora
$ make docker-travis@fedoraThanks,
Fam
Re: [Qemu-devel] [PATCH 02/12] Makefile: Rules for docker testing
Quoted 4 lines · Fam Zheng
Quoted 3 lines · Alex Bennée
Fam Zheng <[email protected]> writes:
<snip>
Quoted 3 lines
I want to distinguish tests from usual tools by prefix (test-). Tools shouldn't be invoked by "make docker-run".
OK fair enough.
Quoted 6 lines
I'll remove the .sh suffixes, and "s/docker-run-FOO/docker-FOO/". Then you just:
$ make docker-test-basic@fedora $ make docker-travis@fedora
Sounds great, thanks ;-)
Quoted 3 lines
Thanks,
Fam
--
Alex Bennée
PATCH 3/12 docker: Add images
In reply to Fam Zheng--- tests/docker/centos6.docker | 5 +++++ tests/docker/fedora.docker | 7 +++++++ tests/docker/ubuntu.docker | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/docker/centos6.docker create mode 100644 tests/docker/fedora.docker create mode 100644 tests/docker/ubuntu.docker
tests/docker/centos6.docker new file +5 -0
@@ -0,0 +1,5 @@ +FROM centos:6 +RUN yum install -y \ + git make gcc g++ \ + zlib-devel glib2-devel SDL-devel pixman-devel +
tests/docker/fedora.docker new file +7 -0
@@ -0,0 +1,7 @@ +FROM fedora:23 +RUN dnf install -y \ + ccache git \ + glib2-devel pixman-devel zlib-devel SDL-devel \ + gcc gcc-c++ clang make perl which bc findutils \ + mingw{32,64}-{pixman,glib2,gmp,SDL,pkg-config,gtk2,gtk3,gnutls,nettle,libtasn1,libjpeg-turbo,libpng,curl,libssh2,bzip2} +ENV FEATURES mingw clang
tests/docker/ubuntu.docker new file +9 -0
@@ -0,0 +1,9 @@ +FROM ubuntu:14.04 +RUN apt-get update +RUN apt-get -y install \ + libusb-1.0-0-dev libiscsi-dev librados-dev libncurses5-dev \ + libseccomp-dev libgnutls-dev libssh2-1-dev libspice-server-dev \ + libspice-protocol-dev libnss3-dev \ + libgtk-3-dev libvte-2.90-dev libsdl1.2-dev libpng12-dev libpixman-1-dev \ + git make ccache python-yaml gcc clang +ENV FEATURES clang ccache pyyaml
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 03/12] docker: Add images
Quoted 40 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/centos6.docker | 5 +++++ tests/docker/fedora.docker | 7 +++++++ tests/docker/ubuntu.docker | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/docker/centos6.docker create mode 100644 tests/docker/fedora.docker create mode 100644 tests/docker/ubuntu.dockertests/docker/centos6.docker new file +5
-0@@ -0,0 +1,5 @@ +FROM centos:6 +RUN yum install -y \ + git make gcc g++ \ + zlib-devel glib2-devel SDL-devel pixman-devel +tests/docker/fedora.docker new file +7
-0@@ -0,0 +1,7 @@ +FROM fedora:23 +RUN dnf install -y \ + ccache git \ + glib2-devel pixman-devel zlib-devel SDL-devel \ + gcc gcc-c++ clang make perl which bc findutils \ + mingw{32,64}-{pixman,glib2,gmp,SDL,pkg-config,gtk2,gtk3,gnutls,nettle,libtasn1,libjpeg-turbo,libpng,curl,libssh2,bzip2} +ENV FEATURES mingw clangtests/docker/ubuntu.docker new file +0
-0
tests/docker/ubuntu.docker line 9
Quoted 9 lines
tests/docker/ubuntu.docker new file +9
-0@@ -0,0 +1,9 @@ +FROM ubuntu:14.04 +RUN apt-get update +RUN apt-get -y install \ + libusb-1.0-0-dev libiscsi-dev librados-dev libncurses5-dev \ + libseccomp-dev libgnutls-dev libssh2-1-dev libspice-server-dev \ + libspice-protocol-dev libnss3-dev \ + libgtk-3-dev libvte-2.90-dev libsdl1.2-dev libpng12-dev libpixman-1-dev \ + git make ccache python-yaml gcc clang +ENV FEATURES clang ccache pyyaml
How are we going to approach naming and upgrading of containers?
Here centos6 is named so explicitly where as fedora (which is a faster moving project) will be replaced at some point. The ubuntu image is the current LTS which will have a new release in a few months although the LTS will be supported for some time.
Maybe we should call them fedora-current and ubuntu-lts?
--
Alex Bennée
Re: [Qemu-devel] [PATCH 03/12] docker: Add images
Quoted 56 lines · Alex Bennée
Quoted 40 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/centos6.docker | 5 +++++ tests/docker/fedora.docker | 7 +++++++ tests/docker/ubuntu.docker | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/docker/centos6.docker create mode 100644 tests/docker/fedora.docker create mode 100644 tests/docker/ubuntu.dockertests/docker/centos6.docker new file +5
-0@@ -0,0 +1,5 @@ +FROM centos:6 +RUN yum install -y \ + git make gcc g++ \ + zlib-devel glib2-devel SDL-devel pixman-devel +tests/docker/fedora.docker new file +7
-0@@ -0,0 +1,7 @@ +FROM fedora:23 +RUN dnf install -y \ + ccache git \ + glib2-devel pixman-devel zlib-devel SDL-devel \ + gcc gcc-c++ clang make perl which bc findutils \ + mingw{32,64}-{pixman,glib2,gmp,SDL,pkg-config,gtk2,gtk3,gnutls,nettle,libtasn1,libjpeg-turbo,libpng,curl,libssh2,bzip2} +ENV FEATURES mingw clangtests/docker/ubuntu.docker new file +0
-0tests/docker/ubuntu.docker line 9
Quoted 9 lines
tests/docker/ubuntu.docker new file +9
-0@@ -0,0 +1,9 @@ +FROM ubuntu:14.04 +RUN apt-get update +RUN apt-get -y install \ + libusb-1.0-0-dev libiscsi-dev librados-dev libncurses5-dev \ + libseccomp-dev libgnutls-dev libssh2-1-dev libspice-server-dev \ + libspice-protocol-dev libnss3-dev \ + libgtk-3-dev libvte-2.90-dev libsdl1.2-dev libpng12-dev libpixman-1-dev \ + git make ccache python-yaml gcc clang +ENV FEATURES clang ccache pyyamlHow are we going to approach naming and upgrading of containers?
Quoted 6 lines
Here centos6 is named so explicitly where as fedora (which is a faster moving project) will be replaced at some point. The ubuntu image is the current LTS which will have a new release in a few months although the LTS will be supported for some time.
Maybe we should call them fedora-current and ubuntu-lts?
I wanted to make the names short and easy to remember. For now I think diversity is more interesting than variations in one distro family, that's why I didn't really care whether it is ubuntu-latest or LTS, and chose 14.04 arbitrarily.
Replacing fedora 23 with future versions only takes one line change in fedora.docker, and a subsequent "make docker-test-*@fedora" will make sure the container image is rebuilt. (It's what tests/docker/docker_build does.)
After all x64 Linuxs are very alike when Mac, Windows and non-x86 hosts are also in the picture, and it would be great if we could cover at least some of them here.
Fam
Re: [Qemu-devel] [PATCH 03/12] docker: Add images
Quoted 62 lines · Fam Zheng
Quoted 61 lines · Alex Bennée
Quoted 40 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/centos6.docker | 5 +++++ tests/docker/fedora.docker | 7 +++++++ tests/docker/ubuntu.docker | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/docker/centos6.docker create mode 100644 tests/docker/fedora.docker create mode 100644 tests/docker/ubuntu.dockertests/docker/centos6.docker new file +5
-0@@ -0,0 +1,5 @@ +FROM centos:6 +RUN yum install -y \ + git make gcc g++ \ + zlib-devel glib2-devel SDL-devel pixman-devel +tests/docker/fedora.docker new file +7
-0@@ -0,0 +1,7 @@ +FROM fedora:23 +RUN dnf install -y \ + ccache git \ + glib2-devel pixman-devel zlib-devel SDL-devel \ + gcc gcc-c++ clang make perl which bc findutils \ + mingw{32,64}-{pixman,glib2,gmp,SDL,pkg-config,gtk2,gtk3,gnutls,nettle,libtasn1,libjpeg-turbo,libpng,curl,libssh2,bzip2} +ENV FEATURES mingw clangtests/docker/ubuntu.docker new file +0
-0tests/docker/ubuntu.docker line 9
Quoted 9 lines
tests/docker/ubuntu.docker new file +9
-0@@ -0,0 +1,9 @@ +FROM ubuntu:14.04 +RUN apt-get update +RUN apt-get -y install \ + libusb-1.0-0-dev libiscsi-dev librados-dev libncurses5-dev \ + libseccomp-dev libgnutls-dev libssh2-1-dev libspice-server-dev \ + libspice-protocol-dev libnss3-dev \ + libgtk-3-dev libvte-2.90-dev libsdl1.2-dev libpng12-dev libpixman-1-dev \ + git make ccache python-yaml gcc clang +ENV FEATURES clang ccache pyyamlHow are we going to approach naming and upgrading of containers?
Here centos6 is named so explicitly where as fedora (which is a faster moving project) will be replaced at some point. The ubuntu image is the current LTS which will have a new release in a few months although the LTS will be supported for some time.
Quoted 6 lines
Quoted 1 line
Maybe we should call them fedora-current and ubuntu-lts?
I wanted to make the names short and easy to remember. For now I think diversity is more interesting than variations in one distro family, that's why I didn't really care whether it is ubuntu-latest or LTS, and chose 14.04 arbitrarily.
Well we care enough for centos. I would at least like to check against debian-stable and debian-testing because a testing target would give us advanced notice of distro breaking changes.
Quoted 8 lines
Replacing fedora 23 with future versions only takes one line change in fedora.docker, and a subsequent "make docker-test-*@fedora" will make sure the container image is rebuilt. (It's what tests/docker/docker_build does.)
After all x64 Linuxs are very alike when Mac, Windows and non-x86 hosts are also in the picture, and it would be great if we could cover at least some of them here.
I'm experimenting with docker on aarch64 ATM so I'll see what happens with these scripts there ;-)
Quoted 2 lines
Fam
--
Alex Bennée
PATCH 4/12 docker: Add test runner
In reply to Fam ZhengIt's better to have a launcher for all tests, to make it easier to initialize and manage the environment.
--- tests/docker/run | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tests/docker/run
tests/docker/run new file +23 -0
@@ -0,0 +1,23 @@ +#!/bin/bash -e +# +# Docker test runner +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +# Prepare the environment +. /etc/profile || true +export PATH=/usr/lib/ccache:$PATH + +tmp=$QEMU_SRC +QEMU_SRC=/var/tmp/qemu.tmp +cp -r $tmp $QEMU_SRC + +cd $QEMU_SRC/tests/docker +"$@"
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner
Quoted 25 lines · Fam Zheng
It's better to have a launcher for all tests, to make it easier to initialize and manage the environment.
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/run | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tests/docker/runtests/docker/run new file +10
-0@@ -0,0 +1,23 @@ +#!/bin/bash -e +# +# Docker test runner +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2
tests/docker/run line 20
Quoted 10 lines
tests/docker/run new file +10
-0+# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +# Prepare the environment +. /etc/profile || true +export PATH=/usr/lib/ccache:$PATH + +tmp=$QEMU_SRC +QEMU_SRC=/var/tmp/qemu.tmp +cp -r $tmp $QEMU_SRC
The first time I ran the fedora target it seems to hang, the second time with V=1 it reported my source tree was an in-tree build.
Could we perhaps use git-archive to grab a pristine copy of the tree? Something like:
STATUS=git stash create
git archive -1 ${STATUS} -o ${TAR}
Would give a clean source tree with current unstaged/uncommited files. Unfortunately this wouldn't include new files yet to be committed in any form to the source tree but using git stash save -u might include a bunch of unwanted stuff.
tests/docker/run line 23
Quoted 3 lines
tests/docker/run new file +3
-0+ +cd $QEMU_SRC/tests/docker +"$@"
--
Alex Bennée
Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner
Quoted 44 lines · Alex Bennée
Quoted 25 lines · Fam Zheng
It's better to have a launcher for all tests, to make it easier to initialize and manage the environment.
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/run | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tests/docker/runtests/docker/run new file +10
-0@@ -0,0 +1,23 @@ +#!/bin/bash -e +# +# Docker test runner +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2tests/docker/run line 20
Quoted 10 lines
tests/docker/run new file +10
-0+# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +# Prepare the environment +. /etc/profile || true +export PATH=/usr/lib/ccache:$PATH + +tmp=$QEMU_SRC +QEMU_SRC=/var/tmp/qemu.tmp +cp -r $tmp $QEMU_SRCThe first time I ran the fedora target it seems to hang, the second time with V=1 it reported my source tree was an in-tree build.
Could we perhaps use git-archive to grab a pristine copy of the tree? Something like:
Quoted 7 lines
STATUS=
git stash create
git archive -1 ${STATUS} -o ${TAR}Would give a clean source tree with current unstaged/uncommited files. Unfortunately this wouldn't include new files yet to be committed in any form to the source tree but using git stash save -u might include a bunch of unwanted stuff.
OK that won't work if you have alternates in your git setup. It seems to me the creation of the pristine tree for docker should be done before we enter the docker environment.
There is a slight wrinkle as to what happens if the user wants to enter an interactive session for debugging. However that doesn't seem possible via the makefile and perhaps that is just as well. Perhaps that should be a helper script for the user?
Quoted 4 lines
tests/docker/run line 23
Quoted 4 lines
tests/docker/run new file +3
-0+ +cd $QEMU_SRC/tests/docker +"$@"
--
Alex Bennée
Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner
Quoted 55 lines · Alex Bennée
Quoted 44 lines · Alex Bennée
Quoted 25 lines · Fam Zheng
It's better to have a launcher for all tests, to make it easier to initialize and manage the environment.
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/run | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tests/docker/runtests/docker/run new file +10
-0@@ -0,0 +1,23 @@ +#!/bin/bash -e +# +# Docker test runner +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2tests/docker/run line 20
Quoted 10 lines
tests/docker/run new file +10
-0+# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +# Prepare the environment +. /etc/profile || true +export PATH=/usr/lib/ccache:$PATH + +tmp=$QEMU_SRC +QEMU_SRC=/var/tmp/qemu.tmp +cp -r $tmp $QEMU_SRCThe first time I ran the fedora target it seems to hang, the second time with V=1 it reported my source tree was an in-tree build.
Could we perhaps use git-archive to grab a pristine copy of the tree? Something like:
Quoted 7 lines
STATUS=
git stash create
git archive -1 ${STATUS} -o ${TAR}Would give a clean source tree with current unstaged/uncommited files. Unfortunately this wouldn't include new files yet to be committed in any form to the source tree but using git stash save -u might include a bunch of unwanted stuff.
Quoted 8 lines
OK that won't work if you have alternates in your git setup. It seems to me the creation of the pristine tree for docker should be done before we enter the docker environment.
There is a slight wrinkle as to what happens if the user wants to enter an interactive session for debugging. However that doesn't seem possible via the makefile and perhaps that is just as well. Perhaps that should be a helper script for the user?
We can use "make distclean" in the copied tree.
Fam
Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner
Quoted 15 lines · Fam Zheng
Quoted 14 lines · Alex Bennée
Quoted 11 lines · Alex Bennée
Quoted 9 lines · Fam Zheng
It's better to have a launcher for all tests, to make it easier to initialize and manage the environment.
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/run | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tests/docker/run
<snip>
Quoted 10 lines
Quoted 8 lines
OK that won't work if you have alternates in your git setup. It seems to me the creation of the pristine tree for docker should be done before we enter the docker environment.
There is a slight wrinkle as to what happens if the user wants to enter an interactive session for debugging. However that doesn't seem possible via the makefile and perhaps that is just as well. Perhaps that should be a helper script for the user?
We can use "make distclean" in the copied tree.
I wouldn't - distclean isn't always that clean due to *mumble mumble* makefile reasons. You could try this approach:
commit f838d3bbe2f71c731dfe172f1c3286084de203c8
Author: Alex Bennée <[email protected]> Date: Mon Feb 15 12:52:21 2016 +0000
tests/docker/Makefile.include: snapshot the src for docker
Instead of providing a live version of the source tree to the docker container we snapshot it with git-archive. This ensure the tree is in a pristine state for whatever operations the container is going to run on them.
Uncommitted changes known to files known by the git index will be included in the snapshot if there are any.
tests/docker/Makefile.include +8 -3
@@ -2,7 +2,7 @@ $(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak)) -.PHONY: docker docker-build docker-run docker-clean +.PHONY: docker docker-build docker-qemu-src docker-run docker-clean DOCKER_SUFFIX = .docker
@@ -16,12 +16,17 @@ DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS)) TESTS ?= % IMAGES ?= % +docker-qemu-src: + $(if git diff-index --quiet HEAD --, \ + git archive -1 HEAD --prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp, \ + git archive -1 `git stash create` --prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp) + $(foreach i,$(DOCKER_IMAGES), \ $(eval docker-build: docker-build-$i) \ $(foreach t,$(DOCKER_SCRIPTS), \ $(eval docker-build-$i docker-run-$t@$i: IMAGE=$i) \ $(eval docker-run-$t@$i: SCRIPT=$t) \ - $(eval docker-run-$t@$i: docker-build-$i) \ + $(eval docker-run-$t@$i: docker-build-$i docker-qemu-src) \ $(if $(filter test-%,$t), \ $(eval docker-run: docker-run-$t@$i) \ $(eval docker-run-$t@: docker-run-$t@$i) \
@@ -74,7 +79,7 @@ docker-run-%: $(call quiet-command,\ $(SRC_PATH)/tests/docker/docker_run \ --privileged -t --rm --net=none \ - -v $$(realpath $(SRC_PATH)):/var/tmp/qemu \ + -v $$(realpath /tmp/qemu-docker-snapshot/):/var/tmp/qemu \ -e QEMU_SRC=/var/tmp/qemu \ -e V=$(V) \ -v /var/tmp/qemu-docker-ccache:/var/tmp/ccache \
Quoted 2 lines
Fam
--
Alex Bennée
Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner
Quoted 4 lines · Alex Bennée
Quoted 4 lines
Quoted 4 lines
There is a slight wrinkle as to what happens if the user wants to enter an interactive session for debugging. However that doesn't seem possible via the makefile and perhaps that is just as well. Perhaps that should be a helper script for the user?
Good idea. The "docker run" invocation should be able to drop stdio into an interactive shell, with Makefile. I'll take a look in v2.
Fam
Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner
In reply to Alex BennéeQuoted 63 lines · Alex Bennée
Quoted 15 lines · Fam Zheng
Quoted 14 lines · Alex Bennée
Quoted 11 lines · Alex Bennée
Quoted 9 lines · Fam Zheng
It's better to have a launcher for all tests, to make it easier to initialize and manage the environment.
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/run | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tests/docker/run<snip>
Quoted 10 lines
Quoted 8 lines
OK that won't work if you have alternates in your git setup. It seems to me the creation of the pristine tree for docker should be done before we enter the docker environment.
There is a slight wrinkle as to what happens if the user wants to enter an interactive session for debugging. However that doesn't seem possible via the makefile and perhaps that is just as well. Perhaps that should be a helper script for the user?
We can use "make distclean" in the copied tree.
I wouldn't - distclean isn't always that clean due to *mumble mumble* makefile reasons. You could try this approach:
commit
f838d3bbe2f71c731dfe172f1c3286084de203c8Author: Alex Bennée <[email protected]> Date: Mon Feb 15 12:52:21 2016 +0000tests/docker/Makefile.include: snapshot the src for docker
Instead of providing a live version of the source tree to the docker container we snapshot it with git-archive. This ensure the tree is in a pristine state for whatever operations the container is going to run on them.
Uncommitted changes known to files known by the git index will be included in the snapshot if there are any.
Signed-off-by Alex Bennée <[email protected]>tests/docker/Makefile.include +1
-1@@ -2,7 +2,7 @@ $(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak)) -.PHONY: docker docker-build docker-run docker-clean +.PHONY: docker docker-build docker-qemu-src docker-run docker-clean DOCKER_SUFFIX = .docker
tests/docker/Makefile.include DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS)) · line 22
Quoted 7 lines
tests/docker/Makefile.include +4
-0@@ -16,12 +16,17 @@ DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS)) TESTS ?= % IMAGES ?= % +docker-qemu-src: + $(if git diff-index --quiet HEAD --, \ + git archive -1 HEAD --prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp, \ + git archive -1 `git stash create` --prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp)
Does this clutter the user's git stash list? Or we can just error out if the working tree is not clean.
Fam
Re: [Qemu-devel] [PATCH 04/12] docker: Add test runner
Quoted 67 lines · Fam Zheng
Quoted 66 lines · Alex Bennée
Quoted 15 lines · Fam Zheng
Quoted 14 lines · Alex Bennée
Quoted 11 lines · Alex Bennée
Quoted 9 lines · Fam Zheng
It's better to have a launcher for all tests, to make it easier to initialize and manage the environment.
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/run | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 tests/docker/run<snip>
Quoted 10 lines
Quoted 8 lines
OK that won't work if you have alternates in your git setup. It seems to me the creation of the pristine tree for docker should be done before we enter the docker environment.
There is a slight wrinkle as to what happens if the user wants to enter an interactive session for debugging. However that doesn't seem possible via the makefile and perhaps that is just as well. Perhaps that should be a helper script for the user?
We can use "make distclean" in the copied tree.
I wouldn't - distclean isn't always that clean due to *mumble mumble* makefile reasons. You could try this approach:
commit
f838d3bbe2f71c731dfe172f1c3286084de203c8Author: Alex Bennée <[email protected]> Date: Mon Feb 15 12:52:21 2016 +0000tests/docker/Makefile.include: snapshot the src for docker
Instead of providing a live version of the source tree to the docker container we snapshot it with git-archive. This ensure the tree is in a pristine state for whatever operations the container is going to run on them.
Uncommitted changes known to files known by the git index will be included in the snapshot if there are any.
Signed-off-by Alex Bennée <[email protected]>tests/docker/Makefile.include +1
-1@@ -2,7 +2,7 @@ $(if $(quiet-command),,$(eval include $(SRC_PATH)/rules.mak)) -.PHONY: docker docker-build docker-run docker-clean +.PHONY: docker docker-build docker-qemu-src docker-run docker-clean DOCKER_SUFFIX = .docker@@ -16,12 +16,17 @@ DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS)) TESTS ?= % IMAGES ?= %
Quoted 7 lines
tests/docker/Makefile.include DOCKER_TOOLS := $(filter-out test-%, $(DOCKER_SCRIPTS)) · line 22
Quoted 4 lines
tests/docker/Makefile.include +4
-0+docker-qemu-src: + $(if git diff-index --quiet HEAD --, \ + git archive -1 HEAD --prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp, \ + git archive -1 `git stash create` --prefix=qemu-docker-snapshot/ --format=tar.gz | tar -xz -C /tmp)Does this clutter the user's git stash list? Or we can just error out if the working tree is not clean.
No it doesn't, it is a temporary dangling object, quoth the manual:
create
Create a stash (which is a regular commit object) and return its object name, without storing it anywhere in the ref namespace. This is intended to be useful for scripts. It is probably not the command you want to use; see "save" above.
Quoted 2 lines
Fam
--
Alex Bennée
PATCH 5/12 docker: Add common.rc
In reply to Fam Zheng"requires" checks the "FEATURE" environment for specified prerequisits, and skip the execution of test if not found.
--- tests/docker/common.rc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 tests/docker/common.rc
tests/docker/common.rc new file +28 -0
@@ -0,0 +1,28 @@ +#!/bin/sh +# +# Common routines for docker test scripts. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +requires() +{ + for c in $@; do + if ! echo "$FEATURES" | grep -wq -e "$c"; then + echo "Prerequisite '$c' not present, skip" + exit 0 + fi + done +} + +build_qemu() +{ + $QEMU_SRC/configure "$@" + make $MAKEFLAGS +}
Signature · 1 line
2.4.3
PATCH 6/12 docker: Add basic test
In reply to Fam Zheng--- tests/docker/test-basic.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 tests/docker/test-basic.sh
tests/docker/test-basic.sh new file +22 -0
@@ -0,0 +1,22 @@ +#!/bin/bash -e +# +# Basic compiling test that everyone already does. But why not automate it? +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +. common.rc + +cd $(mktemp -d) +mkdir build +mkdir install +cd build +build_qemu --target-list=x86_64-softmmu --prefix="${pwd}/install" +make check $MAKEFLAGS +make install
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 06/12] docker: Add basic test
Quoted 35 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- tests/docker/test-basic.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 tests/docker/test-basic.shtests/docker/test-basic.sh new file +22
-0@@ -0,0 +1,22 @@ +#!/bin/bash -e +# +# Basic compiling test that everyone already does. But why not automate it? +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +. common.rc + +cd $(mktemp -d) +mkdir build +mkdir install +cd build +build_qemu --target-list=x86_64-softmmu --prefix="${pwd}/install" +make check $MAKEFLAGS +make install
Quoted 1 line
From my excursions last week into the tests directory I discovered the
unit tests are built for a number of different qtest binaries. For completeness we should probably include the whole list:
#+name: qtest-targets
#+begin_src sh :dir ~/lsrc/qemu/qemu.git :results scalar
grep -E "check-qtest-[[:alnum:]]+-y " tests/Makefile | cut -d " " -f 1 | sort -u #+end_src
#+RESULTS: qtest-targets
#+begin_example
check-qtest-arm-y
check-qtest-generic-y
check-qtest-i386-y
check-qtest-ipack-y
check-qtest-microblazeel-y
check-qtest-mips64el-y
check-qtest-mips64-y
check-qtest-mips-y
check-qtest-pci-y
check-qtest-ppc64-y
check-qtest-ppc-y
check-qtest-sh4eb-y
check-qtest-sh4-y
#check-qtest-sparc64-y
check-qtest-sparc64-y
#check-qtest-sparc-y
check-qtest-virtioserial-y
check-qtest-virtio-y
check-qtest-x86_64-y
check-qtest-xtensaeb-y
check-qtest-y
#+end_example
--
Alex Bennée
Re: [Qemu-devel] [PATCH 06/12] docker: Add basic test
Quoted 7 lines · Alex Bennée
tests/docker/test-basic.sh line 20
Quoted 5 lines · Fam Zheng
tests/docker/test-basic.sh new file +5
-0+cd $(mktemp -d) +mkdir build +mkdir install +cd build +build_qemu --target-list=x86_64-softmmu --prefix="${pwd}/install"
Why restrict the target list ?
Quoted 28 lines
tests/docker/test-basic.sh line 22
Quoted 2 lines
tests/docker/test-basic.sh new file +2
-0+make check $MAKEFLAGS +make installFrom my excursions last week into the tests directory I discovered the unit tests are built for a number of different qtest binaries. For completeness we should probably include the whole list:
#+name: qtest-targets
#+begin_src sh :dir ~/lsrc/qemu/qemu.git :results scalar
grep -E "check-qtest-[[:alnum:]]+-y " tests/Makefile | cut -d " " -f 1 | sort -u #+end_src#+RESULTS: qtest-targets
#+begin_example
check-qtest-arm-y
check-qtest-generic-y
check-qtest-i386-y
check-qtest-ipack-y
check-qtest-microblazeel-y
check-qtest-mips64el-y
check-qtest-mips64-y
check-qtest-mips-y
check-qtest-pci-y
check-qtest-ppc64-y
check-qtest-ppc-y
check-qtest-sh4eb-y
check-qtest-sh4-y
#check-qtest-sparc64-y
Quoted 8 lines
check-qtest-sparc64-y
#check-qtest-sparc-y
check-qtest-virtioserial-y
check-qtest-virtio-y
check-qtest-x86_64-y
check-qtest-xtensaeb-y
check-qtest-y
#+end_example
I'm having difficulty figuring out what you're proposing here, but it looks like you're suggesting listing all the check-qtest-* test names again here, which seems worth avoiding. We should just do a build and make check and let that take care of running all the tests.
thanks
-- PMM
Re: [Qemu-devel] [PATCH 06/12] docker: Add basic test
Quoted 48 lines · Peter Maydell
Quoted 7 lines · Alex Bennée
tests/docker/test-basic.sh line 20
Quoted 5 lines · Fam Zheng
tests/docker/test-basic.sh new file +5
-0+cd $(mktemp -d) +mkdir build +mkdir install +cd build +build_qemu --target-list=x86_64-softmmu --prefix="${pwd}/install"Why restrict the target list ?
Quoted 28 lines
tests/docker/test-basic.sh line 22
Quoted 2 lines
tests/docker/test-basic.sh new file +2
-0+make check $MAKEFLAGS +make installFrom my excursions last week into the tests directory I discovered the unit tests are built for a number of different qtest binaries. For completeness we should probably include the whole list:
#+name: qtest-targets
#+begin_src sh :dir ~/lsrc/qemu/qemu.git :results scalar
grep -E "check-qtest-[[:alnum:]]+-y " tests/Makefile | cut -d " " -f 1 | sort -u #+end_src#+RESULTS: qtest-targets
#+begin_example
check-qtest-arm-y
check-qtest-generic-y
check-qtest-i386-y
check-qtest-ipack-y
check-qtest-microblazeel-y
check-qtest-mips64el-y
check-qtest-mips64-y
check-qtest-mips-y
check-qtest-pci-y
check-qtest-ppc64-y
check-qtest-ppc-y
check-qtest-sh4eb-y
check-qtest-sh4-y
#check-qtest-sparc64-yQuoted 8 lines
check-qtest-sparc64-y
#check-qtest-sparc-y
check-qtest-virtioserial-y
check-qtest-virtio-y
check-qtest-x86_64-y
check-qtest-xtensaeb-y
check-qtest-y
#+end_example
Quoted 5 lines
I'm having difficulty figuring out what you're proposing here, but it looks like you're suggesting listing all the check-qtest-* test names again here, which seems worth avoiding. We should just do a build and make check and let that take care of running all the tests.
Well there is a halfway house between building one target and building all possible targets. Not all the softmmu targets include additional tests. Having said that it is probably simpler as you say to just build everything.
Quoted 3 lines
thanks
-- PMM
--
Alex Bennée
Re: [Qemu-devel] [PATCH 06/12] docker: Add basic test
Quoted 5 lines · Alex Bennée
Quoted 2 lines · Peter Maydell
Quoted 1 line · Alex Bennée
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
tests/docker/test-basic.sh line 20
Quoted 5 lines · Fam Zheng
tests/docker/test-basic.sh new file +5
-0+cd $(mktemp -d) +mkdir build +mkdir install +cd build +build_qemu --target-list=x86_64-softmmu --prefix="${pwd}/install"Why restrict the target list ?
There is no particular reason, just I wanted to keep the "basic test" basic. I'll rename it to "quick".
That said, this is only one of many possible tests, multiplied by the number of images we ship. We need to be careful with the matrix, because the point of having these tests is to run them frequently (either manually by developers or automatically by CI on every patch series or even every patch). 10+ minutes for a single test/image combination just makes that hard.
Quoted 44 lines
Quoted 38 lines
Quoted 29 lines
tests/docker/test-basic.sh line 22
Quoted 3 lines
tests/docker/test-basic.sh new file +2
-0+make check $MAKEFLAGS +make installFrom my excursions last week into the tests directory I discovered the unit tests are built for a number of different qtest binaries. For completeness we should probably include the whole list:
#+name: qtest-targets
#+begin_src sh :dir ~/lsrc/qemu/qemu.git :results scalar
grep -E "check-qtest-[[:alnum:]]+-y " tests/Makefile | cut -d " " -f 1 | sort -u #+end_src#+RESULTS: qtest-targets
#+begin_example
check-qtest-arm-y
check-qtest-generic-y
check-qtest-i386-y
check-qtest-ipack-y
check-qtest-microblazeel-y
check-qtest-mips64el-y
check-qtest-mips64-y
check-qtest-mips-y
check-qtest-pci-y
check-qtest-ppc64-y
check-qtest-ppc-y
check-qtest-sh4eb-y
check-qtest-sh4-y
#check-qtest-sparc64-yQuoted 8 lines
check-qtest-sparc64-y
#check-qtest-sparc-y
check-qtest-virtioserial-y
check-qtest-virtio-y
check-qtest-x86_64-y
check-qtest-xtensaeb-y
check-qtest-y
#+end_exampleQuoted 5 lines
I'm having difficulty figuring out what you're proposing here, but it looks like you're suggesting listing all the check-qtest-* test names again here, which seems worth avoiding. We should just do a build and make check and let that take care of running all the tests.
Quoted 4 lines
Well there is a halfway house between building one target and building all possible targets. Not all the softmmu targets include additional tests. Having said that it is probably simpler as you say to just build everything.
Sure, but I'd create a separate "full" test for that.
Fam
PATCH 7/12 docker: Add clang test
In reply to Fam ZhengThe configure options are suggested by John Snow <[email protected]>.
--- tests/docker/test-clang.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 tests/docker/test-clang.sh
tests/docker/test-clang.sh new file +26 -0
@@ -0,0 +1,26 @@ +#!/bin/bash -e +# +# Compile and check with clang. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +. common.rc + +requires clang + +cd $(mktemp -d) +build_qemu \ + --target-list=x86_64-softmmu,aarch64-softmmu \ + --enable-debug \ + --cxx=clang++ --cc=clang --host-cc=clang \ + --extra-cflags=-Werror --extra-cflags=-fsanitize=undefined \ + --extra-cflags=-Wno-deprecated-declarations \ + --extra-cflags=-fno-sanitize=float-divide-by-zero +make $MAKEFLAGS check
Signature · 1 line
2.4.3
PATCH 8/12 docker: Add mingw test
In reply to Fam Zheng--- tests/docker/test-mingw.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tests/docker/test-mingw.sh
tests/docker/test-mingw.sh new file +34 -0
@@ -0,0 +1,34 @@ +#!/bin/bash -e +# +# Cross compile QEMU with mingw toolchain on Linux. +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +. common.rc + +requires mingw + +cd $(mktemp -d) +for prefix in x86_64-w64-mingw32- i686-w64-mingw32-; do + build_qemu --cross-prefix=$prefix \ + --target-list=x86_64-softmmu,aarch64-softmmu \ + --enable-trace-backends=simple \ + --enable-debug \ + --enable-gnutls \ + --enable-nettle \ + --enable-curl \ + --enable-vnc \ + --enable-bzip2 \ + --enable-guest-agent \ + --with-sdlabi=1.2 \ + --with-gtkabi=2.0 + +done +
Signature · 1 line
2.4.3
PATCH 9/12 docker: Add travis tool
In reply to Fam ZhengThe script is not named test-travis.sh so it won't run with "make docker-run", because it can take too long.
Run it with "make docker-run-travis.sh@ubuntu".
--- tests/docker/travis.py | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/docker/travis.sh | 20 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 tests/docker/travis.py create mode 100755 tests/docker/travis.sh
tests/docker/travis.py new file +53 -0
@@ -0,0 +1,53 @@ +#!/usr/bin/env python2 -B +# +# Travis YAML config parser +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +import sys +import yaml +import json +import itertools + +def load_yaml(fname): + return yaml.load(open(sys.argv[1], "r").read()) + +def conf_iter(conf): + def env_list(e): + return e if type(e) is list else [e] + global_env = conf["env"]["global"] + for c in conf["matrix"]["include"]: + a = { "env": global_env + env_list(c["env"]), + "compiler": c["compiler"] + } + yield a + for c in itertools.product(conf["compiler"], + conf["env"]["matrix"]): + a = { "env": global_env + env_list(c[1]), + "compiler": c[0] + } + yield a + +def main(): + if len(sys.argv) < 2: + sys.stderr.write("Usage: %s <travis-file>\n" % sys.argv[0]) + return 1 + conf = load_yaml(sys.argv[1]) + for config in conf_iter(conf): + print "(" + print "\n".join(config["env"]) + print "CC=" + config["compiler"] + print "\n".join(conf["before_script"]) + print "\n".join(conf["script"]) + print ")" + return 0 + +if __name__ == "__main__": + sys.exit(main())
tests/docker/travis.sh new file +20 -0
@@ -0,0 +1,20 @@ +#!/bin/bash -e +# +# Mimic a travis testing matrix of environment +# +# Copyright (c) 2016 Red Hat Inc. +# +# Authors: +# Fam Zheng <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or (at your option) any later version. See the COPYING file in +# the top-level directory. + +. common.rc + +requires pyyaml + +cd $(mktemp -d) +$QEMU_SRC/tests/docker/travis.py $QEMU_SRC/.travis.yml > travis_command_list +. travis_command_list
Signature · 1 line
2.4.3
PATCH 10/12 docs: Add text for tests/docker in build-system.txt
In reply to Fam Zheng--- docs/build-system.txt | 5 +++++ 1 file changed, 5 insertions(+)
docs/build-system.txt +5 -0
@@ -438,6 +438,11 @@ top level Makefile, so anything defined in this file will influence the entire build system. Care needs to be taken when writing rules for tests to ensure they only apply to the unit test execution / build. +- tests/docker/Makefile.include + +Rules for Docker tests. Like tests/Makefile, this file is included +directly by the top level Makefile, anything defined in this file will +influence the entire build system. - po/Makefile
Signature · 1 line
2.4.3
PATCH 11/12 .gitignore: Ignore temporary dockerfile
In reply to Fam Zheng--- .gitignore | 1 + 1 file changed, 1 insertion(+)
.gitignore +1 -0
@@ -109,3 +109,4 @@ cscope.* tags TAGS *~ +/tests/docker/*.docker.tmp
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 11/12] .gitignore: Ignore temporary dockerfile
Quoted 10 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- .gitignore | 1 + 1 file changed, 1 insertion(+).gitignore +0
-0
.gitignore cscope.* · line 112
Quoted 4 lines
.gitignore +1
-0@@ -109,3 +109,4 @@ cscope.* tags TAGS *~ +/tests/docker/*.docker.tmp
Is this left over from the python bindings called in docker_build? If so can we say so in the commit if we can't persuade the bindings to not clutter up the tree?
--
Alex Bennée
Re: [Qemu-devel] [PATCH 11/12] .gitignore: Ignore temporary dockerfile
Quoted 8 lines · Alex Bennée
Quoted 5 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- .gitignore | 1 + 1 file changed, 1 insertion(+)
Quoted 13 lines
.gitignore cscope.* · line 112
Quoted 9 lines
.gitignore +1
-0@@ -109,3 +109,4 @@ cscope.* tags TAGS *~ +/tests/docker/*.docker.tmpIs this left over from the python bindings called in
docker_build? If so can we say so in the commit if we can't persuade the bindings to not clutter up the tree?
Okay, it has to be in the tree because of the "docker build context". docker_build should remove this file at exit but this is just in case it fails to.
I'll update the commit message.
Fam
PATCH 12/12 MAINTAINERS: Add tests/docker
In reply to Fam Zheng--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -1573,3 +1573,10 @@ Build system architecture M: Daniel P. Berrange <[email protected]> S: Odd Fixes F: docs/build-system.txt + +Docker testing +-------------- +Docker based testing framework and cases +M: Fam Zheng <[email protected]> +S: Maintained +F: tests/docker/
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 12/12] MAINTAINERS: Add tests/docker
Quoted 10 lines · Fam Zheng
Signed-off-by Fam Zheng <[email protected]>--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)MAINTAINERS +0
-0
MAINTAINERS Build system architecture · line 1582
Quoted 10 lines
MAINTAINERS +7
-0@@ -1573,3 +1573,10 @@ Build system architecture M: Daniel P. Berrange <[email protected]> S: Odd Fixes F: docs/build-system.txt + +Docker testing +-------------- +Docker based testing framework and cases +M: Fam Zheng <[email protected]> +S: Maintained +F: tests/docker/
--
Alex Bennée
Quoted 6 lines · Fam Zheng
v1: Since RFC, addressed comments from reviewers, and improved a lot of things.
Thanks to Daniel, Eric, Paolo, Stefan, for the feedback.This series adds a new "docker" make target family to run tests in created docker containers.
Quoted 7 lines
To begin with, this can be a place to store standard env/command combinations to build and test QEMU.
Secondly, CI usually provides "docker" capability (such as travis [1]), where we define standard/repeatable test environments, and run tests in them. However, what tests to cover is better maintained in-tree, in order to keep in sync with the code development.
We've actually just switched to using Travis' containers for our builds which I think don't allow the use of docker. This is because Travis has more build capacity with the container infrastructure compared to the old VM based solution.
That said that we could switch back.
Quoted 3 lines
Lastly, this makes it very simple for developers to replicate such tests themselves.
However I think this is the most useful part. Making it easier for developers to run tests on something other than their desktop. I shall have a look through. Thanks!
Quoted 44 lines
[1]: https://docs.travis-ci.com/user/docker/
Fam Zheng (12):
tests: Add utilities for docker testing
Makefile: Rules for docker testing
docker: Add images
docker: Add test runner
docker: Add common.rc
docker: Add basic test
docker: Add clang test
docker: Add mingw test
docker: Add travis tool
docs: Add text for tests/docker in build-system.txt .gitignore: Ignore temporary dockerfile
MAINTAINERS: Add tests/docker.gitignore | 1 + MAINTAINERS | 7 +++ Makefile | 4 +- docs/build-system.txt | 5 ++ tests/docker/Makefile.include | 88 ++++++++++++++++++++++++++++++++++ tests/docker/centos6.docker | 5 ++ tests/docker/common.rc | 28 +++++++++++ tests/docker/docker.py | 108 ++++++++++++++++++++++++++++++++++++++++++ tests/docker/docker_build | 42 ++++++++++++++++ tests/docker/docker_clean | 22 +++++++++ tests/docker/docker_run | 28 +++++++++++ tests/docker/fedora.docker | 7 +++ tests/docker/run | 23 +++++++++ tests/docker/test-basic.sh | 22 +++++++++ tests/docker/test-clang.sh | 26 ++++++++++ tests/docker/test-mingw.sh | 34 +++++++++++++ tests/docker/travis.py | 53 +++++++++++++++++++++ tests/docker/travis.sh | 20 ++++++++ tests/docker/ubuntu.docker | 9 ++++ 19 files changed, 531 insertions(+), 1 deletion(-) create mode 100644 tests/docker/Makefile.include create mode 100644 tests/docker/centos6.docker create mode 100755 tests/docker/common.rc create mode 100755 tests/docker/docker.py create mode 100755 tests/docker/docker_build create mode 100755 tests/docker/docker_clean create mode 100755 tests/docker/docker_run
Quoted 8 lines
create mode 100644 tests/docker/fedora.docker create mode 100755 tests/docker/run create mode 100755 tests/docker/test-basic.sh create mode 100755 tests/docker/test-clang.sh create mode 100755 tests/docker/test-mingw.sh create mode 100755 tests/docker/travis.py create mode 100755 tests/docker/travis.sh create mode 100644 tests/docker/ubuntu.docker
--
Alex Bennée
Quoted 8 lines · Alex Bennée
Quoted 7 lines
To begin with, this can be a place to store standard env/command combinations to build and test QEMU.
Secondly, CI usually provides "docker" capability (such as travis [1]), where we define standard/repeatable test environments, and run tests in them. However, what tests to cover is better maintained in-tree, in order to keep in sync with the code development.
Quoted 4 lines
We've actually just switched to using Travis' containers for our builds which I think don't allow the use of docker. This is because Travis has more build capacity with the container infrastructure compared to the old VM based solution.
Sure, we should still keep testing matrix for Travis in .travis.yml.
The actual background of this is I'm trying to make progress on Patchew (apologies, it's going slow), for which I still want all the build flags to be maintained in qemu.git, hence the "make docker" commands.
Quoted 7 lines
Quoted 3 lines
Lastly, this makes it very simple for developers to replicate such tests themselves.
However I think this is the most useful part. Making it easier for developers to run tests on something other than their desktop. I shall have a look through. Thanks!
Especially so when a patch contributor gets an automatical reply to their patches about a build/test failure and he/she is up to fix it.
Fam
Quoted 8 lines · Fam Zheng
v1: Since RFC, addressed comments from reviewers, and improved a lot of things.
Thanks to Daniel, Eric, Paolo, Stefan, for the feedback.This series adds a new "docker" make target family to run tests in created docker containers.
To begin with, this can be a place to store standard env/command combinations to build and test QEMU.
I think I'm done for this review pass. Please CC me on your next version.
I've run a quick test on my ARM64 Debian Jessie box which predictably failed. It looks like this is a docker hub issue for one thing as:
docker pull debian:stable
creates an x86_64 image on the arm64 box which predictably fails. I suspect the only solution is going to be storing our own built images on the docker hub and tweaking the tooling to take host architecture into account.
Do you have any non-x86 boxes to test against or are you going to need some help with non-x86 support?
Cheers,
--
Alex Bennée
Quoted 6 lines · Alex Bennée
Quoted 3 lines · Fam Zheng
v1: Since RFC, addressed comments from reviewers, and improved a lot of things.
Thanks to Daniel, Eric, Paolo, Stefan, for the feedback.
Quoted 8 lines
Quoted 5 lines
This series adds a new "docker" make target family to run tests in created docker containers.
To begin with, this can be a place to store standard env/command combinations to build and test QEMU.
I think I'm done for this review pass. Please CC me on your next version.
Sure!
Quoted 10 lines
I've run a quick test on my ARM64 Debian Jessie box which predictably failed. It looks like this is a docker hub issue for one thing as:
docker pull debian:stable
creates an
x86_64image on the arm64 box which predictably fails. I suspect the only solution is going to be storing our own built images on the docker hub and tweaking the tooling to take host architecture into account.
Yes I think that makes sense.
Quoted 3 lines
Do you have any non-x86 boxes to test against or are you going to need some help with non-x86 support?
You're right docker isn't platform aware. At the moment I don't have a non-x86 box to test, it is great if you can help.
Thanks!
Fam