# Test Case: Mixed Workload

**Test ID**: TC130-mixed-workload  
**Category**: Boundary & Stress  
**Priority**: High  
**Regression**: None

## Objective

Run simultaneous sequential compare, full hash, two deterministic random-read
streams, multi-file hashes, recursive names, and stat-size inventory. Persist
and wait every PID, then prove complete process/mount/provider cleanup.

## Preconditions

- Complete `G7-MANUAL-SETUP.md` and TC126-TC129 prerequisites.

## Manual Steps

```sh
G7=/root/repo22-g7
FIX=$G7/fixtures
SRC=$FIX/sources/workloads
IMAGE=$FIX/images/workloads.erofs
MNT=/mnt/repo22-g7-tc130
E=$G7/evidence/TC130
mkdir -p "$MNT" "$E"
rm -f "$E"/*.tmp "$E"/pids.tsv "$E"/waits.tsv
unit=$(mdconfig -a -t vnode -f "$IMAGE")
mount -t erofs -o ro "/dev/$unit" "$MNT"
: > "$E/pids.tsv"
(
  cmp "$SRC/sequential/sequential.bin" \
    "$MNT/sequential/sequential.bin"
) > "$E/sequential.log" 2>&1 &
pid=$!; printf 'sequential\t%s\n' "$pid" >> "$E/pids.tsv"
(
  expected=$(sha256 -q "$SRC/pressure/pressure.bin")
  actual=$(sha256 -q "$MNT/pressure/pressure.bin")
  printf 'expected=%s actual=%s\n' "$expected" "$actual"
  test "$actual" = "$expected"
) > "$E/full-hash.log" 2>&1 &
pid=$!; printf 'full-hash\t%s\n' "$pid" >> "$E/pids.tsv"
(
  "$G7/g7_probe" random "$SRC/random/random.bin" \
    "$MNT/random/random.bin" 0xbb67ae8584caa73b 8192 4096
) > "$E/random-a.log" 2>&1 &
pid=$!; printf 'random-a\t%s\n' "$pid" >> "$E/pids.tsv"
(
  "$G7/g7_probe" random "$SRC/random/random.bin" \
    "$MNT/random/random.bin" 0x3c6ef372fe94f82b 8192 4096
) > "$E/random-b.log" 2>&1 &
pid=$!; printf 'random-b\t%s\n' "$pid" >> "$E/pids.tsv"
(
  index=0
  while [ "$index" -lt 16 ]; do
    file=$(printf 'reader-%02d.bin' "$index")
    expected=$(sha256 -q "$SRC/concurrent/$file")
    actual=$(sha256 -q "$MNT/concurrent/$file")
    printf '%s expected=%s actual=%s\n' "$file" "$expected" "$actual"
    test "$actual" = "$expected" || exit 1
    index=$((index + 1))
  done
) > "$E/multi-hash.log" 2>&1 &
pid=$!; printf 'multi-hash\t%s\n' "$pid" >> "$E/pids.tsv"
(
  (cd "$SRC" && find . -type f -print | sort) > "$E/source.names.tmp"
  (cd "$MNT" && find . -type f -print | sort) > "$E/target.names.tmp"
  cmp "$E/source.names.tmp" "$E/target.names.tmp"
) > "$E/names.log" 2>&1 &
pid=$!; printf 'names\t%s\n' "$pid" >> "$E/pids.tsv"
(
  (cd "$SRC" && find . -type f -exec stat -f '%N %z' {} + | sort) \
    > "$E/source.stat.tmp"
  (cd "$MNT" && find . -type f -exec stat -f '%N %z' {} + | sort) \
    > "$E/target.stat.tmp"
  cmp "$E/source.stat.tmp" "$E/target.stat.tmp"
) > "$E/stat.log" 2>&1 &
pid=$!; printf 'stat\t%s\n' "$pid" >> "$E/pids.tsv"
test "$(wc -l < "$E/pids.tsv" | tr -d ' ')" -eq 7
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"/*.log
test "$failed" -eq 0
test "$(wc -l < "$E/waits.tsv" | tr -d ' ')" -eq 7
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
mv "$E/source.names.tmp" "$E/source.names"
mv "$E/target.names.tmp" "$E/target.names"
mv "$E/source.stat.tmp" "$E/source.stat"
mv "$E/target.stat.tmp" "$E/target.stat"
test -z "$(find "$E" -name '*.tmp' -print)"
test -z "$(find "$G7/evidence" \( -name 'go-*' -o -name 'stop-*' \) -print)"
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 seven PIDs and seven waits are persisted; every child exits 0 and
  no recorded PID remains alive.
- Sequential bytes, full hash, both random streams, all 16 file hashes, exact
  names, and exact stat sizes match their sources.
- All temporary, synchronization, process, mount, and md resources are gone;
  evidence logs remain for audit.
- No `killall`, timeout masking, deadlock, panic, hang, or unexpected dmesg
  error occurs.
