jdk

Форк
0
/
TestMakeBase.gmk 
727 строк · 23.9 Кб
1
#
2
# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
#
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.
8
#
9
# This code is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
# version 2 for more details (a copy is included in the LICENSE file that
13
# accompanied this code).
14
#
15
# You should have received a copy of the GNU General Public License version
16
# 2 along with this work; if not, write to the Free Software Foundation,
17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
#
19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
# or visit www.oracle.com if you need additional information or have any
21
# questions.
22
#
23

24
default: all
25

26
include $(SPEC)
27
include MakeBase.gmk
28
include UtilsForTests.gmk
29

30
THIS_FILE := $(TOPDIR)/test/make/TestMakeBase.gmk
31
DEPS := $(THIS_FILE) \
32
    $(TOPDIR)/make/common/MakeBase.gmk \
33
    #
34

35
OUTPUT_DIR := $(TESTMAKE_OUTPUTDIR)/make-base
36
$(call MakeDir, $(OUTPUT_DIR))
37

38
################################################################################
39
# Escape $
40
ifneq ($(call EscapeDollar, foo$$bar), foo\$$bar)
41
  $(error EscapeDollar failed $(call EscapeDollar, foo$$bar) foo\$$bar)
42
endif
43

44
ESCAPE_DOLLAR_DIR := $(OUTPUT_DIR)/escape-dollar
45

46
$(ESCAPE_DOLLAR_DIR)/_escape_dollar: $(DEPS)
47
	$(RM) -r $(@D)
48
	$(MKDIR) -p $(@D)
49
	$(ECHO) foo\$$bar > $(@D)/file1
50
	$(ECHO) $(call EscapeDollar, foo$$bar) > $(@D)/file2
51
	$(ECHO) $(call EscapeDollar, foo\$$bar) > $(@D)/file3
52
	$(DIFF) $(@D)/file1 $(@D)/file2
53
	$(DIFF) $(@D)/file1 $(@D)/file3
54
	$(TOUCH) $@
55

56
TEST_TARGETS += $(ESCAPE_DOLLAR_DIR)/_escape_dollar
57

58
################################################################################
59
# Test containing and not-containing
60

61
CONT_LIST := foo bar baz foobar foobaz
62

63
# Param 1 - string to look for
64
# Param 2 - expected result
65
define TestContaining
66
  value := $$(call containing, $1, $(CONT_LIST))
67
  ifneq ($$(value), $2)
68
    $$(info (call containing, $1, $(CONT_LIST)))
69
    $$(error result >$$(value)<, expected >$2<)
70
  endif
71
endef
72

73
$(eval $(call TestContaining,bar,bar foobar))
74
$(eval $(call TestContaining,foo bar,foo bar foobar foobaz))
75

76
# Param 1 - string to look for
77
# Param 2 - expected result
78
define TestNotContaining
79
  value := $$(call not-containing, $1, $(CONT_LIST))
80
  ifneq ($$(value), $2)
81
    $$(info (call not-containing, $1, $(CONT_LIST)))
82
    $$(error result >$$(value)<, expected >$2<)
83
  endif
84
endef
85

86
$(eval $(call TestNotContaining,bar,foo baz foobaz))
87
$(eval $(call TestNotContaining,foo bar,baz))
88

89
################################################################################
90
# Test Equals
91

92
EQUALS_VALUE1 := value1$(SPACE)
93
EQUALS_VALUE2 := value2
94
EQUALS_EMPTY :=
95

96
ifneq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE2)), )
97
  $(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE2)< are equal)
98
endif
99

100
ifeq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE1)), )
101
  $(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE1)< are not equal)
102
endif
103

104
ifeq ($(call equals, $(EQUALS_EMPTY), $(EQUALS_EMPTY)), )
105
  $(error The strings >$(EQUALS_EMPTY)< and >$(EQUALS_EMPTY)< are not equal)
106
endif
107

108
ifneq ($(call equals, $(EQUALS_EMPTY), $(EQUALS_VALUE2)), )
109
  $(error The strings >$(EQUALS_EMPTY)< and >$(EQUALS_VALUE2)< are equal)
110
endif
111

112
ifneq ($(call equals, $(EQUALS_VALUE2), $(EQUALS_EMPTY)), )
113
  $(error The strings >$(EQUALS_VALUE2)< and >$(EQUALS_EMPTY)< are equal)
