# Test Case: Concurrent Reads

**Test ID**: TC126-concurrent-reads  
**Category**: Boundary & Stress  
**Priority**: High  
**Regression**: None

## Objective

Verify 16 simultaneous full-file reads, with every PID, exit code, expected
source hash, and mounted-file hash recorded and checkable.

## Preconditions

- Complete `G7-MANUAL-SETUP.md` and verify the workload source inventory.

## Manual Steps

```sh
G7=/root/repo22-g7
FIX=$G7/fixtures
SRC=$FIX/sources/workloads/concurrent
IMAGE=$FIX/images/workloads.erofs
MNT=/mnt/repo22-g7-tc126
E=$G7/evidence/TC126
mkdir -p "$MNT" "$E"
unit=$(mdconfig -a -t vnode -f "$IMAGE")
mount -t erofs -o ro "/dev/$unit" "$MNT"
: > "$E/pids.tsv"
index=0
while [ "$index" -lt 16 ]; do
  file=$(printf 'reader-%02d.bin' "$index")
  expected=$(sha256 -q "$SRC/$file")
  (
    actual=$(sha256 -q "$MNT/concurrent/$file")
    printf 'worker=%02d file=%s expected=%s actual=%s\n' \
      "$index" "$file" "$expected" "$actual"
    test "$actual" = "$expected"
  ) > "$E/worker-$(printf '%02d' "$index").log" 2>&1 &
  pid=$!
  printf '%02d\t%s\n' "$index" "$pid" >> "$E/pids.tsv"
  index=$((index + 1))
done
failed=0
: > "$E/waits.tsv"
while IFS="$(printf '\t')" read -r worker pid; do
  wait "$pid"
  rc=$?
  printf '%s\t%s\t%s\n' "$worker" "$pid" "$rc" >> "$E/waits.tsv"
  test "$rc" -eq 0 || failed=$((failed + 1))
done < "$E/pids.tsv"
cat "$E/pids.tsv" "$E/waits.tsv" "$E"/worker-*.log
test "$failed" -eq 0
test "$(wc -l < "$E/pids.tsv" | tr -d ' ')" -eq 16
test "$(wc -l < "$E/waits.tsv" | tr -d ' ')" -eq 16
alive=0
while IFS="$(printf '\t')" read -r worker pid; do
  if kill -0 "$pid" 2>/dev/null; then
    printf 'still-alive worker=%s pid=%s\n' "$worker" "$pid"
    alive=$((alive + 1))
  fi
done < "$E/pids.tsv"
test "$alive" -eq 0
umount "$MNT"
mdconfig -d -u "${unit#md}"
test -z "$(mount -p | awk -v m="$MNT" '$2 == m { print }')"
test -z "$(mdconfig -l | tr ' ' '\n' | grep -x "$unit")"
```

## PASS Gate

- Exactly 16 PIDs and 16 waits are recorded; every wait exit code is 0.
- Every worker log contains identical expected/source and actual/mounted
  SHA256 values.
- None of the recorded PIDs remains alive; no `killall` or unrelated-process
  cleanup is used.
- No deadlock, panic, hang, dmesg error, mount leak, or provider leak occurs.
