-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmakefile
337 lines (287 loc) · 9.48 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
CF_AGENT = cf-agent
EFL_LIB = masterfiles/lib/EFL
CF_REPO = https://github.com/cfengine
CSVTOJSON = ./bin/eflconvert -i csv -o json
CSVTOYAML = ./bin/eflconvert -i csv -o yaml
export PATH := /usr/local/bin:/usr/local/sbin:$(PATH)
# Don't changes this, it's hard coded in some CF policy data
TEST_DIR = /tmp/efl_test
EFL_FILES = \
$(EFL_LIB)/efl_common.cf \
$(EFL_LIB)/evolve_freelib.cf \
$(EFL_LIB)/efl_update.cf
EFL_TEST_FILES = \
test/$(EFL_LIB)/efl_common.cf \
test/$(EFL_LIB)/evolve_freelib.cf \
test/$(EFL_LIB)/efl_update.cf
AUTORUN = masterfiles/services/autorun/efl.cf
eflmaker = ./bin/eflmaker
cfstdlib = \
test/lib/commands.cf \
test/lib/processes.cf \
test/lib/feature.cf \
test/lib/vcs.cf \
test/lib/cfe_internal.cf \
test/lib/reports.cf \
test/lib/guest_environments.cf \
test/lib/bundles.cf \
test/lib/services.cf \
test/lib/common.cf \
test/lib/users.cf \
test/lib/storage.cf \
test/lib/packages.cf \
test/lib/paths.cf \
test/lib/files.cf \
test/lib/databases.cf \
test/lib/edit_xml.cf \
test/lib/examples.cf \
test/lib/monitor.cf \
test/lib/stdlib.cf
.PHONY: all
all: $(EFL_FILES) $(AUTORUN) $(EFL_TEST_FILES)
$(EFL_FILES): $(EFL_LIB) src/includes/param_parser.cf \
src/includes/param_file_picker.cf src/$@
cp src/$@ $@
$(eflmaker) --tar $@ \
--tag no_csv_param_parser -i src/includes/no_csv_param_parser.cf
$(eflmaker) --tar $@ \
--tag param_parser -i src/includes/param_parser.cf
$(eflmaker) --tar $@ \
--tag param_file_picker -i src/includes/param_file_picker.cf
$(EFL_TEST_FILES): $(EFL_FILES) $(cfstdlib) test/$(EFL_LIB)
cp -r $(EFL_LIB)/$(notdir $@) test/$(EFL_LIB)
$(TEST_DIR):
mkdir -p $@
$(EFL_LIB):
mkdir -p $@
test/$(EFL_LIB):
mkdir -p $@
$(AUTORUN): src/masterfiles/services/autorun src/$@
mkdir -p masterfiles/services/autorun
cp -r src/$@ $@
$(cfstdlib): .stdlib
.stdlib:
cd test/masterfiles/; svn export --force \
$(CF_REPO)/masterfiles/trunk/lib/
touch $@
#
# Test, tests, and more tests
#
.PHONY: version
version:
prove t/00_version.t
.PHONY: syntax
syntax: $(cfstdlib) test/$(EFL_LIB) $(EFL_TEST_FILES)
prove t/01_syntax.t
#
# For converting csv files
#
test/masterfiles/efl_data/efl_test_classes/%.json:
CSVTOJSON="../../../../$(CSVTOJSON)" \
$(MAKE) --directory=test/masterfiles/efl_data/efl_test_classes \
$*.json
test/masterfiles/efl_data/efl_test_vars/%.json:
CSVTOJSON="../../../../$(CSVTOJSON)" \
$(MAKE) --directory=test/masterfiles/efl_data/efl_test_vars\
$*.json
# TODO does this ensure efl_main.json is made?
test/masterfiles/efl_data/efl_main.json: \
test/masterfiles/efl_data/efl_main.csv
CSVTOJSON="../../../$(CSVTOJSON)" \
$(MAKE) --directory=test/masterfiles/efl_data/ efl_main.json
test/masterfiles/efl_data/%.json:
CSVTOJSON="../../../$(CSVTOJSON)" \
$(MAKE) --directory=test/masterfiles/efl_data/ $*.json
#
# Calculate json dependencies
# TODO yaml
efl_data_csv_files = $(wildcard test/masterfiles/efl_data/*.csv)
efl_data_json_files = $(patsubst %.csv,%.json,$(efl_data_csv_files))
efl_test_classes_csv_files = \
$(wildcard test/masterfiles/efl_data/efl_test_classes/*.csv)
efl_test_classes_json_files = \
$(patsubst %.csv,%.json,$(efl_test_classes_csv_files))
efl_test_vars_csv_files = \
$(wildcard test/masterfiles/efl_data/efl_test_vars/*.csv)
efl_test_vars_json_files = \
$(patsubst %.csv,%.json,$(efl_test_vars_csv_files))
#
# iteration order tests
#
# TODO yaml order test
io_csv_test_files = \
test/masterfiles/efl_data/efl_test_classes/01_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/02_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/03_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/04_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/05_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/06_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/07_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/08_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/09_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/10_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/11_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/12_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/13_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/14_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/15_iteration_order.csv \
test/masterfiles/efl_data/efl_test_classes/16_iteration_order.csv
io_json_test_files = $(subst csv,json,$(io_csv_test_files))
.PHONY: iteration_order
iteration_order: version syntax test/masterfiles/efl_data/efl_main.json \
$(io_json_test_files)
prove t/iteration_order.t
#
# Test bundles that test other bundles
#
.SECONDEXPANSION:
efl_test_bundles = efl_test_classes efl_test_vars
.PHONY: $(efl_test_bundles)
$(efl_test_bundles): version syntax \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/$$@/$$@.json
prove t/*$@*.t
#
# Testing class generation bundles
#
test_bundles_with_efl_test_classes = \
efl_class_returnszero \
efl_class_cmd_regcmp \
efl_class_expression \
efl_class_classmatch \
efl_class_iprange
.PHONY: $(test_bundles_with_efl_test_classes)
$(test_bundles_with_efl_test_classes): version syntax $(efl_test_bundles) \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/$$@.json \
test/masterfiles/efl_data/efl_test_classes/$$@.json
prove t/$@_csv.t
prove t/$@_json.t
##
.PHONY: efl_class_hostname
efl_class_hostname: version syntax $(efl_test_bundles) \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/efl_class_hostname-017_test_class.txt \
test/masterfiles/efl_data/efl_test_classes/$$@.json
prove t/$@_csv.t
prove t/$@_json.t
##
.PHONY: efl_class_hostname2
efl_class_hostname2: version syntax $(efl_test_bundles) \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/efl_class_hostname2.json \
test/masterfiles/efl_data/efl_test_classes/$$@.json
prove t/$@_csv.t
prove t/$@_json.t
##
test_bundles_with_efl_test_vars = efl_global_strings
.PHONY: $(test_bundles_with_efl_test_vars)
$(test_bundles_with_efl_test_vars): version syntax $(efl_test_bundles) \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/$$@.json \
test/masterfiles/efl_data/efl_test_vars/$$@.json
prove t/30_$@_csv.t
prove t/31_$@_json.t
##
.PHONY: efl_global_slists
efl_global_slists: version syntax \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/efl_global_slists.json
prove t/40_efl_global_slists.t
#
# Testing normal agent bundles
#
test_efl_bundles = \
efl_file_perms \
efl_sysctl_live \
efl_sysctl_conf_file \
efl_command \
efl_link \
efl_delete_files \
efl_copy_files \
efl_rcs_pull
.PHONY: $(test_efl_bundles)
$(test_efl_bundles): version syntax \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/$$@.json
prove t/$@.t
test_efl_packages_bundles = \
efl_packages \
efl_packages_via_cmd \
efl_packages_new
.PHONY: $(test_efl_packages_bundles)
$(test_efl_packages_bundles): version syntax \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/efl_packages.json \
test/masterfiles/efl_data/efl_packages_new.json
prove t/efl_packages.t :: --bundle $@
#
# efl_service* bundles testing
#
.PHONY: test_daemon
test_daemon:
TEST_DIR=$(TEST_DIR) $(MAKE) --directory=test/test_daemon all
.PHONY: templates
templates:
TEST_DIR=$(TEST_DIR) $(MAKE) --directory=test/templates all
test_efl_service_bundles = \
efl_start_service \
efl_service_recurse \
efl_service \
.PHONY: $(test_efl_service_bundles)
$(test_efl_service_bundles): version syntax test_daemon templates \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/efl_global_strings.json \
test/masterfiles/efl_data/efl_global_slists.json \
test/masterfiles/efl_data/$$@.json
prove t/$@.t
test_efl_enable_disable_services = \
efl_enable_service \
efl_disable_service
.PHONY: $(test_efl_enable_disable_services)
$(test_efl_enable_disable_services): version syntax test_daemon \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/$$@.json
prove t/$@.t
.PHONY: efl_edit_template
efl_edit_template: version syntax templates \
test/masterfiles/efl_data/efl_main.json \
test/masterfiles/efl_data/efl_global_strings.json \
test/masterfiles/efl_data/efl_global_slists.json \
test/masterfiles/efl_data/$$@.json
prove t/$@.t
.PHONY: efl_kill_process
efl_kill_process: version syntax efl_start_service \
test/masterfiles/efl_data/efl_main.json
prove t/$@.t
.PHONY: pre_check
# TODO how to make all json and yaml files here?
pre_check: test/$(EFL_LIB) $(cfstdlib) $(EFL_FILES) \
$(io_json_test_files) \
$(efl_data_json_files) \
$(efl_test_classes_json_files) \
$(efl_test_vars_json_files) \
test_daemon \
templates
.PHONY: check
check: pre_check
prove t/*.t
.PHONY: clean
clean:
/bin/systemctl stop $(test_systemd_def); \
rm -fr masterfiles/*
rm -f .stdlib
rm -fr test/$(EFL_LIB)
$(MAKE) --directory=test/masterfiles/efl_data/ clean
$(MAKE) --directory=test/masterfiles/efl_data/efl_test_classes clean
$(MAKE) --directory=test/masterfiles/efl_data/efl_test_vars clean
$(MAKE) --directory=test/test_daemon clean
rm -fr $(TEST_DIR)
rm -f /tmp/ssh/ssh_config
.PHONY: help
help:
$(MAKE) --print-data-base --question | \
awk '/^[^.%][-A-Za-z0-9_]*:/ \
{ print substr($$q, 1, length($$1)-1) }' | \
sort | \
pr --omit-pagination --width=80 --columns=4