291604 |
01-Dec-2015 |
ngie |
MFC r269902,r270101:
r269902:
Convert bin/sh/tests to ATF
The new code uses a "test discovery mechanism" to determine what tests are available for execution
The test shell can be specified via:
kyua test -v test_suites.FreeBSD.bin.sh.test_shell=/path/to/test/sh
Sponsored by: EMC / Isilon Storage Division Approved by: jmmv (mentor) Reviewed by: jilles (maintainer)
r270101 (by jilles):
sh: Don't hardcode relative paths in the tests stderr files.
These paths have had to be adjusted to changes in the testsuite runner several times, so modify the tests to remove the need for such adjustment.
A cp in functional_test.sh is now unneeded, but this matters little in performance. |
287755 |
13-Sep-2015 |
jilles |
MFC r268436,273243,278806,280920,286971: sh: Add various tests.
These new tests from head pass with unmodified stable/10 sh. |
262951 |
09-Mar-2014 |
jmmv |
Sync sh(1) in stable/10 to head.
This is a MFC of all the commits listed below.
My original goal of this change was to only merge the move of the tests from tools/regression/bin/ into the new layout (which include tests for sh(1) and other tools as well). However, doing so is tricky due to the ongoing work in sh(1) and, especially, the many changes to its tests since stable/10 was first branched.
Merging everything is the simplest way to achieve this goal and, as a bonus point, we get various fixes and miscellaneous improvements into the branch.
Per jilles' suggestion, I'm avoiding the merge of a couple of changes (r256850 and r257506) that required depending kernel changes. I'm also avoiding very recent changes that have not had a long enough time to be validated in current.
This is "make tinderbox" clean.
r256735 sh: Remove one syscall when waiting for a foreground job. r257399 sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'. r257504 sh: Reorder union node to reduce its size on 64-bit platforms. r257920 sh: Add a test case for would-be assignments that are not due to quoting. r257929 sh: Properly quote alias output from command -v. r258489 sh: Add tests for the </dev/null implicit in a background command. r258533 sh: Add more tests for the </dev/null implicit in a background command. r258535 sh: Make <&0 disable the </dev/null implicit in a background command. r258776 sh: Prefer memcpy() to strcpy() in most cases. Remove the scopy macro. r259047 sh: Split set -x output into a separate function. r259210 Migrate tools/regression/bin/ tests to the new layout. r259844 sh: Remove an unused variable. r259846 sh: Initialize OPTIND=1 even if it came from the environment. r259874 sh: Simplify code related to PPID variable. r259946 sh: Don't check input for non-whitespace if history is disabled. r260246 sh(1): Discourage use of -e. r260506 Run the sh(1) and test(1) tests as unprivileged. r260586 Mark the bin/pax tests as requiring perl. r260634 Use TAP_TESTS_PERL to register the legacy_test in bin/pax. r260635 Replace hand-crafted Kyuafiles with automatic generation. r260654 sh: Remove SIGWINCH handler and just check for resize before every read. r261121 sh: Add test for nested alias. r261125 sh: Solve the alias recursion problem in a less hackish way. r261141 sh: Do not depend on parse/execute split in new alias test. r261160 sh: Add tests for alias names after another alias. r261192 sh: Allow aliases to force alias substitution on the following word. r262533 sh: Make expari() static. r262565 sh: Do not corrupt internal representation if LINENO inner expansion fails. r262697 sh: Simplify expari().
Reviewed by: jilles |
259210 |
11-Dec-2013 |
jmmv |
Migrate tools/regression/bin/ tests to the new layout.
This change is a proof of concept on how to easily integrate existing tests from the tools/regression/ hierarchy into the /usr/tests/ test suite and on how to adapt them to the new layout for src.
To achieve these goals, this change:
- Moves tests from tools/regression/bin/<tool>/ to bin/<tool>/tests/. - Renames the previous regress.sh files to legacy_test.sh. - Adds Makefiles to build and install the tests and all their supporting data files into /usr/tests/bin/. - Plugs the legacy_test test programs into the test suite using the new TAP backend for Kyua (appearing in 0.8) so that the code of the test programs does not have to change. - Registers the new directories in the BSD.test.dist mtree file.
Reviewed by: freebsd-testing Approved by: rpaulo (mentor)
|
257920 |
10-Nov-2013 |
jilles |
sh: Add a test case for would-be assignments that are not due to quoting.
|
254843 |
25-Aug-2013 |
jilles |
sh: Disallow empty simple commands.
As per POSIX, a simple command must have at least one redirection, assignment word or command word.
These occured in rare cases such as eval "f()" .
The extension of allowing no commands inside { }, if, while, for, etc. remains.
|
254335 |
14-Aug-2013 |
jilles |
sh: Allow a lone redirection before '|', ';;' or ';&'.
Example: </dev/null | :
PR: 181240 MFC after: 1 week
|
245382 |
13-Jan-2013 |
jilles |
sh: Fix crash when parsing '{ } &'.
MFC after: 1 week
|
243252 |
18-Nov-2012 |
jilles |
sh: Apply rlimits to parser/alias10.0 so it fails fast.
Requested by: uqs
|
242767 |
08-Nov-2012 |
jilles |
sh: Add tests for modifying an alias (r242766).
Note: parser/alias10.0 will eat a lot of memory/cpu time when it fails (with the old sh).
|
242721 |
07-Nov-2012 |
jilles |
sh: Test that a redefined alias works.
|
240825 |
22-Sep-2012 |
jilles |
sh: Add some tests for aliasing a utility to itself.
|
224104 |
16-Jul-2011 |
jilles |
sh: Add a test for a fairly obscure case with aliases.
This also passes on stable/8.
|
222813 |
07-Jun-2011 |
attilio |
etire the cpumask_t type and replace it with cpuset_t usage.
This is intended to fix the bug where cpu mask objects are capped to 32. MAXCPU, then, can now arbitrarely bumped to whatever value. Anyway, as long as several structures in the kernel are statically allocated and sized as MAXCPU, it is suggested to keep it as low as possible for the time being.
Technical notes on this commit itself: - More functions to handle with cpuset_t objects are introduced. The most notable are cpusetobj_ffs() (which calculates a ffs(3) for a cpuset_t object), cpusetobj_strprint() (which prepares a string representing a cpuset_t object) and cpusetobj_strscan() (which creates a valid cpuset_t starting from a string representation). - pc_cpumask and pc_other_cpus are target to be removed soon. With the moving from cpumask_t to cpuset_t they are now inefficient and not really useful. Anyway, for the time being, please note that access to pcpu datas is protected by sched_pin() in order to avoid migrating the CPU while reading more than one (possible) word - Please note that size of cpuset_t objects may differ between kernel and userland. While this is not directly related to the patch itself, it is good to understand that concept and possibly use the patch as a reference on how to deal with cpuset_t objects in userland, when accessing kernland members. - KTR_CPUMASK is changed and now is represented through a string, to be set as the example reported in NOTES.
Please additively note that no MAXCPU is bumped in this patch, but private testing has been done until to MAXCPU=128 on a real 8x8x2(htt) machine (amd64).
Please note that the FreeBSD version is not yet bumped because of the upcoming pcpu changes. However, note that this patch is not targeted for MFC.
People to thank for the time spent on this patch: - sbruno, pluknet and Nicholas Esborn (nick AT desert DOT net) tested several revision of the patches and really helped in improving stability of this work. - marius fixed several bugs in the sparc64 implementation and reviewed patches related to ktr. - jeff and jhb discussed the basic approach followed. - kib and marcel made targeted review on some specific part of the patch. - marius, art, nwhitehorn and andreast reviewed MD specific part of the patch. - marius, andreast, gonzo, nwhitehorn and jceel tested MD specific implementations of the patch. - Other people have made contributions on other patches that have been already committed and have been listed separately.
Companies that should be mentioned for having participated at several degrees: - Yahoo! for having offered the machines used for testing on big count of CPUs. - The FreeBSD Foundation for having sponsored my devsummit attendance, which has been instrumental. - Sandvine for having offered offices and infrastructure during development.
(I really hope I didn't forget anyone, if it happened I apologize in advance).
|
222512 |
30-May-2011 |
jilles |
sh: Add tests for some somewhat obscure aspects of function definitions.
|
222165 |
21-May-2011 |
jilles |
sh: Expand aliases after assignments and redirections.
|
222134 |
20-May-2011 |
jilles |
sh: Allow terminating a heredoc with a terminator at EOF without a newline.
This is sometimes used with eval or old-style command substitution, and most shells other than ash derivatives allow it.
It can also be used with scripts that violate POSIX's requirement on the application that they end in a newline (scripts must be text files except that line length is unlimited).
Example: v=`cat <<EOF foo EOF` echo $v
This commit does not add support for the similar construct with new-style command substitution, like v=$(cat <<EOF foo EOF) This continues to require a newline after the terminator.
|
221887 |
14-May-2011 |
jilles |
sh: Add tests for lines that look like heredoc delimiters but are not.
|
221669 |
08-May-2011 |
jilles |
sh: Add \u/\U support (in $'...') for UTF-8.
Because we have no iconv in base, support for other charsets is not possible.
Note that \u/\U are processed using the locale that was active when the shell started. This is necessary to avoid behaviour that depends on the parse/execute split (for example when placing braces around an entire script). Therefore, UTF-8 encoding is implemented manually.
|
221513 |
05-May-2011 |
jilles |
sh: Add $'quoting' (C-style escape sequences).
A string between $' and ' may contain backslash escape sequences similar to the ones in a C string constant (except that a single-quote must be escaped and a double-quote need not be). Details are in the sh(1) man page.
This construct is useful to include unprintable characters, tabs and newlines in strings; while this can be done with a command substitution containing a printf command, that needs ugly workarounds if the result is to end with a newline as command substitution removes all trailing newlines.
The construct may also be useful in future to describe unprintable characters without needing to write those characters themselves in 'set -x', 'export -p' and the like.
The implementation attempts to comply to the proposal for the next issue of the POSIX specification. Because this construct is not in POSIX.1-2008, using it in scripts intended to be portable is unwise.
Matching the minimal locale support in the rest of sh, the \u and \U sequences are currently not useful.
Exp-run done by: pav (with some other sh(1) changes)
|
218891 |
20-Feb-2011 |
jilles |
sh: Add some tests for omitting whitespace whereever possible.
|
218889 |
20-Feb-2011 |
jilles |
sh: Split off some special behaviour into separate tests.
This allows some other shells to pass the tests for basic behaviour.
|
214709 |
02-Nov-2010 |
jilles |
sh: Fix some issues with aliases and case, by importing dash checkkwd code.
This moves the function of the noaliases variable into the checkkwd variable. This way it is properly reset on errors and aliases can be used normally in the commands for each case (the case labels recognize the keyword esac but no aliases).
The new code is clearer as well.
Obtained from: dash
|
214291 |
24-Oct-2010 |
jilles |
sh: Make sure defined functions can actually be called.
Add some conservative checks on function names: - Disallow expansions or quoting characters; these can only be called via strange control characters - Disallow '/'; these functions cannot be called anyway, as exec.c assumes they are pathnames - Make the CTL* bytes work properly in function names.
These are syntax errors.
POSIX does not require us to support more than names (letters, digits and underscores, not starting with a digit), but I do not want to restrict it that much at this time.
Exp-run done by: pav (with some other sh(1) changes)
|
214281 |
24-Oct-2010 |
jilles |
sh: Change ! within a pipeline to start a new pipeline instead.
This is how ksh93 treats ! within a pipeline and makes the ! in a | ! b | c negate the exit status of the pipeline, as if it were a | { ! b | c; }
Side effect: something like f() ! a is now a syntax error, because a function definition takes a command, not a pipeline.
Exp-run done by: pav (with some other sh(1) changes)
|
214280 |
24-Oct-2010 |
jilles |
sh: Add some testcases for alias expansion.
|
211405 |
16-Aug-2010 |
jilles |
sh: Split off a more dubious test from parser/heredoc2.0.
|
210488 |
25-Jul-2010 |
jilles |
sh: Fix crash due to uninitialized here-document.
If an ; or & token was followed by an EOF token, pending here-documents were left uninitialized. Execution would crash, either in the main shell process for literal here-documents or in a child process for expanded here-documents. In the latter case the problem is hard to detect apart from the core dumps and log messages.
Side effect: slightly different retries on inputs where EOF is not persistent.
Note that tools/regression/bin/sh/parser/heredoc6.0 still causes a similar crash in a child process. The text passed to eval is malformed and should be rejected.
|
210221 |
18-Jul-2010 |
jilles |
sh: Allow a background command consisting solely of redirections.
Example: </dev/null &
MFC after: 2 weeks
|
208656 |
30-May-2010 |
jilles |
sh: Fix a crash if a heredoc was not properly ended and parsing continued.
Example (in interactive mode): cat <<EOF && ) The next command typed caused sh to segfault, because the state for the here document was not reset.
Like parser_temp, this uses the fact that the parser is not re-entered.
|
208655 |
30-May-2010 |
jilles |
sh: Change interaction of command substitution and here documents.
If a command substitution contains a newline token, this no longer starts here documents of outer commands. This way, we follow POSIX's idea of the command substitution being a separate script more closely. It also matches other shells better and is consistent with newline characters in quotes not starting here documents.
The extension tested in parser/heredoc3.0 ($(cat <<EOF)\ntext\nEOF\n) continues to be supported.
In particular, this change allows things like cat <<EOF && echo `pwd` (a `` command substitution after a here document) which formerly silently used an empty file as the here document, because the EOF of the inner command "pwd" also forced an empty here document.
|
207824 |
09-May-2010 |
jilles |
sh: Add some parser tests.
case1.0 tests POSIX requirements and one more for keywords in case statements. The others test very special cases of command substitution.
These also work on stable/8.
|
206145 |
03-Apr-2010 |
jilles |
sh: Fix various things about expansions: * remove the backslash from \} inside double quotes inside +-=? substitutions, e.g. "${$+\}a}" * maintain separate double-quote state for ${v#...} and ${v%...}; single and double quotes are special inside, even in a double-quoted string or here document * keep track of correct order of substitutions and arithmetic
This is different from dash's approach, which does not track individual double quotes in the parser, trying to fix this up during expansion. This treats single quotes inside "${v#...}" incorrectly, however.
This is similar to NetBSD's approach (as submitted in PR bin/57554), but recognizes the difference between +-=? and #% substitutions hinted at in POSIX and is more refined for arithmetic expansion and here documents.
PR: bin/57554 Exp-run done by: erwin (with some other sh(1) changes)
|
204836 |
07-Mar-2010 |
jilles |
sh: Add various testcases for here documents.
They are mainly about expansions in here documents but because all the testcases are in $() command substitution, we also test that $() command substitution is recursively parsed (or very close to it).
|
200193 |
06-Dec-2009 |
jilles |
sh: Test ;<newline> as well as ; in the 'for' parser test.
|
199282 |
14-Nov-2009 |
jilles |
sh: Allow a newline before "in" in a for command, as required by POSIX.
|
191010 |
13-Apr-2009 |
stefanf |
Add a test for r191009.
|