smoke-test.sh added by mario-goulart on Thu Dec 4 19:57:51 2025

#! /bin/sh

set -ex

usage() {
    cat <<EOF
Usage: $(basename "$0") [-h|-help|--help]

The following environment variables are considered by this script:

* CHICKEN: path to the chicken executable to be used by setting.  By
  default chicken will be used from \$PATH.

* MAKE_JOBS: the maximum number of make jobs to use.  On Linux the
  default value is the output of nproc.  On other systems it is 1.

* C_COMPILER: the C compiler to use.  The default is gcc.

EOF
}

[ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ] && {
    usage
    exit 0
}

chicken=${CHICKEN:-chicken}
c_compiler=${C_COMPILER:-gcc}

make=make
make_jobs=1
case "$(uname)" in
    Linux)
        make_jobs=${MAKE_JOBS:-$(nproc)}
        ;;
    *BSD)
        make=gmake
        ;;
esac

# Using a directory in the current directory as /tmp might be mounted
# on a filesystem that disallow execution.
tmpdir=$(mktemp -p "$PWD" -d smoke-test-XXXXXX.tmp)

# manual-labor is needed by make dist to generate the HTML files of
# the manual
command -v manual-labor >/dev/null 2>&1 || {
    echo "manual-labor could not be found.  Install it with chicken-install." >&2
    exit 1
}

./configure --chicken "$chicken"
make C_COMPILER=$C_COMPILER dist -j "$make_jobs"

tarball_dir=chicken-$(cat buildversion)
tarball=${tarball_dir}.tar.gz

mv "$tarball" "$tmpdir"
cd "$tmpdir"
tar xzf "$tarball"
cd "$tarball_dir"
./configure --prefix "$PWD/../chicken" --chicken "$chicken" --c-compiler "$C_COMPILER"
make -j "$make_jobs"
make install
make check
../chicken/bin/chicken-install -v salmonella
../chicken/bin/salmonella base64
echo "========== ALL GOOD! =========="