From patchwork Fri Jan 22 18:18:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 368650 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1746907jam; Fri, 22 Jan 2021 10:20:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxv0jzE40PcJxm5v6zl15tGAefYK1ibnjaNZMzsuz/mI9+FIbXk4L8y2BA1bYAzAjRaPH1s X-Received: by 2002:a25:d311:: with SMTP id e17mr8918537ybf.149.1611339649508; Fri, 22 Jan 2021 10:20:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611339649; cv=none; d=google.com; s=arc-20160816; b=dmeq12ZQKwUPevjB0H3yiSNPJgEN/+/UcXkoiWBjg0mXRVt0DckMownuJ8oonCKDvw VLyQpysuDb9wQbtryeQuQ6vwbyOQM9WZFEtryLlyyBFWca2qXsbGTiCoZr/VbYRrJqGC Wlh0ucSiAohI3zr1D8fHgAQal708ATPpwSGUd3QTHwCnpIrqe1By1yuPpCExz1J0ywwO rSXLZ1Sga6nasRhBLtEDG5FyWUF1AVgwgdgihOEf4FnF+YNVfkqTWFP/SHlyalzGOyTt 50Lsx5cs8TEMhRF9zhp5yOeDxyly3hKbE3IvrSknl0DDl6fHWXHjBvNgcjaFC7P2ojHu Z7rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=r/l3rZk8GOIQaj/zcskGUMbwB8AQ01WgfPICmp322OI=; b=UBoKBlTtMowkhtoNT+QhqwsMy6z68vtnDnm/TBiMBEIgxOaGCqsigZbwWku5x5jruk PWs0HPPfLRQ4knatCDfhSwXumDjXAModkxfDskLZo1uEBux+AZTDpSWAfAceqjHLJpsz VApUjH77OTsAJ0qXu92TPrAS9AOw9eoOg7paBviaQtySB751JDGSZxfugrWY3u30TI4E RmQxMBrTJJnci0K7S23QXTIasPe/AhRdWjJHN6iZO7hNoMf/2M0e4AkDooA6Cpl8b1Wv 6FrbvjC3qeQc5TZNq/qgB9c8ri5NFqECGw9Iw1DU1sKrLq4Jo9Vddesckgw+8rXBoFAY 7gxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q0ekPi8d; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c6si3085869ybr.119.2021.01.22.10.20.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Jan 2021 10:20:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q0ekPi8d; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l313A-0000S1-S8 for patch@linaro.org; Fri, 22 Jan 2021 13:20:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l311X-0007ZE-7R for qemu-devel@nongnu.org; Fri, 22 Jan 2021 13:19:07 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:52144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l311V-0006sI-8P for qemu-devel@nongnu.org; Fri, 22 Jan 2021 13:19:07 -0500 Received: by mail-wm1-x330.google.com with SMTP id m2so5108401wmm.1 for ; Fri, 22 Jan 2021 10:19:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r/l3rZk8GOIQaj/zcskGUMbwB8AQ01WgfPICmp322OI=; b=Q0ekPi8ddPsLqWk/bzAAyuQOjZVex9EEdlUKCZGUQJLW+Cfs0cDpxDELPJlzsfuSQs YnxDQEmRSdjU8dtnMDfJptl86GwsXKt5MRLfiFG3g79iAhqkaqxsREB4qkBcJ26IM9KK 11f54O7pFgrQgAGtb4dWWBoroYQNS1jStLBxh/58ZclnyYwIrjwBe0M4UKVBXOxqzbPz SelAsbec5NS0ts+0lJkhykzge18kqObgVwRZARD/z3BR8tmfKiRZPkTydw9CWO1cLYVP m6E2wB8u6wjQqip6BS6LgDW5FsK5xjJIoc7s5JFNnabw5CLhjWtpsD6MwyKET3QBYx1A ACUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r/l3rZk8GOIQaj/zcskGUMbwB8AQ01WgfPICmp322OI=; b=ZjFB9nuuJz+SkyHln0y1/6Jf7IUlCo0YBE/rTGtjaAp3UDElVO2UH7lNxR0xWwPd5n KTGcVjbmxMUJkVDvQPRG9x6zgTgMH/jwD5OwUXlv6clWGaEwPfFvzTb2hlKxvPfJbq3h JjmNJRWl3TDTRQ6QuDUaGjj7jdf/vFQX20oTp1aIELBrVzQweQjfL51OlQP3+bG3zvwv ObVt6s04HmUNGvrznMmNKFsPeyDmckop7KSmvna+HsmZ4JhrmZhitU9blZfz88Q9AfGX swI/mNAVocaUZrxvA6bt5tPQu12FLbL8KFaPeAbROm+0l/7u0p1k49MgHefwhZA6PojS EZgg== X-Gm-Message-State: AOAM53017QyJx8GXTXJjTx/lEglqDl6y9x9RudyBnevgeSP+mQRWU7c5 /RCCs3KJrBbbGWeV8pv4SINcWA== X-Received: by 2002:a7b:cf3a:: with SMTP id m26mr5220564wmg.66.1611339543951; Fri, 22 Jan 2021 10:19:03 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id 192sm13636662wme.27.2021.01.22.10.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 10:18:59 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 351AC1FF92; Fri, 22 Jan 2021 18:18:55 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 6/8] tests/docker: add a docker-exec-copy-test Date: Fri, 22 Jan 2021 18:18:52 +0000 Message-Id: <20210122181854.23105-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210122181854.23105-1-alex.bennee@linaro.org> References: <20210122181854.23105-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This provides test machinery for checking the QEMU copying logic works properly. It takes considerably less time to run than starting a debootstrap only for it to fail later. I considered adding a remove command to docker.py but figured that might be gold plating given the relative size of the containers compared to the ones with actual stuff in them. Signed-off-by: Alex Bennée --- tests/docker/Makefile.include | 20 +++++++++++++++++++- tests/docker/docker.py | 7 ++++++- tests/docker/dockerfiles/empty.docker | 8 ++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/docker/dockerfiles/empty.docker -- 2.20.1 diff --git a/tests/docker/Makefile.include b/tests/docker/Makefile.include index a5c1e4a615..93b29ad823 100644 --- a/tests/docker/Makefile.include +++ b/tests/docker/Makefile.include @@ -11,7 +11,7 @@ HOST_ARCH = $(if $(ARCH),$(ARCH),$(shell uname -m)) DOCKER_SUFFIX := .docker DOCKER_FILES_DIR := $(SRC_PATH)/tests/docker/dockerfiles # we don't run tests on intermediate images (used as base by another image) -DOCKER_PARTIAL_IMAGES := debian10 debian11 debian-bootstrap +DOCKER_PARTIAL_IMAGES := debian10 debian11 debian-bootstrap empty DOCKER_IMAGES := $(sort $(notdir $(basename $(wildcard $(DOCKER_FILES_DIR)/*.docker)))) DOCKER_TARGETS := $(patsubst %,docker-image-%,$(DOCKER_IMAGES)) # Use a global constant ccache directory to speed up repetitive builds @@ -92,6 +92,24 @@ docker-binfmt-image-debian-%: $(DOCKER_FILES_DIR)/debian-bootstrap.docker { echo "You will need to build $(EXECUTABLE)"; exit 1;},\ "CHECK", "debian-$* exists")) +# These are test targets +USER_TCG_TARGETS=$(patsubst %-linux-user,qemu-%,$(filter %-linux-user,$(TARGET_DIRS))) +EXEC_COPY_TESTS=$(patsubst %,docker-exec-copy-test-%, $(USER_TCG_TARGETS)) + +$(EXEC_COPY_TESTS): docker-exec-copy-test-%: $(DOCKER_FILES_DIR)/empty.docker + $(call quiet-command, \ + $(DOCKER_SCRIPT) build -t qemu/exec-copy-test-$* -f $< \ + $(if $V,,--quiet) --no-cache \ + --include-executable=$* \ + --skip-binfmt, \ + "TEST","copy $* to container") + $(call quiet-command, \ + $(DOCKER_SCRIPT) run qemu/exec-copy-test-$* \ + /$* -version > tests/docker-exec-copy-test-$*.out, \ + "TEST","check $* works in container") + +docker-exec-copy-test: $(EXEC_COPY_TESTS) + endif # Enforce dependencies for composite images diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 39da3fefcf..d28df4c140 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -438,6 +438,9 @@ class BuildCommand(SubCommand): help="""Specify a binary that will be copied to the container together with all its dependent libraries""") + parser.add_argument("--skip-binfmt", + action="store_true", + help="""Skip binfmt entry check (used for testing)""") parser.add_argument("--extra-files", nargs='*', help="""Specify files that will be copied in the Docker image, fulfilling the ADD directive from the @@ -466,7 +469,9 @@ class BuildCommand(SubCommand): docker_dir = tempfile.mkdtemp(prefix="docker_build") # Validate binfmt_misc will work - if args.include_executable: + if args.skip_binfmt: + qpath = args.include_executable + elif args.include_executable: qpath, enabled = _check_binfmt_misc(args.include_executable) if not enabled: return 1 diff --git a/tests/docker/dockerfiles/empty.docker b/tests/docker/dockerfiles/empty.docker new file mode 100644 index 0000000000..9ba980f1a8 --- /dev/null +++ b/tests/docker/dockerfiles/empty.docker @@ -0,0 +1,8 @@ +# +# Empty Dockerfile +# + +FROM scratch + +# Add everything from the context into the container +ADD . /