-
Notifications
You must be signed in to change notification settings - Fork 3
/
check_examples.sh
executable file
·83 lines (69 loc) · 1.92 KB
/
check_examples.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# export environment variables that MESA needs
export MESA_CONTRIB_DIR=$(pwd)
export MESA_FORCE_PGSTAR_FLAG=false
# make tmpdir for testing
# local to script; MESA doesn't need it so no need to export
MESA_WORK_DIR_BASE=$(mktemp -d)
# arguments are
# 1. folder name of hook
# 2. module name (star/binary/astero)
do_one(){
(
echo checking "$1" "$2"
EXAMPLE_DIR="${MESA_CONTRIB_DIR}"/"$1""$2"_example
# if this kind of example doesn't exist, exit
if [ ! -d "${EXAMPLE_DIR}" ]; then
exit
fi
# set MESA_WORK_DIR
MESA_WORK_DIR="${MESA_WORK_DIR_BASE}"/"$1""$2"
mkdir -p "${MESA_WORK_DIR}"
# go there
cd "${MESA_WORK_DIR}" || exit
# copy in files from stock workdir
cp -r "${MESA_DIR}"/"$2"/work/* .
# copy in example test files
# cp -vr "${EXAMPLE_DIR}"/src/* src/
cp -vr "${EXAMPLE_DIR}"/* ./
# try and make it
if ./mk > mk.out 2> mk.err; then
if [ -s 'mk.err' ]; then
echo "[COMPILE WARN]"
echo "see $MESA_WORK_DIR for details"
exit
else
echo "[COMPILE OK]"
# cleanup
# rm -rf "${MESA_WORK_DIR}"
fi
else
echo "[COMPILE FAIL]"
echo "see $MESA_WORK_DIR for details"
exit
fi
# try to run it
if ./rn > rn.out 2> rn.err; then
if [ -s 'rn.err' ]; then
echo "[RUN WARN]"
echo "see $MESA_WORK_DIR for details"
exit
else
echo "[RUN OK]"
# cleanup
rm -rf "${MESA_WORK_DIR}"
fi
else
echo "[RUN FAIL]"
echo "see $MESA_WORK_DIR for details"
exit
fi
)
}
echo
for d in hooks/*/ ; do
do_one "$d" star
do_one "$d" binary
do_one "$d" astero
echo
done