From patchwork Mon Sep 25 17:57:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 726249 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65938CE7AB1 for ; Mon, 25 Sep 2023 17:58:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232326AbjIYR6I (ORCPT ); Mon, 25 Sep 2023 13:58:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231360AbjIYR6G (ORCPT ); Mon, 25 Sep 2023 13:58:06 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A3FD1A5 for ; Mon, 25 Sep 2023 10:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695664678; x=1727200678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8kO+KrNTR8kWxuX/LyKXcB+Gb7mODQeojOqMSeENlHM=; b=MEKKYlgIloyLK/Hwmho6D2XOiIMTPXRt2KKhx3Gez4KbHwjLuE0Pth2q 9Xm24if/rt+PAx6+ZSq6SXFN96Wuyhi96OwAGfXoJB76BV7gYI5bf3l+x tHZELoA9iRwb/NbbtoF2be8lI7B4ZT+YO3lTwgDvlkLxs/uLZwB10eU8A NNlQox2XGIBr2iM/6Pw6gYPsYnzT2b26uyouBiTVf10lk9ojawMpnY87h 6+IsWtrK0hZhkd1uZpcWzvznxuZTDVYUzeNfquWE2h5HSJJwA+eJsWbZS Auf4FAGGA+Pkz0wXBG8RrSllxe+xwcXrWzQbr5hA4qENQZJ+ilV+ueNk4 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="371643649" X-IronPort-AV: E=Sophos;i="6.03,175,1694761200"; d="scan'208";a="371643649" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2023 10:57:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="995489266" X-IronPort-AV: E=Sophos;i="6.03,175,1694761200"; d="scan'208";a="995489266" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.249.131.28]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2023 10:57:54 -0700 From: Michal Wajdeczko To: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Cc: Michal Wajdeczko , David Gow , Rae Moar Subject: [PATCH 1/4] kunit: Drop redundant text from suite init failure message Date: Mon, 25 Sep 2023 19:57:30 +0200 Message-Id: <20230925175733.1379-2-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20230925175733.1379-1-michal.wajdeczko@intel.com> References: <20230925175733.1379-1-michal.wajdeczko@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org If a suite initialization fails, then our diagnostic message will include redundant indent and hash sign as all this was already added by the kunit_printk() used by kunit_err() macro. This could be easily seen if we force some error in our example test by modyfing example_test_init_suite() and running: $ ./tools/testing/kunit/kunit.py run --raw_output \ --kunitconfig ./lib/kunit/.kunitconfig "example.*" KTAP version 1 1..1 # example: initializing suite # example: # failed to initialize (-19) not ok 1 example Fix that and while around improve error code reporting by using error pointer format %pe that gives more user friendly output: KTAP version 1 1..1 # example: initializing suite # example: failed to initialize (-ENODEV) not ok 1 example Signed-off-by: Michal Wajdeczko Cc: David Gow Cc: Rae Moar Reviewed-by: Rae Moar --- lib/kunit/test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kunit/test.c b/lib/kunit/test.c index f2eb71f1a66c..fb5981ce578d 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -568,8 +568,8 @@ int kunit_run_tests(struct kunit_suite *suite) if (suite->suite_init) { suite->suite_init_err = suite->suite_init(suite); if (suite->suite_init_err) { - kunit_err(suite, KUNIT_SUBTEST_INDENT - "# failed to initialize (%d)", suite->suite_init_err); + kunit_err(suite, "failed to initialize (%pe)", + ERR_PTR(suite->suite_init_err)); goto suite_end; } }