]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (bits) add --width tests for invalid values
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 6 Apr 2026 21:42:17 +0000 (17:42 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 7 Apr 2026 14:46:10 +0000 (10:46 -0400)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests/expected/bits/bits-width-greater-128KB.err [new file with mode: 0644]
tests/expected/bits/bits-width-zero.err [new file with mode: 0644]
tests/helpers/test_strerror.c
tests/ts/bits/bits

diff --git a/tests/expected/bits/bits-width-greater-128KB.err b/tests/expected/bits/bits-width-greater-128KB.err
new file mode 100644 (file)
index 0000000..254313f
--- /dev/null
@@ -0,0 +1 @@
+bits: invalid --width: '132096': ERANGE
diff --git a/tests/expected/bits/bits-width-zero.err b/tests/expected/bits/bits-width-zero.err
new file mode 100644 (file)
index 0000000..59ae634
--- /dev/null
@@ -0,0 +1 @@
+bits: invalid --width
index a574c6ef3fac1d275250f6fe9c0290de8b66ab30..322ce659bef9bfd9d293f52d1f1f7d7cb941bfaf 100644 (file)
@@ -21,6 +21,7 @@ static struct {
        E(ENOTTY),
        E(EILSEQ),
        E(EINVAL),
+       E(ERANGE),
 };
 
 int main(int argc, const char *argv[])
@@ -42,3 +43,4 @@ int main(int argc, const char *argv[])
        fprintf(stderr, "Invalid errno: %s\n", argv[1]);
        return -1;
 }
+
index 57db84c6840c090110aa5ff29413e4a75a073169..167d968f05f4847f42bb9e2acaa942c073b65472 100755 (executable)
@@ -44,11 +44,20 @@ $TS_CMD_BITS -l 1,10000 >> $TS_OUTPUT 2>> $TS_ERRLOG
 ts_finalize_subtest
 
 ts_init_subtest "width"
-$TS_CMD_BITS -w 16384 -l 10000  >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_BITS --width 16384 -l 10000  >> $TS_OUTPUT 2>> $TS_ERRLOG
 ts_finalize_subtest
 
 ts_init_subtest "width-truncate"
-$TS_CMD_BITS -w 32 -l 11,22,33,44 >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_BITS --width 32 -l 11,22,33,44 >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "width-zero"
+$TS_CMD_BITS --width 0 -l 11,22,33,44 >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+ts_init_subtest "width-greater-128KB"
+$TS_CMD_BITS --width $(( 129 * 1024 )) -l 11,22,33,44 >> $TS_OUTPUT 2>> $TS_ERRLOG
+sed -i -e "s@$($TS_HELPER_STRERROR ERANGE)@ERANGE@" $TS_OUTPUT $TS_ERRLOG
 ts_finalize_subtest
 
 ts_init_subtest "parse-mask"