114
endif
115

116
################################################################################
117
# Test boolean operators
118

119
$(eval $(call assert-equals, $(call And,  true  true  true ), true))
120
$(eval $(call assert-equals, $(call And,  true  false true ), false))
121
$(eval $(call assert-equals, $(call And,  false false false ), false))
122
$(eval $(call assert-equals, $(call And, true), true))
123
$(eval $(call assert-equals, $(call And, false), false))
124
$(eval $(call assert-equals, $(call And,    ), true))
125

126
$(eval $(call assert-equals, $(call Or,  true  true  true ), true))
127
$(eval $(call assert-equals, $(call Or,  true  false true ), true))
128
$(eval $(call assert-equals, $(call Or,  false false false ), false))
129
$(eval $(call assert-equals, $(call Or, true), true))
130
$(eval $(call assert-equals, $(call Or, false), false))
131
$(eval $(call assert-equals, $(call Or,    ), false))
132

133
# We cannot catch $(error) while testing, but you can enable this manually
134
# by uncommenting and watch make fails.
135
#$(eval $(call assert-equals, $(call And,  non-boolean  ), $(error ...)))
136
#$(eval $(call assert-equals, $(call Or,  non-boolean  ), $(error ...)))
137

138
################################################################################
139
# Test remove-prefixes
140

141
$(call AssertEquals, \
142
    $(call remove-prefixes, pre, prefix postfix), fix postfix, \
143
    Prefixes not properly removed)
144

145
$(call AssertEquals, \
146
    $(call remove-prefixes, pre post, prefix postfix), fix fix, \
147
    Prefixes not properly removed)
148

149
################################################################################
150
# Test ShellQuote
151

152
SHELL_QUOTE_VALUE := foo '""' "''" bar
153
SHELL_QUOTE_RESULT := $(shell $(ECHO) $(call ShellQuote, \
154
    $(SHELL_QUOTE_VALUE)))
155

156
ifneq ($(SHELL_QUOTE_VALUE), $(SHELL_QUOTE_RESULT))
157
  $(error Expected: >$(SHELL_QUOTE_VALUE)< - Result: >$(SHELL_QUOTE_RESULT)<)
158
endif
159

160
################################################################################
161
# Test read and write to file
162

163
READ_WRITE_FILE := $(OUTPUT_DIR)/read-write
164
READ_WRITE_VALUE := foo '""' "''" \t\n\\ bar
165
$(call WriteFile, $(READ_WRITE_VALUE), $(READ_WRITE_FILE))
166
READ_WRITE_RESULT := $(call ReadFile, $(READ_WRITE_FILE))
167

168
ifneq ($(READ_WRITE_VALUE), $(READ_WRITE_RESULT))
169
  $(error Expected: >$(READ_WRITE_VALUE)< - Result: >$(READ_WRITE_RESULT)<)
170
endif
171

172
TEST_STRING_1 := 1234
173
TEST_STRING_2 := 1234$(NEWLINE)
174
TEST_STRING_3 := 1234$(NEWLINE)$(NEWLINE)
175

176
# Writing a string ending in newline should not add a newline, but if it does
177
# not, a newline should be added. We check this by verifying that the size of the
178
# file is 5 characters for both test strings.
179
TEST_FILE_1 := $(OUTPUT_DIR)/write-file-1
180
TEST_FILE_2 := $(OUTPUT_DIR)/write-file-2
181
TEST_FILE_3 := $(OUTPUT_DIR)/write-file-3
182

183
$(call WriteFile, $(TEST_STRING_1), $(TEST_FILE_1))
184
$(call WriteFile, $(TEST_STRING_2), $(TEST_FILE_2))
185
$(call WriteFile, $(TEST_STRING_3), $(TEST_FILE_3))
186

187
TEST_FILE_1_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_1)))
188
TEST_FILE_2_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_2)))
189
TEST_FILE_3_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_3)))
190

191
ifneq ($(TEST_FILE_1_SIZE), 5)
192
  $(error Expected file size 5 for WriteFile 1, got $(TEST_FILE_1_SIZE))
193
endif
194
ifneq ($(TEST_FILE_2_SIZE), 5)
195
  $(error Expected file size 5 for WriteFile 2, got $(TEST_FILE_2_SIZE))
