From patchwork Tue Sep 29 09:06:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pengxu@kylinos.cn X-Patchwork-Id: 144840 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A00884BB24F6 for ; Tue, 29 Sep 2026 09:07:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A00884BB24F6 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by sourceware.org (Postfix) with ESMTPS id 448DF4BA9036 for ; Tue, 29 Sep 2026 09:07:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 448DF4BA9036 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kylinos.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 448DF4BA9036 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790672829; cv=none; b=nbp5VRcNsFmg6l89tJzODLMyWblJ79ZrvBE6R3yYoD5YRuyxhjtNRaTGNUSmvQsZJyQrDPXPS56cYJFvFbLc5zc45y6xwbhmroTG4B2KWge4RxNkk+IbCx0sDCXiFqzuVcgeDPeeDv9n1nSkIVGC75k5h4m47ayId3B6B2o0PsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790672829; c=relaxed/simple; bh=aep5mNZDi/e6MiAiAedsvI3eNDHVc+P9MNfBGw4/9I0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=PsxvOEzervfZiXU839aQO9gL728gt4wNAZ+GN/nUDqnosHiR6Bv0Z+YCbBGPQ77HVI4y1oFh2qqaTAHWkRSKfy8Xseznt3mmMnYwu/C25Dy0ko3pPUQvrlT0xHQySuaStqU9DhmeSBo6UyaYzMNj0J8FjPKqbLsz4hVUtSgc7RE= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 448DF4BA9036 X-UUID: 1f94513ebbe511f19a56ed5b684f684d-20260929 X-CID-CACHE: Type:Local,Time:202609291654+08,HitQuantity:1 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.19, REQID:ce1786f4-a102-4d20-82f8-dde201b61fe2, IP:0, U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:7db8b62, CLOUDID:2a46e3614aa8e647b2fb81bd07263f04, BulkI D:nil,BulkQuantity:0,SF:81|82|102|123|136|865|898,TC:nil,Content:0|15|50|9 9,EDM:-3|-100,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,O SI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 1f94513ebbe511f19a56ed5b684f684d-20260929 X-User: pengxu@kylinos.cn Received: from kylinos.cn [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1480523551; Tue, 29 Sep 2026 17:06:57 +0800 From: pengxu@kylinos.cn To: jbeulich@suse.com Cc: binutils@sourceware.org, pengxu@kylinos.cn Subject: [PATCH] Add strings -n option test case Date: Tue, 29 Sep 2026 17:06:40 +0800 Message-Id: <20260929090640.663904-2-pengxu@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260929090640.663904-1-pengxu@kylinos.cn> References: <3da15824-06d2-4398-8733-b315fd9f78bf@suse.com> <20260929090640.663904-1-pengxu@kylinos.cn> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, UNPARSEABLE_RELAY shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org From: pengxu This patch adds strings -n test case, including n=4(default),5 and 7. For example , when n = 5, the "strings -n" result only show symbols whose length >= 5. At the same time ,add "strings" command support in binutils-common.exp. Signed-off-by: pengxu --- .../testsuite/binutils-all/strings-len-default.d | 9 +++++++++ binutils/testsuite/binutils-all/strings-len-n-5.d | 8 ++++++++ binutils/testsuite/binutils-all/strings-len-n-7.d | 7 +++++++ binutils/testsuite/binutils-all/strings-len.s | 12 ++++++++++++ binutils/testsuite/binutils-all/strings.exp | 10 ++++++++++ binutils/testsuite/lib/binutils-common.exp | 8 +++++--- 6 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 binutils/testsuite/binutils-all/strings-len-default.d create mode 100644 binutils/testsuite/binutils-all/strings-len-n-5.d create mode 100644 binutils/testsuite/binutils-all/strings-len-n-7.d create mode 100644 binutils/testsuite/binutils-all/strings-len.s diff --git a/binutils/testsuite/binutils-all/strings-len-default.d b/binutils/testsuite/binutils-all/strings-len-default.d new file mode 100644 index 00000000000..e971e3898c7 --- /dev/null +++ b/binutils/testsuite/binutils-all/strings-len-default.d @@ -0,0 +1,9 @@ +#name: strings default minimum length (4) +#source: strings-len.s +#DUMPPROG: strings +#strings: -d + +bbbb +ccccc +dddddddd +eeeeeeeeeee diff --git a/binutils/testsuite/binutils-all/strings-len-n-5.d b/binutils/testsuite/binutils-all/strings-len-n-5.d new file mode 100644 index 00000000000..0fb9265ffe1 --- /dev/null +++ b/binutils/testsuite/binutils-all/strings-len-n-5.d @@ -0,0 +1,8 @@ +#name: strings -n 5 (5-char minimum) +#source: strings-len.s +#DUMPPROG: strings +#strings: -d -n 5 + +ccccc +dddddddd +eeeeeeeeeee diff --git a/binutils/testsuite/binutils-all/strings-len-n-7.d b/binutils/testsuite/binutils-all/strings-len-n-7.d new file mode 100644 index 00000000000..c363b933155 --- /dev/null +++ b/binutils/testsuite/binutils-all/strings-len-n-7.d @@ -0,0 +1,7 @@ +#name: strings -n 7 (excludes 3-/4-/5-/6-char runs) +#source: strings-len.s +#DUMPPROG: strings +#strings: -d -n 7 + +dddddddd +eeeeeeeeeee diff --git a/binutils/testsuite/binutils-all/strings-len.s b/binutils/testsuite/binutils-all/strings-len.s new file mode 100644 index 00000000000..cf24189e91a --- /dev/null +++ b/binutils/testsuite/binutils-all/strings-len.s @@ -0,0 +1,12 @@ +/* Prepare different length of symbols for string -n test */ + .section .data +.Lstr1: + .asciz "aaa" +.Lstr2: + .asciz "bbbb" +.Lstr3: + .asciz "ccccc" +.Lstr4: + .asciz "dddddddd" +.Lstr5: + .asciz "eeeeeeeeeee" diff --git a/binutils/testsuite/binutils-all/strings.exp b/binutils/testsuite/binutils-all/strings.exp index 1a317e1022c..7ce491cf852 100644 --- a/binutils/testsuite/binutils-all/strings.exp +++ b/binutils/testsuite/binutils-all/strings.exp @@ -48,3 +48,13 @@ proc test_print_file_name {testfile} { } test_print_file_name $srcdir/$subdir/strings-1.bin + +set strings_len_tests { + strings-len-default + strings-len-n-5 + strings-len-n-7 +} + +foreach t $strings_len_tests { + run_dump_test $t +} diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp index e7e8c223389..f5e5a719d20 100644 --- a/binutils/testsuite/lib/binutils-common.exp +++ b/binutils/testsuite/lib/binutils-common.exp @@ -945,11 +945,12 @@ proc prune_dump_output { output } { # objdump: FLAGS # readelf: FLAGS # size: FLAGS +# strings: FLAGS # Use the specified program to analyze the output file, and pass it # FLAGS, in addition to the output name. Note that they are run # with LC_ALL=C in the environment to give consistent sorting of # symbols. If no FLAGS are needed then you can use: -# DUMPPROG: [nm objdump readelf addr2line] +# DUMPPROG: [nm objdump readelf addr2line strings] # instead, or just pass a flag that happens to be the default. # If objdump is the dump tool and we're not dumping binary, nor # have run ld, then the standard section names (.text, .data and @@ -1051,7 +1052,7 @@ proc run_dump_test { name {extra_options {}} } { global ADDR2LINE ADDR2LINEFLAGS AS ASFLAGS CC_FOR_TARGET CFLAGS_FOR_TARGET global ELFEDIT ELFEDITFLAGS LD LDFLAGS NM NMFLAGS OBJCOPY OBJCOPYFLAGS global OBJDUMP OBJDUMPFLAGS READELF READELFFLAGS STRIP STRIPFLAGS - global SIZE SIZEFLAGS + global SIZE SIZEFLAGS STRINGS STRINGSFLAGS global copyfile env runtests srcdir subdir verbose base_dir global DT_RELR_LDFLAGS NO_DT_RELR_LDFLAGS global NO_ROSEGMENT_LDFLAGS @@ -1314,6 +1315,7 @@ proc run_dump_test { name {extra_options {}} } { objdump { set dumpprogram objdump } readelf { set dumpprogram readelf } size { set dumpprogram size } + strings { set dumpprogram strings } default { perror "unrecognized DUMPPROG option $opts(DUMPPROG) in $file.d" unresolved $base_testname @@ -1322,7 +1324,7 @@ proc run_dump_test { name {extra_options {}} } { } } else { # Guess which program to run, by seeing which option was specified. - foreach p {addr2line nm objdump readelf size} { + foreach p {addr2line nm objdump readelf size strings} { if {$opts($p) != ""} { if {$dumpprogram != ""} { perror "ambiguous dump program in $file.d"