-
Notifications
You must be signed in to change notification settings - Fork 3
/
lab5_test
79 lines (67 loc) · 1.62 KB
/
lab5_test
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
#!/bin/bash
REQUIRED_FILES1="lab5.pdf cs133_lab5 *.xclbin"
REQUIRED_FILES2="cnn.cpp kernel.cl sdaccel_profile_summary.csv"
# usage
if [ $# -ne 1 ]
then
echo "Usage: $0 Your_UID" 1>&2
exit
fi
ORI_DIR=`pwd`
TMP_DIR=/tmp/${1}_tmp
FOLDER_NAME=$1
ZIP_FILE="lab5-${1}.tar.gz"
# clean any existing files
rm -rf ${TMP_DIR}
mkdir ${TMP_DIR}
if [ ! -f ${ZIP_FILE} ]; then
echo "ERROR: Cannot find ${ZIP_FILE}, ensure this script is put in the same directory of your ${ZIP_FILE} file. Otherwise check the tar file name" 1>&2
rm -rf ${TMP_DIR}
echo "rmd"
exit 1
fi
# change directory to the grading folder
cp ${ZIP_FILE} ${TMP_DIR}
cd ${TMP_DIR}
# unzip the submission zip file
tar -xzf ${ZIP_FILE}
if [ "$?" -ne "0" ]; then
echo "ERROR: Cannot unzip ${ZIP_FILE} to ${TMP_DIR}"
rm -rf ${TMP_DIR}
exit 1
fi
if [ ! -d ${FOLDER_NAME} ];
then
echo "Check your folder name is EXACTLY the same as UID you typed"
rm -rf ${TMP_DIR}
exit 1
fi
cd ${FOLDER_NAME}
# check the existence of the required files
for FILE in ${REQUIRED_FILES1}
do
if [ ! -f ${FILE} ]; then
echo "ERROR: Cannot find ${FILE} in the root folder of your tar file" 1>&2
rm -rf ${TMP_DIR}
exit 1
fi
done
OCL_FOLDER=opencl
if [ ! -d ${OCL_FOLDER} ];
then
echo "ERROR: Cannot find ${OCL_FOLDER} folder" 1>&2
rm -rf ${TMP_DIR}
exit 1
fi
cd ${OCL_FOLDER}
for FILE in ${REQUIRED_FILES2}
do
if [ ! -f ${FILE} ]; then
echo "ERROR: Cannot find ${FILE} in the ${OCL_FOLDER} folder of your tar file" 1>&2
rm -rf ${TMP_DIR}
exit 1
fi
done
echo "Check File Successfully. Please upload your ${ZIP_FILE} file to GradeScope."
rm -rf ${TMP_DIR}
exit 0