From: Sami Kerola Date: Fri, 26 Jun 2020 21:24:25 +0000 (+0100) Subject: col: add more tests X-Git-Tag: v2.37-rc1~461^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b97981a7075e551bb5c3badf73e73241882e8207;p=thirdparty%2Futil-linux.git col: add more tests 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 --- diff --git a/tests/expected/col/io b/tests/expected/col/io new file mode 100644 index 0000000000..d74a8586dd --- /dev/null +++ b/tests/expected/col/io @@ -0,0 +1,238 @@ +trailing spaces +1 +2 +tab backspace +1 2 +various spaces +1 2 +cr +12 +vt1 +1 +243 +5 +vt2 + c + + b + +a +reverse lf +13 +2 +so si +esc-tab + +1 +esc-backspace +12 +cs_normal + 0 + +# +# 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 "> $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 diff --git a/tests/ts/col/multibyte b/tests/ts/col/multibyte index 1ed4b5ff8c..b9240d6b41 100755 --- a/tests/ts/col/multibyte +++ b/tests/ts/col/multibyte @@ -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 diff --git a/tests/ts/col/newlines b/tests/ts/col/newlines index cc1d97abd2..96e82edb16 100755 --- a/tests/ts/col/newlines +++ b/tests/ts/col/newlines @@ -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 index 0000000000..b7825c66ab --- /dev/null +++ b/tests/ts/col/options @@ -0,0 +1,39 @@ +#!/bin/bash + +# +# Copyright (C) 2020 Sami Kerola +# +# 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