Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0CE94C001DF for ; Sun, 16 Jul 2023 00:38:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7EA6F865B6; Sun, 16 Jul 2023 02:37:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="C5Pi9TGk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 353C386301; Sun, 16 Jul 2023 02:37:35 +0200 (CEST) Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 774448623A for ; Sun, 16 Jul 2023 02:37:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-345fcf8951fso13351045ab.1 for ; Sat, 15 Jul 2023 17:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689467849; x=1692059849; 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=+/fz14k1vADZQn93QXbIox+48+zmHOwCXoWfxWSZRLA=; b=C5Pi9TGk/i5ccLkpY/6F6xpid66j37h8Yy0Cl59M0ctpMOPXhA4YpR2eYQ9q+nJfE7 WEuQCi1AGWoy1C/hKbyMGaTsrygRyWmhBAoC6jGT/6jniOr3jbvN7btVRTFUs3LXJycj nsWbpiOTkWeQKABkC/WbQdeo6AzH1THHs6yeY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689467849; x=1692059849; 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=+/fz14k1vADZQn93QXbIox+48+zmHOwCXoWfxWSZRLA=; b=mEjQaI+fxG3+7g/DkDbsNbGlrI9Q8B4Ief/td1s1qaKTTUANxiLpZhjoaiwWgZMHGs WmoaOwqxn66IS4FRiB3o1Wh5ATwzaUXXIPqXjQGTXsHxi5izVfTGR3KxVxVqW7spA20a R6KdvqlMjFTa5iUzb5PQ3OlNQcWBo/B10dMxMM7X5QEnIWpsRIt/DSmym9PB99N5CVzI W2ZaBL+O73MQv5371m+l8hfT1tIKnHJJEjO/ixwssNQm32Vk4cKtwyiOlGrEYxLpkRxv /CmTKZX6TeviTRBtEqEpAuuOCUQ8iZ06bgRaZqM5/nPUpmK8Yc21yvR0RaOaBVyEF73J BjKA== X-Gm-Message-State: ABy/qLbgOm1H1ONNBTbD/R7fqLvd2I6w5PGHRERHNie1BkSZoMenUBvU /ISIPb1bCGk+RSHfG38UymXwn+zIhZYgQVfN1Vk= X-Google-Smtp-Source: APBJJlGNNc8zq5BzCrnb7Ve0OTb3lni4CYsN5toKtLPbSihqUTeNi3kCWLqY4QeVWd7OOSnMYJrJSA== X-Received: by 2002:a92:da88:0:b0:346:6d97:ffd1 with SMTP id u8-20020a92da88000000b003466d97ffd1mr7916483iln.18.1689467849070; Sat, 15 Jul 2023 17:37:29 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id t3-20020a05663801e300b0042b52dc77e3sm3510512jaq.158.2023.07.15.17.37.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jul 2023 17:37:28 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v3 08/81] buildman: Add a test for Boards.output_is_new() Date: Sat, 15 Jul 2023 18:35:36 -0600 Message-ID: <20230716003718.231903-9-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.455.g037347b96a-goog In-Reply-To: <20230716003718.231903-1-sjg@chromium.org> References: <20230716003718.231903-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Add a test for this code, adjusting the timestamp on various files to check each use case. Signed-off-by: Simon Glass --- Changes in v3: - Add new patch with a test for Boards.output_is_new() tools/buildman/func_test.py | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index d423457ea24a..70e2af19fd46 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -3,9 +3,11 @@ # import os +from pathlib import Path import shutil import sys import tempfile +import time import unittest from buildman import board @@ -816,3 +818,62 @@ CONFIG_LOCALVERSION=y self.assertEquals('config2', board2['config']) self.assertEquals('board2', board2['target']) + def test_output_is_new(self): + """Test detecting new changes to Kconfig""" + base = self._base_dir + src = self._git_dir + config_dir = os.path.join(src, 'configs') + delay = 0.02 + + # Create a boards.cfg file + boards_cfg = os.path.join(base, 'boards.cfg') + content = b'''# +# List of boards +# Automatically generated by buildman/boards.py: don't edit +# +# Status, Arch, CPU, SoC, Vendor, Board, Target, Config, Maintainers + +Active aarch64 armv8 - armltd corstone1000 board0 +Active aarch64 armv8 - armltd total_compute board2 +''' + # Check missing file + self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src)) + + # Check that the board.cfg file is newer + time.sleep(delay) + tools.write_file(boards_cfg, content) + self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src)) + + # Touch the Kconfig files after a show delay to avoid a race + time.sleep(delay) + Path(os.path.join(src, 'Kconfig')).touch() + self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src)) + Path(boards_cfg).touch() + self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src)) + + # Touch a different Kconfig file + time.sleep(delay) + Path(os.path.join(src, 'Kconfig.something')).touch() + self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src)) + Path(boards_cfg).touch() + self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src)) + + # Touch a MAINTAINERS file + time.sleep(delay) + Path(os.path.join(src, 'MAINTAINERS')).touch() + self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src)) + + Path(boards_cfg).touch() + self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src)) + + # Touch a defconfig file + time.sleep(delay) + Path(os.path.join(config_dir, 'board0_defconfig')).touch() + self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src)) + Path(boards_cfg).touch() + self.assertTrue(boards.output_is_new(boards_cfg, config_dir, src)) + + # Remove a board and check that the board.cfg file is now older + Path(os.path.join(config_dir, 'board0_defconfig')).unlink() + self.assertFalse(boards.output_is_new(boards_cfg, config_dir, src)) + -- 2.41.0.455.g037347b96a-goog