xref: /freebsd/tools/boot/lua-test.sh (revision f98c671d073627099f6ac3bd2e79747c5b72caef)
1ca72e2e2SWarner Losh#!/bin/sh
2ca72e2e2SWarner Losh# $FreeBSD$
3ca72e2e2SWarner Losh
4574a8bf9SKyle Evans# Will image the test directory (default /tmp/loadertest) if it doesn't exist
5574a8bf9SKyle Evans
6ca72e2e2SWarner Loshdie() {
7ca72e2e2SWarner Losh    echo $*
8ca72e2e2SWarner Losh    exit 1
9ca72e2e2SWarner Losh}
10ca72e2e2SWarner Losh
11ca72e2e2SWarner Loshdir=$1
12574a8bf9SKyle Evansscriptdir=$(dirname $(realpath $0))
13ca72e2e2SWarner Loshcd $(make -V SRCTOP)/stand
14ca72e2e2SWarner Loshobj=$(make -V .OBJDIR)
15ca72e2e2SWarner Losht=$obj/userboot/test/test
16ca72e2e2SWarner Losh
17ff840987SKyle Evans[ -n "$dir" ] || dir=/tmp/loadertest
18574a8bf9SKyle Evans[ -d "$dir" ] || ${scriptdir}/lua-img.sh ${dir}
19*f98c671dSKyle Evans# We'll try userboot.so from the test directory before plucking it straight out
20*f98c671dSKyle Evans# of .OBJDIR.
21*f98c671dSKyle Evansu=$dir/boot/userboot.so
22*f98c671dSKyle Evans[ -f "$u" ] || u=$obj/userboot/userboot_lua/userboot_lua.so
23ca72e2e2SWarner Losh[ -f "$dir/boot/lua/loader.lua" ] || die "No boot/lua/loader.lua found"
24ca72e2e2SWarner Losh[ -f "$dir/boot/kernel/kernel" ] || die "No kernel to load"
25ca72e2e2SWarner Losh[ -x "$t" ] || die "no userboot test jig found ($t)"
26*f98c671dSKyle Evans[ -f "$u" ] || die "no userboot.so ($u) found"
27ca72e2e2SWarner Losh
28ca72e2e2SWarner Losh$t -h $dir -b $u
29