test/make/TestMakeBase.gmk
changeset 44027 3a3050924db2
parent 42134 bbcdb49521b1
child 47217 72e3ae9a25eb
--- a/test/make/TestMakeBase.gmk	Fri Mar 03 01:44:55 2017 +0000
+++ b/test/make/TestMakeBase.gmk	Fri Mar 03 12:57:57 2017 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2017, 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
@@ -179,7 +179,7 @@
 	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 
+        # Make the target file again and verify that the value is updated with
         # the new value
         #
 	$(SLEEP_ON_MAC)
@@ -341,5 +341,60 @@
 ))
 
 ################################################################################
+# 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, \
+    KEYWORDS := APA GURKA SUM, \
+    STRING_KEYWORDS := COUNT MANY_WORDS, \
+))
+
+$(eval $(call assert-equals, \
+    $(KWBASE_APA), \
+    banan, \
+    ParseKeywordVariable failed to parse APA, \
+))
+
+$(eval $(call assert-equals, \
+    $(KWBASE_COUNT), \
+    1 2 3 4 5, \
+    ParseKeywordVariable failed to parse COUNT, \
+))
+
+$(eval $(call assert-equals, \
+    $(KWBASE_SUM), \
+    1+2+3+4+5, \
+    ParseKeywordVariable failed to parse SUM, \
+))
+
+$(eval $(call assert-equals, \
+    $(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, \
+    KEYWORDS := APA GURKA SUM, \
+    STRING_KEYWORDS := COUNT, \
+))
+
+$(eval $(call assert-equals, \
+    $(KWBASE_WEIRD_APA), \
+    skansen, \
+    ParseKeywordVariable failed to overwrite APA, \
+))
+
+$(eval $(call assert-equals, \
+    $(KWBASE_WEIRD_GURKA), \
+    paprika, \
+    ParseKeywordVariable failed to preserve GURKA, \
+))
+
+################################################################################
 
 all: $(TEST_TARGETS)