tests: update host utility tests for new features; fix chmod symbolic modes and grep -l
Host utility tests (tests/test_host_utils.sh):
- Add getdents shim for host builds (glibc only exposes getdents64)
- Add _DEFAULT_SOURCE to CFLAGS for BSD extensions (DT_DIR, etc.)
- Enhanced grep tests: -i (case-insensitive), -l (list files), -q (quiet), -E (extended regex)
- Enhanced sed tests: -n/p (suppress auto-print), d (delete), y (transliterate), line addressing
- Enhanced awk tests: BEGIN/END blocks, -v var=val, NR, NF
- Enhanced find tests: -name single file, -type f, -maxdepth, ! negation
- Enhanced dd tests: conv=ucase, count=1
- Enhanced rm test: -f flag
- Enhanced cp/mv tests: permission preservation
- New chmod tests: symbolic modes (u+x, go-w, a+x, a=rw)
- New stat tests: filename, type, mtime formatting
- New kill tests: -l signal listing, bad PID
- New ls tests: compilation and flag parsing (-l, -a, -n)
- New date tests: output format
- New du tests: single file
- New env tests: environment variable display
- New hostname tests: output
- New sleep tests: 1s delay
- New uptime tests: output
chmod (user/cmds/chmod/chmod.c):
- Fix symbolic mode parsing: who mask was incorrectly ANDed with perm bits,
causing u+x to only add setuid+user-x overlap (0100) instead of user-x (0100).
Now permissions are mapped per-who: u+x→0100, g+x→0010, o+x→0001, etc.
grep (user/cmds/grep/grep.c):
- Fix grep -l: was returning 1 (no match) immediately on first match without
printing the filename. Now prints filename and returns 0 on match.