diff options
Diffstat (limited to '')
-rw-r--r-- | src/kmk/testcase-2ndtargetexp.kmk | 68 | ||||
-rw-r--r-- | src/kmk/testcase-assignments.kmk | 29 | ||||
-rw-r--r-- | src/kmk/testcase-if1of.kmk | 80 | ||||
-rw-r--r-- | src/kmk/testcase-ifeq-escape.kmk | 18 | ||||
-rw-r--r-- | src/kmk/testcase-includedep-esc-sub.kmk | 113 | ||||
-rw-r--r-- | src/kmk/testcase-includedep-esc.kmk | 133 | ||||
-rw-r--r-- | src/kmk/testcase-includedep-sub.kmk | 28 | ||||
-rw-r--r-- | src/kmk/testcase-includedep.kmk | 90 | ||||
-rw-r--r-- | src/kmk/testcase-kBuild-define.kmk | 141 | ||||
-rw-r--r-- | src/kmk/testcase-lazy-deps-vars.kmk | 72 | ||||
-rw-r--r-- | src/kmk/testcase-libpath.kmk | 20 | ||||
-rw-r--r-- | src/kmk/testcase-local.kmk | 127 | ||||
-rw-r--r-- | src/kmk/testcase-math.kmk | 98 | ||||
-rw-r--r-- | src/kmk/testcase-root.kmk | 30 | ||||
-rw-r--r-- | src/kmk/testcase-stack.kmk | 86 | ||||
-rw-r--r-- | src/kmk/testcase-which.kmk | 5 | ||||
-rw-r--r-- | src/kmk/testcase-xargs.kmk | 59 | ||||
-rw-r--r-- | src/kmk/testcase/testcase-export.kmk | 48 |
18 files changed, 1245 insertions, 0 deletions
diff --git a/src/kmk/testcase-2ndtargetexp.kmk b/src/kmk/testcase-2ndtargetexp.kmk new file mode 100644 index 0000000..1e19a8b --- /dev/null +++ b/src/kmk/testcase-2ndtargetexp.kmk @@ -0,0 +1,68 @@ +# $Id: testcase-2ndtargetexp.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild - testcase for the 2nd target expansion feature. +# + +# +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk + +# +# Enable it. +# +.SECONDTARGETEXPANSION: + + +# +# This is expanded immediately. +# +foo1 = foo1 +$(foo1): + $(if $(eq $@,foo1),$(ECHO) "foo1 works",$(ECHO) "foo1 is busted @=$@"; exit 1) + +# Mostly for making sure the ifeq test works below. +flush_command_recoding := 1 # see record_waiting_files() in read.c +ifeq ($(strip $(commands foo1)),) +$(error No commands for foo1: $(commands foo1)) +endif + + +# +# This is expanded in the 2nd round. +# +$$(foo2): + $(if $(eq $@,foo2),$(ECHO) "foo2 works",$(ECHO) "foo2 is busted @=$@"; exit 1) + +# Check that a $(foo2) file exists. +flush_command_recoding := 1 # see record_waiting_files() in read.c +# $ (info $$(foo2) commands: $(commands $$(foo2))) +ifeq ($(strip $(commands $$(foo2))),) +$(error No commands for $$(foo2): $(commands $$(foo2))) +endif + + +all_recursive: foo1 foo2 + $(ECHO) "2nd target expansion passes smoke testing" + +# define this last +foo2 = foo2 + diff --git a/src/kmk/testcase-assignments.kmk b/src/kmk/testcase-assignments.kmk new file mode 100644 index 0000000..1ef2431 --- /dev/null +++ b/src/kmk/testcase-assignments.kmk @@ -0,0 +1,29 @@ +# $Id: testcase-assignments.kmk 3154 2018-03-15 23:35:33Z bird $ +# Testcase for weird various assignment operators and parsing. + + + +SIMPLE1 := simple1 +ifneq ($(SIMPLE1),simple1) + $(error simple1 assignment no 1 failed: SIMPLE1=$(SIMPLE1)) +endif + +SIMPLE2 := simple2-$(SIMPLE1) +ifneq ($(SIMPLE2),simple2-simple1) + $(error simple assignment no 2 failed: $(SIMPLE2)) +endif + +$(SIMPLE1)-3 := simple3-$(SIMPLE1) +ifneq ($(simple1-3),simple3-simple1) + $(error simple assignment no 3 failed: $($(SIMPLE1)-3)) +endif + +$(subst 1,4,$(SIMPLE1)) := simple4 +ifneq ($(simple4),simple4) + $(error simple assignment no 4 failed: simple4=$(simple4)) # (Including an equal inside the error call here.) +endif + +all: + @echo okay + + diff --git a/src/kmk/testcase-if1of.kmk b/src/kmk/testcase-if1of.kmk new file mode 100644 index 0000000..dc878ba --- /dev/null +++ b/src/kmk/testcase-if1of.kmk @@ -0,0 +1,80 @@ +# $Id: testcase-if1of.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild - testcase for the if1of and ifn1of conditionals. +# + +# +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk + +# the basics. +if1of (asdf,asdf) +else + $(error busted) +endif +ifn1of (asdf,asdf) + $(error busted) +endif + +# larger sets. +if1of (1,2 3 4 5 6 7 8 9 0) + $(error busted) +endif +if1of (1,12 3 4 5 6 7 8 9 0) + $(error busted) +endif +if1of (1,2 31 4 5 6 7 8 9 0) + $(error busted) +endif +ifn1of (1,1 2 3 4 5 6 7 8 9 0) + $(error busted) +endif +ifn1of (8,1 2 3 4 5 6 7 8 9 0) + $(error busted) +endif +ifn1of (asdf,asdf) + $(error busted) +endif +ifn1of (asdf,asdf asdf) + $(error busted) +endif + +# any in set 1 match any in set 2. +if1of (1 3 5 7 9, 2 4 6 8) + $(error busted) +endif +ifn1of (1 2 3 4 5, 2 4 6 8) + $(error busted) +endif + +# real life. +ifn1of (win linux, linux) + $(error busted) +endif +ifn1of (win.x86, win.amd64 linux.x86 darwin.x86 win.x86 os2.x86) + $(error busted) +endif + + +all_recursive: + $(ECHO) "if1of and ifn1of work fine" + diff --git a/src/kmk/testcase-ifeq-escape.kmk b/src/kmk/testcase-ifeq-escape.kmk new file mode 100644 index 0000000..500b812 --- /dev/null +++ b/src/kmk/testcase-ifeq-escape.kmk @@ -0,0 +1,18 @@ +# $Id: testcase-ifeq-escape.kmk 3154 2018-03-15 23:35:33Z bird $ +# Testcase for weird 'ifeq' and funny escapes. + +ifeq "1 \ + \ + \ + \ + \ + " \ +"1 " +$(info info: ifeq -> equal) +else +$(error info: ifeq -> not equal - wrong) +endif + +all: + @echo okay + diff --git a/src/kmk/testcase-includedep-esc-sub.kmk b/src/kmk/testcase-includedep-esc-sub.kmk new file mode 100644 index 0000000..fe132d5 --- /dev/null +++ b/src/kmk/testcase-includedep-esc-sub.kmk @@ -0,0 +1,113 @@ +# $Id: testcase-includedep-esc-sub.kmk 3318 2020-04-01 07:05:32Z bird $ +## @file +# kBuild - testcase for the includdep directive with filename escaping, helper +# file that gets included. +# + +# +# Copyright (c) 2007-2020 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +testcase-includedep-esc-sub.kmk=included + +# spaces +/phoney/file-with-two-spaces\ \ .c: \ + /phoney/header-file-with-two-spaces\ \ .h + + +# +# From example-spaces.kmk +# +/phoney-dep-ignore: + +phoney\ space\ \ 1: /phoney-dep\ space\ \ 1 + +phoney\ colon\:\ 2: /phoney-dep\ colon\:\ 2 \ + +phoney\ hash\#\ 3 : /phoney-dep\ hash\#\ 3 + +phoney\ dollar$$\ 4 : /phoney-dep\ dollar$$\ 4 \ + +phoney\ slash-space\\\ 5: /phoney-dep\ slash-space\\\ 5 + +phoney\ slash-hash\\\#\ 6: /phoney-dep\ slash-hash\\\#\ 6 \ + +phoney\ slash-slash-hash\\\\\#\ 7: /phoney-dep\ slash-slash-hash\\\\\#\ 7 + +phoney\ equal\=\ 8: /phoney-dep\ equal\=\ 8 + +phoney\ semI\;\ 9: /phoney-dep\ semi\;\ 9 + +# Note! The percent is only escaped on the target side! +phoney\ percent\%\ 10: /phoney-dep\ percent%\ 10 \ + +# Note! The pipe is only escaped on the dependency list side! +phoney\ pipe|\ 11: /phoney-dep\ pipe\|\ 11 + +phoney\ plus+\ 12: \ + /phoney-dep\ plus+\ 12 + +phoney\ trailing-slash13\\: /phoney-dep\ trailing-slash13\ \ + +phoney\ trailing-slash13b\\: /phoney-dep\ trailing-slash13b\ \ + \ + \ + \ + +phoney\ trailing-slash14\\: \ + /phoney-dep\ trailing-slash14\\ \ + /phoney-dep-ignore + +phoney\ 15-trailing-space\ : /phoney-dep\ 15-trailing-space\ /phoney-dep-ignore + +# Note! No stripping spaces! Trailing space here that gets stripped instead of escaped. +phoney\ 16-no-trailing-space\\: /phoney-dep\ 16-no-trailing-space\ + +phoney\ 17-3x-escaped-newlines\ becomes-single-space: /phoney-dep\ 17-3x-escaped-newlines\ \ +\ +\ + becomes-single-space + +# Note! Must have a trailing space or comment. +phoney\ 18-3x-escaped-trailing-spaces-no-newline\ \ \\: \ + /phoney-dep\ 18-3x-escaped-trailing-spaces-no-newline\ \ \ + +phoney\ 19-target-trailing-space-with-padding\ : /phoney-dep\ 19-target-trailing-space-with-padding\ /phoney-dep-ignore + +phoney\ 20-target-trailing-space-with-newline-padding\ \ +\ +: /phoney-dep\ 20-target-trailing-space-with-newline-padding\ /phoney-dep-ignore + +phoney\ 21-target-trailing-space-with-newline-padding-and-tail\ \ +\ + \ + \ +my-tail-21: /phoney-dep\ 21-target-trailing-space-with-newline-padding-and-tail\ \ +\ +\ +my-tail-21 + + +all-trailing-slashes1: /phoney-dep\ trailing-slash13\ \ + +all-trailing-slashes2: /phoney-dep\ trailing-slash13b\ \ + \ + \ + \ + diff --git a/src/kmk/testcase-includedep-esc.kmk b/src/kmk/testcase-includedep-esc.kmk new file mode 100644 index 0000000..0f08b79 --- /dev/null +++ b/src/kmk/testcase-includedep-esc.kmk @@ -0,0 +1,133 @@ +# $Id: testcase-includedep-esc.kmk 3318 2020-04-01 07:05:32Z bird $ +## @file +# kBuild - testcase for the includedep directive with filename escaping. +# + +# +# Copyright (c) 2008-2020 knut st. osmundsen <bird-kBuild-spamxx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +all_recursive: + $(ECHO) "includedep works fine" + +# Include before header to avoid secondary expansion in the noraml +# include scenario. +ifndef USE_NORMAL_INCLUDE +includedep testcase-includedep-esc-sub.kmk +else +include testcase-includedep-esc-sub.kmk +endif + +# We need the header for variables for special characters. +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk + + +ifneq ("$(deps-all /phoney/file-with-two-spaces .c)","/phoney/header-file-with-two-spaces .h") +$(error /phoney/file-with-two-spaces .c: $(deps-all /phoney/file-with-two-spaces .c)) +endif + +ifneq ("$(deps-all phoney space 1)","/phoney-dep space 1") +$(error phoney space 1: $(deps-all phoney space 1)) +endif + +ifneq ("$(deps-all phoney colon: 2)","/phoney-dep colon: 2") +$(error phoney colon: 2: $(deps-all phoney colon: 2)) +endif + +ifneq ("$(deps-all phoney hash$(HASH) 3)","/phoney-dep hash$(HASH) 3") +$(error phoney hash$(HASH) 3: $(deps-all phoney hash$(HASH) 3)) +endif + +ifeq ("$(deps-all phoney dollar$$ 4)","$/phoney-dep dollar$(DOLLAR) 4") +$(error phoney dollar$$ 4: $(deps-all phoney dollar$$ 4)) +endif + +ifneq ("$(deps-all phoney slash-space\ 5)","/phoney-dep slash-space\ 5") +$(error phoney slash-space\ 5: $(deps-all phoney slash-space\ 5)) +endif + +ifneq ("$(deps-all phoney slash-hash\$(HASH) 6)","/phoney-dep slash-hash\$(HASH) 6") +$(error phoney slash-hash\$(HASH) 6: $(deps-all phoney slash-hash\$(HASH) 6)) +endif + +ifneq ("$(deps-all phoney slash-slash-hash\\$(HASH) 7)","/phoney-dep slash-slash-hash\\$(HASH) 7") +$(error phoney slash-slash-hash\\$(HASH) 7: $(deps-all phoney slash-slash-hash\\$(HASH) 7)) +endif + +ifneq ("$(deps-all phoney equal= 8)","/phoney-dep equal= 8") +$(error phoney equal= 8: $(deps-all phoney equal= 8)) +endif + +ifneq ("$(deps-all phoney semI; 9)","/phoney-dep semi; 9") +$(error phoney semI; 9: $(deps-all phoney semI; 9)) +endif + +ifneq ("$(deps-all phoney percent% 10)","/phoney-dep percent% 10") +$(error phoney percent% 10: $(deps-all phoney percent% 10)) +endif + +ifneq ("$(deps-all phoney pipe| 11)","/phoney-dep pipe| 11") +$(error phoney pipe| 11: $(deps-all phoney pipe| 11)) +endif + +ifneq ("$(deps-all phoney plus+ 12)","/phoney-dep plus+ 12") +$(error phoney plus+ 12: $(deps-all phoney plus+ 12)) +endif + +ifneq ("$(deps-all phoney trailing-slash13\)","/phoney-dep trailing-slash13\") +$(error phoney trailing-slash13\: $(deps-all phoney trailing-slash13\)) +endif + +ifneq ("$(deps-all phoney trailing-slash13b\)","/phoney-dep trailing-slash13b\") +$(error phoney trailing-slash13b\: $(deps-all phoney trailing-slash13b\)) +endif + +ifneq ("$(deps-all phoney trailing-slash14\)","/phoney-dep trailing-slash14\ /phoney-dep-ignore") +$(error phoney trailing-slash14\: $(deps-all phoney trailing-slash14\)) +endif + +ifneq ("$(deps-all phoney 15-trailing-space )","/phoney-dep 15-trailing-space /phoney-dep-ignore") +$(error phoney 15-trailing-space : $(deps-all phoney 15-trailing-space )) +endif + +ifneq ("$(deps-all phoney 16-no-trailing-space\)","/phoney-dep 16-no-trailing-space\") +$(error phoney 16-no-trailing-space\: $(deps-all phoney 16-no-trailing-space\)) +endif + +ifneq ("$(deps-all phoney 17-3x-escaped-newlines becomes-single-space)","/phoney-dep 17-3x-escaped-newlines becomes-single-space") +$(error phoney 17-3x-escaped-newlines becomes-single-space: $(deps-all phoney 17-3x-escaped-newlines becomes-single-space)) +endif + +ifneq ("$(deps-all phoney 18-3x-escaped-trailing-spaces-no-newline \)","/phoney-dep 18-3x-escaped-trailing-spaces-no-newline \") +$(error phoney 18-3x-escaped-trailing-spaces-no-newline \: $(deps-all phoney 18-3x-escaped-trailing-spaces-no-newline \)) +endif + +ifneq ("$(deps-all phoney 19-target-trailing-space-with-padding )","/phoney-dep 19-target-trailing-space-with-padding /phoney-dep-ignore") +$(error phoney 19-target-trailing-space-with-padding : $(deps-all phoney 19-target-trailing-space-with-padding )) +endif + +ifneq ("$(deps-all phoney 20-target-trailing-space-with-newline-padding )","/phoney-dep 20-target-trailing-space-with-newline-padding /phoney-dep-ignore") +$(error phoney 20-target-trailing-space-with-newline-padding : $(deps-all phoney 20-target-trailing-space-with-newline-padding )) +endif + +ifneq ("$(deps-all phoney 21-target-trailing-space-with-newline-padding-and-tail my-tail-21)","/phoney-dep 21-target-trailing-space-with-newline-padding-and-tail my-tail-21") +$(error 21-target-trailing-space-with-newline-padding-and-tail my-tail-21: $(deps-all 21-target-trailing-space-with-newline-padding-and-tail my-tail-21)) +endif + diff --git a/src/kmk/testcase-includedep-sub.kmk b/src/kmk/testcase-includedep-sub.kmk new file mode 100644 index 0000000..b5bf546 --- /dev/null +++ b/src/kmk/testcase-includedep-sub.kmk @@ -0,0 +1,28 @@ +# $Id: testcase-includedep-sub.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild - testcase for the includdep directive, helper file +# that gets included all the time. +# + +# +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +testcase-includedep-sub.kmk=included + diff --git a/src/kmk/testcase-includedep.kmk b/src/kmk/testcase-includedep.kmk new file mode 100644 index 0000000..685f527 --- /dev/null +++ b/src/kmk/testcase-includedep.kmk @@ -0,0 +1,90 @@ +# $Id: testcase-includedep.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild - testcase for the includedep directive. +# + +# +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk + +ifdef testcase-includedep-sub.kmk +$(error testcase-includedep-sub.kmk is defined at the start of the testcase.) +endif + + +foo = testcase-includedep-sub +includedep $(foo).kmk +ifneq ($(testcase-includedep-sub.kmk),included) +$(error The first test failed.) +endif +testcase-includedep-sub.kmk := +ifdef testcase-includedep-sub.kmk +$(error testcase-includedep-sub.kmk is persistent and does not want to be undefed.) +endif + + +foo = includedep +includedep testcase-$(foo)-sub.kmk +ifneq ($(testcase-includedep-sub.kmk),included) +$(error The second test failed.) +endif +testcase-includedep-sub.kmk := +ifdef testcase-includedep-sub.kmk +$(error testcase-includedep-sub.kmk is persistent and does not want to be undefed.) +endif + + +foo = kmk +includedep testcase-includedep-sub.$(foo) +ifneq ($(testcase-includedep-sub.kmk),included) +$(error The thrid test failed.) +endif +testcase-includedep-sub.kmk := +ifdef testcase-includedep-sub.kmk +$(error testcase-includedep-sub.kmk is persistent and does not want to be undefed.) +endif + + +includedep testcase-includedep-sub.kmk +ifneq ($(testcase-includedep-sub.kmk),included) +$(error The forth test failed.) +endif +testcase-includedep-sub.kmk := +ifdef testcase-includedep-sub.kmk +$(error testcase-includedep-sub.kmk is persistent and does not want to be undefed.) +endif + + +foo = asdf +includedep testcase-$(foo)-sub.kmk +ifeq ($(testcase-includedep-sub.kmk),included) +$(error The fifth test failed.) +endif +testcase-includedep-sub.kmk := +ifdef testcase-includedep-sub.kmk +$(error testcase-includedep-sub.kmk is persistent and does not want to be undefed.) +endif + + +all_recursive: + $(ECHO) "includedep works fine" + diff --git a/src/kmk/testcase-kBuild-define.kmk b/src/kmk/testcase-kBuild-define.kmk new file mode 100644 index 0000000..1074e72 --- /dev/null +++ b/src/kmk/testcase-kBuild-define.kmk @@ -0,0 +1,141 @@ +# $Id: testcase-kBuild-define.kmk 2720 2014-01-01 22:59:50Z bird $ +## @file +# kBuild - testcase for the kBuild-define-* directives. +# + +# +# Copyright (c) 2011-2013 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +#DEPTH = ../.. +#include $(PATH_KBUILD)/header.kmk + +## +# Test if $($1) == $2 and raises an error if it isn't. +# +# @param 1 Something to apply '$' to. +# @param 2 The expected value. +TEST_EQ = $(if-expr "$($1)" == "$2",,$(error $1 is '$($1)' not '$2')) + +if 0 +# object definition syntax: +# kobject <type> <name> [extends <object> [by <||>]] [object specific args...] +# kendobj [<type> [name]] +kobject kb-target MyTarget +.TOOL = GCC +.SOURCES = file.c +kendobj +else +# Target definition. +# kBuild-define-target <name> [extends <target> [by <||>]] [using <template>] +# kBuild-endef-target [name] +kBuild-define-target MyTarget +_TOOL = GCC +_SOURCES = file.c +kBuild-endef-target +endif + +if 0 +# accesses an already defined object. +# syntax: +# kaccess <type> <name> +# kendacc [<type> [name]] +kaccess kb-target MyTarget +.SOURCES += file2.c +kendacc +else +#kBuild-access-target MyTarget +#_SOURCES += file2.c +#kBuild-endacc-target +endif + + +# Referencing an object variable, the object must exist. +# syntax: [<type>@<name>].<property> +[target@MyTarget]_SOURCES += file3.c +$(info [target@MyTarget]_SOURCES is $([target@MyTarget]_SOURCES)) + + +# Test #1 +kBuild-define-target BaseTarget using DUMMY +_SOURCES = BaseTargetSource.c +kBuild-endef-target BaseTarget +$(if-expr "$([target@BaseTarget]_SOURCES)" == "BaseTargetSource.c",,$(error [target@BaseTarget]_SOURCES is '$([target@BaseTarget]_SOURCES)' not 'BaseTargetSource.c')) +$(if-expr "$(BaseTarget_SOURCES)" == "BaseTargetSource.c",,$(error BaseTarget's _SOURCES wasn't set correctly in the global space)) + +$(if-expr "$([target@BaseTarget]_TEMPLATE)" == "DUMMY",,$(error [target@BaseTarget]_TEMPLATE is '$([target@BaseTarget]_TEMPLATE)' not 'DUMMY')) +$(if-expr "$(BaseTarget_TEMPLATE)" == "DUMMY",,$(error BaseTarget's _TEMPLATE wasn't set correctly in the global space)) + +# Test #2 +kBuild-define-target TargetWithLocals +local _LOCAL_PROP = no global alias +kBuild-endef-target +$(if-expr "$([target@TargetWithLocals]_LOCAL_PROP)" == "no global alias",,$(error [target@TargetWithLocals]_LOCAL_PROP is '$([target@TargetWithLocals]_LOCAL_PROP)' not 'no global alias')) +$(if-expr "$(TargetWithLocals_LOCAL_PROP)" == "",,$(error TargetWithLocals_LOCAL_PROP's local property 'LOCAL_PROP' was exposed globally.)) + +# Test #3 +kBuild-define-target OutsideMod +_SOURCES = file3.c +_OTHER = inside-value +kBuild-endef-target +[target@OutsideMod]_SOURCES += file4.c +[target@OutsideMod]_SOURCES <= file2.c +[target@OutsideMod]_OTHER = outside-value +$(if-expr "$([target@OutsideMod]_SOURCES)" == "file2.c file3.c file4.c",,$(error [target@OutsideMod]_SOURCES is '$([target@OutsideMod]_SOURCES)' not 'file2.c file3.c file4.c')) +$(if-expr "$(OutsideMod_SOURCES)" == "file2.c file3.c file4.c",,$(error OutsideMod_SOURCES is '$(OutsideMod_SOURCES)' not 'file2.c file3.c file4.c')) + +$(if-expr "$([target@OutsideMod]_OTHER)" == "outside-value",,$(error [target@OutsideMod]_OTHER is '$([target@OutsideMod]_OTHER)' not 'outside-value')) +$(if-expr "$(OutsideMod_OTHER)" == "outside-value",,$(error OutsideMod_OTHER is '$(OutsideMod_OTHER)' not 'outside-value')) + +# Test #4 +kBuild-define-target SpecialBase +_SOURCES = file1.c file2.c +_DEFS.win.x86 = XXX YYY +_DEFS.win.amd64 = $(filter-out YYY,$([@self]_DEFS.win.x86)) +# Unnecessary use of [@self]. +[@self]_LIBS = MyLib +kBuild-endef-target + +kBuild-define-target SpecialChild extending SpecialBase +_SOURCES = file1-child.c $(filter-out file1.c,$([@super]_SOURCES)) +# Rare use of [@super]. +[@super]_SET_BY_CHILD = 42 +kBuild-endef-target + +$(call TEST_EQ,[target@SpecialBase]_LIBS,MyLib) +$(call TEST_EQ,SpecialBase_LIBS,MyLib) + +$(call TEST_EQ,[target@SpecialBase]_SET_BY_CHILD,42) +$(call TEST_EQ,SpecialBase_SET_BY_CHILD,42) +$(call TEST_EQ,[target@SpecialChild]_SET_BY_CHILD,42) +#$(call TEST_EQ,SpecialChild_SET_BY_CHILD,42) ## @todo + +$(call TEST_EQ,[target@SpecialBase]_DEFS.win.x86,XXX YYY) +$(call TEST_EQ,[target@SpecialBase]_DEFS.win.amd64,XXX) +$(call TEST_EQ,SpecialBase_DEFS.win.amd64,XXX) +$(call TEST_EQ,[target@SpecialChild]_DEFS.win.x86,XXX YYY) +$(call TEST_EQ,[target@SpecialChild]_DEFS.win.amd64,XXX) +#$(call TEST_EQ,SpecialChild_DEFS.win.amd64,XXX) ## @todo + +$(call TEST_EQ,[target@SpecialChild]_SOURCES,file1-child.c file2.c) +$(call TEST_EQ,SpecialChild_SOURCES,file1-child.c file2.c) + +all_recursive: + @kmk_echo "kBuild-define-xxxx works fine" + diff --git a/src/kmk/testcase-lazy-deps-vars.kmk b/src/kmk/testcase-lazy-deps-vars.kmk new file mode 100644 index 0000000..75b6b9b --- /dev/null +++ b/src/kmk/testcase-lazy-deps-vars.kmk @@ -0,0 +1,72 @@ +# $Id: testcase-lazy-deps-vars.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild - testcase for the lazy dependency lists. +# + +# +# Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk + +ifneq ($(not 1),) + $(error The 'not' function is missing) +endif +ifneq ($(eq 1,1),1) + $(error The 'eq' function is missing) +endif + + +all: simple_1 + + +simple_1: variable.c variable.h variable.c variable.c variable.h function.c | variable.h read.c + @$(ECHO) "testcase-lazy-deps-vars.kmk::$@: TESTING..." + @$(ECHO) "pluss: $+" + $(if $(eq $+,variable.c variable.h variable.c variable.c variable.h function.c),,exit 1) + $(if $(eq $(deps-all $@,1),variable.c),,exit 1) + $(if $(eq $(deps-all $@,2),variable.h),,exit 2) + $(if $(eq $(deps-all $@,3),variable.c),,exit 3) + $(if $(eq $(deps-all $@,4),variable.c),,exit 4) + $(if $(eq $(deps-all $@,5),variable.h),,exit 5) + $(if $(eq $(deps-all $@,6),function.c),,exit 6) + $(if $(eq $(deps-all $@,7),),,exit 7) + + @$(ECHO) "caret: $^" + $(if $(eq $^,variable.c variable.h function.c),,exit 1) + $(if $(eq $(deps $@,1),variable.c),,exit 1) + $(if $(eq $(deps $@,2),variable.h),,exit 2) + $(if $(eq $(deps $@,3),function.c),,exit 3) + $(if $(eq $(deps $@,4),),,exit 4) + + @$(ECHO) "qmark: $?" + $(if $(eq $?,variable.c variable.h function.c),,exit 1) + $(if $(eq $(deps-newer $@,1),variable.c),,exit 1) + $(if $(eq $(deps-newer $@,2),variable.h),,exit 2) + $(if $(eq $(deps-newer $@,3),function.c),,exit 3) + $(if $(eq $(deps-newer $@,4),),,exit 4) + + @$(ECHO) " bar: $|" + $(if $(eq $|,read.c),,exit 1) + $(if $(eq $(deps-oo $@,1),read.c),,exit 1) + $(if $(eq $(deps-oo $@,2),),,exit 2) + + @$(ECHO) "testcase-lazy-deps-vars.kmk::simple_1: SUCCESS" + diff --git a/src/kmk/testcase-libpath.kmk b/src/kmk/testcase-libpath.kmk new file mode 100644 index 0000000..c5c0efc --- /dev/null +++ b/src/kmk/testcase-libpath.kmk @@ -0,0 +1,20 @@ + +all: + @kmk_builtin_echo "" + @kmk_builtin_echo "Warning: This testcase requires manual inspection and is intended for OS/2 only." + @kmk_builtin_echo "" + @kmk_builtin_echo "getting:" + @kmk_builtin_echo "libpath BEGINLIBPATH: $(libpath BEGINLIBPATH)" + @kmk_builtin_echo "libpath LIBPATH: $(libpath LIBPATH)" + @kmk_builtin_echo "libpath ENDLIBPATH: $(libpath ENDLIBPATH)" + @kmk_builtin_echo "libpath LIBPATHSTRICT: $(libpath LIBPATHSTRICT)" + @kmk_builtin_echo "setting:" + @kmk_builtin_echo "libpath ENDLIBPATH,\foobar: $(libpath ENDLIBPATH,\foobar) -> $(libpath ENDLIBPATH)" + @kmk_builtin_echo "libpath ENDLIBPATH,: $(libpath ENDLIBPATH,) -> $(libpath ENDLIBPATH)" + @kmk_builtin_echo "libpath BEGINLIBPATH,\qwerty: $(libpath BEGINLIBPATH,\qwerty) -> $(libpath BEGINLIBPATH)" + @kmk_builtin_echo "libpath BEGINLIBPATH,: $(libpath BEGINLIBPATH,) -> $(libpath BEGINLIBPATH)" + @kmk_builtin_echo "libpath LIBPATHSTRICT,T: $(libpath LIBPATHSTRICT,T) -> $(libpath LIBPATHSTRICT)" + @kmk_builtin_echo "libpath LIBPATHSTRICT,qwerty: $(libpath LIBPATHSTRICT,qwerty) -> $(libpath LIBPATHSTRICT)" + @kmk_builtin_echo "libpath LIBPATHSTRICT,F: $(libpath LIBPATHSTRICT,F) -> $(libpath LIBPATHSTRICT)" + @kmk_builtin_echo "libpath LIBPATHSTRICT,: $(libpath LIBPATHSTRICT,) -> $(libpath LIBPATHSTRICT)" + diff --git a/src/kmk/testcase-local.kmk b/src/kmk/testcase-local.kmk new file mode 100644 index 0000000..710f0e9 --- /dev/null +++ b/src/kmk/testcase-local.kmk @@ -0,0 +1,127 @@ +# +# local variables: +# o The keyword will make sure the variable is defined in +# current variable context instead of the global one. +# o Local variables are readable by children but not writable, +# writes goes to the globle space (a sideeffect / feature). +# o Local variables hides global and parent variables. +# + + +# global variable. +var_exists1 = 1 + + + +## +# A simple define that is $(eval)uated. +define def_test1 + +# check that the existing variable is accessible. +ifneq ($(var_exists1),1) + $(error var_exists1=$(var_exists1) (def_test1/1)) +endif + +# Quick check with a couple of local variables. +local var_local1 = 2 +ifneq ($(var_local1),2) + $(error var_local1=$(var_local1) (def_test1/2)) +endif +local var_local2 = 3 +ifneq ($(var_local2),3) + $(error var_local2=$(var_local2) (def_test1/3)) +endif + +# var_local1 and var_local2 should remain unchanged, var_local3 shouldn't exist. +$(evalctx $(value def_test2)) + +ifneq ($(var_local1),2) + $(error var_local1=$(var_local1) (def_test1/4)) +endif +ifneq ($(var_local2),3) + $(error var_local2=$(var_local2) (def_test1/5)) +endif +ifneq ($(var_local3),) + $(error var_local3=$(var_local3) (def_test1/6)) +endif + +endef # def_test1 + + + +## +# Called by def_test1, this checks that the locals of def_test1 +# are accessible and can be hidden by another local variable +# or updated if assigned to. +define def_test2 + +# check that the existing variables are accessible, including the def_test1 ones. +ifneq ($(var_exists1),1) + $(error var_exists1=$(var_exists1) (def_test2/1)) +endif +ifneq ($(var_local1),2) + $(error var_local1=$(var_local1) (def_test2/2)) +endif +ifneq ($(var_local2),3) + $(error var_local2=$(var_local2) (def_test2/3)) +endif + +# Make a local var_local1 that hides the one in def_test1. +local var_local1 = 20 +ifneq ($(var_local1),20) + $(error var_local1=$(var_local1) (def_test2/4)) +endif + +# FEATURE: Update the var_local2 variable, this should be visible in the global space and not the local. +var_local2 = 30 +ifneq ($(var_local2),3) + $(error var_local2=$(var_local2) (def_test2/5)) +endif + +# create a new local variable that isn't accessible from def_test1. +local var_local3 = 4 +ifneq ($(var_local3),4) + $(error var_local3=$(var_local3) (def_test2/6)) +endif + +endef # def_test2 + + + +# +# The test body +# + +# None of the local variables should exist. +ifneq ($(var_local1),) + $(error var_local1=$(var_local1)) +endif +ifneq ($(var_local2),) + $(error var_local2=$(var_local2)) +endif +ifneq ($(var_local3),) + $(error var_local3=$(var_local3)) +endif + +# Evaluate the function in a local context. +$(evalctx $(value def_test1)) + +# FEATURE: see var_local2 = 30 in def_test2. +ifneq ($(var_local2),30) + $(error var_local2=$(var_local2)) +endif + +# None of the other local variables should exist. +ifneq ($(var_local1),) + $(error var_local1=$(var_local1)) +endif +ifneq ($(var_local3),) + $(error var_local3=$(var_local3)) +endif + + + +# dummy +all: + echo local variables works. + diff --git a/src/kmk/testcase-math.kmk b/src/kmk/testcase-math.kmk new file mode 100644 index 0000000..bd4fb7e --- /dev/null +++ b/src/kmk/testcase-math.kmk @@ -0,0 +1,98 @@ +# $Id: testcase-math.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild - testcase for the math functions. +# + +# +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk + +ifneq ($(not 1),) + $(error The 'not' function is missing) +endif +ifneq ($(eq 1,1),1) + $(error The 'eq' function is missing) +endif + + +ASSERT_TRUE = $(if $(not $(1)),$(error failure: '$(1)' isn't true)) +ASSERT_FALSE = $(if $(1) ,$(error failure: '$(1)' isn't false)) + +$(call ASSERT_TRUE, $(int-eq 0x0, 0)) +$(call ASSERT_FALSE,$(int-eq 1, 0)) +$(call ASSERT_FALSE,$(int-eq 1123123123, 9898787987)) +$(call ASSERT_TRUE, $(int-eq 1234567890, 1234567890)) +$(call ASSERT_TRUE, $(int-eq 0x1c, 28)) +$(call ASSERT_TRUE, $(int-eq 1c, 28)) +$(call ASSERT_TRUE, $(int-ne 0x123, -0x123)) +$(call ASSERT_TRUE, $(int-ne 123, -0x123)) +$(call ASSERT_FALSE,$(int-ne 0x100, 256)) +$(call ASSERT_FALSE,$(int-ne 0x0, 0)) +$(call ASSERT_FALSE,$(int-ne 0x1c, 28)) +$(call ASSERT_TRUE, $(int-le 0, 0)) +$(call ASSERT_TRUE, $(int-le -0, 0)) +$(call ASSERT_FALSE,$(int-le 5, 1)) +$(call ASSERT_FALSE,$(int-lt 5, 1)) +$(call ASSERT_FALSE,$(int-lt 5, 5)) +$(call ASSERT_TRUE, $(int-lt 9, 10)) +$(call ASSERT_TRUE, $(int-lt -9, -8)) +$(call ASSERT_TRUE, $(int-ge 0, 0)) +$(call ASSERT_TRUE, $(int-ge -0, 0)) +$(call ASSERT_TRUE, $(int-ge 1, 0)) +$(call ASSERT_TRUE, $(int-ge -55, -55)) +$(call ASSERT_TRUE, $(int-ge 512, 400)) +$(call ASSERT_TRUE, $(int-ge -18, -19)) +$(call ASSERT_FALSE,$(int-ge -19, -18)) +$(call ASSERT_FALSE,$(int-ge 15, 20)) +$(call ASSERT_FALSE,$(int-gt 15, 20)) +$(call ASSERT_FALSE,$(int-gt 15, 15)) +$(call ASSERT_TRUE, $(int-gt 20, 15)) + +ASSERT2 = $(if $(not $(int-eq $(1),$(2))),$(error failure: '$(1)' -ne '$(2)')) +$(call ASSERT2,$(int-add 1, 1),0x2) +$(call ASSERT2,$(int-add 1, 1, 1, 1, 1, 1, 1),7) +$(call ASSERT2,$(int-add 1, -1),0) +$(call ASSERT2,$(int-sub 1, -1),2) +$(call ASSERT2,$(int-sub 1, 5),-4) +$(call ASSERT2,$(int-mul 0x10, 0x20),0x200) +$(call ASSERT2,$(int-mul 0x20, 0x10),0x200) +$(call ASSERT2,$(int-mul 4, 7),28) +$(call ASSERT2,$(int-mul 2, 2, 2, 2, 2, 4, 1, 1, 1, 1),128) +$(call ASSERT2,$(int-div 0x1000, 0x100),0x10) +$(call ASSERT2,$(int-div 999, 10),99) +$(call ASSERT2,$(int-div 4096, 4,2,2,2,2),64) +#$(call ASSERT2,$(int-div 0x1230023213, 0),0x0) +$(call ASSERT2,$(int-mod 19, 10),9) +$(call ASSERT2,$(int-mod 9, 10),9) +$(call ASSERT2,$(int-mod 30, 10),0) +$(call ASSERT2,$(int-not 0),-1) +$(call ASSERT2,$(int-and 1, 1),1) +$(call ASSERT2,$(int-and 0x123123214, 0xfff),0x214) +$(call ASSERT2,$(int-and 0x123123214, 0xf0f, 0xf),4) +$(call ASSERT2,$(int-or 1, 1, 1, 2, 2),3) +$(call ASSERT2,$(int-xor 1, 1, 2, 2),0) +$(call ASSERT2,$(int-xor 1, 2, 4),7) + + +all_recursive: + $(ECHO) The math works. 6 * 7 = $(int-mul 6,7) + diff --git a/src/kmk/testcase-root.kmk b/src/kmk/testcase-root.kmk new file mode 100644 index 0000000..92de5c5 --- /dev/null +++ b/src/kmk/testcase-root.kmk @@ -0,0 +1,30 @@ +# +# The $(root ...) and $(notroot ) functions. +# + + + +x := $(root /a) +y := $(notroot /a) +ifneq ($x,/) + $(error x=$x) +endif +ifneq ($y,a) + $(error y=$y) +endif + +x := $(root /a /b /) +y := $(notroot /a /b /) +ifneq ($x,/ / /) + $(error x=$x) +endif +ifneq ($y,a b .) + $(error y=$y) +endif + + +# dummy +all: + echo The root and notroot functions works. + + diff --git a/src/kmk/testcase-stack.kmk b/src/kmk/testcase-stack.kmk new file mode 100644 index 0000000..e610319 --- /dev/null +++ b/src/kmk/testcase-stack.kmk @@ -0,0 +1,86 @@ +# $Id: testcase-stack.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild - testcase for the functions. +# + +# +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk + +ifneq ($(not 1),) + $(error The 'not' function is missing) +endif +ifneq ($(eq 1,1),1) + $(error The 'eq' function is missing) +endif + +ASSERT1 = $(if $(not $(eq $(STACK1),$(1))),$(error failure: STACK1:='$(STACK1)' expected='$(1)')) +$(call stack-push,STACK1,1) +$(call ASSERT,1) +$(call stack-push,STACK1,2) +$(call ASSERT,1 2) +$(call stack-push,STACK1,3) +$(call ASSERT,1 2 3) +$(call stack-push,STACK1,4) +$(call ASSERT,1 2 3 4) +$(call stack-push,STACK1,5) +$(call ASSERT,1 2 3 4 5) +$(call stack-popv,STACK1) +$(call ASSERT,1 2 3 4) +$(call stack-push,STACK1,5) +$(call ASSERT,1 2 3 4 5) +$(call stack-popv,STACK1) +$(call ASSERT,1 2 3 4) +$(call stack-popv,STACK1) +$(call ASSERT,1 2 3) +$(call stack-push,STACK1,4) +$(call ASSERT,1 2 3 4) +$(call stack-push,STACK1,5) +$(call ASSERT,1 2 3 4 5) +top := $(call stack-top,STACK1) +$(if $(not $(eq $(top),5)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='5')) +$(call ASSERT,1 2 3 4 5) +top := $(call stack-pop,STACK1) +$(if $(not $(eq $(top),5)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='5')) +$(call ASSERT,1 2 3 4) +top := $(call stack-pop,STACK1) +$(if $(not $(eq $(top),4)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='4')) +$(call ASSERT,1 2 3) +top := $(call stack-pop,STACK1) +$(if $(not $(eq $(top),3)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='3')) +$(call ASSERT,1 2) +top := $(call stack-pop,STACK1) +$(if $(not $(eq $(top),2)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='2')) +$(call ASSERT,1) +top := $(call stack-top,STACK1) +$(if $(not $(eq $(top),1)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='1')) +$(call ASSERT,1) +top := $(call stack-pop,STACK1) +$(if $(not $(eq $(top),1)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='1')) +$(call ASSERT,) +top := $(call stack-pop,STACK1) +$(if $(not $(eq $(top),)),$(error failure STACK1:='$(STACK1)' top:='$(top)' expected='')) +$(call ASSERT,) + +all_recursive: + $(ECHO) The stack works.$(STACK1) + diff --git a/src/kmk/testcase-which.kmk b/src/kmk/testcase-which.kmk new file mode 100644 index 0000000..9ff82c7 --- /dev/null +++ b/src/kmk/testcase-which.kmk @@ -0,0 +1,5 @@ + +all: + @echo which kmk: $(which kmk) + @echo which kmk: $(which kmk kmk kmk ) + diff --git a/src/kmk/testcase-xargs.kmk b/src/kmk/testcase-xargs.kmk new file mode 100644 index 0000000..ee6b5a8 --- /dev/null +++ b/src/kmk/testcase-xargs.kmk @@ -0,0 +1,59 @@ +# $Id: testcase-xargs.kmk 2413 2010-09-11 17:43:04Z bird $ +## @file +# kBuild - testcase for the xargs function. +# Requires manual inspection of the output. +# + +# +# Copyright (c) 2007-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net> +# +# This file is part of kBuild. +# +# kBuild is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# kBuild 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 for more details. +# +# You should have received a copy of the GNU General Public License +# along with kBuild. If not, see <http://www.gnu.org/licenses/> +# +# + +DEPTH = ../.. +include $(PATH_KBUILD)/header.kmk + +ifneq ($(not 1),) + $(error The 'not' function is missing) +endif +ifneq ($(eq 1,1),1) + $(error The 'eq' function is missing) +endif + + +ASSERT_TRUE = $(if $(not $(1)),$(error failure: '$(1)' isn't true)) +ASSERT_FALSE = $(if $(1) ,$(error failure: '$(1)' isn't false)) + +# 94 bytes +ONEARG = abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_abcdefghijklmnopqrstuvwxyz_xxxxxxxxxxxx +ITERATIONS := 0 1 2 3 4 5 6 7 8 9 +ITERATIONS := $(foreach i, 0 1 2 3 4 5 6 7 8 9,$(addprefix $(i),$(ITERATIONS))) +ITERATIONS := $(foreach i, 0 1 2 3 4 5 6 7 8 9,$(addprefix $(i),$(ITERATIONS))) +ITERATIONS := $(foreach i, 0 1 2 3 4 5 6 7 8 9,$(addprefix $(i),$(ITERATIONS))) +ITERATIONS := $(foreach i, 0 1 2 3 4 5 6 7 8 9,$(addprefix $(i),$(ITERATIONS))) + +# add a 5 bytes sequence number and a space, then duplicate it 10000 times: +# 100 bytes * 10000 = 1,000,000 bytes. +REALLY_LONG := $(foreach i,$(ITERATIONS),$(i)$(ONEARG)) + + +#$(call ASSERT_TRUE, $(xargs $(ECHO) 1:, $(ECHO) 2:, $(ECHO) 3:, asdf asdf asdf asdf asdf asdf asdf adf asdf asdf)) + +all_recursive: + $(xargs @$(ECHO_EXT) 1:, @$(ECHO_EXT) 2:, @$(ECHO_EXT) 3:, $(REALLY_LONG)) + $(ECHO) done + diff --git a/src/kmk/testcase/testcase-export.kmk b/src/kmk/testcase/testcase-export.kmk new file mode 100644 index 0000000..5d0c4b4 --- /dev/null +++ b/src/kmk/testcase/testcase-export.kmk @@ -0,0 +1,48 @@ + + +var0 = value0 +var1 = value1 +var2 = value2 +var3 = value3 +var4 = value4 +var5 = value5 +var6 = value6 +var7 = value7 +var8 = value8 +var9 = value9 + +varname1 = var1 +varname2 = var2 +varname3 = var3 +varname4 = var4 +varname5 = var5 +varname5 = var5 +varname6 = var6 +varname7 = var7 +varname8 = var8 +varname9 = var9 + +export var0 var8 $(varname1) $(subst foo,var, foo2 ) +export $(foreach x, 3 4 \ +,$(subst \ +odd(, \ + parenthesis parsing behaviour), dont-mind-this-type{ except if you put a ${dollar} in front of it, \ +$(varname$(x)) \ +)\ +) + +export ${foreach x, 5 \ +,${subst \ +odd{, \ + parenthesis parsing behaviour}, dont-mind-this-type( \ + except if you put a $(dollar) in front of it; two dollars $$(does do the trick though, \ +${varname$x}} \ +}\ +} + +export $ ${varname6} +export $(varname7$) + +all: + kmk_ash -c "export | kmk_sed '/var/!d' + |