]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
col: add more tests
authorSami Kerola <kerolasa@iki.fi>
Fri, 26 Jun 2020 21:24:25 +0000 (22:24 +0100)
committerSami Kerola <kerolasa@iki.fi>
Fri, 11 Sep 2020 19:55:01 +0000 (20:55 +0100)
With these tests coverage is about 89%.

The ts_run is added to ensure ASAN_OPTIONS and UBSAN_OPTIONS are set
correctly when the tests run.

Reference: https://github.com/karelzak/util-linux/pull/1115#issuecomment-670140224
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tests/expected/col/io [new file with mode: 0644]
tests/expected/col/options [new file with mode: 0644]
tests/ts/col/io [new file with mode: 0755]
tests/ts/col/multibyte
tests/ts/col/newlines
tests/ts/col/options [new file with mode: 0755]

diff --git a/tests/expected/col/io b/tests/expected/col/io
new file mode 100644 (file)
index 0000000..d74a858
--- /dev/null
@@ -0,0 +1,238 @@
+trailing spaces
+1
+2
+tab backspace
+1      2
+various spaces
+1      2
+cr
+1\b2
+vt1
+1
+2\b43
+5
+vt2
+  c
+
+ b
+
+a
+reverse lf
+13
+2
+so si
+esc-tab
+
+1
+esc-backspace
+12
+cs_normal
+       \ e0
+\ f<B
+cs_alternate
+1      \ e2\ f
+allocate here
+       2
+1\b3
+half line
+\e9\r1
+\e9flushing
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
diff --git a/tests/expected/col/options b/tests/expected/col/options
new file mode 100644 (file)
index 0000000..e175e50
--- /dev/null
@@ -0,0 +1,9 @@
+no-backspaces
+FIXME
+pass
+ab
+a\11b
+tabs
+       1
+spaces
+        1
diff --git a/tests/ts/col/io b/tests/ts/col/io
new file mode 100755 (executable)
index 0000000..62f6a81
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2020 Sami Kerola <kerolasa@iki.fi>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="io effects"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_COL"
+
+ts_log "trailing spaces"
+printf "1 \t\n2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "tab backspace"
+printf "1\t\x082\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "various spaces"
+printf "1 \t\f2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "cr"
+printf "1\r2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "vt1"
+printf "1\n23\v\n4\n5\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "vt2"
+printf "a\v\vb\v\vc" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "reverse lf"
+printf "1\n2\e\x073\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "so si"
+printf "\x0e\x0f" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "esc-tab"
+printf "\e\t\b1\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "esc-backspace"
+printf "1\e\b2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "cs_normal"
+printf "<B\x10\x0E\t\v\x100" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "cs_alternate"
+printf "1\t\x0E2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "allocate here"
+printf "1\t\v2\t\n3" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>&1
+
+ts_log "half line"
+printf "\e\t\b1\n" | ts_run $TS_CMD_COL --fine >> $TS_OUTPUT 2>&1
+
+ts_log "flushing"
+seq 1 199 | ts_run $TS_CMD_COL --lines 8 >> $TS_OUTPUT 2>&1
+
+ts_finalize
index 1ed4b5ff8ccf1016b877c158326ab7a0de76fa2c..b9240d6b41a2de69c90dd35411189ca6e44e0d5b 100755 (executable)
@@ -24,7 +24,8 @@ ts_init "$*"
 ts_check_test_command "$TS_CMD_COL"
 ts_check_test_command "$TS_HELPER_STRERROR"
 
-cat $TS_SELF/multibyte.data | LC_ALL=C.UTF-8 $TS_CMD_COL 2>&1 > /dev/null |
+cat $TS_SELF/multibyte.data |
+    LC_ALL=C.UTF-8 ts_run $TS_CMD_COL 2>&1 > /dev/null |
     sed -e "s@$($TS_HELPER_STRERROR EILSEQ)@EILSEQ@" > $TS_OUTPUT
 
 ts_finalize
index cc1d97abd2ed5b6dc333ac68c8ca8c620102f763..96e82edb16f43f8ca2f5473058d6feec1476df29 100755 (executable)
@@ -24,18 +24,18 @@ ts_init "$*"
 ts_check_test_command "$TS_CMD_COL"
 
 ts_log "zero length file"
-printf "" | $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
+printf "" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
 
 ts_log "one line no nl"
-printf "1" | $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
+printf "1" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
 
 ts_log "one line with nl"
-printf "1\n" | $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
+printf "1\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
 
 ts_log "second line no nl"
-printf "1\n2" | $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
+printf "1\n2" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
 
 ts_log "second line with nl"
-printf "1\n2\n" | $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
+printf "1\n2\n" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
 
 ts_finalize
diff --git a/tests/ts/col/options b/tests/ts/col/options
new file mode 100755 (executable)
index 0000000..b7825c6
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2020 Sami Kerola <kerolasa@iki.fi>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="options"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_COL"
+
+ts_log "no-backspaces"
+printf "FIXME" | ts_run $TS_CMD_COL --no-backspaces >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_log "pass"
+printf "a\x11b" | ts_run $TS_CMD_COL >> $TS_OUTPUT 2>> $TS_ERRLOG
+printf "a\x11b" | ts_run $TS_CMD_COL --pass >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_log "tabs"
+printf "        1\n" | ts_run $TS_CMD_COL --tabs >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_log "spaces"
+printf "\t1\n" | ts_run $TS_CMD_COL --spaces >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+ts_finalize