Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3758013ybb; Mon, 6 Apr 2020 15:17:12 -0700 (PDT) X-Google-Smtp-Source: APiQypLhHIuzK+qCm82K4jxfUwOw7qW4Llj72fPtUj5x8GxhYCXPy23uCg2feUgGE5CPHMWrCFR9 X-Received: by 2002:a05:6830:1c77:: with SMTP id s23mr19989946otg.191.1586211432506; Mon, 06 Apr 2020 15:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586211432; cv=none; d=google.com; s=arc-20160816; b=XxkqRXMQJ+mrTLAhSQlGje6j0QZeWMppkLY7hOZRwtOrQ50hFp5WWYdfMlby6cmTB4 D7RhaLRLUif3IyqEksgTOFGM+FcEoU2nbQgkoOySP+imORKjPfrd/rn9IHdZiMWMmH35 2MTACwBfvdcvsi21cPr/NVws8OlcR0wEBgCKlDkNB3xAbGIVBVBKlNAU5nrCRWHoRvHk 6XrwyZ94oMy1TvmzSwnl/h8iqpwJtjTCF82+oxILwZIKpYac5/ND4Or0/1rzbZ4/7hk6 w1mUtPJv+r7WyqNZBF8YW7S11mbd/ThonZVMC6RGXT9JP4bgHTm4Zw0wy+4bRBwPkGp9 fM/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=j72I6B2yv1MtQdVXUp6mfzONbbVa//fDwmUTKLmhZlM=; b=C6lxi0O5qeLzEtv+dRT8yitnMqhwCvgQdSw77ZGTJOISmTLAygRsA819iBD9WDvplv bfNHL0/lvQjWfttEmCzko6oZW7dmCzNU8c3U4ipOx3q+IA0KpWHtSrwzpTqaQ5QacMv4 X+afdjewzvj9NTRjNzjWHxQ64VlCOdLQu264UkPQ9RUFKE9em4IzYLzzQGBSTaOw5vlM 9KFQ4iqbai98Cpoubxz2mrwgktq+vq92ti/LNMXq/MqgyXb7TXdCNexNPePWkSAgfgxF 4SdPJ4CeKGTvU/36tN9MVGUjxoyJsI7ibEfPuQ2wXR8ouYAEr2a394YNeQc8Y+GTSByv yb9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@massaru-org.20150623.gappssmtp.com header.s=20150623 header.b=UmseYPFd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si385949ood.66.2020.04.06.15.16.59; Mon, 06 Apr 2020 15:17:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@massaru-org.20150623.gappssmtp.com header.s=20150623 header.b=UmseYPFd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726684AbgDFWPM (ORCPT + 99 others); Mon, 6 Apr 2020 18:15:12 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:33732 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbgDFWPK (ORCPT ); Mon, 6 Apr 2020 18:15:10 -0400 Received: by mail-qt1-f194.google.com with SMTP id c14so1232651qtp.0 for ; Mon, 06 Apr 2020 15:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=massaru-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=j72I6B2yv1MtQdVXUp6mfzONbbVa//fDwmUTKLmhZlM=; b=UmseYPFdd9OfC6LhQ+NAWOTbLOsEpFb06VKPLLcq3VeJFuFwva7Bg5Bglq5Z8WlJBY qazf1OFqJZw0RMObUPU24HzIGgofGjlz7oNnwpQVtW2HYVx2ARu2/gXxzAPRfev3g2Yc 0rXQdub7D4sLzZR6PE4GVGQ2vWuokGmZxWF5OWTuynE62r/VRhMq7Ff9Co8wIMde3tid S04vh6x8Xz1q89PJiffvk0mkeb68WqucLMDSzdwWAnj0aLoS/8P+tFDx5Bda5dBRbrBe PHDBXGtw4FvPhYXQFGBfm6kI9quTC/6Hg2alzxea5pWiUzDYf6RXpslx0EyT37QQetYg z9wg== 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:mime-version :content-transfer-encoding; bh=j72I6B2yv1MtQdVXUp6mfzONbbVa//fDwmUTKLmhZlM=; b=MweLrGNhquEFmiYai+UgbdtaUemQtzXneOdg4tDCwo/4KxnBISh0+cY7qjTNURdhOy wPZ3vrt2/fXYkEtLGkNYV78fTIo8zvRxwi9Us8peKGA5f0wLA7wWmSH3e5McW841R2zC mE0+ZCPTFzmoXDg+Cu1pCUHUUpq7Zz01ET7jzVPeCK134FQpj3YflG9ySZu3+Tncl1wE BKFQnqLPW0/3t9EaPMpJKR49c9fGpKsDVAXl5VoM5XqYmsLbchvPCNbithJytITwwN+0 KdHOF92swbi4wWClqPtZ5yMBQBLmNXVTbDpEz4oMTmr7OlqED8MOZzVctWiduJIORD35 Sk4A== X-Gm-Message-State: AGi0PuaboMm837vf8xvpKVqh3cRogv/LzmxHqJAqO5tQ0XrckJP8fKJJ QnAdb2TOWbBCnlEXRdRlpYlQfQ== X-Received: by 2002:aed:32c7:: with SMTP id z65mr1711174qtd.81.1586211307951; Mon, 06 Apr 2020 15:15:07 -0700 (PDT) Received: from bbking.lan ([2804:14c:4a5:36c::cd2]) by smtp.gmail.com with ESMTPSA id e10sm1834923qkl.48.2020.04.06.15.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 15:15:07 -0700 (PDT) From: Vitor Massaru Iha To: kunit-dev@googlegroups.com Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, brendanhiggins@google.com, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [PATCH v3] kunit: Fix kunit.py run --build_dir='' fails on "unclean" trees Date: Mon, 6 Apr 2020 19:15:03 -0300 Message-Id: <20200406221503.49760-1-vitor@massaru.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix this bug: https://bugzilla.kernel.org/show_bug.cgi?id=205219 For some reason, the environment variable ARCH is used instead of ARCH passed as an argument, this patch uses a copy of the env, but using ARCH=um and CROSS_COMPILER='' to avoid this problem. This patch doesn't change the user's environment variables, avoiding side effects. Signed-off-by: Vitor Massaru Iha --- v2: - Use the correct next branch v3: - Use torvalds/master branch - Use base parameter on git send-email --- tools/testing/kunit/kunit_kernel.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index 63dbda2d029f..96216c699fde 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -20,6 +20,7 @@ import kunit_parser KCONFIG_PATH = '.config' kunitconfig_path = '.kunitconfig' BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config' +env = dict(os.environ.copy(), ARCH='um', CROSS_COMPILE='') class ConfigError(Exception): """Represents an error trying to configure the Linux kernel.""" @@ -41,13 +42,15 @@ class LinuxSourceTreeOperations(object): raise ConfigError(e.output) def make_olddefconfig(self, build_dir, make_options): - command = ['make', 'ARCH=um', 'olddefconfig'] + command = ['make', 'olddefconfig'] if make_options: command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command, stderr=subprocess.PIPE) + subprocess.check_output(command, + stderr=subprocess.PIPE, + env=env) except OSError as e: raise ConfigError('Could not call make command: ' + e) except subprocess.CalledProcessError as e: @@ -57,9 +60,10 @@ class LinuxSourceTreeOperations(object): kunit_parser.print_with_timestamp( 'Enabling all CONFIGs for UML...') process = subprocess.Popen( - ['make', 'ARCH=um', 'allyesconfig'], + ['make', 'allyesconfig'], stdout=subprocess.DEVNULL, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + env=env) process.wait() kunit_parser.print_with_timestamp( 'Disabling broken configs to run KUnit tests...') @@ -71,13 +75,13 @@ class LinuxSourceTreeOperations(object): 'Starting Kernel with all configs takes a few minutes...') def make(self, jobs, build_dir, make_options): - command = ['make', 'ARCH=um', '--jobs=' + str(jobs)] + command = ['make', '--jobs=' + str(jobs)] if make_options: command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command) + subprocess.check_output(command, env=env) except OSError as e: raise BuildError('Could not call execute make: ' + e) except subprocess.CalledProcessError as e: @@ -91,7 +95,8 @@ class LinuxSourceTreeOperations(object): with open(outfile, 'w') as output: process = subprocess.Popen([linux_bin] + params, stdout=output, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + env=env) process.wait(timeout) -- 2.25.1