#! /bin/sh
# Run as VERBOSE=x ./runtests

dotest=tools/dotest

# all ok
$dotest test001 1 file1 "OK"
$dotest test001 2 file123 "OK" "OK" "OK"
$dotest test001 3 file12345 "OK" "OK" "OK" "OK" "OK"

# 1st missing
$dotest test002 1 file1 "MISSING"
$dotest test002 2 file123 "MISSING" "INDETERMINABLE" "OK"
$dotest test002 3 file12345 "MISSING" "INDETERMINABLE" "OK" "OK" "OK"

# 2nd missing
$dotest test003 2 file123 "INDETERMINABLE" "MISSING" "INDETERMINABLE"
$dotest test003 3 file12345 "INDETERMINABLE" "MISSING" "INDETERMINABLE" "OK" "OK"

# last mising
$dotest test004 2 file123 "OK" "INDETERMINABLE" "MISSING"
$dotest test004 3 file12345 "OK" "OK" "OK" "INDETERMINABLE" "MISSING"

# 1st and 2nd missing
$dotest test005 2 file123 "MISSING" "MISSING" "INDETERMINABLE"
$dotest test005 3 file12345 "MISSING" "MISSING" "INDETERMINABLE" "OK" "OK"

# 1st and 3rd missing
$dotest test006 2 file123 "MISSING" "INDETERMINABLE" "MISSING"
$dotest test006 3 file12345 "MISSING" "INDETERMINABLE" "MISSING" "INDETERMINABLE" "OK"

# 1st and 5th missing
$dotest test007 3 file12345 "MISSING" "INDETERMINABLE" "OK" "INDETERMINABLE" "MISSING"

# 2nd and 3rd missing
$dotest test008 2 file123 "INDETERMINABLE" "MISSING" "MISSING"
$dotest test008 3 file12345 "INDETERMINABLE" "MISSING" "MISSING" "INDETERMINABLE" "OK"

# 3rd and 4th missing
$dotest test009 3 file12345 "OK" "INDETERMINABLE" "MISSING" "INDETERMINABLE" "MISSING"

# 4th and 5th missing
$dotest test010 3 file12345 "OK" "OK" "INDETERMINABLE" "MISSING" "MISSING"

# all missing
$dotest test011 2 file123 "MISSING" "MISSING" "MISSING"
$dotest test011 3 file12345 "MISSING" "MISSING" "MISSING" "MISSING" "MISSING"

# first file corrupted 1 byte in head
$dotest test012 1 file1 "FAILED"
$dotest test012 2 file123 "FAILED" "OK" "OK"
$dotest test012 3 file12345 "FAILED" "OK" "OK" "OK" "OK"

# first file corrupted 1 byte in middle
$dotest test013 1 file1 "FAILED"
$dotest test013 2 file123 "FAILED" "OK" "OK"
$dotest test013 3 file12345 "FAILED" "OK" "OK" "OK" "OK"

# first file corrupted 1 byte in tail
$dotest test014 1 file1 "FAILED"
$dotest test014 2 file123 "INDETERMINABLE" "INDETERMINABLE" "OK"
$dotest test014 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "OK" "OK" "OK"

# second file corrupted 1 byte in head
$dotest test015 2 file123 "INDETERMINABLE" "INDETERMINABLE" "OK"
$dotest test015 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "OK" "OK" "OK"

# second file corrupted 1 byte in middle
$dotest test016 2 file123 "OK" "FAILED" "OK"
$dotest test016 3 file12345 "OK" "FAILED" "OK" "OK" "OK"

# second file corrupted 1 byte in tail
$dotest test017 2 file123 "OK" "INDETERMINABLE" "INDETERMINABLE"
$dotest test017 3 file12345 "OK" "INDETERMINABLE" "INDETERMINABLE" "OK" "OK"

# last file corrupted 1 byte in head
$dotest test018 2 file123 "OK" "INDETERMINABLE" "INDETERMINABLE"
$dotest test018 3 file12345 "OK" "OK" "OK" "INDETERMINABLE" "INDETERMINABLE"

