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 29E54C001B0 for ; Wed, 19 Jul 2023 23:51:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 53E5E867D5; Thu, 20 Jul 2023 01:50:28 +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="Tx2heCa2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DD43186774; Thu, 20 Jul 2023 01:50:12 +0200 (CEST) Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 8DAF0867A3 for ; Thu, 20 Jul 2023 01:50:06 +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-io1-xd2a.google.com with SMTP id ca18e2360f4ac-783698a37beso9166839f.0 for ; Wed, 19 Jul 2023 16:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689810605; x=1690415405; 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=s4zXua0guVHUyJhg9rNR/wz9bCASGiuzWsZqDeEH3gQ=; b=Tx2heCa2sDl16vbv1U1he8rQJranan+J35wWuLWsKw63DAne0x4M793OSX1VPJc0W1 bA3Li4kpHWCAJp0JKx/fgLzjnhtKuJEpVa54hJMdr10jHXhAVMZ53ytn22eIKh6nEyZU MxH7KBgaQfFFt6Q6jdsXiZydzv0496icaGlkY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689810605; x=1690415405; 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=s4zXua0guVHUyJhg9rNR/wz9bCASGiuzWsZqDeEH3gQ=; b=Ib9sIQmsAXCWHDIZcBb4zerWkL9xzb5o39R4ncRQgWLSSccozBsOUfuMb3pzPKvTvl iPv01yLxKeCOte9XxencUVbY4A12FPbpsQCEbOZ/yBImH5royREItsvcZSCyWcOISz7T gxFz44Uyex8FO268G7IPprTIhVYlnqsrWZ/4L/ku+tgU41gVR0gncJSbkYbA9rscC8wX EdiXWSTwkO4FV94xVq+/cw76RbD5KNRzyaB42ZNdSQIR5rpqcWv6vgjhVnYHIsXdh98P e2mKPDCzIsbvhUd+OT6JGeJB+mtUfoFrRe7APfq6TzC8nJJjzFjcFMiEJoQMtXzrK6E7 zJOA== X-Gm-Message-State: ABy/qLYVis5GRxJgAJgWDaev/kAgLzBtiohBycD171fTEG/A6Y/1s36W Tz4WMzevdt70klGIqw43oKvTBykltzPwpfhYVn8= X-Google-Smtp-Source: APBJJlHP+H1tO8EatQJGkKymL02LrAy7mbHkUt3tzNstF4mkeLo+AsYAjqFGKXjmkfe6t0gD2T6mSQ== X-Received: by 2002:a5e:aa0c:0:b0:783:71b1:50cf with SMTP id s12-20020a5eaa0c000000b0078371b150cfmr7864926ioe.11.1689810605058; Wed, 19 Jul 2023 16:50:05 -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 ed16-20020a056638291000b0042bb1779c18sm1551779jab.151.2023.07.19.16.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 16:50:04 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Mike Frysinger , Simon Glass Subject: [PATCH v4 08/83] buildman: Add a test for Boards.output_is_new() Date: Wed, 19 Jul 2023 17:48:16 -0600 Message-ID: <20230719234953.796101-9-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230719234953.796101-1-sjg@chromium.org> References: <20230719234953.796101-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 --- (no changes since v3) 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.487.g6d72f3e995-goog