| 1 |
#! /bin/sh -vx |
| 2 |
# $Id$ |
| 3 |
# Copyright 2018-2026 Japanese TeX Development Community <[email protected]> |
| 4 |
# You may freely use, modify and/or distribute this file. |
| 5 |
|
| 6 |
BinDir=${BinDir:-.} |
| 7 |
ExeExt=${ExeExt:-} |
| 8 |
_dvispc=$BinDir/dvispc$ExeExt |
| 9 |
|
| 10 |
testdir=$srcdir/tests |
| 11 |
|
| 12 |
DIFF="diff" |
| 13 |
CMP="cmp" |
| 14 |
# pre-generated test results in the repository are stored in LF |
| 15 |
# but the output might be written in CRLF on some platform. |
| 16 |
# if 'diff --strip-trailing-cr' is available, exploit it. |
| 17 |
# (useful for tests on win32 binaries run on MSYS shell) |
| 18 |
$DIFF --strip-trailing-cr $0 $0 \ |
| 19 |
&& DIFF="diff --strip-trailing-cr" || echo |
| 20 |
|
| 21 |
TEXMFCNF=$srcdir/../kpathsea |
| 22 |
export TEXMFCNF |
| 23 |
|
| 24 |
## show banner |
| 25 |
$_dvispc |
| 26 |
|
| 27 |
rc=0 |
| 28 |
|
| 29 |
## EXE2SPECIAL |
| 30 |
|
| 31 |
$_dvispc -s $testdir/oldindep.dvi x0oldindep.spc && \ |
| 32 |
$DIFF $testdir/oldindep.spc x0oldindep.spc && echo || rc=1 |
| 33 |
|
| 34 |
$_dvispc -s $testdir/oldindep.dvi > x1oldindep.spc && \ |
| 35 |
$DIFF $testdir/oldindep.spc x1oldindep.spc && echo || rc=2 |
| 36 |
|
| 37 |
## invalid usage |
| 38 |
#$_dvispc -s < $testdir/oldindep.dvi x2oldindep.spc && \ |
| 39 |
# diff $testdir/oldindep.spc x2oldindep.spc && echo || rc=3 |
| 40 |
|
| 41 |
## stdin is a DVI, random access may not be supported, no test |
| 42 |
#$_dvispc -s < $testdir/oldindep.dvi > x3oldindep.spc && \ |
| 43 |
# diff $testdir/oldindep.spc x3oldindep.spc && echo || rc=4 |
| 44 |
|
| 45 |
|
| 46 |
## EXE2TEXT + EXE2DVI |
| 47 |
|
| 48 |
$_dvispc -a $testdir/oldindep.dvi x0oldindepa.txt && \ |
| 49 |
$_dvispc -x x0oldindepa.txt x0oldindepax.dvi && \ |
| 50 |
$CMP $testdir/oldindep.dvi x0oldindepax.dvi && echo || rc=11 |
| 51 |
|
| 52 |
$_dvispc -a $testdir/oldindep.dvi > x1oldindepa.txt && \ |
| 53 |
$_dvispc -x < x1oldindepa.txt > x1oldindepax.dvi && \ |
| 54 |
$CMP $testdir/oldindep.dvi x1oldindepax.dvi && echo || rc=12 |
| 55 |
|
| 56 |
# not working as expected only for test (redirect??) |
| 57 |
#$_dvispc -a $testdir/oldindep.dvi | $_dvispc -x x2oldindepax.dvi && \ |
| 58 |
# $CMP $testdir/oldindep.dvi x2oldindepax.dvi && echo || rc=13 |
| 59 |
|
| 60 |
$_dvispc -a $testdir/oldindep.dvi | $_dvispc -x > x3oldindepax.dvi && \ |
| 61 |
$CMP $testdir/oldindep.dvi x3oldindepax.dvi && echo || rc=14 |
| 62 |
|
| 63 |
|
| 64 |
## EXE2MODIFY & EXE2CHECK (should be consistent) |
| 65 |
|
| 66 |
$_dvispc -d $testdir/oldindep.dvi >x0oldindep.dry |
| 67 |
$DIFF $testdir/oldindep.dry x0oldindep.dry && echo || rc=21 |
| 68 |
|
| 69 |
$_dvispc -c $testdir/oldindep.dvi x0oldindepout.dvi && \ |
| 70 |
$CMP $testdir/oldindepout.dvi x0oldindepout.dvi && echo || rc=22 |
| 71 |
|
| 72 |
$_dvispc -c $testdir/oldindep.dvi > x1oldindepout.dvi && \ |
| 73 |
$CMP $testdir/oldindepout.dvi x1oldindepout.dvi && echo || rc=23 |
| 74 |
|
| 75 |
## invalid usage |
| 76 |
#$_dvispc -c < $testdir/oldindep.dvi x2oldindepout.dvi && \ |
| 77 |
# $CMP $testdir/oldindepout.dvi x2oldindepout.dvi && echo || rc=24 |
| 78 |
|
| 79 |
## stdin is a DVI, random access may not be supported, no test |
| 80 |
#$_dvispc -c < $testdir/oldindep.dvi > x3oldindepout.dvi && \ |
| 81 |
# $CMP $testdir/oldindepout.dvi x3oldindepout.dvi && echo || rc=25 |
| 82 |
|
| 83 |
## check default is -c |
| 84 |
$_dvispc $testdir/oldindep.dvi x2oldindepout.dvi && \ |
| 85 |
$CMP $testdir/oldindepout.dvi x2oldindepout.dvi && echo || rc=26 |
| 86 |
|
| 87 |
## check default overwrite |
| 88 |
# not working as expected only for test (redirect??) |
| 89 |
#cp $testdir/oldindep.dvi x3write.dvi && \ |
| 90 |
# $_dvispc x3write.dvi |
| 91 |
# $CMP $testdir/oldindepout.dvi x3write.dvi && echo || rc=31 |
| 92 |
|
| 93 |
## case of underflow |
| 94 |
$_dvispc $testdir/under.dvi x0underout.dvi && \ |
| 95 |
$CMP $testdir/underout.dvi x0underout.dvi && echo || rc=32 |
| 96 |
rm -f x1underout.dvi |
| 97 |
$_dvispc x0underout.dvi x1underout.dvi && \ |
| 98 |
if test -f x1underout.dvi; then exit 1; else echo; fi || rc=33 |
| 99 |
|
| 100 |
$_dvispc && echo || exit $rc |
| 101 |
|
| 102 |
# the following tests will not pass for old version written by SHIMA. |
| 103 |
# that version can be distinguished from the new version by |
| 104 |
# exit code 1 for usage without argument. (the above line did it!) |
| 105 |
|
| 106 |
# correction for tpicpn.dvi is needed but should be minimal |
| 107 |
$_dvispc -d $testdir/tpicpn.dvi >x0tpicpn.dry |
| 108 |
$DIFF $testdir/tpicpn.dry x0tpicpn.dry && echo || exit 1 |
| 109 |
$_dvispc $testdir/tpicpn.dvi x0tpicpnout.dvi && \ |
| 110 |
$CMP $testdir/tpicpnout.dvi x0tpicpnout.dvi && echo || exit 1 |
| 111 |
|
| 112 |
# correction for tpicsh.dvi is never needed, check no output |
| 113 |
$_dvispc -d $testdir/tpicsh.dvi >x0tpicsh.dry |
| 114 |
$DIFF $testdir/tpicsh.dry x0tpicsh.dry && echo || exit 1 |
| 115 |
rm -f x0tpicshout.dvi |
| 116 |
$_dvispc $testdir/tpicsh.dvi x0tpicshout.dvi && \ |
| 117 |
if test -f x0tpicshout.dvi; then exit 1; else echo; fi || exit 1 |
| 118 |
|
| 119 |
## page independence in reverse order which requires prior scanning |
| 120 |
$_dvispc -d $testdir/reverse.dvi >xreverse.dry |
| 121 |
$DIFF $testdir/reverse.dry xreverse.dry && echo || exit 1 |
| 122 |
$_dvispc $testdir/reverse.dvi xreverseout.dvi && \ |
| 123 |
$CMP $testdir/reverseout.dvi xreverseout.dvi && echo || exit 1 |
| 124 |
|
| 125 |
# prior scanning should not mess up |
| 126 |
$_dvispc -d $testdir/first.dvi >xfirst.dry |
| 127 |
$DIFF $testdir/first.dry xfirst.dry && echo || exit 1 |
| 128 |
$_dvispc $testdir/first.dvi xfirstout.dvi && \ |
| 129 |
$CMP $testdir/firstout.dvi xfirstout.dvi && echo || exit 1 |
| 130 |
|
| 131 |
# prior scanning should not mess up (no correction) |
| 132 |
$_dvispc -d $testdir/firstpn.dvi >xfirstpn.dry |
| 133 |
$DIFF $testdir/firstpn.dry xfirstpn.dry && echo || exit 1 |
| 134 |
rm -f xfirstpn.dvi |
| 135 |
$_dvispc $testdir/firstpn.dvi xfirstpn.dvi && \ |
| 136 |
if test -f xfirstpn.dvi; then exit 1; else echo; fi || exit 1 |
| 137 |
|
| 138 |
# ==== future work start ==== |
| 139 |
|
| 140 |
## page independence of annotation |
| 141 |
#$_dvispc -d $testdir/annot.dvi >xannot.dry |
| 142 |
# $DIFF $testdir/annot.dry xannot.dry && echo || exit 2 |
| 143 |
#$_dvispc $testdir/annot.dvi xannotout.dvi && \ |
| 144 |
# $CMP $testdir/annotout.dvi xannotout.dvi && echo || exit 2 |
| 145 |
|
| 146 |
## page independence of long (>255) specials (e.g. annotation) |
| 147 |
## disabled because annotation is unsupported |
| 148 |
#$_dvispc -d $testdir/longspec.dvi >xlongspec.dry |
| 149 |
# $DIFF $testdir/longspec.dry xlongspec.dry && echo || exit 3 |
| 150 |
#$_dvispc $testdir/longspec.dvi xlongspecout.dvi && \ |
| 151 |
# $CMP $testdir/longspecout.dvi xlongspecout.dvi && echo || exit 3 |
| 152 |
|
| 153 |
## flatten nested anotation |
| 154 |
#$_dvispc -d $testdir/flatnest.dvi >xflatnest.dry |
| 155 |
# $DIFF $testdir/flatnest.dry xflatnest.dry && echo || exit 3 |
| 156 |
#$_dvispc $testdir/flatnest.dvi xflatnestout.dvi && \ |
| 157 |
# $CMP $testdir/flatnestout.dvi xflatnestout.dvi && echo || exit 4 |
| 158 |
|
| 159 |
# ==== future work end ==== |
| 160 |
|
| 161 |
## check -b backup works (old version did not!) |
| 162 |
# not working as expected only for test (redirect??) |
| 163 |
#cp $testdir/oldindep.dvi x4write.dvi && \ |
| 164 |
# $_dvispc -b x4write.dvi |
| 165 |
# $CMP $testdir/oldindepout.dvi x4write.dvi && echo || exit 1 |
| 166 |
# $CMP $testdir/oldindep.dvi x4write.dvi.bak && echo || exit 1 |
| 167 |
|
| 168 |
## without .dvi extension (old version missed for outfile!) |
| 169 |
cp $testdir/oldindep.dvi x5write.dvi && \ |
| 170 |
$_dvispc x5write x5writeout |
| 171 |
$CMP $testdir/oldindepout.dvi x5writeout.dvi && echo || exit 2 |
| 172 |
|
| 173 |
|
| 174 |
# ==== TeX Live specific start ==== |
| 175 |
|
| 176 |
## EXE2TEXT + EXE2DVI: check for -J option |
| 177 |
|
| 178 |
$_dvispc -a -Ju $testdir/jisx0208.dvi jisx0208.da.txt || exit 2 |
| 179 |
$DIFF $testdir/jisx0208.txt jisx0208.da.txt || exit 1 |
| 180 |
$_dvispc -x $testdir/jisx0208.txt jisx0208.da.dvi || exit 2 |
| 181 |
$CMP $testdir/jisx0208.dvi jisx0208.da.dvi || exit 1 |
| 182 |
|
| 183 |
$_dvispc -a -Js $testdir/jisx0208.dvi jisx0208-sjp.da.txt || exit 2 |
| 184 |
$_dvispc -a -Je $testdir/jisx0208.dvi jisx0208-ejp.da.txt || exit 2 |
| 185 |
|
| 186 |
if [ -x ../ptexenc/ptekf ]; then |
| 187 |
cp $testdir/jisx0208.txt ./jisx0208.txt || exit 40 |
| 188 |
../ptexenc/ptekf -Us ./jisx0208.txt || exit 41 |
| 189 |
mv jisx0208.txt.out jisx0208-s.txt || exit 42 |
| 190 |
../ptexenc/ptekf -Ue ./jisx0208.txt || exit 41 |
| 191 |
mv jisx0208.txt.out jisx0208-e.txt || exit 42 |
| 192 |
$DIFF jisx0208-s.txt jisx0208-sjp.da.txt || exit 2 |
| 193 |
$DIFF jisx0208-e.txt jisx0208-ejp.da.txt || exit 2 |
| 194 |
fi |
| 195 |
|
| 196 |
## EXE2TEXT: printing ASCII/Japanese characters |
| 197 |
$_dvispc -a -Ju $testdir/putj.dump.dvi putj.da.txt || exit 2 |
| 198 |
$DIFF $testdir/putj.txt putj.da.txt || exit 1 |
| 199 |
$_dvispc -a -JU $testdir/put.dump.dvi put.da.txt || exit 2 |
| 200 |
$DIFF $testdir/put.txt put.da.txt || exit 1 |
| 201 |
|
| 202 |
|
| 203 |
## EXE2TEXT + EXE2DVI: different position of fntdef, nop |
| 204 |
$_dvispc -a $testdir/fntdef0.dvi xfntdef0.txt || exit 2 |
| 205 |
$DIFF $testdir/fntdef0.txt xfntdef0.txt || exit 1 |
| 206 |
$_dvispc -x xfntdef0.txt xfntdef0.dvi || exit 2 |
| 207 |
$CMP $testdir/fntdef0.dvi xfntdef0.dvi || exit 1 |
| 208 |
|
| 209 |
$_dvispc -a $testdir/fntdef1.dvi xfntdef1.txt || exit 2 |
| 210 |
$DIFF $testdir/fntdef1.txt xfntdef1.txt || exit 1 |
| 211 |
$_dvispc -x xfntdef1.txt xfntdef1.dvi || exit 2 |
| 212 |
$CMP $testdir/fntdef1.dvi xfntdef1.dvi || exit 1 |
| 213 |
|
| 214 |
$_dvispc -a $testdir/fntdef2.dvi xfntdef2.txt || exit 2 |
| 215 |
$DIFF $testdir/fntdef2.txt xfntdef2.txt || exit 1 |
| 216 |
$_dvispc -x xfntdef2.txt xfntdef2.dvi || exit 2 |
| 217 |
$CMP $testdir/fntdef2.dvi xfntdef2.dvi || exit 1 |
| 218 |
|
| 219 |
$_dvispc -a $testdir/fntdef3.dvi xfntdef3.txt || exit 2 |
| 220 |
$DIFF $testdir/fntdef3.txt xfntdef3.txt || exit 1 |
| 221 |
$_dvispc -x xfntdef3.txt xfntdef3.dvi || exit 2 |
| 222 |
$CMP $testdir/fntdef3.dvi xfntdef3.dvi || exit 1 |
| 223 |
|
| 224 |
$_dvispc -a -t $testdir/fntdef0.dvi xfntdef0-dtl.txt || exit 2 |
| 225 |
$DIFF $testdir/fntdef0-dtl.txt xfntdef0-dtl.txt || exit 1 |
| 226 |
$_dvispc -x xfntdef0-dtl.txt xfntdef0-dtl.dvi || exit 2 |
| 227 |
$CMP $testdir/fntdef0.dvi xfntdef0-dtl.dvi || exit 1 |
| 228 |
|
| 229 |
$_dvispc -a -t $testdir/fntdef3.dvi xfntdef3-dtl.txt || exit 2 |
| 230 |
$DIFF $testdir/fntdef3-dtl.txt xfntdef3-dtl.txt || exit 1 |
| 231 |
$_dvispc -x xfntdef3-dtl.txt xfntdef3-dtl.dvi || exit 2 |
| 232 |
$CMP $testdir/fntdef3.dvi xfntdef3-dtl.dvi || exit 1 |
| 233 |
|
| 234 |
## Unicode filename |
| 235 |
if [ "$COMSPEC" != "" ] || [ "$ExeExt" = ".exe" ]; then |
| 236 |
echo "*** We guess OS is Windows." |
| 237 |
MyOS=Windows |
| 238 |
command_line_encoding=utf8 |
| 239 |
export command_line_encoding |
| 240 |
else |
| 241 |
echo "*** We guess OS is not Windows." |
| 242 |
MyOS=nonWindows |
| 243 |
fi |
| 244 |
cp $testdir/put.dump.dvi ./putΔДदダ打다𝕯🎉.dump.dvi || exit 50 |
| 245 |
$_dvispc -a -JU ./putΔДदダ打다𝕯🎉.dump.dvi putΔДदダ打다𝕯🎉.da.txt || exit 2 |
| 246 |
$DIFF $testdir/put.txt putΔДदダ打다𝕯🎉.da.txt || exit 1 |
| 247 |
$_dvispc -x putΔДदダ打다𝕯🎉.da.txt putΔДदダ打다𝕯🎉.da.dvi || exit 2 |
| 248 |
$CMP putΔДदダ打다𝕯🎉.dump.dvi putΔДदダ打다𝕯🎉.da.dvi || exit 1 |
| 249 |
|
| 250 |
## EXE2SPECIAL, Japanese encoding (EUC-JP, Shift_JIS or UTF-8) |
| 251 |
|
| 252 |
### ptex, ambiguous encoding: EUC-JP or Shift_JIS |
| 253 |
$_dvispc -s $testdir/spc000_es.dvi x0spc000_es.spc && \ |
| 254 |
$DIFF $testdir/spc000_es.spc x0spc000_es.spc && echo || rc=1 |
| 255 |
|
| 256 |
$_dvispc -s $testdir/spc000_es.dvi > x1spc000_es.spc && \ |
| 257 |
$DIFF $testdir/spc000_es.spc x1spc000_es.spc && echo || rc=2 |
| 258 |
|
| 259 |
# output STDOUT to terminal |
| 260 |
$_dvispc -s $testdir/spc000_es.dvi |
| 261 |
|
| 262 |
### (u)ptex, ambiguous encoding: UTF-8 or EUC-JP |
| 263 |
$_dvispc -s $testdir/spc000_ue.dvi x0spc000_ue.spc && \ |
| 264 |
$DIFF $testdir/spc000_ue.spc x0spc000_ue.spc && echo || rc=1 |
| 265 |
|
| 266 |
$_dvispc -s $testdir/spc000_ue.dvi > x1spc000_ue.spc && \ |
| 267 |
$DIFF $testdir/spc000_ue.spc x1spc000_ue.spc && echo || rc=2 |
| 268 |
|
| 269 |
# output STDOUT to terminal |
| 270 |
$_dvispc -s $testdir/spc000_ue.dvi |
| 271 |
|
| 272 |
### (u)ptex, ambiguous encoding: UTF-8 or Shift_JIS |
| 273 |
$_dvispc -s $testdir/spc000_us.dvi x0spc000_us.spc && \ |
| 274 |
$DIFF $testdir/spc000_us.spc x0spc000_us.spc && echo || rc=1 |
| 275 |
|
| 276 |
$_dvispc -s $testdir/spc000_us.dvi > x1spc000_us.spc && \ |
| 277 |
$DIFF $testdir/spc000_us.spc x1spc000_us.spc && echo || rc=2 |
| 278 |
|
| 279 |
# output STDOUT to terminal |
| 280 |
$_dvispc -s $testdir/spc000_us.dvi |
| 281 |
|
| 282 |
exit 0 |
| 283 |
|