aboutsummaryrefslogtreecommitdiff
path: root/testsuite (follow)
Commit message (Collapse)AuthorAgeFilesLines
* cut: detect error when bounds are reversedRon Yorston2024-10-221-1/+4
| | | | | | | | | | | | | The command 'cut -b 3-2' failed to detect that the bounds were incorrectly ordered, though the check worked when the difference between the bounds was larger. The comparison was made after the lower bound has been decremented but before the upper bound had. Adds 0-16 bytes. (GitHub issue #467)
* make: changes to .DEFAULT/inference rulesRon Yorston2024-10-201-12/+20
| | | | | | | | | | | | | | | The POSIX standard allows inference rules to be redefined but not the .DEFAULT rule. There is no explicit exception for .DEFAULT to: Only one target rule for any given target can contain commands. Treat redefinition of a .DEFAULT rule as an error in POSIX mode but allow it as an extension. Also, the code didn't allow an inference rule with dependencies to redefine an existing inference rule. This is no longer the case. Adds 64-96 bytes.
* make: reinstate conditional skipping of command linesRon Yorston2024-09-101-0/+2
| | | | | | | | | | | | | | Commit e90345c10 (make: allow empty commands) rearranged readline() in a way that broke the use of conditionals within the definition of a rule. Add a test case to detect this. Adjust readline() so that conditionals are processed before returning command lines or checking for empty lines and comments. Remove the test for a leading tab in skip_lines(). This allows conditionals in the definition of a rule to be indented with a leading tab.
* make: disallow inference rules for phony targetsRon Yorston2024-08-101-0/+14
| | | | | | | | | | | | | | GNU make doesn't allow inference rules or the .DEFAULT target to be used for phony targets. POSIX is unclear on the matter but there doesn't seem to be an explicit prohibition of inference rules or .DEFAULT. Follow the GNU make behaviour as a non-POSIX extension. Adds 48-80 bytes. (pdpmake GitHub issue 56)
* make: allow empty commandsRon Yorston2024-08-081-0/+11
| | | | | | | | | | | | | | | | | | | | | pdpmake didn't allow rules to have empty commands. There are circumstances where this may be useful. Make the following changes: - Add a flag to readline() to indicate the next line is expected to be a command. If this flag is true and the input line starts with a tab return it immediately, thus skipping the check for an empty line or comment line. - In docmds() skip tabs and spaces after a command prefix. If the resulting command is empty don't print it or try to execute it. - In newcmd() allow empty commands. Adds 48-96 bytes. (pdpmake GitHub issue 56)
* ed: fix line insertion before current lineRon Yorston2024-07-181-0/+21
| | | | | | | | | | | | | | When text is inserted by insertLine() the lines following the insertion are moved down and the insertion point is made the new current line. To avoid too much scanning of the linked list of lines setCurNum() may use the position of the old current line to determine the location of the new current line. If the insertion point is before the old current line in the file the latter will have been moved down, so its line pointer needs to be adjusted. (GitHub issue #431)
* Merge branch 'busybox' into mergeRon Yorston2024-07-101-11/+20
|\
| * awk: restore assignment precedence to be lower than ternary ?:Denys Vlasenko2024-07-091-11/+20
| | | | | | | | | | | | | | Something is fishy with constrcts like "3==v=3" in gawk, they should not work, but do. Ignore those for now. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: update for POSIX 2024Ron Yorston2024-06-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Now that POSIX.1-2024 has been released we can replace all references to the 202X draft standard with 2024. Make this change throughout the code and testsuite. The pragma 'posix_2024' has been added. 'posix_202x' remains as an alias for the same. The 2024 standard is enforced by default in POSIX mode.
* | make: move test for complex chain of macro assignmentsRon Yorston2024-06-011-14/+14
| | | | | | | | | | | | The test 'Complex chain of macro assignments' relies on recursive macro expansion. This is a POSIX 202X feature, so the test should be moved to the appropriate section of the test script.
* | make: fix detection of target rules (take 2)Ron Yorston2024-05-311-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit d6b764116 (make: fix detection of target rules) checked for target rules before macro assignments. This failed for some Makefiles generated by autotools because partially defined macros were expanded while testing for a target rule. Revert to checking for macro assignments first, but try to detect if the proposed left hand side of the assignment might form part of a target rule with an inline command. Also handle the case where the ';' separator of the inline command has been obfuscated by putting it in a macro. Saves 128-160 bytes. (GitHub pdpmake issues 31, 44)
* | make: allow :::= macro assignment on command lineRon Yorston2024-05-291-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | GNU make and bmake have different implementations for := macro assignment. In POSIX 202X these are supported by the forms ::= and :::= respectively. Only the former was supported on the pdpmake command line. Add the required support in process_macros() and update the usage message. Adds 48-64 bytes.
* | make: relax the test 'Return error if command fails'Ron Yorston2024-05-291-1/+1
| | | | | | | | | | The test 'Return error if command fails' needed an exit code of 2. POSIX only requires an exit code greater than 0.
* | make: fixes to -q optionRon Yorston2024-05-281-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | The -q option returns an exit status to indicate if targets are up-to-date (0) or in need of updating (1) but without updating them. As an exception (imported from GNU make) build commands with a '+' prefix are executed. pdpmake didn't implement the exception. Doing so required moving handling of the -q option down into docmds(). Saves 48 bytes.
* | make: fixes to -t optionRon Yorston2024-05-281-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The -t option (in general) causes targets to be touched instead of having build commands run to create them. There were two problems. The flag variable 'ssilent' in docmds was too small (uint8_t) to contain the value of 'dotouch' (uint32_t). Truncation of the value resulted in build commands being echoed when they shouldn't have been. The POSIX specification is unclear as to how build commands with a '+' prefix interact with touch. The rationale indicates that this feature was imported from GNU make, so the behaviour has been made to match what it does: if a '+' build command is run the target is not touched. The code has been rearranged to move the call to touch() up into docmds(). Adds 48 bytes.
* | make: fix tests for BSDRon Yorston2024-05-241-4/+4
| | | | | | | | | | | | A couple of tests require backslashes to be escaped. The test for CURDIR should use 'pwd -P' to resolve symlinks.
* | make: add support for ifeq/ifneqRon Yorston2024-05-221-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for the conditional directives ifeq and ifneq. These follow GNU make in allowing things like: ifeq (arg1,arg2) ifeq 'arg1' 'arg2' In the second case single or double quotes may be used. Macros are expanded in the two arguments and the resulting strings are compared. Adds 240-248 bytes.
* | make: set $< and $* for target rulesRon Yorston2024-05-221-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX only requires $< and $* to be set for inference rules, not target rules. As an extension allow them to be set for target rules, as in GNU make. This may or may not be useful. In POSIX mode, when $< and $* are only set for inference rules, they're set to an empty string for target rules. This avoids the possibility of stale values being used. Adds 64-80 bytes. (GitHub issue #407)
* | make: add support for CURDIR macroRon Yorston2024-05-221-0/+25
| | | | | | | | | | | | | | | | | | | | | | Austin Group defect report 1626 introduced support for the CURDIR macro: https://www.austingroupbugs.net/view.php?id=1626 Implement this as a POSIX 202X feature. Adds 160-176 bytes.
* | make: allow mixed macros and targets on command lineRon Yorston2024-04-211-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | POSIX requires macro definitions to appear before targets on the command line. Allow mixed macros and targets as an extension. All macros on the command line are read first, then the targets are processed. Costs 64-80 bytes. (GitHub issue #406)
* | make: skip shell -e option when running commandsRon Yorston2024-04-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX says, regarding execution of commands: The execution line shall then be executed by a shell as if it were passed as the argument to the system() interface, except that if errors are not being ignored then the shell -e option shall also be in effect. As a non-POSIX extension, skip the use of the -e option. This is how GNU make and BSD make behave. (GitHub issue #409)
* | make: allow '#' to be escaped with a backslashRon Yorston2024-03-111-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX doesn't allow the '#' comment marker to be escaped, though some implementations do. As a non-POSIX extension allow '#' to be escaped with a preceding backslash. It isn't necessary to escape '#' in macro expansions or command lines: these cases are covered by an existing extension. Commit 0aceca867 (make: comments in macro expansions and command lines) Adds 16-32 bytes. (pdpmake GitHub issue 38)
* | Merge branch 'busybox' into mergeRon Yorston2024-01-052-0/+44
|\|
| * time: implement %% and \escapes in -f FMTDenys Vlasenko2024-01-011-0/+37
| | | | | | | | | | | | | | function old new delta time_main 1217 1316 +99 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix handling of empty fieldsDenys Vlasenko2023-12-311-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by M Rubon <rubonmtz@gmail.com>: Busybox awk handles references to empty (not provided in the input) fields differently during the first line of input, as compared to subsequent lines. $ (echo a ; echo b) | awk '$2 != 0' #wrong b No field $2 value is provided in the input. When awk references field $2 for the "a" line, it is seen to have a different behaviour than when it is referenced for the "b" line. Problem in BusyBox v1.36.1 embedded in OpenWrt 23.05.0 Same problem also in 21.02 versions of OpenWrt Same problem in BusyBox v1.37.0.git I get the correct expected output from Ubuntu gawk and Debian mawk, and from my fix. will@dev:~$ (echo a ; echo b) | awk '$2 != 0' #correct a b will@dev:~/busybox$ (echo a ; echo b ) | ./busybox awk '$2 != 0' #fixed a b I built and poked into the source code at editors/awk.c The function fsrealloc(int size) is core to allocating, initializing, reallocating, and reinitializing fields, both real input line fields and imaginary fields that the script references but do not exist in the input. When fsrealloc() needs more field space than it has previously allocated, it initializes those new fields differently than how they are later reinitialized for the next input line. This works fine for fields defined in the input, like $1, but does not work the first time when there is no input for that field (e.g. field $99) My one-line fix simply makes the initialization and clrvar() reinitialization use the same value for .type. I am not sure if there are regression tests to run, but I have not done those. I'm not sure if I understand why clrvar() is not setting .type to a default constant value, but in any case I have left that untouched. function old new delta ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: proper handling of build failure with '-k'Ron Yorston2023-12-221-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | When a build command fails and the '-k' option (continue on error) is in effect, no further commands should be executed for the current target. Also, the resulting diagnostic should be reported to stderr. As should the final 'not built due to errors' diagnostic. Adds 80 bytes. (pdpmake GitHub issue 35)
* | Merge branch 'busybox' into mergeFRP-5236-g7dff7f376Ron Yorston2023-12-051-0/+20
|\|
| * start-stop-daemon: add -d DIR chdir optionejaaskel2023-11-071-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add option to change the running directory before starting the process. This can be done using -d or --chdir options. Add also test cases to start-stop-daemon to test out the directory change option. function old new delta packed_usage 34602 34648 +46 start_stop_daemon_main 1107 1130 +23 start_stop_daemon_longopts 156 164 +8 .rodata 105382 105384 +2 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 79/0) Total: 79 bytes Signed-off-by: ejaaskel <esa.jaaskela@suomi24.fi> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | make: fix detection of target rulesRon Yorston2023-10-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The presence of an equal sign in an inline command on a target rule caused the line to be detected as a macro assignment. For example: target:; @echo a = $(a) Rearrange input parsing so target rules are detected before macro assignments. This is made more complex by having to allow for the ':=', '::=' and ':::=' assignment operators. (And for targets containing colons on Windows.) Costs 240-248 bytes.
* | make: return non-zero exit status when a command failsRon Yorston2023-09-121-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a build command returned a non-zero exit status 'make' reported a warning and returned an exit code of zero. This was due to the misuse of the status returned by system(3). As the man page says: the return value is a "wait status" that can be examined using the macros described in waitpid(2). (i.e., WIFEXITED(), WEXITSTATUS(), and so on). Use the error() function to correctly report the problem on stderr and return an exit status of 2. Some additional changes in the same area: - When a target is removed report the diagnostic on stderr, as required by POSIX. - When a build command receives a signal GNU make removes the target. bmake doesn't and it isn't required by POSIX. Implement this as an extension. - Expand the error message when a build command fails so it includes the exit status or signal number, as obtained from the value returned by system(3). - Alter the WIN32 implementation of system(3) to handle exit codes which represent termination as if by a signal. Adds 200-240 bytes. (GitHub issue #354)
* | Add test for .DEFAULT rule for prerequisiteRon Yorston2023-08-241-0/+7
| | | | | | | | Add a test for the problem reported in -w32 GitHub issue #354.
* | testsuite: skip some tests in native buildRon Yorston2023-08-192-0/+6
| | | | | | | | | | The testsuite includes some Windows-specific tests. Exclude these when running a test on a native build to avoid upsetting the results.
* | diff: more changes to --binaryRon Yorston2023-08-061-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The changes introduced to support the --binary option gave incorrect results when comparing files with CRLF line endings *without* the --binary option present. The code needs to keep track of the position within the file and is confused by text mode. As an alternative solution, always use binary mode but skip the CR of a CRLF pair when the --binary option isn't used. This gives results matching GNU diff when comparing files with matching line endings, with or without --binary. When line endings differ the results aren't always the same. Costs 32 bytes in the 32-bit build, saves 16 in 64-bit. (GitHub issue #348)
* | Merge branch 'busybox' into mergeRon Yorston2023-06-164-0/+404
|\|
| * awk: fix subst code to handle "start of word" pattern correctly (needs ↵Denys Vlasenko2023-06-081-13/+15
| | | | | | | | | | | | | | | | | | REG_STARTEND) function old new delta awk_sub 637 714 +77 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix backslash handling in sub() builtinsDenys Vlasenko2023-06-031-0/+47
| | | | | | | | | | | | | | function old new delta awk_sub 559 544 -15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix precedence of = relative to ==Denys Vlasenko2023-05-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Discovered while adding code to disallow assignments to non-lvalues function old new delta parse_expr 936 991 +55 .rodata 105243 105247 +4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 59/0) Total: 59 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix splitting with default FSDenys Vlasenko2023-05-271-0/+7
| | | | | | | | | | | | | | function old new delta awk_split 543 544 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: -l,I,L indeed depend on sizeof(long), fix thisDenys Vlasenko2023-05-261-18/+19
| | | | | | | | | | | | | | | | | | | | function old new delta .rodata 105255 105252 -3 od_main 1917 1901 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-19) Total: -19 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * awk: fix use-after-realloc (CVE-2021-42380), closes 15601Denys Vlasenko2023-05-261-0/+55
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * libbb/dump: correct handling of 1-byte signed int formatDenys Vlasenko2023-05-261-1/+33
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od, hexdump: byte 0x11 is "dc1" not "dcl"Denys Vlasenko2023-05-262-7/+41
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: support -DOHXILDenys Vlasenko2023-05-261-28/+16
| | | | | | | | | | | | | | | | | | | | function old new delta od_main 1866 1917 +51 .rodata 105306 105321 +15 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 66/0) Total: 66 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: fix default format, shrinkDenys Vlasenko2023-05-261-0/+10
| | | | | | | | | | | | | | | | | | | | function old new delta od_main 556 568 +12 .rodata 104613 104555 -58 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 12/-58) Total: -46 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: stop printing extra trailing spacesDenys Vlasenko2023-05-251-24/+19
| | | | | | | | | | | | | | | | | | | | | | | | function old new delta .rodata 104598 104613 +15 display 1475 1485 +10 od_main 549 556 +7 rewrite 971 967 -4 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 32/-4) Total: 28 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: implement -BDenys Vlasenko2023-05-251-4/+3
| | | | | | | | | | | | | | | | | | | | function old new delta .rodata 105305 105306 +1 od_main 1880 1866 -14 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 1/-14) Total: -13 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: correct -i, enable tests which pass for DESKTOP tooDenys Vlasenko2023-05-251-29/+33
| | | | | | | | | | | | | | function old new delta .rodata 105302 105305 +3 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: for !DESKTOP, match output more closely to GNU coreutils 9.1, implement -sDenys Vlasenko2023-05-251-39/+44
| | | | | | | | Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| * od: add testsDavid Leonard2023-05-252-0/+220
| | | | | | | | | | | | | | | | * Added tests for od (non-DESKTOP little-endian) * Allow 'optional' to invert meaning of a config option with '!' Signed-off-by: David Leonard <d+busybox@adaptive-enterprises.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
* | Merge branch 'busybox' into mergeRon Yorston2023-04-171-0/+4
|\|