-
Notifications
You must be signed in to change notification settings - Fork 9
/
landslide
executable file
·113 lines (96 loc) · 3.4 KB
/
landslide
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
IDDIR=id
IDEXE=landslide-id
if [ ! -d "pebsim" -o ! -d "work" ]; then
echo -e "\033[01;31m$0 must be run from the root of the landslide repository.\033[00m"
exit 1
fi
if [ ! -f "$IDDIR/$IDEXE" ]; then
echo -e "\033[01;31mp2-setup.sh was not run or did not succeed.\033[00m"
exit 1
fi
if [ "`cat pebsim/current-architecture.txt 2>/dev/null`" = "p2" ]; then
cd pebsim/p2-basecode
./check-need-p2-setup-again.sh || exit 1
cd ../../
# try to find the program name and check the kernel is built with it
# if we let until build.sh to catch this error, quicksand will hang
if echo "$@" | grep -- "-p " >/dev/null; then
TEST_CASE=`echo " $@" | sed 's/.* -p *//' | sed 's/ .*//'`
KERNEL_IMG=pebsim/kernel
if ! grep "${TEST_CASE}_exec2obj_userapp_code_ptr" $KERNEL_IMG 2>&1 >/dev/null; then
echo -e "\033[01;31mSpecified test program '$TEST_CASE' wasn't built with your p2.\033[00m"
echo -e "\033[01;31mPlease consult lecture slide #34 regarding Landslide-friendly tests,\033[00m"
echo -e "\033[01;31mor consult the user guide point 3(d) on how to include custom test cases.\033[00m"
exit 1
fi
fi
fi
SUFFIX=`date +%Y%m%d%H%M%S`
CMDLINE_OPTION_FILE=`mktemp "ls-id-options-$SUFFIX.cfg.XXXXXXXX"`
echo "$@" > $CMDLINE_OPTION_FILE
WRAPPER_LOG="ls-id-log-$SUFFIX.log"
# this should really be using flock instead
LOCKFILE="landslide_already_running_in_this_directory"
# students, if you're reading this, WHAT'S WRONG WITH THIS CODE??
if [ -f "$LOCKFILE" ]; then
echo -e "\033[01;31mIt seems like Landslide is already running in this directory.\033[00m"
echo -e "\033[01;31mIf you want to run multiple Landslides at once, please make a separate\033[00m"
echo -e "\033[01;31m'git clone' and run one Landslide in each.(see user guide, page 2).\033[00m"
echo -e "\033[01;31mTo override this message, remove the file '$LOCKFILE'.\033[00m"
exit 1
else
touch "$LOCKFILE"
fi
ORIGDIR="$PWD"
cd "$IDDIR"
./$IDEXE -L $WRAPPER_LOG "$@"
RV=$?
cd "$ORIGDIR"
rm -f "$LOCKFILE"
ID_EXIT_USAGE=2
ID_EXIT_CTRL_C=3
if [ "$RV" = "$ID_EXIT_USAGE" ]; then
exit $RV
elif [ "$RV" = "$ID_EXIT_CTRL_C" ]; then
reset -I
echo
fi
echo -e "\033[01;33mSaving results. Please be patient.\033[00m"
for logfile in id/ls*log*; do
gzip -q $logfile
done
#SNAPSHOT_DIR="/afs/cs.cmu.edu/academic/class/15410-f18/user/$USER/mygroup/landslide/"
#TEMP_SNAP_DIR="/dev/shm"
#SNAPSHOT_NAME="ls-snap-$USER-$SUFFIX.tar.bz2"
#umask 077
#tar cvjf "$TEMP_SNAP_DIR/$SNAPSHOT_NAME" \
# --exclude="pebsim/p2-basecode/410user/*" \
# --exclude="pebsim/p2-basecode/410kern/*" \
# --exclude="pebsim/p2-basecode/temp/*" \
# --exclude=".git/*" \
# --exclude="work/*" \
# --exclude="tests/*" \
# --exclude="*.o" \
# --exclude="*.a" \
# --exclude="*.bz2" \
# --exclude="*.dep" \
# --exclude="*.py" \
# --exclude="*.pyc" \
# --exclude="*landslide-id" \
# --exclude="*kernel" \
# --exclude="*bootfd.img" \
# --exclude="*kernel.strip" \
# --exclude="*kernel.log" \
# "./" >/dev/null
#mv "$TEMP_SNAP_DIR/$SNAPSHOT_NAME" "$SNAPSHOT_DIR"
#MV_RV=$?
#if [ "$MV_RV" != "0" ]; then
# echo -e "\033[01;31mFailed to save snapshot ($TEMP_SNAP_DIR/$SNAPSHOT_NAME) into 410 AFS space ($SNAPSHOT_DIR). Please email Ben <bblum@cs.cmu.edu> for support, and copy that .tar.bz2 file as an attachment."
# echo -e "\033[00m(landslide's exit code was $RV)"
# exit 1
#fi
#
## prevent quadratic usage of student AFS volume space :O
#rm -f id/ls*log* pebsim/config.quicksand.* pebsim/pps-and-such.quicksand.*
exit $RV