diff options
| author | Danilo M. <danix@danix.xyz> | 2026-09-19 12:12:00 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-09-19 12:12:00 +0200 |
| commit | 3b58f17a3fc7f6aa50cfb8bdba14b2321abb4679 (patch) | |
| tree | f57fb6a4a98ad8e263b4522de9ceb97a91108481 /test_compat32ctl.sh | |
| download | install-compat32-3b58f17a3fc7f6aa50cfb8bdba14b2321abb4679.tar.gz install-compat32-3b58f17a3fc7f6aa50cfb8bdba14b2321abb4679.zip | |
Manage AlienBOB's compat32 package collection: mirror the -current tree with lftp, verify it against CHECKSUMS.md5, and install/update/remove the 32-bit layer with upgradepkg/removepkg. Includes a man page and a dry-run self-check.
Diffstat (limited to 'test_compat32ctl.sh')
| -rwxr-xr-x | test_compat32ctl.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test_compat32ctl.sh b/test_compat32ctl.sh new file mode 100755 index 0000000..eadf304 --- /dev/null +++ b/test_compat32ctl.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# Runnable self-check for compat32ctl. +# Exercises argument handling and the --dry-run previews, so it runs anywhere +# (no root, no Slackware pkgtools required). Exits nonzero on any failure. +# +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# SPDX-License-Identifier: GPL-2.0-only +# +set -u +cd "$(dirname "$0")" +failed=0 + +pass() { printf 'ok - %s\n' "$1"; } +fail() { printf 'FAIL - %s\n' "$1"; failed=1; } + +# --- syntax --------------------------------------------------------------- +if bash -n compat32ctl; then pass "syntax (bash -n)"; else fail "syntax (bash -n)"; fi + +# --- argument handling ---------------------------------------------------- +./compat32ctl >/dev/null 2>&1 && fail "no args -> usage, nonzero" || pass "no args -> usage, nonzero" +./compat32ctl help >/dev/null 2>&1 && pass "help -> 0" || fail "help -> 0" +./compat32ctl bogus >/dev/null 2>&1 && fail "unknown cmd -> nonzero" || pass "unknown cmd -> nonzero" + +# --- dry-run previews ----------------------------------------------------- +sync_out=$(./compat32ctl sync -n 2>&1) +printf '%s' "$sync_out" | grep -q 'mirror -c -e -v' && pass "sync -n shows lftp mirror -v" || fail "sync -n shows lftp mirror -v" +printf '%s' "$sync_out" | grep -q 'cmd:show-status on' && pass "sync -n enables lftp status" || fail "sync -n enables lftp status" +printf '%s' "$sync_out" | grep -q 'md5sum -c --ignore-missing' && pass "sync -n shows md5 verify" || fail "sync -n shows md5 verify" + +install_out=$(./compat32ctl install -n 2>&1) +printf '%s' "$install_out" | grep -q 'upgradepkg --install-new' && pass "install -n shows upgradepkg" || fail "install -n shows upgradepkg" +[ "$install_out" = "$(./compat32ctl update -n 2>&1)" ] && pass "update -n matches install -n" || fail "update -n matches install -n" + +# --- remove refuses without root ------------------------------------------ +if [ "$(id -u)" -ne 0 ]; then + ./compat32ctl remove >/dev/null 2>&1 && fail "remove (real) refuses non-root" || pass "remove (real) refuses non-root" +fi + +# --- remove discovery ----------------------------------------------------- +tmp=$(mktemp -d) +touch "$tmp/aaa_libraries-compat32-16.0-x86_64-1compat32" \ + "$tmp/compat32-tools-3.10-noarch-18alien" \ + "$tmp/unrelated-1.0-x86_64-1" +remove_out=$(PKGDIR="$tmp" ./compat32ctl remove -n 2>&1) +rm -rf "$tmp" +printf '%s' "$remove_out" | grep -q 'aaa_libraries-compat32-16.0-x86_64-1compat32' && pass "remove -n finds compat32 libs" || fail "remove -n finds compat32 libs" +printf '%s' "$remove_out" | grep -q 'compat32-tools-3.10-noarch-18alien' && pass "remove -n finds compat32-tools" || fail "remove -n finds compat32-tools" +printf '%s' "$remove_out" | grep -q 'unrelated' && fail "remove -n skips unrelated" || pass "remove -n skips unrelated" + +# --- remove on an empty package db ---------------------------------------- +tmp=$(mktemp -d) +PKGDIR="$tmp" ./compat32ctl remove -n >/dev/null 2>&1 && pass "remove -n empty db -> 0" || fail "remove -n empty db -> 0" +rm -rf "$tmp" + +exit $failed |