196
endif
197
ifneq ($(TEST_FILE_3_SIZE), 5)
198
  $(error Expected file size 5 for WriteFile 3, got $(TEST_FILE_3_SIZE))
199
endif
200

201
# Also test append (assumes WriteFile works as expected)
202
$(call WriteFile, $(TEST_STRING_1), $(TEST_FILE_1))
203
$(call AppendFile, $(TEST_STRING_1), $(TEST_FILE_1))
204
$(call AppendFile, $(TEST_STRING_1), $(TEST_FILE_1))
205

206
$(call WriteFile, $(TEST_STRING_2), $(TEST_FILE_2))
207
$(call AppendFile, $(TEST_STRING_2), $(TEST_FILE_2))
208
$(call AppendFile, $(TEST_STRING_2), $(TEST_FILE_2))
209

210
$(call WriteFile, $(TEST_STRING_3), $(TEST_FILE_3))
211
$(call AppendFile, $(TEST_STRING_3), $(TEST_FILE_3))
212
$(call AppendFile, $(TEST_STRING_3), $(TEST_FILE_3))
213

214
TEST_FILE_1_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_1)))
215
TEST_FILE_2_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_2)))
216
TEST_FILE_3_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_3)))
217

218
ifneq ($(TEST_FILE_1_SIZE), 15)
219
  $(error Expected file size 15 for AppendFile 1, got $(TEST_FILE_1_SIZE))
220
endif
221
ifneq ($(TEST_FILE_2_SIZE), 15)
222
  $(error Expected file size 15 for AppendFile 2, got $(TEST_FILE_2_SIZE))
223
endif
224
ifneq ($(TEST_FILE_3_SIZE), 15)
225
  $(error Expected file size 15 for AppendFile 3, got $(TEST_FILE_3_SIZE))
226
endif
227

228
################################################################################
229
# Test creating dependencies on make variables
230

231
VARDEP_DIR := $(OUTPUT_DIR)/vardep
232
VARDEP_SRC_FILE := $(VARDEP_DIR)/src-file
233
VARDEP_TARGET_FILE := $(VARDEP_DIR)/target-file
234
VARDEP_FLAG_FILE := $(VARDEP_DIR)/flag-file
235

236
$(VARDEP_SRC_FILE):
237
	$(MKDIR) -p $(@D)
238
	$(ECHO) "some string XXX" > $@
239

240
$(VARDEP_TARGET_FILE): $(VARDEP_SRC_FILE) \
241
    $(call DependOnVariable, VARDEP_TEST_VAR)
242
	$(MKDIR) -p $(@D)
243
	$(SED) -e 's/XXX/$(VARDEP_TEST_VAR)/g' $< > $@
244
	$(TOUCH) $(VARDEP_FLAG_FILE)
245

246
test-vardep:
247
	$(RM) $(VARDEP_SRC_FILE) $(VARDEP_TARGET_FILE) $(VARDEP_FLAG_FILE)
248
        #
249
        # Simply create the target file and verify that it has the correct value
250
        #
251
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value1 $(VARDEP_TARGET_FILE)
252
	$(PRINTF) "Expecting value1: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
253
	test "some string value1" = "`$(CAT) $(VARDEP_DIR)/target-file`"
254
	test -e $(VARDEP_FLAG_FILE)
255
        #
256
        # Make the target file again and verify that the value is updated with
257
        # the new value
258
        #
259
	$(SLEEP_ON_MAC)
260
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value2 $(VARDEP_TARGET_FILE)
261
	$(PRINTF) "Expecting value2: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
262
	test "some string value2" = "`$(CAT) $(VARDEP_DIR)/target-file`"
263
	test -e $(VARDEP_FLAG_FILE)
264
        #
265
        # Make the target again with the same value and verify that the recipe
266
        # was never run by checking that the flag file was not recreated
267
        #
268
	$(SLEEP_ON_MAC)
269
	$(RM) $(VARDEP_FLAG_FILE)
270
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value2 $(VARDEP_TARGET_FILE)
271
	$(PRINTF) "Expecting value2: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
272
	test "some string value2" = "`$(CAT) $(VARDEP_DIR)/target-file`"
273
	test ! -e $(VARDEP_FLAG_FILE)
274
        #
275
        # Test running with spaces at the end and the middle of the value
