From patchwork Thu Oct 29 22:09:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Latypov X-Patchwork-Id: 315008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72E37C2D0A3 for ; Thu, 29 Oct 2020 22:10:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1206E20838 for ; Thu, 29 Oct 2020 22:10:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dyMOA9oq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725747AbgJ2WKV (ORCPT ); Thu, 29 Oct 2020 18:10:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725562AbgJ2WKV (ORCPT ); Thu, 29 Oct 2020 18:10:21 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31AA6C0613D2 for ; Thu, 29 Oct 2020 15:10:20 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id i11so2016667pgi.2 for ; Thu, 29 Oct 2020 15:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc :content-transfer-encoding; bh=8FO8hKhWo8C4LkpWBb3TOyUhwVl2tgrqtKgNpxdQBao=; b=dyMOA9oqMOS6va+C/MbpRoprIAGsBsKj1w9S6Sa1dTZMXbYw0nv5t8CI+BZaLnrCbl pumiqx7Th1d8ahZvnpzU3Ma2a2JVTcmXpmpP2XA74m3XnHXf3bX/bcF8tn1MohB/KbBd UdoVF9ynHw3k8hds5HbRpLU78GHgvzaxotAUW2krmNhuXHtO++tHwvhoibMFd3bFd4Ks opCJkclDRD42843Kld6nJMH50Xqhheh6gf6KNkj/zPCrVyxX0q/9/Hhxsx+zsEqcjvik H3uiLcftU/ltNESOsMInt4gMcieOIFchEXaOrJsDx8xS0LJpFfruQmcUBzje25Y+fE+5 4uxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc:content-transfer-encoding; bh=8FO8hKhWo8C4LkpWBb3TOyUhwVl2tgrqtKgNpxdQBao=; b=lM/sxMJFX5WelbfcfhoZEOfw2w6u44yiZYw7SWAbYB5SXG8WijvYuci11ZW+hVTMiV cKU/oH+d/hrY+pOzvsN5tNzLBVy+THkEdqbxdXeY9Uw4oqA38Ddgt+pbbN6Cvljg2yqh /WmnPCZGEq0fLmc+hST4WOTLC2Evzvmleh3ncafcgoS9ZJYfXweMX1zCnhAJw7RtgUEI SoiBZu9cgfA5eNiz55TPeMrVRFy6+xbUa0B0Hs0JX/I7UG30d6LUpMxQEYekv1oHFQSe bl4K6Fv5MCrFV2vEzmboAdoecrYbHzv0VWzAZRwwIuvwhC6pkctM1dwfUlPmIwoREd2L oXTw== X-Gm-Message-State: AOAM530rPXy2L2Jx62iX2o3jFGfJSpNbAJDAs9u67IpT6dK9Q68RMTlp Yc07ZeSfowesYyIfJSxL5h6dOLI2+yH9sA== X-Google-Smtp-Source: ABdhPJxg7AkIoi6WznVzqpiz7XfH4HE0lhenNJ8tvH0f4uyzgciqlKQIsmU062LGVpfDclTmOoKlRwpzDOMD3Q== Sender: "dlatypov via sendgmr" X-Received: from dlatypov.svl.corp.google.com ([2620:15c:2cd:202:a28c:fdff:fee3:28c6]) (user=dlatypov job=sendgmr) by 2002:a17:90b:f85:: with SMTP id ft5mr100494pjb.1.1604009419252; Thu, 29 Oct 2020 15:10:19 -0700 (PDT) Date: Thu, 29 Oct 2020 15:09:29 -0700 Message-Id: <20201029220929.4068251-1-dlatypov@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH] kunit: tool: print out stderr from make (like build warnings) From: Daniel Latypov To: brendanhiggins@google.com Cc: davidgow@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, skhan@linuxfoundation.org, Daniel Latypov Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Currently the tool redirects make stdout + stderr, and only shows them if the make command fails. This means build warnings aren't shown to the user. This change prints the contents of stderr even if make succeeds, under the assumption these are only build warnings or other messages the user likely wants to see. We drop stdout from the raised exception since we can no longer easily collate stdout and stderr and just showing the stderr seems fine. Example with a warning: [14:56:35] Building KUnit Kernel ... ../lib/kunit/kunit-test.c: In function ‘kunit_test_successful_try’: ../lib/kunit/kunit-test.c:19:6: warning: unused variable ‘unused’ [-Wunused-variable] 19 | int unused; | ^~~~~~ [14:56:40] Starting KUnit Kernel ... Note the stderr has a trailing \n, and since we use print, we add another, but it helps separate make and kunit.py output. Example with a build error: [15:02:45] Building KUnit Kernel ... ERROR:root:../lib/kunit/kunit-test.c: In function ‘kunit_test_successful_try’: ../lib/kunit/kunit-test.c:19:2: error: unknown type name ‘invalid_type’ 19 | invalid_type *test = data; | ^~~~~~~~~~~~ ... Signed-off-by: Daniel Latypov Reviewed-by: David Gow --- tools/testing/kunit/kunit_kernel.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) base-commit: 07e0887302450a62f51dba72df6afb5fabb23d1c diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py index b557b1e93f98..326e82746d41 100644 --- a/tools/testing/kunit/kunit_kernel.py +++ b/tools/testing/kunit/kunit_kernel.py @@ -82,11 +82,16 @@ class LinuxSourceTreeOperations(object): if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command, stderr=subprocess.STDOUT) + proc = subprocess.Popen(command, + stderr=subprocess.PIPE, + stdout=subprocess.DEVNULL) except OSError as e: - raise BuildError('Could not call execute make: ' + str(e)) - except subprocess.CalledProcessError as e: - raise BuildError(e.output.decode()) + raise BuildError('Could not call make command: ' + str(e)) + _, stderr = proc.communicate() + if proc.returncode != 0: + raise BuildError(stderr.decode()) + if stderr: # likely only due to build warnings + print(stderr.decode()) def linux_bin(self, params, timeout, build_dir, outfile): """Runs the Linux UML binary. Must be named 'linux'."""