-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (67 loc) · 2.12 KB
/
Makefile
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
RAND := $(shell awk 'BEGIN{srand();printf("%d", 65536*rand())}')
DIR := workplace
# This is only for TAs to run base test, students do not know the token
TOKEN_SHA1 := $(shell echo -n '$(passwd)' | sha1sum | xargs | awk -F' ' '{ print $$1 }')
ifeq ($(TOKEN_SHA1), 2ade230f77ab63c1a4b5abd7c34ea308a692d8e4)
BASE := 1
BASE_CHAR := b
else
BASE := 0
# For students, report will be counted in to pass the CI
ifeq ($(CHAPTER), 3)
LAB := 1
else ifeq ($(CHAPTER), 4)
LAB := 2
else ifeq ($(CHAPTER), 5)
LAB := 3
else ifeq ($(CHAPTER), 6)
LAB := 4
else ifeq ($(CHAPTER), 7)
# For ch7 we have no ch7_usertest, so just run ch7b_usertest to pass the CI
BASE_CHAR := b
LAB := 4
else ifeq ($(CHAPTER), 8)
LAB := 5
endif
endif
randomize:
find $(DIR)/user/src -name "*.c" | xargs -I {} sh -c 'sed -i.bak 's/OK/OK$(RAND)/g' {} && rm -rf {}.bak'
find check -name "*.py" | xargs -I {} sh -c 'sed -i.bak 's/OK/OK$(RAND)/g' {} && rm -rf {}.bak'
test: randomize
mkdir -p $(DIR)/os
cp ../os/* $(DIR)/os/
cp overwrite/Makefile $(DIR)/Makefile
ifeq ($(shell test $(CHAPTER) -ge 6; echo $$?),0)
cp overwrite/Makefile-nfs $(DIR)/Makefile
mkdir -p $(DIR)/nfs
cp ../nfs/* $(DIR)/nfs/
endif
ifeq ($(CHAPTER), 1)
echo `no ci for ch1`
else ifeq ($(CHAPTER), 2)
echo `no ci for ch2`
else ifeq ($(CHAPTER), 5)
make -C $(DIR) clean
make -C $(DIR) test CHAPTER=5 BASE=$(BASE) INIT_PROC=ch5$(BASE_CHAR)_usertest | tee stdout-ch5
python3 check/ch5$(BASE_CHAR).py < stdout-ch5
ifndef BASE
make -C $(DIR) clean
make -C $(DIR) test CHAPTER=5t BASE=0 INIT_PROC=ch5t_usertest | tee stdout-ch5t
python3 check/ch5t.py < stdout-ch5 #t
endif
else
make -C $(DIR) clean
make -C $(DIR) test CHAPTER=$(CHAPTER) BASE=$(BASE) INIT_PROC=ch$(CHAPTER)$(BASE_CHAR)_usertest | tee stdout-ch$(CHAPTER)
python3 check/ch$(CHAPTER)$(BASE_CHAR).py < stdout-ch$(CHAPTER)
endif
ifdef LAB
@for i in $(shell seq $(LAB)); do \
if ! [ -f ../reports/lab$$i.pdf -o -f ../reports/lab$$i.md ]; then \
echo "Report for lab$$i needed. Add your report to reports/lab$$i.pdf or reports/lab$$i.md" ; \
exit 1 ; \
else \
echo "Report for lab$$i found." ; \
fi; \
done
endif
.PHONY: test