From patchwork Mon Feb 8 12:38:12 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: 378585 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp4919269jah; Mon, 8 Feb 2021 10:28:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnPAtd27b36Tv2Sl558+621K5mXY9Cq0mFUM6l50sDgTtSqBr21K6GecTzcQG7itdN4Tvt X-Received: by 2002:a05:6902:1025:: with SMTP id x5mr26979903ybt.493.1612808889427; Mon, 08 Feb 2021 10:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612808889; cv=none; d=google.com; s=arc-20160816; b=MV7KhELDxlJX3IX9NTelbj2hG/EwBMJlba1HEz1VIYTve+wzqNgt5gD+PKKXLHxftp RaMr/cFqLbmWoBEGSd/bZZ4+DMYj+VWUXXImCkN0n5mZDhqnz7sgYAp7x9S8ntvwrcm7 COlM0aik89PTO40TSilbZIAoqjDgLTD5Moh+s/aFVA6ifC5cfTE7SRxG81HnDdGHRrXx RZdui2VKruphwrJ2VT3Txztffh+aIxhEmPru8j6w8qlPe1fxQr30mdj7xSsrb57xbfKi IL242q51fuaFBySDx/Y8GmZYDlGLhEFU1W4SNffWqJ4sH2MldLZmCCOLsxKKctfK5GV2 jjIg== 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=d8SAynJQad14L3Py3XDAFmtolIKvB3ca7JcHt4TgWgo=; b=MRlDfaXo5WV3Lhmm0APwkGxnGBZu5eLxeoPqjJUz/5JgTqsU2PfExOlp3a/Iikz6QO 0BK0bRUXQabMydd1zPDRjGiyNatEUv+hmCcvE56aT25oSaus7peMaJlqtF4iBunfR1el kpAN8rJsumyczbusnqFcdIdLasLp+bLiHk0BPaldWQ3pCr60g0nYx6Sz6aExzL9Wrv0A thw0lAHp1CLxyHfXhNrVmnSDTO+1XAJU2DGTml4B5oKStgE2wQ9NGsGk2ikRZ4uM4Tc4 YydUxabcB347gs5oytqXMZ5amECW1bVzvc+X1U5FQyu8PZDHnD5r2kyKHpC012dQdYG2 +DUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FtiiTcn+; 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 e3si18555774ybi.121.2021.02.08.10.28.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Feb 2021 10:28:09 -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=FtiiTcn+; 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]:52746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9BGa-0006o9-Sw for patch@linaro.org; Mon, 08 Feb 2021 13:28:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l95pA-0003fq-RP for qemu-devel@nongnu.org; Mon, 08 Feb 2021 07:39:32 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:42572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l95oh-0007jq-Ho for qemu-devel@nongnu.org; Mon, 08 Feb 2021 07:39:16 -0500 Received: by mail-wr1-x436.google.com with SMTP id r21so669451wrr.9 for ; Mon, 08 Feb 2021 04:38:41 -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=d8SAynJQad14L3Py3XDAFmtolIKvB3ca7JcHt4TgWgo=; b=FtiiTcn+tp0rl6Lf/BbR88impAXsCEEV48lXn6oB8GcCKTcPsRgHa8kNLxW84NSuiV 9+jp/A7ByhcceNuC7caxclfTZVhoDuueH3RBiPwpxgf67YiNSc4PoCdoHkafngOfCSHy 5z36ZBxM5TLVpqRRqDnLCwuk2RUqJq+YAYTvDj89fEq8UhN3mtlFajSf0IdaCn4YrWMw 3/5tZYiz0dOGC1i3p92UxCoiggJ5B6TZQbwPvCGr08CZCqmnpWfAnxmLPNNBUWAmepnu urNv7/LP8yZnvEZc2geA6vH51B8WJHDsnOqXkl1Z4jiftpCLJjnnoEdH5+X8mGj9lLl4 Aafw== 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=d8SAynJQad14L3Py3XDAFmtolIKvB3ca7JcHt4TgWgo=; b=jLd/uYJEX8FowLgWuuOcnHtdnqzl5T1rfZZAsXKxcQumCq+txLmNqWD0olKFMCn/GP c1g3lDRHXSawbAmiE0V1TviwfGzLJJc0kBq3dQWX1OVBtJ3rRaW1rRdis2vAtIYjBGqy CnYdlZ4A8OYdB2P2jeRPA1qFvrpYdz2BQmiawxx0wKWwecvVpKOoKPbb5WsDIHstruL7 YY2/SUHOoXPQq0v2MxMfH92zHl0b4WZEhIjd8Dyf+FJMRDu/VfJWghMtiuJAw07xLhKY o63n9w0mjnRUcS3uHkOsEwPygcWVHmZFj1ZrLeXSMTATl5jQ8Ssa5WK8PqRxDFZQhMAq eUfQ== X-Gm-Message-State: AOAM53379gNCsNwnbyD0eDFXQpOY0CaqnMR/crCQdFWWA278mZYdG116 t9Dq3O6YzEgQNvt76IGlAg1bUA== X-Received: by 2002:adf:bc45:: with SMTP id a5mr11741218wrh.290.1612787920142; Mon, 08 Feb 2021 04:38:40 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id e16sm3769174wrt.36.2021.02.08.04.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 04:38:30 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6169F1FF93; Mon, 8 Feb 2021 12:38:22 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 07/16] tests/docker: add a docker-exec-copy-test Date: Mon, 8 Feb 2021 12:38:12 +0000 Message-Id: <20210208123821.19818-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210208123821.19818-1-alex.bennee@linaro.org> References: <20210208123821.19818-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.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=unavailable 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?= , qemu-devel@nongnu.org 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 Message-Id: <20210202134001.25738-7-alex.bennee@linaro.org> -- 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 . /