]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
tests: update host utility tests for new features; fix chmod symbolic modes and grep -l
authorTulio A M Mendes <[email protected]>
Mon, 27 Apr 2026 16:40:36 +0000 (13:40 -0300)
committerTulio A M Mendes <[email protected]>
Mon, 4 May 2026 23:52:08 +0000 (20:52 -0300)
commitce8562690ced2bba54b0bf6f12c22d9ac4aebc77
treebc7285853bfffd075ed37242a9547fff6fec6ebe
parent21309b3b0658f00b2ea666102244d9508b5c6605
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.

Test results: 111/111 host PASS, 120/120 QEMU PASS, 33/33 battery PASS
tests/test_host_utils.sh
user/cmds/chmod/chmod.c
user/cmds/grep/grep.c