The NetBSD Project

CVS log for src/usr.bin/make/unit-tests/varmod-loop.mk

[BACK] Up to [cvs.NetBSD.org] / src / usr.bin / make / unit-tests

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.26: download - view: text, markup, annotated - select for diffs
Sun Jun 2 15:31:26 2024 UTC (5 months, 4 weeks ago) by rillig
Branches: MAIN
CVS tags: perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs, HEAD
Diff to: previous 1.25: preferred, colored
Changes since revision 1.25: +5 -5 lines
make: sync VarEvalMode constant names with their debug log names

Revision 1.25: download - view: text, markup, annotated - select for diffs
Sat Jun 1 05:08:48 2024 UTC (6 months ago) by rillig
Branches: MAIN
Diff to: previous 1.24: preferred, colored
Changes since revision 1.24: +3 -5 lines
make: remove unused VARE_EVAL_KEEP_DOLLAR

Revision 1.24: download - view: text, markup, annotated - select for diffs
Sun Nov 19 21:47:52 2023 UTC (12 months, 1 week ago) by rillig
Branches: MAIN
Diff to: previous 1.23: preferred, colored
Changes since revision 1.23: +3 -3 lines
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity.  The wording in make's diagnostics will be changed in a
follow-up commit.

Revision 1.23: download - view: text, markup, annotated - select for diffs
Sat Feb 18 11:55:20 2023 UTC (21 months, 1 week ago) by rillig
Branches: MAIN
Diff to: previous 1.22: preferred, colored
Changes since revision 1.22: +16 -3 lines
tests/make: document the modifier ':@var@body@'

Revision 1.22: download - view: text, markup, annotated - select for diffs
Sat Feb 18 11:16:09 2023 UTC (21 months, 1 week ago) by rillig
Branches: MAIN
Diff to: previous 1.21: preferred, colored
Changes since revision 1.21: +3 -4 lines
make: fix parsing of unevaluated subexpressions with unbalanced '{}'

Since var.c 1.323 from 2020-07-26, modifiers containing unbalanced
braces or parentheses were parsed differently, depending on whether they
were relevant or not.

For example, the expression '${VAR:...}' is enclosed with braces. When
this expression has a modifier ':S,},}},g' that would double each '}' in
that expression, the parser got confused:

If the expression was relevant, the modifier was parsed as usual, taking
into account that the 3 '}' in the modifier are ordinary characters.

If the expression was irrelevant, the parser only counted the '{' and
the '}', without taking into account that a '}' might be escaped by a
'\' or be an ordinary character.  Parsing therefore stopped at the first
'}', assuming it would finish the expression '${VAR:S,}'.

This parsing mode of only counting balanced '{' and '}' makes sense for
the modifier ':@var@...@', which expands each word of the expression
using the template from the '...'.  These templates tend to be simple
enough that counting the '{' and '}' suffices.

Revision 1.21: download - view: text, markup, annotated - select for diffs
Tue Aug 23 21:13:46 2022 UTC (2 years, 3 months ago) by rillig
Branches: MAIN
CVS tags: netbsd-10-base, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10
Diff to: previous 1.20: preferred, colored
Changes since revision 1.20: +33 -1 lines
tests/make: document how the modifier ':@' works

Revision 1.20: download - view: text, markup, annotated - select for diffs
Tue Aug 23 19:22:01 2022 UTC (2 years, 3 months ago) by rillig
Branches: MAIN
Diff to: previous 1.19: preferred, colored
Changes since revision 1.19: +3 -2 lines
make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.

Revision 1.19: download - view: text, markup, annotated - select for diffs
Tue Aug 23 17:40:43 2022 UTC (2 years, 3 months ago) by rillig
Branches: MAIN
Diff to: previous 1.18: preferred, colored
Changes since revision 1.18: +13 -1 lines
tests/make: demonstrate parse error in ':@' modifier (since 2022-08-08)

Reported by sjg via private mail.

