|
- #!/bin/sh
- set -eu
-
- manifest=smf/o6h-memory-guard.xml
- config=etc/o6h-memory-guard.conf
-
- if grep -Fq -- '--force-dry-run' "$manifest"; then
- echo 'FAIL SMF manifest must not force dry-run' >&2
- exit 1
- fi
-
- test "$(grep -Fxc ' exec="/opt/custom/bin/o6h-memory-guard --daemon --config /opt/custom/etc/o6h-memory-guard.conf"' "$manifest")" -eq 1
- test "$(grep -Fxc ' <common_name><loctext xml:lang="C">o6h memory pressure guard</loctext></common_name>' "$manifest")" -eq 1
- test "$(grep -Fxc 'ACTION_MODE dry-run' "$config")" -eq 1
- test "$(grep -Fxc 'SYSLOG_ENABLED yes' "$config")" -eq 1
- test "$(grep -Fxc 'SYSLOG_FACILITY local5' "$config")" -eq 1
-
- while IFS= read -r setting; do
- test "$(grep -Fxc "$setting" "$config")" -eq 1
- done <<'EOF'
- PRE_SECONDS 1
- PRESSURE_SECONDS 2
- CRITICAL_SECONDS 2
- RECOVERY_SECONDS 15
- CRITICAL_TERM_GRACE_SECONDS 5
- EMERGENCY_TERM_GRACE_SECONDS 1
- FLOOR_KILL_DELAY_SECONDS 0
- MAX_CACHED_CANDIDATE_AGE_SECONDS 15
- MAX_VICTIMS_EPISODE 4
- MAX_VICTIMS_MINUTE 4
- MAX_EMERGENCY_VICTIMS_EPISODE 8
- MAX_FLOOR_VICTIMS_EPISODE 12
- EOF
-
- grep -Fq -- '"--force-dry-run"' src/main.c
- grep -Fq 'openlog(ident, LOG_PID | LOG_NDELAY' src/support.c
- grep -Fq 'syslog(priority, "%s", message)' src/support.c
- grep -Fq 'closelog()' src/support.c
- if grep -Eq '(system|popen|execl|execv)[[:space:]]*\(' src/support.c; then
- echo 'FAIL syslog backend must not invoke commands or a shell' >&2
- exit 1
- fi
- grep -Fq '#define CACHED_CANDIDATES 16' src/main.c
- grep -Fq '#define EVENT_QUEUE_SIZE 512' src/main.c
- grep -Fq 'pthread_mutex_trylock(&event_mutex)' src/main.c
- grep -Fq 'pthread_mutex_trylock(&scan_mutex)' src/main.c
- signal_line=$(grep -n ' platform_dispatch' src/main.c | cut -d: -f1)
- commit_line=$(grep -n 'action_commit(&controller' src/main.c | cut -d: -f1)
- enqueue_line=$(grep -n 'enqueue_start = monotime' src/main.c | cut -d: -f1)
- test "$signal_line" -lt "$commit_line"
- test "$commit_line" -lt "$enqueue_line"
- echo 'PASS distribution defaults to ACTION_MODE dry-run; production SMF does not force it'
|