276
        # and verify that the file isn't rewritten the second time
277
        #
278
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="value3  foo " $(VARDEP_TARGET_FILE)
279
	$(RM) $(VARDEP_FLAG_FILE)
280
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="value3 foo" $(VARDEP_TARGET_FILE)
281
	test ! -e $(VARDEP_FLAG_FILE)
282
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=" value3  foo" $(VARDEP_TARGET_FILE)
283
	test ! -e $(VARDEP_FLAG_FILE)
284
        #
285
        # Test including some problematic characters
286
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$ORIGIN' $(VARDEP_TARGET_FILE)
287
	$(RM) $(VARDEP_FLAG_FILE)
288
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$ORIGIN' $(VARDEP_TARGET_FILE)
289
	test ! -e $(VARDEP_FLAG_FILE)
290
        #
291
        # Test having the variable be empty, first from scratch, with even
292
        # the vardep file deleted.
293
	$(SLEEP_ON_MAC)
294
	$(RM) $(VARDEP_FLAG_FILE) $(VARDEP_TARGET_FILE) \
295
	    $(call DependOnVariableFileName,VARDEP_TEST_VAR)
296
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="" $(VARDEP_TARGET_FILE)
297
	$(PRINTF) "Expecting '': %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
298
	test "some string " = "`$(CAT) $(VARDEP_DIR)/target-file`"
299
	test -e $(VARDEP_FLAG_FILE)
300
        #
301
        # Then rebuild with same empty value, nothing should happen
302
	$(SLEEP_ON_MAC)
303
	$(RM) $(VARDEP_FLAG_FILE)
304
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="" $(VARDEP_TARGET_FILE)
305
	$(PRINTF) "Expecting '': %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
306
	test "some string " = "`$(CAT) $(VARDEP_DIR)/target-file`"
307
	test ! -e $(VARDEP_FLAG_FILE)
308
        #
309
        # Try setting a value again and verify that the target gets rebuilt
310
	$(SLEEP_ON_MAC)
311
	$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value2 $(VARDEP_TARGET_FILE)
312
	$(PRINTF) "Expecting value2: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
313
	test "some string value2" = "`$(CAT) $(VARDEP_DIR)/target-file`"
314
	test -e $(VARDEP_FLAG_FILE)
315

316
# Test specifying a specific value file to store variable in
317
VARDEP_VALUE_FILE := $(VARDEP_DIR)/value-file
318
VARDEP_TEST_VAR2 := value3
319

320
VARDEP_RETURN_VALUE := $(call DependOnVariable, VARDEP_TEST_VAR2, $(VARDEP_VALUE_FILE))
321
$(call AssertEquals, $(VARDEP_RETURN_VALUE), $(VARDEP_VALUE_FILE), \
322
    Wrong filename returned)
323
-include $(VARDEP_VALUE_FILE)
324
$(call AssertEquals, $(VARDEP_TEST_VAR2_old), $(VARDEP_TEST_VAR2), \
325
    Wrong contents in vardeps file)
326

327
# Test with a variable value containing some problematic characters
328
VARDEP_TEST_VAR3 := foo '""' "''" bar \$$ORIGIN &\#x00a9
329
VARDEP_VALUE_FILE := $(call DependOnVariable, VARDEP_TEST_VAR3)
330
-include $(VARDEP_VALUE_FILE)
331
$(call AssertEquals, $(call EscapeHash,$(VARDEP_TEST_VAR3_old)), \
332
    $(call EscapeHash,$(VARDEP_TEST_VAR3)), \
333
    Wrong contents in vardep file)
334

335
TEST_TARGETS += test-vardep
336

337
################################################################################
338
# Test sequence
339

340
ifneq ($(call sequence, 1, 1), 1)
341
  $(error Sequence 1, 1 should be "1", but was $(call sequence, 1, 1))
342
endif
343

344
ifneq ($(call sequence, 2, 3), 2 3)
345
  $(error Sequence 2, 3 should be "2 3", but was $(call sequence, 2, 3))
346
endif
347

348
ifneq ($(call sequence, 4, 9), 4 5 6 7 8 9)
349
  $(error Sequence 4, 9 should be "4 5 6 7 8 9", but was $(call sequence, 4, 9))
350
endif
351