# last file corrupted 1 byte in middle
$dotest test019 2 file123 "OK" "OK" "FAILED"
$dotest test019 3 file12345 "OK" "OK" "OK" "OK" "FAILED"

# last file corrupted 1 byte in tail
$dotest test020 2 file123 "OK" "OK" "FAILED"
$dotest test020 3 file12345 "OK" "OK" "OK" "OK" "FAILED"

# all files corrupted 1 byte in head
$dotest test025 2 file123 "FAILED" "INDETERMINABLE" "INDETERMINABLE"
$dotest test025 3 file12345 "FAILED" "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE"

# all files corrupted 1 byte in middle
$dotest test026 2 file123 "FAILED" "FAILED" "FAILED"
$dotest test026 3 file12345 "FAILED" "FAILED" "FAILED" "FAILED" "FAILED"

# all files corrupted 1 byte in tail
$dotest test027 2 file123 "INDETERMINABLE" "INDETERMINABLE" "FAILED"
$dotest test027 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE" "FAILED"

# first file corrupted 1 byte in head, 1 byte in tail
$dotest test028 2 file123 "FAILED" "INDETERMINABLE" "OK"
$dotest test028 3 file12345 "FAILED" "INDETERMINABLE" "OK" "OK" "OK"

# first file corrupted 1 byte in head, 1 byte in middle, 1 byte in tail
$dotest test029 2 file123 "FAILED" "INDETERMINABLE" "OK"
$dotest test029 3 file12345 "FAILED" "INDETERMINABLE" "OK" "OK" "OK"

# second file corrupted 1 byte in head, 1 byte in tail
$dotest test030 2 file123 "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE"
$dotest test030 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE" "OK" "OK"

# second file corrupted 1 byte in head, 1 byte in middle, 1 byte in tail
$dotest test031 2 file123 "INDETERMINABLE" "FAILED" "INDETERMINABLE"
$dotest test031 3 file12345 "INDETERMINABLE" "FAILED" "INDETERMINABLE" "OK" "OK"

# last file corrupted 1 byte in head, 1 byte in tail
$dotest test032 2 file123 "OK" "INDETERMINABLE" "FAILED"
$dotest test032 3 file12345 "OK" "OK" "OK" "INDETERMINABLE" "FAILED"

# last file corrupted 1 byte in head, 1 byte in middle, 1 byte in tail
$dotest test033 2 file123 "OK" "INDETERMINABLE" "FAILED"
$dotest test033 3 file12345 "OK" "OK" "OK" "INDETERMINABLE" "FAILED"

# all files corrupted 1 byte in head, 1 byte in tail
$dotest test034 2 file123 "FAILED" "INDETERMINABLE" "FAILED"
$dotest test034 3 file12345 "FAILED" "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE" "FAILED"

# all files corrupted 1 byte in head, 1 byte in middle, 1 byte in tail
$dotest test035 2 file123 "FAILED" "FAILED" "FAILED"
$dotest test035 3 file12345 "FAILED" "FAILED" "FAILED" "FAILED" "FAILED"

# first file corrupted first byte in second piece
$dotest test036 1 file1 "FAILED"
$dotest test036 2 file123 "FAILED" "OK" "OK"
$dotest test036 3 file12345 "FAILED" "OK" "OK" "OK" "OK"

# first file corrupted 1 byte before second piece
$dotest test037 1 file1 "FAILED"
$dotest test037 2 file123 "FAILED" "OK" "OK"
$dotest test037 3 file12345 "FAILED" "OK" "OK" "OK" "OK"

# second file corrupted first byte in second piece
$dotest test038 2 file123 "OK" "FAILED" "OK"
$dotest test038 3 file12345 "OK" "FAILED" "OK" "OK" "OK"

# second file corrupted 1 byte before second piece
$dotest test039 2 file123 "INDETERMINABLE" "INDETERMINABLE" "OK"
$dotest test039 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "OK" "OK" "OK"

# third file corrupted first byte in second piece
$dotest test040 2 file123 "OK" "OK" "FAILED"
$dotest test040 3 file12345 "OK" "OK" "FAILED" "OK" "OK"