Revision 1.18: download - view: text, markup, annotated - select for diffs
Sun Dec 5 15:20:13 2021 UTC (2 years, 11 months ago) by rillig
Branches: MAIN
Diff to: previous 1.17: preferred, colored
Changes since revision 1.17: +1 -29 lines
make: fix use-after-free in modifier ':@'

Without memory allocator debugging, the newly added test doesn't show
any obvious failure.

With memory allocator debugging enabled, all make versions since
2016.02.27.16.20.06 crash with a segmentation fault.

Revision 1.17: download - view: text, markup, annotated - select for diffs
Sun Dec 5 15:01:04 2021 UTC (2 years, 11 months ago) by rillig
Branches: MAIN
Diff to: previous 1.16: preferred, colored
Changes since revision 1.16: +29 -4 lines
tests/make: demonstrate use-after-free in modifier ':@'

Revision 1.16: download - view: text, markup, annotated - select for diffs
Tue Nov 30 23:52:19 2021 UTC (3 years ago) by rillig
Branches: MAIN
Diff to: previous 1.15: preferred, colored
Changes since revision 1.15: +4 -1 lines
tests/make: test and document .MAKE.SAVE_DOLLARS and ':='

Revision 1.15: download - view: text, markup, annotated - select for diffs
Sun Apr 11 13:35:56 2021 UTC (3 years, 7 months ago) by rillig
Branches: MAIN
CVS tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Diff to: previous 1.14: preferred, colored
Changes since revision 1.14: +2 -2 lines
make: clean up remaining references to VarEvalFlags

VarEvalFlags has been replaced with VarEvalMode.  There were some
comments and tests that still referred to the old names.

No functional change.

Revision 1.14: download - view: text, markup, annotated - select for diffs
Sun Apr 4 13:20:52 2021 UTC (3 years, 7 months ago) by rillig
Branches: MAIN
Diff to: previous 1.13: preferred, colored
Changes since revision 1.13: +1 -70 lines
tests/make: split test for modifier ':@' into separate files

The file varmod-loop.mk has grown too large to be single-purpose, plus
it combined parse-time and run-time tests.  This has the downside that
as soon as a parse-time test results in an error, the run-time tests are
not run anymore.

Revision 1.13: download - view: text, markup, annotated - select for diffs
Mon Mar 15 17:54:49 2021 UTC (3 years, 8 months ago) by rillig
Branches: MAIN
Diff to: previous 1.12: preferred, colored
Changes since revision 1.12: +32 -21 lines
tests/make: convert varmod-loop to parse-time

In case of unexpected failures, this provides the line number of the
'.error' directive.

Revision 1.12: download - view: text, markup, annotated - select for diffs
Mon Mar 15 17:11:08 2021 UTC (3 years, 8 months ago) by rillig
Branches: MAIN
Diff to: previous 1.11: preferred, colored
Changes since revision 1.11: +2 -1 lines
tests/make: add position marker in test 'varmod-loop'

Revision 1.11: download - view: text, markup, annotated - select for diffs
Mon Mar 15 12:15:03 2021 UTC (3 years, 8 months ago) by rillig
Branches: MAIN
Diff to: previous 1.10: preferred, colored
Changes since revision 1.10: +10 -10 lines
make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c.  It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases.  Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly.  This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.

Revision 1.10: download - view: text, markup, annotated - select for diffs
Tue Feb 23 14:17:21 2021 UTC (3 years, 9 months ago) by rillig
Branches: MAIN
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +105 -6 lines
make: demonstrate how to undefine variables during evaluation

For a very long time now, I had thought that it would be impossible to
undefine global variables during the evaluation of variable expressions.
This is something that the memory management in Var_Parse relies upon,
see the comment 'the value of the variable must not change'.

After several unsuccessful attempts at referring to an already freed
previous value of a variable, today I discovered how to unset a global
variable while evaluating an expression, which has the same effect.  To
demonstrate that this use-after-free can reliably crash make, it would
need a memory allocator with a debug mode that never re-allocates the
same memory block after it has been used once.  This is something that
jemalloc cannot do at the moment.  Valgrind would be another idea, but
that has not been ported to NetBSD.

