This repository has been archived by the owner on Apr 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
193 lines (171 loc) · 9.21 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
CC = gcc
CFLAGS = -g -Wall -std=c99 -c
LDFLAGS = -g -Wall
CUNIT = -L/home/ff/cs61c/cunit/install/lib -I/home/ff/cs61c/cunit/install/include -lcunit
BUILD_DIR = ./build
# A phony target is one that is not really the name of a file;
# rather it is just a name for a recipe to be executed when you make an explicit request.
# You can read more about them here: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY : all test clean unittest
all : philphix
philphix : philphix.o hashtable.o
$(CC) $(LDFLAGS) -o philphix $(BUILD_DIR)/philphix.o $(BUILD_DIR)/hashtable.o
philphix.o : src/philphix.c src/philphix.h src/hashtable.h build_dir
$(CC) $(CFLAGS) src/philphix.c -o $(BUILD_DIR)/philphix.o
hashtable.o : src/hashtable.c src/hashtable.h build_dir
$(CC) $(CFLAGS) src/hashtable.c -o $(BUILD_DIR)/hashtable.o
build_dir :
mkdir -p $(BUILD_DIR)
clean :
rm -f $(BUILD_DIR)/*.o philphix unittest
# Make sure you leave testpassedall as the last thing in this line. You can add your own custom tests before it.
test: test_basic test_alphanumeric test_large_dict test_capitalization test_empty test_tabs_and_spaces test_numbers test_no_newline test_no_newline_longer test_binary test_long_word_input test_long_word_dict testpassedall
test_basic: clean philphix
touch tests/basic/test_basic.out
rm tests/basic/test_basic.out
@echo "================Running Program...================="
cat tests/basic/test_basic.in | ./philphix tests/basic/test_basic.dict > tests/basic/test_basic.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/basic/test_basic.out tests/basic/test_basic.ref
@echo "-----------------------None!-----------------------"
@echo
test_alphanumeric: clean philphix
touch tests/alphanumeric/test_alphanumeric.out
rm tests/alphanumeric/test_alphanumeric.out
@echo "================Running Program...================="
cat tests/alphanumeric/test_alphanumeric.in | ./philphix tests/alphanumeric/test_alphanumeric.dict > tests/alphanumeric/test_alphanumeric.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/alphanumeric/test_alphanumeric.out tests/alphanumeric/test_alphanumeric.ref
@echo "-----------------------None!-----------------------"
@echo
test_large_dict: clean philphix
touch tests/large_dict/test_large_dict.out
rm tests/large_dict/test_large_dict.out
@echo "================Running Program...================="
cat tests/large_dict/test_large_dict.in | ./philphix tests/large_dict/test_large_dict.dict > tests/large_dict/test_large_dict.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/large_dict/test_large_dict.out tests/large_dict/test_large_dict.ref
@echo "-----------------------None!-----------------------"
@echo
test_capitalization: clean philphix
touch tests/capitalization/test_capitalization.out
rm tests/capitalization/test_capitalization.out
@echo "================Running Program...================="
cat tests/capitalization/test_capitalization.in | ./philphix tests/capitalization/test_capitalization.dict > tests/capitalization/test_capitalization.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/capitalization/test_capitalization.out tests/capitalization/test_capitalization.ref
@echo "-----------------------None!-----------------------"
@echo
test_empty: clean philphix
touch tests/empty/test_empty.out
rm tests/empty/test_empty.out
@echo "================Running Program...================="
cat tests/empty/test_empty.in | ./philphix tests/empty/test_empty.dict > tests/empty/test_empty.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/empty/test_empty.out tests/empty/test_empty.ref
@echo "-----------------------None!-----------------------"
@echo
test_tabs_and_spaces: clean philphix
touch tests/tabs_and_spaces/test_tabs_and_spaces.out
rm tests/tabs_and_spaces/test_tabs_and_spaces.out
@echo "================Running Program...================="
cat tests/tabs_and_spaces/test_tabs_and_spaces.in | ./philphix tests/tabs_and_spaces/test_tabs_and_spaces.dict > tests/tabs_and_spaces/test_tabs_and_spaces.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/tabs_and_spaces/test_tabs_and_spaces.out tests/tabs_and_spaces/test_tabs_and_spaces.ref
@echo "-----------------------None!-----------------------"
@echo
test_numbers: clean philphix
touch tests/numbers/test_numbers.out
rm tests/numbers/test_numbers.out
@echo "================Running Program...================="
cat tests/numbers/test_numbers.in | ./philphix tests/numbers/test_numbers.dict > tests/numbers/test_numbers.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/numbers/test_numbers.out tests/numbers/test_numbers.ref
@echo "-----------------------None!-----------------------"
@echo
test_no_newline: clean philphix
touch tests/no_newline/test_no_newline.out
rm tests/no_newline/test_no_newline.out
@echo "================Running Program...================="
cat tests/no_newline/test_no_newline.in | ./philphix tests/no_newline/test_no_newline.dict > tests/no_newline/test_no_newline.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/no_newline/test_no_newline.out tests/no_newline/test_no_newline.ref
@echo "-----------------------None!-----------------------"
@echo
test_no_newline_longer: clean philphix
touch tests/no_newline_longer/test_no_newline_longer.out
rm tests/no_newline_longer/test_no_newline_longer.out
@echo "================Running Program...================="
cat tests/no_newline_longer/test_no_newline_longer.in | ./philphix tests/no_newline_longer/test_no_newline_longer.dict > tests/no_newline_longer/test_no_newline_longer.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/no_newline_longer/test_no_newline_longer.out tests/no_newline_longer/test_no_newline_longer.ref
@echo "-----------------------None!-----------------------"
@echo
test_binary: clean philphix
touch tests/binary/test_binary.out
rm tests/binary/test_binary.out
@echo "================Running Program...================="
cat tests/binary/test_binary.in | ./philphix tests/binary/test_binary.dict > tests/binary/test_binary.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/binary/test_binary.out tests/binary/test_binary.ref
@echo "-----------------------None!-----------------------"
@echo
test_long_word_input: clean philphix
touch tests/long_word_input/test_long_word_input.out
rm tests/long_word_input/test_long_word_input.out
@echo "================Running Program...================="
cat tests/long_word_input/test_long_word_input.in | ./philphix tests/long_word_input/test_long_word_input.dict > tests/long_word_input/test_long_word_input.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/long_word_input/test_long_word_input.out tests/long_word_input/test_long_word_input.ref
@echo "-----------------------None!-----------------------"
@echo
test_long_word_dict: clean philphix
touch tests/long_word_dict/test_long_word_dict.out
rm tests/long_word_dict/test_long_word_dict.out
@echo "================Running Program...================="
cat tests/long_word_dict/test_long_word_dict.in | ./philphix tests/long_word_dict/test_long_word_dict.dict > tests/long_word_dict/test_long_word_dict.out
@echo "================Program Finished!=================="
@echo ""
@echo "Difference between test output and reference output"
@echo "---------------------------------------------------"
@diff tests/long_word_dict/test_long_word_dict.out tests/long_word_dict/test_long_word_dict.ref
@echo "-----------------------None!-----------------------"
@echo
testpassedall:
@echo "You have passed all of the tests!"
unittest:
$(CC) $(LDFLAGS) -D _PHILPHIX_UNITTEST ./tests/phil_test.c ./src/philphix.c ./src/hashtable.c -o unittest $(CUNIT)
./unittest