#!/bin/bash
# Test a minimal program that depends on an ASDF system (for detecting
# regressions such as #900099).

set -e

cd ${AUTOPKGTEST_TMP}

HOME=${AUTOPKGTEST_TMP} buildapp --load-system alexandria \
         --eval '(defun main (argv) (princ (alexandria:factorial (parse-integer (second argv)))) (terpri))' \
         --entry main \
         --output factorial || EXIT=$?

if [ ${EXIT:-0} != 0 ]; then
    case $(dpkg --print-architecture) in
        riscv64) exit 77 ;; # ignore failure; see #1117549
        *) exit $EXIT ;;
    esac
fi

f5=$(./factorial 5)

(( $f5 == 120 ))