352
ifneq ($(call sequence, 5, 15), 5 6 7 8 9 10 11 12 13 14 15)
353
  $(error Sequence 5, 15 should be "5 6 7 8 9 10 11 12 13 14 15", \
354
      but was $(call sequence, 5, 15))
355
endif
356

357
################################################################################
358
# Test that PathList is safe when called multiple nested times.
359

360
PATHLIST_INPUT := foo bar baz
361

362
$(call AssertEquals, \
363
    $(call PathList, $(call PathList, $(PATHLIST_INPUT))), \
364
    $(call PathList, $(PATHLIST_INPUT)), \
365
    PathList call not safe for calling twice, \
366
)
367

368
################################################################################
369
# Test FindCommonPathPrefix
370

371
$(call AssertEquals, \
372
    $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/banan), \
373
    /foo/bar, \
374
    FindCommonPathPrefix, \
375
)
376

377
$(call AssertEquals, \
378
    $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar), \
379
    /foo/bar, \
380
    FindCommonPathPrefix, \
381
)
382

383
$(call AssertEquals, \
384
    $(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/), \
385
    /foo/bar, \
386
    FindCommonPathPrefix, \
387
)
388

389
$(call AssertEquals, \
390
    $(call FindCommonPathPrefix, foo/bar/baz, foo/bar/banan), \
391
    foo/bar, \
392
    FindCommonPathPrefix, \
393
)
394

395
$(call AssertEquals, \
396
    $(call FindCommonPathPrefix, foo/bar/baz, /foo/bar/banan), \
397
    , \
398
    FindCommonPathPrefix, \
399
)
400

401
$(call AssertEquals, \
402
    $(call FindCommonPathPrefix, /foo/bar/, /foo/bar), \
403
    /foo/bar, \
404
    FindCommonPathPrefix, \
405
)
406

407
$(call AssertEquals, \
408
    $(call FindCommonPathPrefix, /fo oo/bar1/, /fo oo/bar2), \
409
    /fo oo, \
410
    FindCommonPathPrefix, \
411
)
412

413
################################################################################
414
# RelativePath
415

416
$(call AssertEquals, \
417
    $(call RelativePath, foo/bar/baz, foo/bar/banan), \
418
    ../baz, \
419
    RelativePath, \
420
)
421

422
$(call AssertEquals, \
423
    $(call RelativePath, foo/bar/baz/banan/kung, foo/bar/banan/kung), \
424
    ../../baz/banan/kung, \
425
    RelativePath, \
426
)
427

428
$(call AssertEquals, \
429
    $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/banan/kung/), \
430
    ../../baz/banan/kung, \
431
    RelativePath, \
432
)
433

434
$(call AssertEquals, \
435
    $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/baz), \
436
    banan/kung, \
437
    RelativePath, \
438
)
439

440
$(call AssertEquals, \
441
    $(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/baz/), \
442
    banan/kung, \
443
    RelativePath, \
444
)
445

446
$(call AssertEquals, \
447
    $(call RelativePath, /foo/bar, /foo/bar/baz), \
448
    .., \
449
    RelativePath, \
450
)
451

452
$(call AssertEquals, \
453
    $(call RelativePath, /foo/bar/baz/, /foo/bar/baz), \
454
    ., \
455
    RelativePath, \
456
)
457

458
$(call AssertEquals, \
459
    $(call RelativePath, /fo oo/bar/baz/ban an, /fo oo/bar/), \
460
    baz/ban an, \
461
    RelativePath, \
462
)
463

464
$(call AssertEquals, \
465
    $(call RelativePath, /foo/ba rr/ba zz, /foo/ba rr/banan), \
466
    ../ba zz, \
467
    RelativePath, \
468
)
469

470
$(call AssertEquals, \
471
    $(call RelativePath, /foo, /bar), \
472
    ../foo, \
473
    RelativePath, \
474
)
475

476
################################################################################
477
# Test ParseKeywordVariable
478

479
KWBASE := APA=banan;GURKA=tomat;COUNT=1%202%203%204%205;SUM=1+2+3+4+5;MANY_WORDS=I have the best words.
480

481
$(eval $(call ParseKeywordVariable, KWBASE, \
482
    SINGLE_KEYWORDS := APA GURKA SUM, \
483
    STRING_KEYWORDS := COUNT MANY_WORDS, \
484
))
485