# third file corrupted 1 byte before second piece
$dotest test041 2 file123 "OK" "INDETERMINABLE" "INDETERMINABLE"
$dotest test041 3 file12345 "OK" "INDETERMINABLE" "INDETERMINABLE" "OK" "OK"

# fifth file corrupted in second piece
$dotest test042 3 file12345 "OK" "OK" "OK" "OK" "FAILED"

# fifth file corrupted 1 byte before second piece
$dotest test043 3 file12345 "OK" "OK" "OK" "INDETERMINABLE" "INDETERMINABLE"

# first file truncated 1 byte
$dotest test044 1 file1 "INDETERMINABLE"
$dotest test044 2 file123 "INDETERMINABLE" "INDETERMINABLE" "OK"
$dotest test044 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "OK" "OK" "OK"

# second file truncated 1 byte
$dotest test045 2 file123 "OK" "INDETERMINABLE" "INDETERMINABLE"
$dotest test045 3 file12345 "OK" "INDETERMINABLE" "INDETERMINABLE" "OK" "OK"

# third file truncated 1 byte
$dotest test046 2 file123 "OK" "OK" "INDETERMINABLE"
$dotest test046 3 file12345 "OK" "OK" "INDETERMINABLE" "INDETERMINABLE" "OK"

# fifth file truncated 1 byte
$dotest test047 3 file12345 "OK" "OK" "OK" "OK" "INDETERMINABLE"

# first file truncated 1 byte and corrupted in last byte
$dotest test048 1 file1 "INDETERMINABLE"
$dotest test048 2 file123 "INDETERMINABLE" "INDETERMINABLE" "OK"
$dotest test048 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "OK" "OK" "OK"

# second file truncated 1 byte and corrupted in last byte
$dotest test049 2 file123 "OK" "INDETERMINABLE" "INDETERMINABLE"
$dotest test049 3 file12345 "OK" "INDETERMINABLE" "INDETERMINABLE" "OK" "OK"

# third file truncated 1 byte and corrupted in last byte
$dotest test050 2 file123 "OK" "OK" "INDETERMINABLE"
$dotest test050 3 file12345 "OK" "OK" "INDETERMINABLE" "INDETERMINABLE" "OK"

# fifth file truncated 1 byte and corrupted in last byte
$dotest test051 3 file12345 "OK" "OK" "OK" "OK" "INDETERMINABLE"

# first file truncated 1 byte and corrupted in first byte
$dotest test052 1 file1 "FAILED"
$dotest test052 2 file123 "FAILED" "INDETERMINABLE" "OK"
$dotest test052 3 file12345 "FAILED" "INDETERMINABLE" "OK" "OK" "OK"

# second file truncated 1 byte and corrupted in first byte
$dotest test053 2 file123 "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE"
$dotest test053 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE" "OK" "OK"

# third file truncated 1 byte and corrupted in first byte
$dotest test054 2 file123 "OK" "INDETERMINABLE" "INDETERMINABLE"
$dotest test054 3 file12345 "OK" "INDETERMINABLE" "INDETERMINABLE" "INDETERMINABLE" "OK"

# fifth file truncated 1 byte and corrupted in first byte
$dotest test055 3 file12345 "OK" "OK" "OK" "INDETERMINABLE" "INDETERMINABLE"

# first file truncated 1 byte and corrupted in middle byte
$dotest test056 1 file1 "FAILED"
$dotest test056 2 file123 "FAILED" "INDETERMINABLE" "OK"
$dotest test056 3 file12345 "FAILED" "INDETERMINABLE" "OK" "OK" "OK"

# second file truncated 1 byte and corrupted in middle byte
$dotest test057 2 file123 "OK" "FAILED" "INDETERMINABLE"
$dotest test057 3 file12345 "OK" "FAILED" "INDETERMINABLE" "OK" "OK"

# third file truncated 1 byte and corrupted in middle byte
$dotest test058 2 file123 "OK" "OK" "FAILED"
$dotest test058 3 file12345 "OK" "OK" "FAILED" "INDETERMINABLE" "OK"

