[v3] Add strings -n option test case
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_binutils_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_binutils_check--master-arm |
success
|
Test passed
|
Commit Message
From: pengxu <pengxu@kylinos.cn>
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 <pengxu@kylinos.cn>
---
.../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 | 6 ++++++
binutils/testsuite/lib/binutils-common.exp | 8 +++++---
6 files changed, 47 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
Comments
On 29.09.2026 11:52, pengxu@kylinos.cn wrote:
> From: pengxu <pengxu@kylinos.cn>
>
> 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 <pengxu@kylinos.cn>
> ---
> .../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 | 6 ++++++
> binutils/testsuite/lib/binutils-common.exp | 8 +++++---
> 6 files changed, 47 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
The new testcases fail on at least alpha-linuxecoff, alpha-osf4.0,
hppa-hpux, i386-bsd, i386-msdos, i686-darwin, mmix, ns32k-pc532-uxpv,
pdp11-dec-aout, tic4x-coff, and tic54x-coff (after subtracting out
those where e.g. gas isn't being built in the first place). One (the
main?) issue looks to be the use of a .section directive. I'll retry
after replacing ".section .data" with just ".data".
Jan
On 02.10.2026 13:27, Jan Beulich wrote:
> On 29.09.2026 11:52, pengxu@kylinos.cn wrote:
>> From: pengxu <pengxu@kylinos.cn>
>>
>> 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 <pengxu@kylinos.cn>
>> ---
>> .../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 | 6 ++++++
>> binutils/testsuite/lib/binutils-common.exp | 8 +++++---
>> 6 files changed, 47 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
>
> The new testcases fail on at least alpha-linuxecoff, alpha-osf4.0,
> hppa-hpux, i386-bsd, i386-msdos, i686-darwin, mmix, ns32k-pc532-uxpv,
> pdp11-dec-aout, tic4x-coff, and tic54x-coff (after subtracting out
> those where e.g. gas isn't being built in the first place). One (the
> main?) issue looks to be the use of a .section directive. I'll retry
> after replacing ".section .data" with just ".data".
While this improved things, mmix, tic4x-coff, and tic54x-coff remain
to be a problem. mmix may need excluding (albeit with the labels being
the problem, perhaps the labels could be dropped again?), while the TI
ones may need XFAILing (as either .asciz is broken there, or strings
is).
Jan
new file mode 100644
@@ -0,0 +1,9 @@
+#name: strings default minimum length (4)
+#source: strings-len.s
+#DUMPPROG: strings
+#strings: -d
+
+bbbb
+ccccc
+dddddddd
+eeeeeeeeeee
new file mode 100644
@@ -0,0 +1,8 @@
+#name: strings -n 5 (5-char minimum)
+#source: strings-len.s
+#DUMPPROG: strings
+#strings: -d -n 5
+
+ccccc
+dddddddd
+eeeeeeeeeee
new file mode 100644
@@ -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
new file mode 100644
@@ -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"
@@ -48,3 +48,9 @@ proc test_print_file_name {testfile} {
}
test_print_file_name $srcdir/$subdir/strings-1.bin
+
+
+# Test strings -n case
+run_dump_test strings-len-default
+run_dump_test strings-len-n-5
+run_dump_test strings-len-n-7
@@ -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"