From patchwork Mon Nov 25 15:20:39 2024 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: 845342 Delivered-To: patch@linaro.org Received: by 2002:a5d:688e:0:b0:382:43a8:7b94 with SMTP id h14csp1246149wru; Mon, 25 Nov 2024 07:24:10 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXdkE8jTMGd+PXlTXzf6IDUo5cvSI7WcX/FXe2wdFn3ZNA3+iOPK/HAnxmThi1P0XA1ax4fcA==@linaro.org X-Google-Smtp-Source: AGHT+IGXkHR0HyERfnye2KMzoIDum8DQP00LT0DLeRIRTiO+P8JCEWcj6gZhHAA4w//ftX/GdW0v X-Received: by 2002:a05:622a:1807:b0:461:6aa9:9479 with SMTP id d75a77b69052e-4653d631425mr151719401cf.53.1732548250559; Mon, 25 Nov 2024 07:24:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1732548250; cv=none; d=google.com; s=arc-20240605; b=lBU/yMCmPnpHNK3fyc2ZjWEAUSVY4Uv8mNSc/nS6622H1dreU9eLPDFpU42ijkOmiq 995FG3biSKS+FxB1w6fw5cRXK2TA1DcZJreCZhGts0eEryGW2Hi9t8/ud2yZbZBPwksj 6euCHrR7Zk1t+CaSe+ilMfF6AU7Rhr7lrn2hYf24IOB9fpueignhMOlnVHgF5182pZfg 32vZkUdmDXpBfh0WynHVamfLf3P1de6UpwudplRQeYEisHqyEwsejEdmzsDwKmBMQznT oaeO59VpFcttkHymlTFP4vU735wqxSwRWLb+hBguGX9fW2hDvmzeql5c92qBKm08c+Jf jJaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=W2LvUWK0oXyNULzh/PoP5B4uyQP6aDypt8ae/Sui1l0=; fh=cAbVDZirSxfuN2INuWJvLacXr7MJcrQ7UQl1Np2Im2Q=; b=KOKGGyHyeDvVgAZ0xYCYKCJJ2GcxIvxa+J/92l+JXTOoCG3V1gO7aJ4V4C8+Td+dZs 7QgNM/ktgY9561mh9GKaJ+EV2lrjn04sCG1iYXBe25/fAlOnD/FtGJHFE1f1G0TsVq2O qguHLHObGnfC4yiPkmmGIu8CR7bmeTif1nzapZu4I1ZgVDkkzckPh8tfUvdKz1ACTaxu I/fTyT2nR/THypURq0xEhpgD+b6Xv5w3DbjbHw8WlQvXOv0Y8AfFqqUZI9zjgDQHxe/R RNakieZ2B8v0u1nxOLl+DTEAoEmHy5tqeOXswo/Hca+MKE5ywVRBB6fkERRnD+fmP1TY kfAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AGqP9kDr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46686aaf107si42616011cf.360.2024.11.25.07.24.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Nov 2024 07:24:10 -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=pass header.i=@linaro.org header.s=google header.b=AGqP9kDr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFatn-0003ws-Gt; Mon, 25 Nov 2024 10:21:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tFatk-0003uy-S7 for qemu-devel@nongnu.org; Mon, 25 Nov 2024 10:21:12 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tFath-0001js-Hl for qemu-devel@nongnu.org; Mon, 25 Nov 2024 10:21:12 -0500 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-382433611d0so3891427f8f.3 for ; Mon, 25 Nov 2024 07:21:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1732548068; x=1733152868; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W2LvUWK0oXyNULzh/PoP5B4uyQP6aDypt8ae/Sui1l0=; b=AGqP9kDrBkKHlDLOERGUgRimaUr3FCS7HAQImFWXHgtafd9ICndOdwPkiJF9Rk9sUg hLoi/fRncU1PG0fDhaZqabq3L5Kxgqa0zgRzdPBm7qkydciuk1HSGg8znX/iDMoGa8qH XtuhOY7I5LHxyZZOPYiGPzOMQYIeEujfOwKGtqzTdY1PGQnrIIHUURY820PQxYUBJ48A tqVnQL+WEiVuw28zBQzfCvw/4q6Dgn/vVme97BlMwZCEnVrqrjGP3tmCa11Gs0C552Mw YjrH8JkIGw1l9T9ihJRkM7ivdszVB2hOXa2ZSQdjXjxuO/baoirDe99dD+hiahQtmSHt 4bhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732548068; x=1733152868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W2LvUWK0oXyNULzh/PoP5B4uyQP6aDypt8ae/Sui1l0=; b=qM+3TtdHJuN1UwxXLWAr/MKnQv0XEJJMkQlyEwsis6gDsXzzgdSJjTx4HxTcHIuxYq rPzFWf7BqXqCjpTl2558uE0Ovv9uSlhXfN112KLQgesTGSMu7XAp78s2HQ3/k4CP6FYR fdlH+UINkYV9tHVS07TkdA1HrovfVa9/8ZWdHhUqL1B6m8uqZVMsDUv7mTgy2JaQqaoG oglneFLbuLwQlgUOsbsmfJP3NWGAhLlVjPhvM440i5xQBq+4N8cGcvxkl3whJKlZpnGw w0zz0fxGQuMcoYmUD/o0+jdbB4grXcwn6UTB+RsYdpgH2RIQECclqPpVGv5gK4hxnQ8h FbuQ== X-Gm-Message-State: AOJu0YwbfaQ9StmgoI7EKhYamYs74aOzWJqTPdUQddWJ4vjtOCRQ41YZ WWwnfSC0xaZIxEUBEF2rM/uUB8rzGATwfFuartFzejmTI3oZ36YTbhLwfcoSYOg= X-Gm-Gg: ASbGncshmGmA22fc3PRdiYhqNv32Wc4wLlXL8EYB2YX6XZ+om2qzZpratLBbaXKFrig K2pqUpDJ2pfF6mVI0CSmRDRSJaEfFyv/aJ+GIKwpKDa+AO3FsQnxpmSL+tON02UUIde1r9XbfXW ZeMRBxa7r7Tv6xJn5b4VR+H4rs6C5iZVELqtY7DA28LcreilFV3xD2zTwQSnGsWP7teFe5WiSSE CTudsB3mt9/AYBieIV7hQ48flJV84ThMc2i4F8u/4bL/Ge5 X-Received: by 2002:a05:6000:184d:b0:382:465f:336d with SMTP id ffacd0b85a97d-38260b3cabbmr15409059f8f.1.1732548067824; Mon, 25 Nov 2024 07:21:07 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3825fafe147sm10577475f8f.30.2024.11.25.07.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Nov 2024 07:21:06 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 0303B5F8FE; Mon, 25 Nov 2024 15:21:06 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?A?= =?utf-8?q?lex_Benn=C3=A9e?= , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 02/28] tests/functional: automatically clean up scratch files after tests Date: Mon, 25 Nov 2024 15:20:39 +0000 Message-Id: <20241125152105.2100395-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241125152105.2100395-1-alex.bennee@linaro.org> References: <20241125152105.2100395-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42c.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Daniel P. Berrangé The build/tests/functional subdirectories are consuming huge amounts of disk space. Split the location for scratch files into a 'scratch' sub-directory, separate from log files, and delete it upon completion of each test. The new env variable QEMU_TEST_KEEP_SCRATCH can be set to preserve this scratch dir for debugging access if required. Reviewed-by: Alex Bennée Signed-off-by: Daniel P. Berrangé Message-Id: <20241121154218.1423005-3-berrange@redhat.com> Signed-off-by: Alex Bennée Message-Id: <20241121165806.476008-3-alex.bennee@linaro.org> diff --git a/docs/devel/testing/functional.rst b/docs/devel/testing/functional.rst index bf6f1bb81e..6b5d0c5b98 100644 --- a/docs/devel/testing/functional.rst +++ b/docs/devel/testing/functional.rst @@ -65,6 +65,12 @@ to the QEMU binary that should be used for the test, for example:: $ export QEMU_TEST_QEMU_BINARY=$PWD/qemu-system-x86_64 $ python3 ../tests/functional/test_file.py +The test framework will automatically purge any scratch files created during +the tests. If needing to debug a failed test, it is possible to keep these +files around on disk by setting ```QEMU_TEST_KEEP_SCRATCH=1``` as an env +variable. Any preserved files will be deleted the next time the test is run +without this variable set. + Overview -------- diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py index 411978b5ef..b9418e2ac0 100644 --- a/tests/functional/qemu_test/testcase.py +++ b/tests/functional/qemu_test/testcase.py @@ -13,8 +13,9 @@ import logging import os -import subprocess import pycotap +import shutil +import subprocess import sys import unittest import uuid @@ -40,11 +41,12 @@ def setUp(self, bin_prefix): self.assertIsNotNone(self.qemu_bin, 'QEMU_TEST_QEMU_BINARY must be set') self.arch = self.qemu_bin.split('-')[-1] - self.workdir = os.path.join(BUILD_DIR, 'tests/functional', self.arch, - self.id()) + self.outputdir = os.path.join(BUILD_DIR, 'tests', 'functional', + self.arch, self.id()) + self.workdir = os.path.join(self.outputdir, 'scratch') os.makedirs(self.workdir, exist_ok=True) - self.logdir = self.workdir + self.logdir = self.outputdir self.log_filename = os.path.join(self.logdir, 'base.log') self.log = logging.getLogger('qemu-test') self.log.setLevel(logging.DEBUG) @@ -56,6 +58,8 @@ def setUp(self, bin_prefix): self.log.addHandler(self._log_fh) def tearDown(self): + if "QEMU_TEST_KEEP_SCRATCH" not in os.environ: + shutil.rmtree(self.workdir) self.log.removeHandler(self._log_fh) def main(): @@ -108,7 +112,7 @@ def setUp(self): console_log = logging.getLogger('console') console_log.setLevel(logging.DEBUG) - self.console_log_name = os.path.join(self.workdir, 'console.log') + self.console_log_name = os.path.join(self.logdir, 'console.log') self._console_log_fh = logging.FileHandler(self.console_log_name, mode='w') self._console_log_fh.setLevel(logging.DEBUG)