bbc0001.sh 6.3 KB
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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
#!/bin/bash 

#
# Tests for BBCVerifySKSA
#
# Check handling of Read DBE in SK, SA1 or SA2
# Check match boundaries in all different areas
# Check that verify after write works
# Check that write failure on SK causes failure
# Check that error other than data err on write does not mark blocks bad
# Check that a bundle with no T2+SA2 still works
#
TESTID=BBC0001
TESTFILE=testfile.$$
OUTPUT=/dev/null

echo creating test file $TESTFILE ...
./mkcart > $TESTFILE
. ./testlib.sh

#
# Format the cartridge and install SKSA
#
export BBC_BAD_BLKS=""
export BBC_READ_DBE_BLKS=""
export BBC_WRITE_ERR_BLKS=""
export BBC_WRITE_FLAKY_BLKS=""
export BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >out1.$$ 2>err1.$$
u ./$TESTFILE
B
F
Co
V ./Input/sksa.908 1
V ./Input/sksa.908 1
Q
q
END_OF_FILE

#
# Now set up a Read DBE on one of the SA2 blocks.
# This also tests the case that the match boundary
# does not fall on one of the approved boundaries.
#
BBC_BAD_BLKS="4000"
BBC_READ_DBE_BLKS="42,500"
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >> out1.$$ 2>>err1.$$
u ./$TESTFILE
B
Co
V ./Input/sksa.908 1
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

check_log 1 out
check_log 1 err

#
# Now set up a Read DBE on one of the SA1 blocks.
# This also tests the case that the match boundary
# does not fall on one of the approved boundaries.
#
BBC_BAD_BLKS="4000"
BBC_READ_DBE_BLKS="8,500"
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >out2.$$ 2>err2.$$
u ./$TESTFILE
B
Co
V ./Input/sksa.908 1
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

check_log 2 out
check_log 2 err

#
# Now set up a Read DBE on one of the SK blocks.
# This also tests the case that the match boundary
# does not fall on one of the approved boundaries.
#
BBC_BAD_BLKS="4000"
BBC_READ_DBE_BLKS="2,500"
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >out3.$$ 2>err3.$$
u ./$TESTFILE
B
Co
V ./Input/sksa.908 1
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

check_log 3 out
check_log 3 err

#
# Now create a write error on one of the SK blocks
# This should cause a failure of BBCVerifySKSA.
# Such a card is bad and will be unusable.
#
# First write all zeros to the SKSA, so that the
# SK won't match until correctly rewritten
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >out4.$$ 2>err4.$$
u ./$TESTFILE
B
V ./Input/sksa.zero 1
Co
Q
q
END_OF_FILE

#
# Now do it with the write error
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS="3"
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >>out4.$$ 2>>err4.$$
u ./$TESTFILE
B
Co
V ./Input/sksa.908 1
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

check_log 4 out
check_log 4 err

#
# Test write error on SA1 ticket block
#
# This should also fail the card
#
# First write all zeros to the SKSA, so that the
# SK won't match until correctly rewritten
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >out5.$$ 2>err5.$$
u ./$TESTFILE
B
V ./Input/sksa.zero 1
Co
Q
q
END_OF_FILE

#
# Now do it with the write error on SA1 ticket
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS="4"
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >>out5.$$ 2>>err5.$$
u ./$TESTFILE
B
Co
V ./Input/sksa.908 1
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

check_log 5 out
check_log 5 err

#
# Test write error on SA2 ticket
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS="13"
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >>out6.$$ 2>>err6.$$
u ./$TESTFILE
B
Co
V ./Input/sksa.908 1
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

check_log 6 out
check_log 6 err

#
# Test that verify failure is reported correctly
#
BBC_BAD_BLKS="4000"
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS="42"
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >out7.$$ 2>err7.$$
u ./$TESTFILE
B
V ./Input/sksa.zero 1
Co
Q
q
END_OF_FILE

check_log 7 out
check_log 7 err

#
# Test bundle with no SA2
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >out8.$$ 2>err8.$$
u ./$TESTFILE
B
V ./Input/sksa1.only
V ./Input/sksa1.only
Co
Q
q
END_OF_FILE

check_log 8 out
check_log 8 err

#
# Test Comm Error on SK
#
# First write zero SKSA to guarantee full overwrite
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >out9.$$ 2>err9.$$
u ./$TESTFILE
B
V ./Input/sksa.zero 1
Co
Q
q
END_OF_FILE

#
# Test with Comm Error on SK block
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS=""
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS="2"
emsh << END_OF_FILE >>out9.$$ 2>>err9.$$
u ./$TESTFILE
B
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

#
# Test with Comm Error on T1 block
#
BBC_COMM_ERR_BLKS="4"
emsh << END_OF_FILE >>out9.$$ 2>>err9.$$
u ./$TESTFILE
B
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

#
# Test with Comm Error on SA1 block
#
BBC_COMM_ERR_BLKS="7"
emsh << END_OF_FILE >>out9.$$ 2>>err9.$$
u ./$TESTFILE
B
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

#
# Test with Comm Error on T2 block
#
BBC_COMM_ERR_BLKS="14"
emsh << END_OF_FILE >>out9.$$ 2>>err9.$$
u ./$TESTFILE
B
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

#
# Test with Comm Error on SA2 block
#
BBC_COMM_ERR_BLKS="27"
emsh << END_OF_FILE >>out9.$$ 2>>err9.$$
u ./$TESTFILE
B
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

check_log 9 out
check_log 9 err

#
# Test write error in SA1 body
#
BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS="9"
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >>out10.$$ 2>>err10.$$
u ./$TESTFILE
B
V ./Input/sksa.zero 1
Co
Q
q
END_OF_FILE

check_log 10 out
check_log 10 err

#
# Test write error in SA2 body
#
# This will take us over the threshold of 2 bad blocks
# in the SKSA area and should fail the card.
#

BBC_BAD_BLKS=""
BBC_READ_DBE_BLKS=""
BBC_WRITE_ERR_BLKS="25"
BBC_WRITE_FLAKY_BLKS=""
BBC_COMM_ERR_BLKS=""
emsh << END_OF_FILE >>out11.$$ 2>>err11.$$
u ./$TESTFILE
B
V ./Input/sksa.908 1
Co
Q
q
END_OF_FILE

check_log 11 out
check_log 11 err

gzip -d -c Golden/$TESTID/out.gz > out.$$
if ! cmp $TESTFILE out.$$; then
    echo Output file does not compare ... test FAILS
    echo $TESTFILE is saved for debug
    rm out.$$
    exit 1
fi

echo compare is good ... test pass
rm $TESTFILE out.$$
exit 0