summaryrefslogtreecommitdiff
path: root/scripts/testing
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-01-20 05:48:21 -0600
committerCraig Jennings <c@cjennings.net>2026-01-20 05:48:21 -0600
commite084842c15ed4ba2ff5e80bf86f4b95035da1aae (patch)
tree6a865b4b7ff1474ffd35c1af50640eff30d77c65 /scripts/testing
parentbb3c3ae1b1b1d28fb4253a2fe18d0d53859c143d (diff)
fix(testing): fix validation script bugs causing false failures
- Add || true to arithmetic increments (set -e exits on ((0++))) - Fix grep -c multi-file output parsing with tr and defaults - Add fallback UFW check via systemctl when ufw status fails - Add dbus-broker timing error to benign patterns (geoclue) - Use grep -h | wc -l for error counting across multiple log files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts/testing')
-rw-r--r--scripts/testing/lib/validation.sh34
1 files changed, 24 insertions, 10 deletions
diff --git a/scripts/testing/lib/validation.sh b/scripts/testing/lib/validation.sh
index 3dc0ce6..7733233 100644
--- a/scripts/testing/lib/validation.sh
+++ b/scripts/testing/lib/validation.sh
@@ -27,7 +27,7 @@ ssh_cmd() {
validation_pass() {
local test_name="$1"
success "$test_name"
- ((VALIDATION_PASSED++))
+ ((VALIDATION_PASSED++)) || true
}
validation_fail() {
@@ -35,7 +35,7 @@ validation_fail() {
local details="${2:-}"
error "$test_name"
[ -n "$details" ] && info " Details: $details"
- ((VALIDATION_FAILED++))
+ ((VALIDATION_FAILED++)) || true
}
validation_warn() {
@@ -43,7 +43,7 @@ validation_warn() {
local details="${2:-}"
warn "$test_name"
[ -n "$details" ] && info " Details: $details"
- ((VALIDATION_WARNINGS++))
+ ((VALIDATION_WARNINGS++)) || true
}
# Attribute an issue to archsetup or base install
@@ -168,8 +168,12 @@ analyze_log_diff() {
# Compare failed services
if [ -f "$output_dir/pre-install/failed-services.txt" ] && [ -f "$output_dir/post-install/failed-services.txt" ]; then
- local pre_failed=$(grep -c "failed" "$output_dir/pre-install/failed-services.txt" 2>/dev/null || echo 0)
- local post_failed=$(grep -c "failed" "$output_dir/post-install/failed-services.txt" 2>/dev/null || echo 0)
+ local pre_failed post_failed
+ pre_failed=$(grep -c "failed" "$output_dir/pre-install/failed-services.txt" 2>/dev/null | tr -d '[:space:]')
+ post_failed=$(grep -c "failed" "$output_dir/post-install/failed-services.txt" 2>/dev/null | tr -d '[:space:]')
+ # Default to 0 if empty
+ pre_failed=${pre_failed:-0}
+ post_failed=${post_failed:-0}
if [ "$post_failed" -gt "$pre_failed" ]; then
warn "New failed services detected (before: $pre_failed, after: $post_failed)"
@@ -203,6 +207,7 @@ categorize_errors() {
"RAS:.*Correctable Errors"
"ACPI.*AE_NOT_FOUND"
"firmware.*regulatory"
+ "Invalid user name.*in service file" # dbus-broker timing during package install
)
# Patterns that indicate archsetup issues
@@ -629,12 +634,18 @@ validate_service_functions() {
# UFW functional test
step "Testing UFW functionality"
- local ufw_status=$(ssh_cmd "ufw status 2>/dev/null | head -1")
- if echo "$ufw_status" | grep -q "active"; then
+ local ufw_status
+ ufw_status=$(ssh_cmd "ufw status 2>&1 | head -1" | tr -d '[:space:]')
+ if echo "$ufw_status" | grep -qi "active"; then
validation_pass "UFW is active and responding"
else
- validation_fail "UFW not active: $ufw_status"
- attribute_issue "UFW not functioning" "archsetup"
+ # Check if the service is at least running
+ if ssh_cmd "systemctl is-active ufw" &>> "$LOGFILE"; then
+ validation_warn "UFW service active but status unclear: $ufw_status"
+ else
+ validation_fail "UFW not active: $ufw_status"
+ attribute_issue "UFW not functioning" "archsetup"
+ fi
fi
# fail2ban functional test
@@ -756,7 +767,10 @@ validate_autologin_config() {
validate_archsetup_log() {
step "Checking archsetup log for errors"
- local error_count=$(ssh_cmd "grep -c '^Error:' /var/log/archsetup-*.log 2>/dev/null || echo 0")
+ local error_count
+ # Use grep -h to suppress filenames, then wc -l to count total matches
+ error_count=$(ssh_cmd "grep -h '^Error:' /var/log/archsetup-*.log 2>/dev/null | wc -l" | tr -d '[:space:]')
+ error_count=${error_count:-0}
if [ "$error_count" = "0" ]; then
validation_pass "No errors in archsetup log"