Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp653768rdh; Sun, 24 Sep 2023 06:17:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHAEojVoMB8LtpsSmfsw8oMVeaiL5/YZwKPbNCdEtqwJP8B3OQ9Lo8i8p6dIgHHwR2/Z+4K X-Received: by 2002:a17:902:e80f:b0:1c6:7ba:3a9a with SMTP id u15-20020a170902e80f00b001c607ba3a9amr3726112plg.14.1695561447207; Sun, 24 Sep 2023 06:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695561447; cv=none; d=google.com; s=arc-20160816; b=INLQo3eXTIdgVhOQPYFAtSi1srp67UPDj3EkSrwbsyN49W3SLcxaiYPrTAeqqb7ec5 23c3vf3B8Q9n4RcQzDkSRdS13BGkkH6U/l+SLcSn0WbpuMcyv0EGUSRkefqj1ffodppe euuzKZb0WaIw1m7NuFPbLcDvCp2J6rQDEOQ+3YrWILTtMlZRl3W6xDxQDv3l1sHW+rus +JzYyKvbayLLgmdCsXkOmQJLaQZbHtpeTvbq1UohifRLQ5rsmpFMzjGcL631UosZtaog 4FTYAVCwNV1YFA9ac6CT+92zms70eiSK15s1ued1rz6CbfzMLt+q0qimJ/WsIif52rx+ TSsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FxaOv3I2VGVHMGZnwnBej28pCQnT9iu5+i+SAhWfI9E=; fh=fDt8DAffiIO6hd/OS/AF7MFEcX5OIIZ+eJxtvxRfr1c=; b=DFGJSMBvTvDJncLCYNxODxVjIm/ukThY1+pLDMdfTggP6+ZuOMJki1cI12aaSH4Gxn F0d/cBVzpGINgjB3E5wzSadaarp5Y8bhKoSOx+Mn73ux3a/OGriXJuP8Ihnb+k+gxgEq 09pePo3XuDTL9L9ZJXrs2kWEkNRA9pYuqZbdhNtxBbPPeSMu1KNnhtJomy3IJwLt+M4J fzBgQ2luVAmGLW3vpAUtWtVPfTZmbAKTnYPRTPGb9J7YDwOeqAy7CYCWaemUKy/U1ybC bkdBaASAkiqe8OX+xuLUY2yjLtD6L41RMdiEPbk61ctRNkLISl2bIjX4vt2lsP5tLMx7 ZQYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u1LyX8s2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p16-20020a170902e75000b001c3e500e6d4si8246579plf.344.2023.09.24.06.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 06:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u1LyX8s2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C6B3480254E9; Sun, 24 Sep 2023 06:17:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230161AbjIXNRE (ORCPT + 99 others); Sun, 24 Sep 2023 09:17:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229995AbjIXNQj (ORCPT ); Sun, 24 Sep 2023 09:16:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3CD410F1; Sun, 24 Sep 2023 06:16:09 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8AC7C43395; Sun, 24 Sep 2023 13:16:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695561368; bh=DQ05nITZktT3XUtH29/1DjHDHEuzN5CCQYjGsElJma8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u1LyX8s23ikrllKwBps8FLyOmL+ZayjcdGM2Bkp8ZJVlCbYUGHxzweOuZiTEqzw6p CKC82JZ7Kz8kr+d8m5kFg3ob+hCORL1Km0I32nk3IKW0fmeZe6cE/DJsnbOVwfVgd9 9pmaqux5MgBvbfkONowGUPH2nBCrP3UQDJTP2g7wMKYntUBKRpwz4nV+tbFutls39+ RxaRowf/awcDyVRahVUrReoRm3aa7i1AhSrwxK18IrLwJKoGfsL7HfaM2ILGpSulgW Hb/Bxyn13GhifNX6PBMFNQEFANF50kCASLpL8HkuXmhYe9HV6iruJKt7XCO0TnaS4c QvGV94NTwHJrw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Ricardo B. Marliere" , Shuah Khan , Sasha Levin , shuah@kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH AUTOSEL 6.5 16/41] selftests: fix dependency checker script Date: Sun, 24 Sep 2023 09:15:04 -0400 Message-Id: <20230924131529.1275335-16-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230924131529.1275335-1-sashal@kernel.org> References: <20230924131529.1275335-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.5 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 24 Sep 2023 06:17:15 -0700 (PDT) From: "Ricardo B. Marliere" [ Upstream commit 5f9dd2e896a91bfca90f8463eb6808c03d535d8a ] This patch fixes inconsistencies in the parsing rules of the levels 1 and 2 of the kselftest_deps.sh. It was added the levels 4 and 5 to account for a few edge cases that are present in some tests, also some minor identation styling have been fixed (s/ /\t/g). Signed-off-by: Ricardo B. Marliere Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin --- tools/testing/selftests/kselftest_deps.sh | 77 +++++++++++++++++++---- 1 file changed, 65 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/kselftest_deps.sh b/tools/testing/selftests/kselftest_deps.sh index 4bc14d9e8ff1d..de59cc8f03c3f 100755 --- a/tools/testing/selftests/kselftest_deps.sh +++ b/tools/testing/selftests/kselftest_deps.sh @@ -46,11 +46,11 @@ fi print_targets=0 while getopts "p" arg; do - case $arg in - p) + case $arg in + p) print_targets=1 shift;; - esac + esac done if [ $# -eq 0 ] @@ -92,6 +92,10 @@ pass_cnt=0 # Get all TARGETS from selftests Makefile targets=$(grep -E "^TARGETS +|^TARGETS =" Makefile | cut -d "=" -f2) +# Initially, in LDLIBS related lines, the dep checker needs +# to ignore lines containing the following strings: +filter="\$(VAR_LDLIBS)\|pkg-config\|PKG_CONFIG\|IOURING_EXTRA_LIBS" + # Single test case if [ $# -eq 2 ] then @@ -100,6 +104,8 @@ then l1_test $test l2_test $test l3_test $test + l4_test $test + l5_test $test print_results $1 $2 exit $? @@ -113,7 +119,7 @@ fi # Append space at the end of the list to append more tests. l1_tests=$(grep -r --include=Makefile "^LDLIBS" | \ - grep -v "VAR_LDLIBS" | awk -F: '{print $1}') + grep -v "$filter" | awk -F: '{print $1}' | uniq) # Level 2: LDLIBS set dynamically. # @@ -126,7 +132,7 @@ l1_tests=$(grep -r --include=Makefile "^LDLIBS" | \ # Append space at the end of the list to append more tests. l2_tests=$(grep -r --include=Makefile ": LDLIBS" | \ - grep -v "VAR_LDLIBS" | awk -F: '{print $1}') + grep -v "$filter" | awk -F: '{print $1}' | uniq) # Level 3 # memfd and others use pkg-config to find mount and fuse libs @@ -138,11 +144,32 @@ l2_tests=$(grep -r --include=Makefile ": LDLIBS" | \ # VAR_LDLIBS := $(shell pkg-config fuse --libs 2>/dev/null) l3_tests=$(grep -r --include=Makefile "^VAR_LDLIBS" | \ - grep -v "pkg-config" | awk -F: '{print $1}') + grep -v "pkg-config\|PKG_CONFIG" | awk -F: '{print $1}' | uniq) -#echo $l1_tests -#echo $l2_1_tests -#echo $l3_tests +# Level 4 +# some tests may fall back to default using `|| echo -l` +# if pkg-config doesn't find the libs, instead of using VAR_LDLIBS +# as per level 3 checks. +# e.g: +# netfilter/Makefile +# LDLIBS += $(shell $(HOSTPKG_CONFIG) --libs libmnl 2>/dev/null || echo -lmnl) +l4_tests=$(grep -r --include=Makefile "^LDLIBS" | \ + grep "pkg-config\|PKG_CONFIG" | awk -F: '{print $1}' | uniq) + +# Level 5 +# some tests may use IOURING_EXTRA_LIBS to add extra libs to LDLIBS, +# which in turn may be defined in a sub-Makefile +# e.g.: +# mm/Makefile +# $(OUTPUT)/gup_longterm: LDLIBS += $(IOURING_EXTRA_LIBS) +l5_tests=$(grep -r --include=Makefile "LDLIBS +=.*\$(IOURING_EXTRA_LIBS)" | \ + awk -F: '{print $1}' | uniq) + +#echo l1_tests $l1_tests +#echo l2_tests $l2_tests +#echo l3_tests $l3_tests +#echo l4_tests $l4_tests +#echo l5_tests $l5_tests all_tests print_results $1 $2 @@ -164,24 +191,32 @@ all_tests() for test in $l3_tests; do l3_test $test done + + for test in $l4_tests; do + l4_test $test + done + + for test in $l5_tests; do + l5_test $test + done } # Use same parsing used for l1_tests and pick libraries this time. l1_test() { test_libs=$(grep --include=Makefile "^LDLIBS" $test | \ - grep -v "VAR_LDLIBS" | \ + grep -v "$filter" | \ sed -e 's/\:/ /' | \ sed -e 's/+/ /' | cut -d "=" -f 2) check_libs $test $test_libs } -# Use same parsing used for l2__tests and pick libraries this time. +# Use same parsing used for l2_tests and pick libraries this time. l2_test() { test_libs=$(grep --include=Makefile ": LDLIBS" $test | \ - grep -v "VAR_LDLIBS" | \ + grep -v "$filter" | \ sed -e 's/\:/ /' | sed -e 's/+/ /' | \ cut -d "=" -f 2) @@ -197,6 +232,24 @@ l3_test() check_libs $test $test_libs } +l4_test() +{ + test_libs=$(grep --include=Makefile "^VAR_LDLIBS\|^LDLIBS" $test | \ + grep "\(pkg-config\|PKG_CONFIG\).*|| echo " | \ + sed -e 's/.*|| echo //' | sed -e 's/)$//') + + check_libs $test $test_libs +} + +l5_test() +{ + tests=$(find $(dirname "$test") -type f -name "*.mk") + test_libs=$(grep "^IOURING_EXTRA_LIBS +\?=" $tests | \ + cut -d "=" -f 2) + + check_libs $test $test_libs +} + check_libs() { -- 2.40.1