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 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
|
#
# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
default: all
include $(SPEC)
include MakeBase.gmk
include UtilsForTests.gmk
THIS_FILE := $(TOPDIR)/test/make/TestMakeBase.gmk
DEPS := $(THIS_FILE) \
$(TOPDIR)/make/common/MakeBase.gmk \
#
OUTPUT_DIR := $(TESTMAKE_OUTPUTDIR)/make-base
$(call MakeDir, $(OUTPUT_DIR))
################################################################################
# Escape $
ifneq ($(call EscapeDollar, foo$$bar), foo\$$bar)
$(error EscapeDollar failed $(call EscapeDollar, foo$$bar) foo\$$bar)
endif
ESCAPE_DOLLAR_DIR := $(OUTPUT_DIR)/escape-dollar
$(ESCAPE_DOLLAR_DIR)/_escape_dollar: $(DEPS)
$(RM) -r $(@D)
$(MKDIR) -p $(@D)
$(ECHO) foo\$$bar > $(@D)/file1
$(ECHO) $(call EscapeDollar, foo$$bar) > $(@D)/file2
$(ECHO) $(call EscapeDollar, foo\$$bar) > $(@D)/file3
$(DIFF) $(@D)/file1 $(@D)/file2
$(DIFF) $(@D)/file1 $(@D)/file3
$(TOUCH) $@
TEST_TARGETS += $(ESCAPE_DOLLAR_DIR)/_escape_dollar
################################################################################
# Test containing and not-containing
CONT_LIST := foo bar baz foobar foobaz
# Param 1 - string to look for
# Param 2 - expected result
define TestContaining
value := $$(call containing, $1, $(CONT_LIST))
ifneq ($$(value), $2)
$$(info (call containing, $1, $(CONT_LIST)))
$$(error result >$$(value)<, expected >$2<)
endif
endef
$(eval $(call TestContaining,bar,bar foobar))
$(eval $(call TestContaining,foo bar,foo bar foobar foobaz))
# Param 1 - string to look for
# Param 2 - expected result
define TestNotContaining
value := $$(call not-containing, $1, $(CONT_LIST))
ifneq ($$(value), $2)
$$(info (call not-containing, $1, $(CONT_LIST)))
$$(error result >$$(value)<, expected >$2<)
endif
endef
$(eval $(call TestNotContaining,bar,foo baz foobaz))
$(eval $(call TestNotContaining,foo bar,baz))
################################################################################
# Test Equals
EQUALS_VALUE1 := value1$(SPACE)
EQUALS_VALUE2 := value2
EQUALS_EMPTY :=
ifneq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE2)), )
$(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE2)< are equal)
endif
ifeq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE1)), )
$(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE1)< are not equal)
endif
ifeq ($(call equals, $(EQUALS_EMPTY), $(EQUALS_EMPTY)), )
$(error The strings >$(EQUALS_EMPTY)< and >$(EQUALS_EMPTY)< are not equal)
endif
ifneq ($(call equals, $(EQUALS_EMPTY), $(EQUALS_VALUE2)), )
$(error The strings >$(EQUALS_EMPTY)< and >$(EQUALS_VALUE2)< are equal)
endif
ifneq ($(call equals, $(EQUALS_VALUE2), $(EQUALS_EMPTY)), )
$(error The strings >$(EQUALS_VALUE2)< and >$(EQUALS_EMPTY)< are equal)
endif
################################################################################
# Test boolean operators
$(eval $(call assert-equals, $(call And, true true true ), true))
$(eval $(call assert-equals, $(call And, true false true ), false))
$(eval $(call assert-equals, $(call And, false false false ), false))
$(eval $(call assert-equals, $(call And, true), true))
$(eval $(call assert-equals, $(call And, false), false))
$(eval $(call assert-equals, $(call And, ), true))
$(eval $(call assert-equals, $(call Or, true true true ), true))
$(eval $(call assert-equals, $(call Or, true false true ), true))
$(eval $(call assert-equals, $(call Or, false false false ), false))
$(eval $(call assert-equals, $(call Or, true), true))
$(eval $(call assert-equals, $(call Or, false), false))
$(eval $(call assert-equals, $(call Or, ), false))
# We cannot catch $(error) while testing, but you can enable this manually
# by uncommenting and watch make fails.
#$(eval $(call assert-equals, $(call And, non-boolean ), $(error ...)))
#$(eval $(call assert-equals, $(call Or, non-boolean ), $(error ...)))
################################################################################
# Test remove-prefixes
$(call AssertEquals, \
$(call remove-prefixes, pre, prefix postfix), fix postfix, \
Prefixes not properly removed)
$(call AssertEquals, \
$(call remove-prefixes, pre post, prefix postfix), fix fix, \
Prefixes not properly removed)
################################################################################
# Test ShellQuote
SHELL_QUOTE_VALUE := foo '""' "''" bar
SHELL_QUOTE_RESULT := $(shell $(ECHO) $(call ShellQuote, \
$(SHELL_QUOTE_VALUE)))
ifneq ($(SHELL_QUOTE_VALUE), $(SHELL_QUOTE_RESULT))
$(error Expected: >$(SHELL_QUOTE_VALUE)< - Result: >$(SHELL_QUOTE_RESULT)<)
endif
################################################################################
# Test read and write to file
READ_WRITE_FILE := $(OUTPUT_DIR)/read-write
READ_WRITE_VALUE := foo '""' "''" \t\n\\ bar
$(call WriteFile, $(READ_WRITE_VALUE), $(READ_WRITE_FILE))
READ_WRITE_RESULT := $(call ReadFile, $(READ_WRITE_FILE))
ifneq ($(READ_WRITE_VALUE), $(READ_WRITE_RESULT))
$(error Expected: >$(READ_WRITE_VALUE)< - Result: >$(READ_WRITE_RESULT)<)
endif
TEST_STRING_1 := 1234
TEST_STRING_2 := 1234$(NEWLINE)
TEST_STRING_3 := 1234$(NEWLINE)$(NEWLINE)
# Writing a string ending in newline should not add a newline, but if it does
# not, a newline should be added. We check this by verifying that the size of the
# file is 5 characters for both test strings.
TEST_FILE_1 := $(OUTPUT_DIR)/write-file-1
TEST_FILE_2 := $(OUTPUT_DIR)/write-file-2
TEST_FILE_3 := $(OUTPUT_DIR)/write-file-3
$(call WriteFile, $(TEST_STRING_1), $(TEST_FILE_1))
$(call WriteFile, $(TEST_STRING_2), $(TEST_FILE_2))
$(call WriteFile, $(TEST_STRING_3), $(TEST_FILE_3))
TEST_FILE_1_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_1)))
TEST_FILE_2_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_2)))
TEST_FILE_3_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_3)))
ifneq ($(TEST_FILE_1_SIZE), 5)
$(error Expected file size 5 for WriteFile 1, got $(TEST_FILE_1_SIZE))
endif
ifneq ($(TEST_FILE_2_SIZE), 5)
$(error Expected file size 5 for WriteFile 2, got $(TEST_FILE_2_SIZE))
endif
ifneq ($(TEST_FILE_3_SIZE), 5)
$(error Expected file size 5 for WriteFile 3, got $(TEST_FILE_3_SIZE))
endif
# Also test append (assumes WriteFile works as expected)
$(call WriteFile, $(TEST_STRING_1), $(TEST_FILE_1))
$(call AppendFile, $(TEST_STRING_1), $(TEST_FILE_1))
$(call AppendFile, $(TEST_STRING_1), $(TEST_FILE_1))
$(call WriteFile, $(TEST_STRING_2), $(TEST_FILE_2))
$(call AppendFile, $(TEST_STRING_2), $(TEST_FILE_2))
$(call AppendFile, $(TEST_STRING_2), $(TEST_FILE_2))
$(call WriteFile, $(TEST_STRING_3), $(TEST_FILE_3))
$(call AppendFile, $(TEST_STRING_3), $(TEST_FILE_3))
$(call AppendFile, $(TEST_STRING_3), $(TEST_FILE_3))
TEST_FILE_1_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_1)))
TEST_FILE_2_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_2)))
TEST_FILE_3_SIZE := $(strip $(shell $(WC) -c < $(TEST_FILE_3)))
ifneq ($(TEST_FILE_1_SIZE), 15)
$(error Expected file size 15 for AppendFile 1, got $(TEST_FILE_1_SIZE))
endif
ifneq ($(TEST_FILE_2_SIZE), 15)
$(error Expected file size 15 for AppendFile 2, got $(TEST_FILE_2_SIZE))
endif
ifneq ($(TEST_FILE_3_SIZE), 15)
$(error Expected file size 15 for AppendFile 3, got $(TEST_FILE_3_SIZE))
endif
################################################################################
# Test creating dependencies on make variables
VARDEP_DIR := $(OUTPUT_DIR)/vardep
VARDEP_SRC_FILE := $(VARDEP_DIR)/src-file
VARDEP_TARGET_FILE := $(VARDEP_DIR)/target-file
VARDEP_FLAG_FILE := $(VARDEP_DIR)/flag-file
$(VARDEP_SRC_FILE):
$(MKDIR) -p $(@D)
$(ECHO) "some string XXX" > $@
$(VARDEP_TARGET_FILE): $(VARDEP_SRC_FILE) \
$(call DependOnVariable, VARDEP_TEST_VAR)
$(MKDIR) -p $(@D)
$(SED) -e 's/XXX/$(VARDEP_TEST_VAR)/g' $< > $@
$(TOUCH) $(VARDEP_FLAG_FILE)
test-vardep:
$(RM) $(VARDEP_SRC_FILE) $(VARDEP_TARGET_FILE) $(VARDEP_FLAG_FILE)
#
# Simply create the target file and verify that it has the correct value
#
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value1 $(VARDEP_TARGET_FILE)
$(PRINTF) "Expecting value1: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
test "some string value1" = "`$(CAT) $(VARDEP_DIR)/target-file`"
test -e $(VARDEP_FLAG_FILE)
#
# Make the target file again and verify that the value is updated with
# the new value
#
$(SLEEP_ON_MAC)
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value2 $(VARDEP_TARGET_FILE)
$(PRINTF) "Expecting value2: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
test "some string value2" = "`$(CAT) $(VARDEP_DIR)/target-file`"
test -e $(VARDEP_FLAG_FILE)
#
# Make the target again with the same value and verify that the recipe
# was never run by checking that the flag file was not recreated
#
$(SLEEP_ON_MAC)
$(RM) $(VARDEP_FLAG_FILE)
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value2 $(VARDEP_TARGET_FILE)
$(PRINTF) "Expecting value2: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
test "some string value2" = "`$(CAT) $(VARDEP_DIR)/target-file`"
test ! -e $(VARDEP_FLAG_FILE)
#
# Test running with spaces at the end and the middle of the value
# and verify that the file isn't rewritten the second time
#
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="value3 foo " $(VARDEP_TARGET_FILE)
$(RM) $(VARDEP_FLAG_FILE)
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="value3 foo" $(VARDEP_TARGET_FILE)
test ! -e $(VARDEP_FLAG_FILE)
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=" value3 foo" $(VARDEP_TARGET_FILE)
test ! -e $(VARDEP_FLAG_FILE)
#
# Test including some problematic characters
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$ORIGIN' $(VARDEP_TARGET_FILE)
$(RM) $(VARDEP_FLAG_FILE)
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR='value4 \$$ORIGIN' $(VARDEP_TARGET_FILE)
test ! -e $(VARDEP_FLAG_FILE)
#
# Test having the variable be empty, first from scratch, with even
# the vardep file deleted.
$(SLEEP_ON_MAC)
$(RM) $(VARDEP_FLAG_FILE) $(VARDEP_TARGET_FILE) \
$(call DependOnVariableFileName,VARDEP_TEST_VAR)
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="" $(VARDEP_TARGET_FILE)
$(PRINTF) "Expecting '': %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
test "some string " = "`$(CAT) $(VARDEP_DIR)/target-file`"
test -e $(VARDEP_FLAG_FILE)
#
# Then rebuild with same empty value, nothing should happen
$(SLEEP_ON_MAC)
$(RM) $(VARDEP_FLAG_FILE)
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR="" $(VARDEP_TARGET_FILE)
$(PRINTF) "Expecting '': %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
test "some string " = "`$(CAT) $(VARDEP_DIR)/target-file`"
test ! -e $(VARDEP_FLAG_FILE)
#
# Try setting a value again and verify that the target gets rebuilt
$(SLEEP_ON_MAC)
$(MAKE) -f $(THIS_FILE) VARDEP_TEST_VAR=value2 $(VARDEP_TARGET_FILE)
$(PRINTF) "Expecting value2: %s\n" "`$(CAT) $(VARDEP_DIR)/target-file`"
test "some string value2" = "`$(CAT) $(VARDEP_DIR)/target-file`"
test -e $(VARDEP_FLAG_FILE)
# Test specifying a specific value file to store variable in
VARDEP_VALUE_FILE := $(VARDEP_DIR)/value-file
VARDEP_TEST_VAR2 := value3
VARDEP_RETURN_VALUE := $(call DependOnVariable, VARDEP_TEST_VAR2, $(VARDEP_VALUE_FILE))
$(call AssertEquals, $(VARDEP_RETURN_VALUE), $(VARDEP_VALUE_FILE), \
Wrong filename returned)
-include $(VARDEP_VALUE_FILE)
$(call AssertEquals, $(VARDEP_TEST_VAR2_old), $(VARDEP_TEST_VAR2), \
Wrong contents in vardeps file)
# Test with a variable value containing some problematic characters
VARDEP_TEST_VAR3 := foo '""' "''" bar \$$ORIGIN &\#x00a9
VARDEP_VALUE_FILE := $(call DependOnVariable, VARDEP_TEST_VAR3)
-include $(VARDEP_VALUE_FILE)
$(call AssertEquals, $(call EscapeHash,$(VARDEP_TEST_VAR3_old)), \
$(call EscapeHash,$(VARDEP_TEST_VAR3)), \
Wrong contents in vardep file)
TEST_TARGETS += test-vardep
################################################################################
# Test sequence
ifneq ($(call sequence, 1, 1), 1)
$(error Sequence 1, 1 should be "1", but was $(call sequence, 1, 1))
endif
ifneq ($(call sequence, 2, 3), 2 3)
$(error Sequence 2, 3 should be "2 3", but was $(call sequence, 2, 3))
endif
ifneq ($(call sequence, 4, 9), 4 5 6 7 8 9)
$(error Sequence 4, 9 should be "4 5 6 7 8 9", but was $(call sequence, 4, 9))
endif
ifneq ($(call sequence, 5, 15), 5 6 7 8 9 10 11 12 13 14 15)
$(error Sequence 5, 15 should be "5 6 7 8 9 10 11 12 13 14 15", \
but was $(call sequence, 5, 15))
endif
################################################################################
# Test that PathList is safe when called multiple nested times.
PATHLIST_INPUT := foo bar baz
$(call AssertEquals, \
$(call PathList, $(call PathList, $(PATHLIST_INPUT))), \
$(call PathList, $(PATHLIST_INPUT)), \
PathList call not safe for calling twice, \
)
################################################################################
# Test FindCommonPathPrefix
$(call AssertEquals, \
$(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/banan), \
/foo/bar, \
FindCommonPathPrefix, \
)
$(call AssertEquals, \
$(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar), \
/foo/bar, \
FindCommonPathPrefix, \
)
$(call AssertEquals, \
$(call FindCommonPathPrefix, /foo/bar/baz, /foo/bar/), \
/foo/bar, \
FindCommonPathPrefix, \
)
$(call AssertEquals, \
$(call FindCommonPathPrefix, foo/bar/baz, foo/bar/banan), \
foo/bar, \
FindCommonPathPrefix, \
)
$(call AssertEquals, \
$(call FindCommonPathPrefix, foo/bar/baz, /foo/bar/banan), \
, \
FindCommonPathPrefix, \
)
$(call AssertEquals, \
$(call FindCommonPathPrefix, /foo/bar/, /foo/bar), \
/foo/bar, \
FindCommonPathPrefix, \
)
$(call AssertEquals, \
$(call FindCommonPathPrefix, /fo oo/bar1/, /fo oo/bar2), \
/fo oo, \
FindCommonPathPrefix, \
)
################################################################################
# RelativePath
$(call AssertEquals, \
$(call RelativePath, foo/bar/baz, foo/bar/banan), \
../baz, \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, foo/bar/baz/banan/kung, foo/bar/banan/kung), \
../../baz/banan/kung, \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/banan/kung/), \
../../baz/banan/kung, \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/baz), \
banan/kung, \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, /foo/bar/baz/banan/kung, /foo/bar/baz/), \
banan/kung, \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, /foo/bar, /foo/bar/baz), \
.., \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, /foo/bar/baz/, /foo/bar/baz), \
., \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, /fo oo/bar/baz/ban an, /fo oo/bar/), \
baz/ban an, \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, /foo/ba rr/ba zz, /foo/ba rr/banan), \
../ba zz, \
RelativePath, \
)
$(call AssertEquals, \
$(call RelativePath, /foo, /bar), \
../foo, \
RelativePath, \
)
################################################################################
# Test ParseKeywordVariable
KWBASE := APA=banan;GURKA=tomat;COUNT=1%202%203%204%205;SUM=1+2+3+4+5;MANY_WORDS=I have the best words.
$(eval $(call ParseKeywordVariable, KWBASE, \
SINGLE_KEYWORDS := APA GURKA SUM, \
STRING_KEYWORDS := COUNT MANY_WORDS, \
))
$(call AssertEquals, \
$(KWBASE_APA), \
banan, \
ParseKeywordVariable failed to parse APA, \
)
$(call AssertEquals, \
$(KWBASE_COUNT), \
1 2 3 4 5, \
ParseKeywordVariable failed to parse COUNT, \
)
$(call AssertEquals, \
$(KWBASE_SUM), \
1+2+3+4+5, \
ParseKeywordVariable failed to parse SUM, \
)
$(call AssertEquals, \
$(KWBASE_MANY_WORDS), \
I have the best words., \
ParseKeywordVariable failed to parse MANY_WORDS, \
)
# Simulate variable set from command line by using "override"
override KWBASE_WEIRD_GURKA := paprika
KWBASE_WEIRD := ;;APA=banan;;;GURKA=apelsin;APA=skansen;;
$(eval $(call ParseKeywordVariable, KWBASE_WEIRD, \
SINGLE_KEYWORDS := APA GURKA SUM, \
STRING_KEYWORDS := COUNT, \
))
$(call AssertEquals, \
$(KWBASE_WEIRD_APA), \
skansen, \
ParseKeywordVariable failed to overwrite APA, \
)
$(call AssertEquals, \
$(KWBASE_WEIRD_GURKA), \
paprika, \
ParseKeywordVariable failed to preserve GURKA, \
)
################################################################################
# Test recursive wildcard
A_FOOBAR := $(OUTPUT_DIR)/wildcard/a/foo.bar
A_B_DOOBAR := $(OUTPUT_DIR)/wildcard/a/b/doo.bar
A_B_FOOBAR := $(OUTPUT_DIR)/wildcard/a/b/foo.bar
A_B_FOOBAZ := $(OUTPUT_DIR)/wildcard/a/b/foo.baz
X_Y_FOOBAR := $(OUTPUT_DIR)/wildcard/x/y/foo.bar
X_Y_FOOBAZ := $(OUTPUT_DIR)/wildcard/x/y/foo.baz
X_Y_FOODOLLAR := $(OUTPUT_DIR)/wildcard/x/y/foo$$foo
$(call MakeDir, $(OUTPUT_DIR)/wildcard/a/b)
$(call MakeDir, $(OUTPUT_DIR)/wildcard/x/y)
$(shell $(TOUCH) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_DOOBAR) $(A_B_FOOBAZ) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(call ShellQuote, $(X_Y_FOODOLLAR)))
ifeq ($(RWILDCARD_WORKS), true)
$(call AssertEquals, \
$(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, *.bar)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_FOOBAR) $(X_Y_FOOBAR)), \
Wrong files returned from rwildcard, \
)
$(call AssertEquals, \
$(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, doo.*)), \
$(A_B_DOOBAR), \
Wrong files returned from rwildcard, \
)
$(call AssertEquals, \
$(sort $(call rwildcard, $(OUTPUT_DIR)/wildcard, *.bar *.baz)), \
$(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ)), \
Wrong files returned from rwildcard, \
)
$(call AssertEquals, \
$(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard)), \
$(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
Wrong files returned from WildcardFindFiles, \
)
$(call AssertEquals, \
$(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
$(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
Wrong files returned from WildcardFindFiles, \
)
$(call AssertEquals, \
$(sort $(call WildcardFindFiles, $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/x)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
Wrong files returned from WildcardFindFiles, \
)
endif
$(call AssertEquals, \
$(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard)), \
$(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
Wrong files returned from ShellFindFiles, \
)
$(call AssertEquals, \
$(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
$(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
Wrong files returned from ShellFindFiles, \
)
$(call AssertEquals, \
$(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/x)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
Wrong files returned from ShellFindFiles, \
)
$(call AssertEquals, \
$(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, *.bar)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_FOOBAR) $(X_Y_FOOBAR)), \
Wrong files returned from ShellFindFiles, \
)
$(call AssertEquals, \
$(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, doo.*)), \
$(A_B_DOOBAR), \
Wrong files returned from ShellFindFiles, \
)
$(call AssertEquals, \
$(sort $(call ShellFindFiles, $(OUTPUT_DIR)/wildcard, *.bar *.baz)), \
$(sort $(A_B_DOOBAR) $(A_FOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ)), \
Wrong files returned from ShellFindFiles, \
)
################################################################################
$(call AssertEquals, \
$(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a/b)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
CacheFindFiles test 1, \
)
$(call FillFindCache, $(OUTPUT_DIR)/wildcard/a/b)
$(call AssertEquals, \
$(CacheFindFiles_CACHED_DIRS), $(OUTPUT_DIR)/wildcard/a/b, \
Wrong files in find cache dirs, \
)
$(call AssertEquals, \
$(sort $(CacheFindFiles_CACHED_FILES)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
Wrong files in find cache files, \
)
$(call AssertEquals, \
$(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a/b)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ)), \
CacheFindFiles test 1, \
)
$(call AssertEquals, \
$(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
CacheFindFiles test 2, \
)
$(call FillFindCache, $(OUTPUT_DIR)/wildcard/a)
$(call AssertEquals, \
$(CacheFindFiles_CACHED_DIRS), \
$(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a, \
Wrong files in find cache dirs, \
)
$(call AssertEquals, \
$(sort $(CacheFindFiles_CACHED_FILES)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
Wrong files in find cache files, \
)
$(call AssertEquals, \
$(words $(CacheFindFiles_CACHED_FILES)), 4, \
Wrong files in find cache files >$(CacheFindFiles_CACHED_FILES)<, \
)
$(call AssertEquals, \
$(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/a)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR)), \
CacheFindFiles test 2, \
)
$(call AssertEquals, \
$(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x)), \
$(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
CacheFindFiles test 3, \
)
$(call FillFindCache, $(OUTPUT_DIR)/wildcard/x)
$(call AssertEquals, \
$(CacheFindFiles_CACHED_DIRS), \
$(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a $(OUTPUT_DIR)/wildcard/x, \
Wrong files in find cache dirs, \
)
$(call AssertEquals, \
$(sort $(CacheFindFiles_CACHED_FILES)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
Wrong files in find cache files, \
)
$(call AssertEquals, \
$(words $(CacheFindFiles_CACHED_FILES)), 7, \
Wrong files in find cache files, \
)
$(call AssertEquals, \
$(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x)), \
$(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
CacheFindFiles test 3, \
)
$(call AssertEquals, \
$(sort $(call CacheFindFiles, $(OUTPUT_DIR)/wildcard/x/y)), \
$(sort $(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
CacheFindFiles test 4, \
)
$(call FillFindCache, $(OUTPUT_DIR)/wildcard/x/y)
$(call AssertEquals, \
$(CacheFindFiles_CACHED_DIRS), \
$(OUTPUT_DIR)/wildcard/a/b $(OUTPUT_DIR)/wildcard/a $(OUTPUT_DIR)/wildcard/x, \
Wrong files in find cache dirs, \
)
$(call AssertEquals, \
$(sort $(CacheFindFiles_CACHED_FILES)), \
$(sort $(A_B_DOOBAR) $(A_B_FOOBAR) $(A_B_FOOBAZ) $(A_FOOBAR) \
$(X_Y_FOOBAR) $(X_Y_FOOBAZ) $(X_Y_FOODOLLAR)), \
Wrong files in find cache files, \
)
$(call AssertEquals, \
$(words $(CacheFindFiles_CACHED_FILES)), 7, \
Wrong files in find cache files, \
)
################################################################################
all: $(TEST_TARGETS)
|