Undefining a global variable while evaluating an expression is made
possible by an implementation detail of the modifier ':@'.  That
modifier undefines the loop variable, without restoring its previous
value, see ApplyModifier_Loop.

By the very old conventions of ODE Make, these loop variables are named
'.V.' and thus do not conflict with variables from other naming
conventions.  In NetBSD and pkgsrc, these loop variables are typically
called 'var', sometimes '_var' with a leading underscore, which also
doesn't conflict with the typical form 'VAR' of variables in the global
namespace.  Therefore, in practice these loop variables don't interfere
with other variables.

One case that can practically arise is when an outer variable has a
modifier ':@word@${VAR.${word}}@' and one of the referenced variables
uses the same variable name in the modifier, see varmod-loop.mk 1.10
line 91 for a detailed explanation.

By using the ${:@VAR@@} modifier in a place that is evaluated with
cmdline scope, it is not only possible to undefine global variables, it
is possible to undefine cmdline variables as well.  When evaluated in a
specific make target, the expression ${:@\@@@} can even be used to
undefine the variable '.TARGET', which will probably crash make with an
assertion failure.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Thu Feb 4 21:42:47 2021 UTC (3 years, 9 months ago) by rillig
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +3 -3 lines
make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else.  In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope.  It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.

Revision 1.8: download - view: text, markup, annotated - select for diffs
Thu Nov 12 00:40:55 2020 UTC (4 years ago) by rillig
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +3 -1 lines
make(1): fix tests varmod-defined and varmod-loop regarding dollars

Some derived versions of NetBSD's make set .MAKE.SAVE_DOLLARS to no.  In
these versions, running the tests would fail.  Therefore better set
.MAKE.SAVE_DOLLARS to yes explicitly as far as necessary.

Suggested by sjg.

Revision 1.7: download - view: text, markup, annotated - select for diffs
Sun Nov 8 18:05:32 2020 UTC (4 years ago) by rillig
Branches: MAIN
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +44 -1 lines
make(1): add test demonstrating how ':=' and ':@var@' interact

Revision 1.6: download - view: text, markup, annotated - select for diffs
Tue Nov 3 18:21:36 2020 UTC (4 years ago) by rillig
Branches: MAIN
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +2 -2 lines
make(1): in tests, replace "dollar character" with "dollar sign"

Revision 1.5: download - view: text, markup, annotated - select for diffs
Sat Oct 31 12:34:03 2020 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +22 -3 lines
make(1): add test for combining the :@ and :? variable modifiers

Revision 1.4: download - view: text, markup, annotated - select for diffs
Sun Oct 18 21:12:13 2020 UTC (4 years, 1 month ago) by rillig
Branches: MAIN
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +16 -1 lines
make(1): add test for nested :@ modifiers using the same variable name

Revision 1.3: download - view: text, markup, annotated - select for diffs
Sun Sep 13 07:32:32 2020 UTC (4 years, 2 months ago) by rillig
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +6 -1 lines
make(1): add test for empty variable name in :@var@...@ modifier

Revision 1.2: download - view: text, markup, annotated - select for diffs
Sun Aug 16 12:30:45 2020 UTC (4 years, 3 months ago) by rillig
Branches: MAIN
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +60 -5 lines
make(1): move tests for :S, :C, :@ from modmisc to their separate tests

Revision 1.1: download - view: text, markup, annotated - select for diffs
Sun Aug 16 12:07:51 2020 UTC (4 years, 3 months ago) by rillig
Branches: MAIN
make(1): add dummies for fine-grained tests, one per single feature

The test names have been derived from the current manual page.

All these tests are dummies right now, and the code from the existing
tests will be moved into the new tests step by step.

This is done to prevent modmisc, escape, varmod-edge and varmisc from
growing without any bounds, and to reduce the side-effects of one test
to the others.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>