486
$(call AssertEquals, \
487
    $(KWBASE_APA), \
488
    banan, \
489
    ParseKeywordVariable failed to parse APA, \
490
)
491

492
$(call AssertEquals, \
493
    $(KWBASE_COUNT), \
494
    1 2 3 4 5, \
495
    ParseKeywordVariable failed to parse COUNT, \
496
)
497

498
$(call AssertEquals, \
499
    $(KWBASE_SUM), \
500
    1+2+3+4+5, \
501
    ParseKeywordVariable failed to parse SUM, \
502
)
503

504
$(call AssertEquals, \
505
    $(KWBASE_MANY_WORDS), \
506
    I have the best words., \
507
    ParseKeywordVariable failed to parse MANY_WORDS, \
508
)
509

510
# Simulate variable set from command line by using "override"
511
override KWBASE_WEIRD_GURKA := paprika
512
KWBASE_WEIRD := ;;APA=banan;;;GURKA=apelsin;APA=skansen;;
513

514
$(eval $(call ParseKeywordVariable, KWBASE_WEIRD, \
515
    SINGLE_KEYWORDS := APA GURKA SUM, \
516
    STRING_KEYWORDS := COUNT, \
517
))
518

519
$(call AssertEquals, \
520
    $(KWBASE_WEIRD_APA), \
521
    skansen, \
522
    ParseKeywordVariable failed to overwrite APA, \
523
)
524

525
$(call AssertEquals, \
526
    $(KWBASE_WEIRD_GURKA), \
527
    paprika, \
528
    ParseKeywordVariable failed to preserve GURKA, \
529
)
530

531
################################################################################
532
# Test recursive wildcard
533

534
A_FOOBAR := $(OUTPUT_DIR)/wildcard/a/foo.bar
535
A_B_DOOBAR := $(OUTPUT_DIR)/wildcard/a/b/doo.bar
536
A_B_FOOBAR := $(OUTPUT_DIR)/wildcard/a/b/foo.bar
537
A_B_FOOBAZ := $(OUTPUT_DIR)/wildcard/a/b/foo.baz
538
X_Y_FOOBAR := $(OUTPUT_DIR)/wildcard/x/y/foo.bar
539
X_Y_FOOBAZ := $(OUTPUT_DIR)/wildcard/x/y/foo.baz
540
X_Y_FOODOLLAR := $(OUTPUT_DIR)/wildcard/x/y/foo$$foo
541

542
$(call MakeDir, $(OUTPUT_DIR)/wildcard/a/b)
543
$(call MakeDir, $(OUTPUT_DIR)/wildcard/x/y)
544
$(shell $(TOUCH) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_DOOBAR) $(A_B_FOOBAZ) \
545
    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(call ShellQuote, $(X_Y_FOODOLLAR)))
546

547
ifeq ($(RWILDCARD_WORKS), true)
548
  $(call AssertEquals, \
549
      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, *.bar)), \
550
      $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_FOOBAR) $(X_Y_FOOBAR)), \
551
      Wrong files returned from rwildcard, \
552
  )
553

554
  $(call AssertEquals, \
555
      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, doo.*)), \
556
      $(A_B_DOOBAR), \
557
      Wrong files returned from rwildcard, \
558
  )
559

560
  $(call AssertEquals, \
561
      $(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, *.bar *.baz)), \
562
      $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
563
      $(X_Y_FOOBAR) $(X_Y_FOOBAZ)), \
564
      Wrong files returned from rwildcard, \
565
  )
566

567
  $(call AssertEquals, \
568
      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard)), \
569
      $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
570
      $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
571
      Wrong files returned from WildcardFindFiles, \
572
  )
573

574
  $(call AssertEquals, \
575
      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
576
      $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
577
      Wrong files returned from WildcardFindFiles, \
578
  )
579

580
  $(call AssertEquals, \
581
      $(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/x)), \
582
      $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
583
      $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
584
      Wrong files returned from WildcardFindFiles, \
585
  )
586
endif
587

588
$(call AssertEquals, \
589
    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard)), \
590
    $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
591
    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
592
    Wrong files returned from ShellFindFiles, \
593
)
594

595
$(call AssertEquals, \
596
    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
597
    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
598
    Wrong files returned from ShellFindFiles, \
599
)
600

