# Test Case: Large Directory

**Test ID**: TC125-large-directory  
**Category**: Boundary & Stress  
**Priority**: High  
**Regression**: None

## Objective

Verify exact readdir and lookup behavior for one directory containing 12,000
direct child files. Record scan timing without a cross-machine time gate.

## Preconditions

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

## Manual Steps

```sh
G7=/root/repo22-g7
FIX=$G7/fixtures
SRCROOT=$FIX/sources/boundaries
IMAGE=$FIX/images/boundaries.erofs
MNT=/mnt/repo22-g7-tc125
E=$G7/evidence/TC125
mkdir -p "$MNT" "$E"
unit=$(mdconfig -a -t vnode -f "$IMAGE")
mount -t erofs -o ro "/dev/$unit" "$MNT"
(cd "$SRCROOT" && find large-dir -type f -print | sort) > "$E/source.names"
/usr/bin/time -p sh -c \
  'cd "$1" && find large-dir -type f -print | sort > "$2"' \
  sh "$MNT" "$E/target.names" 2> "$E/readdir.time"
cat "$E/readdir.time"
source_count=$(wc -l < "$E/source.names" | tr -d ' ')
target_count=$(wc -l < "$E/target.names" | tr -d ' ')
printf 'source_count=%s\ntarget_count=%s\n' "$source_count" "$target_count" \
  | tee "$E/counts.txt"
test "$source_count" -eq 12000
test "$target_count" -eq 12000
cmp "$E/source.names" "$E/target.names"
for name in entry-00000.txt entry-00001.txt entry-05999.txt \
  entry-11998.txt entry-11999.txt; do
  cmp "$SRCROOT/large-dir/$name" "$MNT/large-dir/$name"
  printf '%s source=%s target=%s\n' "$name" \
    "$(sha256 -q "$SRCROOT/large-dir/$name")" \
    "$(sha256 -q "$MNT/large-dir/$name")"
done | tee "$E/lookups.txt"
(cd "$SRCROOT" && find large-dir -type f -exec sha256sum {} + | sort) \
  > "$E/source.hashes"
(cd "$MNT" && find large-dir -type f -exec sha256sum {} + | sort) \
  > "$E/target.hashes"
cmp "$E/source.hashes" "$E/target.hashes"
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

- Exact sorted names and all 12,000 source/mount hashes match.
- The five boundary/middle lookups match their sources.
- Readdir timing is recorded but has no fixed TCG or cross-machine limit.
- No readdir error, panic, hang, or cleanup leak occurs.
