]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bits: add test for invalid token in cpulist_parse()
authorWanBingjiang <wanbingjiang@webray.com.cn>
Wed, 29 Apr 2026 11:08:24 +0000 (19:08 +0800)
committerWanBingjiang <wanbingjiang@webray.com.cn>
Thu, 7 May 2026 01:51:19 +0000 (09:51 +0800)
Verify that inputs like 1,2,3abc,4 with trailing garbage after a
valid number are rejected.

Signed-off-by: WanBingjiang <wanbingjiang@webray.com.cn>
tests/expected/bits/bits-parse-invalid [new file with mode: 0644]
tests/expected/bits/bits-parse-invalid.err [new file with mode: 0644]
tests/expected/bits/bits-parse-invalid.exit_code [new file with mode: 0644]
tests/ts/bits/bits

diff --git a/tests/expected/bits/bits-parse-invalid b/tests/expected/bits/bits-parse-invalid
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/expected/bits/bits-parse-invalid.err b/tests/expected/bits/bits-parse-invalid.err
new file mode 100644 (file)
index 0000000..714a3f4
--- /dev/null
@@ -0,0 +1 @@
+bits: error: invalid bit list: 1,2,3abc,4
diff --git a/tests/expected/bits/bits-parse-invalid.exit_code b/tests/expected/bits/bits-parse-invalid.exit_code
new file mode 100644 (file)
index 0000000..56a6051
--- /dev/null
@@ -0,0 +1 @@
+1
\ No newline at end of file
index cbf7c6f7cf283079917871911d285c49eefa1ea5..3282917a6c9a2447e76104b1134713c7d6de8159 100755 (executable)
@@ -76,6 +76,10 @@ ts_init_subtest "parse-range"
 $TS_CMD_BITS -g 50-100 75-150 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
 ts_finalize_subtest
 
+ts_init_subtest "parse-invalid"
+$TS_CMD_BITS -l 1,2,3abc,4 >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
 ts_init_subtest "parse-grouped-mask"
 $TS_CMD_BITS -l ,9000000,00000000,0c000000,00000000 >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
 ts_finalize_subtest