# fifth file truncated 1 byte and corrupted in middle byte
$dotest test059 3 file12345 "OK" "OK" "OK" "OK" "FAILED"

# first file extended 1 byte
$dotest test060 1 file1 "TOO LONG"
$dotest test060 2 file123 "TOO LONG" "OK" "OK"
$dotest test060 3 file12345 "TOO LONG" "OK" "OK" "OK" "OK"

# second file extended 1 byte
$dotest test061 2 file123 "OK" "TOO LONG" "OK"
$dotest test061 3 file12345 "OK" "TOO LONG" "OK" "OK" "OK"

# third file extended 1 byte
$dotest test062 2 file123 "OK" "OK" "TOO LONG"
$dotest test062 3 file12345 "OK" "OK" "TOO LONG" "OK" "OK"

# fifth file extended 1 byte
$dotest test063 3 file12345 "OK" "OK" "OK" "OK" "TOO LONG"

# first file extended 1 byte and corrupted in first byte
$dotest test064 1 file1 "FAILED"
$dotest test064 2 file123 "FAILED" "OK" "OK"
$dotest test064 3 file12345 "FAILED" "OK" "OK" "OK" "OK"

# second file extended 1 byte and corrupted in first byte
$dotest test065 2 file123 "INDETERMINABLE" "INDETERMINABLE" "OK"
$dotest test065 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "OK" "OK" "OK"

# third file extended 1 byte and corrupted in first byte
$dotest test066 2 file123 "OK" "INDETERMINABLE" "INDETERMINABLE"
$dotest test066 3 file12345 "OK" "INDETERMINABLE" "INDETERMINABLE" "OK" "OK"

# fifth file extended 1 byte and corrupted in first byte
$dotest test067 3 file12345 "OK" "OK" "OK" "INDETERMINABLE" "INDETERMINABLE"

# first file extended 1 byte and corrupted in last byte (before extend)
$dotest test068 1 file1 "FAILED"
$dotest test068 2 file123 "INDETERMINABLE" "INDETERMINABLE" "OK"
$dotest test068 3 file12345 "INDETERMINABLE" "INDETERMINABLE" "OK" "OK" "OK"

# second file extended 1 byte and corrupted in last byte (before extend)
$dotest test069 2 file123 "OK" "INDETERMINABLE" "INDETERMINABLE"
$dotest test069 3 file12345 "OK" "INDETERMINABLE" "INDETERMINABLE" "OK" "OK"

# third file extended 1 byte and corrupted in last byte (before extend)
$dotest test070 2 file123 "OK" "OK" "FAILED"
$dotest test070 3 file12345 "OK" "OK" "INDETERMINABLE" "INDETERMINABLE" "OK"

# fifth file extended 1 byte and corrupted in last byte (before extend)
$dotest test071 3 file12345 "OK" "OK" "OK" "OK" "FAILED"

# first file extended 1 byte and corrupted in middle byte
$dotest test072 1 file1 "FAILED"
$dotest test072 2 file123 "FAILED" "OK" "OK"
$dotest test072 3 file12345 "FAILED" "OK" "OK" "OK" "OK"

# second file extended 1 byte and corrupted in middle byte
$dotest test073 2 file123 "OK" "FAILED" "OK"
$dotest test073 3 file12345 "OK" "FAILED" "OK" "OK" "OK"

# third file extended 1 byte and corrupted in middle byte
$dotest test074 2 file123 "OK" "OK" "FAILED"
$dotest test074 3 file12345 "OK" "OK" "FAILED" "OK" "OK"

# fifth file extended 1 byte and corrupted in middle byte
$dotest test075 3 file12345 "OK" "OK" "OK" "OK" "FAILED"

# first file shortened to piece boundary
$dotest test076 1 file1 "TOO SHORT"
$dotest test076 2 file123 "TOO SHORT" "INDETERMINABLE" "OK"
$dotest test076 3 file12345 "TOO SHORT" "INDETERMINABLE" "OK" "OK" "OK"
