From: tb Date: Mon, 11 Dec 2017 01:11:12 +0000 (+0000) Subject: Sergey Bronnikov's code coverage analysis shows that a few more code paths X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=21cc68cc2cccc4282e18acb1376c22669c542c6b;p=openbsd Sergey Bronnikov's code coverage analysis shows that a few more code paths could be exercised. Add a few tests to do just that. The wDn test is currently disabled, as it will only pass after a commit to jot.c. --- diff --git a/regress/usr.bin/jot/regress.nb1.out b/regress/usr.bin/jot/regress.nb1.out new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/regress/usr.bin/jot/regress.nb1.out @@ -0,0 +1 @@ +1 diff --git a/regress/usr.bin/jot/regress.nonunif.out b/regress/usr.bin/jot/regress.nonunif.out new file mode 100644 index 00000000000..07193989308 --- /dev/null +++ b/regress/usr.bin/jot/regress.nonunif.out @@ -0,0 +1,9 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 diff --git a/regress/usr.bin/jot/regress.rand1p1.out b/regress/usr.bin/jot/regress.rand1p1.out new file mode 100644 index 00000000000..ce3f36dec92 --- /dev/null +++ b/regress/usr.bin/jot/regress.rand1p1.out @@ -0,0 +1,10 @@ +0.0 +0.1 +0.2 +0.3 +0.4 +0.5 +0.6 +0.7 +0.8 +0.9 diff --git a/regress/usr.bin/jot/regress.rand2p1.out b/regress/usr.bin/jot/regress.rand2p1.out new file mode 100644 index 00000000000..ce3f36dec92 --- /dev/null +++ b/regress/usr.bin/jot/regress.rand2p1.out @@ -0,0 +1,10 @@ +0.0 +0.1 +0.2 +0.3 +0.4 +0.5 +0.6 +0.7 +0.8 +0.9 diff --git a/regress/usr.bin/jot/regress.sh b/regress/usr.bin/jot/regress.sh index 38000f5f260..d6d9df1be73 100644 --- a/regress/usr.bin/jot/regress.sh +++ b/regress/usr.bin/jot/regress.sh @@ -1,4 +1,4 @@ -# $OpenBSD: regress.sh,v 1.4 2016/08/06 15:46:33 tb Exp $ +# $OpenBSD: regress.sh,v 1.5 2017/12/11 01:11:12 tb Exp $ # $FreeBSD: head/usr.bin/jot/tests/regress.sh 208728 2010-06-02 07:47:29Z brian $ JOT=${JOT-jot} @@ -73,9 +73,14 @@ REGRESSION_TEST([[hbbh]], [[${JOT} 15 10 10 2]]) # rand1 and rand2 test coverage (10000 is way too big: 200 should be enough) REGRESSION_TEST([[rand1]], [[${JOT} -r 10000 0 9 | sort -u]]) REGRESSION_TEST([[rand2]], [[${JOT} -r 10000 9 0 | sort -u]]) +# same thing again, but divide by 10 +REGRESSION_TEST([[rand1p1]], [[${JOT} -p 1 -r 10000 0 0.9 | sort -u]]) +REGRESSION_TEST([[rand2p1]], [[${JOT} -p 1 -r 10000 0.9 0 | sort -u]]) # rdhhh and rhdhh test if begin and ender are set to the default with jot -r REGRESSION_TEST([[rdhhh]], [[${JOT} -r 100 - 10 2 2>/dev/null | sort -n | head -1]]) REGRESSION_TEST([[rhdhh]], [[${JOT} -r 100 90 - 2 2>/dev/null | sort -n | tail -1]]) +# test variant of old manpage example, as it exercises the 'use_unif = 0' path +REGRESSION_TEST([[nonunif]], [[jot -p0 -r 10000 0.5 9.5 | sort -u]]) # G: Examples from the FreeBSD manual REGRESSION_TEST([[n21]], [[${JOT} 21 -1 1.00]]) @@ -97,13 +102,19 @@ REGRESSION_TEST([[wg]], [[${JOT} -w "a%20gb" 10]]) REGRESSION_TEST([[wc]], [[${JOT} -w "a%cb" 10 33 43]]) REGRESSION_TEST([[wgd]], [[${JOT} -w "a%gb" 10 .2]]) REGRESSION_TEST([[wu]], [[${JOT} -w "a%ub" 10]]) +REGRESSION_TEST([[wU]], [[${JOT} -w "a%Ub" 10]]) +REGRESSION_TEST([[wlu]], [[${JOT} -w "a%lub" 10]]) REGRESSION_TEST([[wo]], [[${JOT} -w "a%ob" 10]]) +REGRESSION_TEST([[wO]], [[${JOT} -w "a%Ob" 10]]) +REGRESSION_TEST([[wlo]], [[${JOT} -w "a%lob" 10]]) REGRESSION_TEST([[wx]], [[${JOT} -w "a%xb" 10]]) REGRESSION_TEST([[wX1]], [[${JOT} -w "a%Xb" 10]]) REGRESSION_TEST([[wXl]], [[${JOT} -w "a%Xb" 10 2147483648]]) REGRESSION_TEST([[wdl]], [[${JOT} -w "a%db" 10 2147483648 2>/dev/null]]) REGRESSION_TEST([[wxn]], [[${JOT} -w "a%xb" 10 -5 2>/dev/null]]) REGRESSION_TEST([[wdn]], [[${JOT} -w "a%db" 10 -5]]) +#REGRESSION_TEST([[wDn]], [[${JOT} -w "a%Db" 10 -5]]) +REGRESSION_TEST([[wldn]], [[${JOT} -w "a%ldb" 10 -5]]) REGRESSION_TEST([[wp1]], [[${JOT} -w "%%%d%%%%" 10]]) REGRESSION_TEST([[wp2]], [[${JOT} -w "%d%%d%%" 10]]) REGRESSION_TEST([[wp3]], [[${JOT} -w "a%%A%%%d%%B%%b" 10]]) @@ -124,4 +135,7 @@ REGRESSION_TEST([[man8]], [[${JOT} -b x 512]]) REGRESSION_TEST([[man9]], [[${JOT} -s, - 10 132 4]]) REGRESSION_TEST([[man10]], [[${JOT} -s "" -b. 80]]) +# J: Misc tests +REGRESSION_TEST([[nb1]], [[{ ${JOT} -n -b1 1 && echo; }]]) + REGRESSION_END() diff --git a/regress/usr.bin/jot/regress.wDn.out b/regress/usr.bin/jot/regress.wDn.out new file mode 100644 index 00000000000..c4027de9f0d --- /dev/null +++ b/regress/usr.bin/jot/regress.wDn.out @@ -0,0 +1,10 @@ +a-5b +a-4b +a-3b +a-2b +a-1b +a0b +a1b +a2b +a3b +a4b diff --git a/regress/usr.bin/jot/regress.wO.out b/regress/usr.bin/jot/regress.wO.out new file mode 100644 index 00000000000..4c89c92b0b2 --- /dev/null +++ b/regress/usr.bin/jot/regress.wO.out @@ -0,0 +1,10 @@ +a1b +a2b +a3b +a4b +a5b +a6b +a7b +a10b +a11b +a12b diff --git a/regress/usr.bin/jot/regress.wU.out b/regress/usr.bin/jot/regress.wU.out new file mode 100644 index 00000000000..c39e5f6712b --- /dev/null +++ b/regress/usr.bin/jot/regress.wU.out @@ -0,0 +1,10 @@ +a1b +a2b +a3b +a4b +a5b +a6b +a7b +a8b +a9b +a10b diff --git a/regress/usr.bin/jot/regress.wldn.out b/regress/usr.bin/jot/regress.wldn.out new file mode 100644 index 00000000000..c4027de9f0d --- /dev/null +++ b/regress/usr.bin/jot/regress.wldn.out @@ -0,0 +1,10 @@ +a-5b +a-4b +a-3b +a-2b +a-1b +a0b +a1b +a2b +a3b +a4b diff --git a/regress/usr.bin/jot/regress.wlo.out b/regress/usr.bin/jot/regress.wlo.out new file mode 100644 index 00000000000..4c89c92b0b2 --- /dev/null +++ b/regress/usr.bin/jot/regress.wlo.out @@ -0,0 +1,10 @@ +a1b +a2b +a3b +a4b +a5b +a6b +a7b +a10b +a11b +a12b diff --git a/regress/usr.bin/jot/regress.wlu.out b/regress/usr.bin/jot/regress.wlu.out new file mode 100644 index 00000000000..c39e5f6712b --- /dev/null +++ b/regress/usr.bin/jot/regress.wlu.out @@ -0,0 +1,10 @@ +a1b +a2b +a3b +a4b +a5b +a6b +a7b +a8b +a9b +a10b