16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 default: all 27 28 include $(SPEC) 29 include MakeBase.gmk 30 31 THIS_FILE := $(SRC_ROOT)/test/make/TestMakeBase.gmk 32 DEPS := $(THIS_FILE) \ 33 $(SRC_ROOT)/make/common/MakeBase.gmk \ 34 # 35 36 # On macosx, file system timestamps only have 1 second resultion so must add 37 # sleeps to properly test dependencies. 38 ifeq ($(OPENJDK_BUILD_OS), macosx) 39 SLEEP_ON_MAC := sleep 1 40 endif 41 42 OUTPUT_DIR := $(TESTMAKE_OUTPUTDIR)/make-base 43 $(call MakeDir, $(OUTPUT_DIR)) 44 45 ################################################################################ 46 # Escape $ 47 ifneq ($(call EscapeDollar, foo$$bar), foo\$$bar) 48 $(error EscapeDollar failed $(call EscapeDollar, foo$$bar) foo\$$bar) 49 endif 50 51 ESCAPE_DOLLAR_DIR := $(OUTPUT_DIR)/escape-dollar 52 53 $(ESCAPE_DOLLAR_DIR)/_escape_dollar: $(DEPS) 54 $(RM) -r $(@D) 55 $(MKDIR) -p $(@D) 58 $(ECHO) $(call EscapeDollar, foo\$$bar) > $(@D)/file3 59 $(DIFF) $(@D)/file1 $(@D)/file2 60 $(DIFF) $(@D)/file1 $(@D)/file3 61 $(TOUCH) $@ 62 63 TEST_TARGETS += $(ESCAPE_DOLLAR_DIR)/_escape_dollar 64 65 ################################################################################ 66 # Test Equals 67 68 EQUALS_VALUE1 := value1$(SPACE) 69 EQUALS_VALUE2 := value2 70 71 ifneq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE2)), ) 72 $(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE2)< are equal) 73 endif 74 75 ifeq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE1)), ) 76 $(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE1)< are not equal) 77 endif 78 79 ################################################################################ 80 # Test ShellQuote 81 82 SHELL_QUOTE_VALUE := foo '""' "''" bar 83 SHELL_QUOTE_RESULT := $(shell $(ECHO) $(call ShellQuote, \ 84 $(SHELL_QUOTE_VALUE))) 85 86 ifneq ($(SHELL_QUOTE_VALUE), $(SHELL_QUOTE_RESULT)) 87 $(error Expected: >$(SHELL_QUOTE_VALUE)< - Result: >$(SHELL_QUOTE_RESULT)<) 88 endif 89 90 ################################################################################ 91 # Test read and write to file 92 93 READ_WRITE_FILE := $(OUTPUT_DIR)/read-write 94 READ_WRITE_VALUE := foo '""' "''" \t\n\\ bar 95 $(call WriteFile, $(READ_WRITE_VALUE), $(READ_WRITE_FILE)) 96 READ_WRITE_RESULT := $(call ReadFile, $(READ_WRITE_FILE)) 97 | 16 # 17 # You should have received a copy of the GNU General Public License version 18 # 2 along with this work; if not, write to the Free Software Foundation, 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 # or visit www.oracle.com if you need additional information or have any 23 # questions. 24 # 25 26 default: all 27 28 include $(SPEC) 29 include MakeBase.gmk 30 31 THIS_FILE := $(SRC_ROOT)/test/make/TestMakeBase.gmk 32 DEPS := $(THIS_FILE) \ 33 $(SRC_ROOT)/make/common/MakeBase.gmk \ 34 # 35 36 # Assert two strings are equal 37 # 1 - Tested value 38 # 2 - Exepected value 39 # 3 - Error message 40 define assert-equals 41 ifneq ($$(strip $1),$$(strip $2)) 42 $$(error $3 - Expected >$$(strip $2)< - Got >$$(strip $1)<) 43 endif 44 endef 45 46 # On macosx, file system timestamps only have 1 second resultion so must add 47 # sleeps to properly test dependencies. 48 ifeq ($(OPENJDK_BUILD_OS), macosx) 49 SLEEP_ON_MAC := sleep 1 50 endif 51 52 OUTPUT_DIR := $(TESTMAKE_OUTPUTDIR)/make-base 53 $(call MakeDir, $(OUTPUT_DIR)) 54 55 ################################################################################ 56 # Escape $ 57 ifneq ($(call EscapeDollar, foo$$bar), foo\$$bar) 58 $(error EscapeDollar failed $(call EscapeDollar, foo$$bar) foo\$$bar) 59 endif 60 61 ESCAPE_DOLLAR_DIR := $(OUTPUT_DIR)/escape-dollar 62 63 $(ESCAPE_DOLLAR_DIR)/_escape_dollar: $(DEPS) 64 $(RM) -r $(@D) 65 $(MKDIR) -p $(@D) 68 $(ECHO) $(call EscapeDollar, foo\$$bar) > $(@D)/file3 69 $(DIFF) $(@D)/file1 $(@D)/file2 70 $(DIFF) $(@D)/file1 $(@D)/file3 71 $(TOUCH) $@ 72 73 TEST_TARGETS += $(ESCAPE_DOLLAR_DIR)/_escape_dollar 74 75 ################################################################################ 76 # Test Equals 77 78 EQUALS_VALUE1 := value1$(SPACE) 79 EQUALS_VALUE2 := value2 80 81 ifneq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE2)), ) 82 $(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE2)< are equal) 83 endif 84 85 ifeq ($(call equals, $(EQUALS_VALUE1), $(EQUALS_VALUE1)), ) 86 $(error The strings >$(EQUALS_VALUE1)< and >$(EQUALS_VALUE1)< are not equal) 87 endif 88 89 ################################################################################ 90 # Test remove-prefixes 91 92 $(eval $(call assert-equals, \ 93 $(call remove-prefixes, pre, prefix postfix), fix postfix, \ 94 Prefixes not properly removed)) 95 96 $(eval $(call assert-equals, \ 97 $(call remove-prefixes, pre post, prefix postfix), fix fix, \ 98 Prefixes not properly removed)) 99 100 ################################################################################ 101 # Test ShellQuote 102 103 SHELL_QUOTE_VALUE := foo '""' "''" bar 104 SHELL_QUOTE_RESULT := $(shell $(ECHO) $(call ShellQuote, \ 105 $(SHELL_QUOTE_VALUE))) 106 107 ifneq ($(SHELL_QUOTE_VALUE), $(SHELL_QUOTE_RESULT)) 108 $(error Expected: >$(SHELL_QUOTE_VALUE)< - Result: >$(SHELL_QUOTE_RESULT)<) 109 endif 110 111 ################################################################################ 112 # Test read and write to file 113 114 READ_WRITE_FILE := $(OUTPUT_DIR)/read-write 115 READ_WRITE_VALUE := foo '""' "''" \t\n\\ bar 116 $(call WriteFile, $(READ_WRITE_VALUE), $(READ_WRITE_FILE)) 117 READ_WRITE_RESULT := $(call ReadFile, $(READ_WRITE_FILE)) 118 |