xref: /freebsd/tools/boot/lua-test.sh (revision 2008043f386721d58158e37e0d7e50df8095942d)
1#!/bin/sh
2
3# Will image the test directory (default /tmp/loadertest) if it doesn't exist
4
5die() {
6    echo $*
7    exit 1
8}
9
10dir=$1
11scriptdir=$(dirname $(realpath $0))
12cd $(make -V SRCTOP)/stand
13obj=$(make -V .OBJDIR)
14t=$obj/userboot/test/test
15
16[ -n "$dir" ] || dir=/tmp/loadertest
17[ -d "$dir" ] || ${scriptdir}/lua-img.sh ${dir}
18# We'll try userboot.so from the test directory before plucking it straight out
19# of .OBJDIR.
20u=$dir/boot/userboot.so
21[ -f "$u" ] || u=$obj/userboot/userboot_lua/userboot_lua.so
22[ -f "$dir/boot/lua/loader.lua" ] || die "No boot/lua/loader.lua found"
23[ -f "$dir/boot/kernel/kernel" ] || die "No kernel to load"
24[ -x "$t" ] || die "no userboot test jig found ($t)"
25[ -f "$u" ] || die "no userboot.so ($u) found"
26
27$t -h $dir -b $u
28