601
$(call AssertEquals, \
602
    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/x)), \
603
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
604
    $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
605
    Wrong files returned from ShellFindFiles, \
606
)
607

608
$(call AssertEquals, \
609
    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, *.bar)), \
610
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_FOOBAR) $(X_Y_FOOBAR)), \
611
    Wrong files returned from ShellFindFiles, \
612
)
613

614
$(call AssertEquals, \
615
    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, doo.*)), \
616
    $(A_B_DOOBAR), \
617
    Wrong files returned from ShellFindFiles, \
618
)
619

620
$(call AssertEquals, \
621
    $(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, *.bar *.baz)), \
622
    $(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
623
    $(X_Y_FOOBAR) $(X_Y_FOOBAZ)), \
624
    Wrong files returned from ShellFindFiles, \
625
)
626

627
################################################################################
628

629
$(call AssertEquals, \
630
    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a/b)), \
631
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
632
    CacheFindFiles test 1, \
633
)
634
$(call FillFindCache, $(OUTPUT_DIR)/wildcard/a/b)
635
$(call AssertEquals, \
636
    $(CacheFindFiles_CACHED_DIRS), $(OUTPUT_DIR)/wildcard/a/b, \
637
    Wrong files in find cache dirs, \
638
)
639
$(call AssertEquals, \
640
    $(sort $(CacheFindFiles_CACHED_FILES)), \
641
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
642
    Wrong files in find cache files, \
643
)
644
$(call AssertEquals, \
645
    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a/b)), \
646
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
647
    CacheFindFiles test 1, \
648
)
649

650
$(call AssertEquals, \
651
    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a)), \
652
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
653
    CacheFindFiles test 2, \
654
)
655
$(call FillFindCache, $(OUTPUT_DIR)/wildcard/a)
656
$(call AssertEquals, \
657
    $(CacheFindFiles_CACHED_DIRS), \
658
    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a, \
659
    Wrong files in find cache dirs, \
660
)
661
$(call AssertEquals, \
662
    $(sort $(CacheFindFiles_CACHED_FILES)), \
663
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
664
    Wrong files in find cache files, \
665
)
666
$(call AssertEquals, \
667
    $(words $(CacheFindFiles_CACHED_FILES)), 4, \
668
    Wrong files in find cache files >$(CacheFindFiles_CACHED_FILES)<, \
669
)
670
$(call AssertEquals, \
671
    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a)), \
672
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
673
    CacheFindFiles test 2, \
674
)
675

676
$(call AssertEquals, \
677
    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x)), \
678
    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
679
    CacheFindFiles test 3, \
680
)
681
$(call FillFindCache, $(OUTPUT_DIR)/wildcard/x)
682
$(call AssertEquals, \
683
    $(CacheFindFiles_CACHED_DIRS), \
684
    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a $(OUTPUT_DIR)/wildcard/x, \
685
    Wrong files in find cache dirs, \
686
)
687
$(call AssertEquals, \
688
    $(sort $(CacheFindFiles_CACHED_FILES)), \
689
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR) \
690
        $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
691
    Wrong files in find cache files, \
692
)
693
$(call AssertEquals, \
694
    $(words $(CacheFindFiles_CACHED_FILES)), 7, \
695
    Wrong files in find cache files, \
696
)
697
$(call AssertEquals, \
698
    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x)), \
699
    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
700
    CacheFindFiles test 3, \
701
)
702

703
$(call AssertEquals, \
704
    $(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
705
    $(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
706
    CacheFindFiles test 4, \
707
)
708
$(call FillFindCache, $(OUTPUT_DIR)/wildcard/x/y)
709
$(call AssertEquals, \
710
    $(CacheFindFiles_CACHED_DIRS), \
711
    $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a $(OUTPUT_DIR)/wildcard/x, \
712
    Wrong files in find cache dirs, \
713
)
714
$(call AssertEquals, \
715
    $(sort $(CacheFindFiles_CACHED_FILES)), \
716
    $(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR) \
717
        $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
718
    Wrong files in find cache files, \
719
)
720
$(call AssertEquals, \
721
    $(words $(CacheFindFiles_CACHED_FILES)), 7, \
722
    Wrong files in find cache files, \
723
)
724

725
################################################################################
726

727
all: $(TEST_TARGETS)
728

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.