History log of /freebsd-10-stable/bin/sh/tests/execution/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
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.

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


/freebsd-10-stable/bin/Makefile
/freebsd-10-stable/bin/date/Makefile
/freebsd-10-stable/bin/date/tests
/freebsd-10-stable/bin/mv/Makefile
/freebsd-10-stable/bin/mv/tests
/freebsd-10-stable/bin/pax/Makefile
/freebsd-10-stable/bin/pax/tests
/freebsd-10-stable/bin/pax/tests/Makefile
/freebsd-10-stable/bin/pax/tests/legacy_test.pl
/freebsd-10-stable/bin/pax/tests/legacy_test.sh
/freebsd-10-stable/bin/sh/Makefile
/freebsd-10-stable/bin/sh/alias.c
/freebsd-10-stable/bin/sh/cd.c
/freebsd-10-stable/bin/sh/eval.c
/freebsd-10-stable/bin/sh/exec.c
/freebsd-10-stable/bin/sh/expand.c
/freebsd-10-stable/bin/sh/expand.h
/freebsd-10-stable/bin/sh/input.c
/freebsd-10-stable/bin/sh/jobs.c
/freebsd-10-stable/bin/sh/memalloc.c
/freebsd-10-stable/bin/sh/mystring.c
/freebsd-10-stable/bin/sh/mystring.h
/freebsd-10-stable/bin/sh/nodetypes
/freebsd-10-stable/bin/sh/parser.c
/freebsd-10-stable/bin/sh/parser.h
/freebsd-10-stable/bin/sh/redir.c
/freebsd-10-stable/bin/sh/sh.1
/freebsd-10-stable/bin/sh/show.c
/freebsd-10-stable/bin/sh/tests
/freebsd-10-stable/bin/sh/tests/Makefile
/freebsd-10-stable/bin/sh/tests/builtins/Makefile
/freebsd-10-stable/bin/sh/tests/builtins/command3.0.stdout
/freebsd-10-stable/bin/sh/tests/builtins/command5.0.stdout
/freebsd-10-stable/bin/sh/tests/builtins/command6.0.stdout
/freebsd-10-stable/bin/sh/tests/builtins/lineno2.0
/freebsd-10-stable/bin/sh/tests/parameters/Makefile
/freebsd-10-stable/bin/sh/tests/parameters/optind2.0
/freebsd-10-stable/bin/sh/tests/parser/Makefile
/freebsd-10-stable/bin/sh/tests/parser/alias11.0
/freebsd-10-stable/bin/sh/tests/parser/alias12.0
/freebsd-10-stable/bin/sh/tests/parser/alias13.0
/freebsd-10-stable/bin/sh/tests/parser/alias14.0
/freebsd-10-stable/bin/sh/tests/parser/alias15.0
/freebsd-10-stable/bin/sh/tests/parser/alias15.0.stdout
/freebsd-10-stable/bin/sh/trap.c
/freebsd-10-stable/bin/sh/trap.h
/freebsd-10-stable/bin/sh/var.c
/freebsd-10-stable/bin/sh/var.h
/freebsd-10-stable/bin/test/Makefile
/freebsd-10-stable/bin/test/tests
/freebsd-10-stable/bin/test/tests/Makefile
/freebsd-10-stable/bin/tests
/freebsd-10-stable/etc/mtree/BSD.tests.dist
/freebsd-10-stable/tools/regression/bin
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)


258535 24-Nov-2013 jilles

sh: Make <&0 disable the </dev/null implicit in a background command.

Although <&0 does nothing, it is a redirection affecting standard input and
should therefore disable the </dev/null redirection implicit in a background
command.


258533 24-Nov-2013 jilles

sh: Add more tests for the </dev/null implicit in a background command.


258489 22-Nov-2013 jilles

sh: Add tests for the </dev/null implicit in a background command.


253271 12-Jul-2013 jilles

sh: Do not read from stdin if an error occurs during -i -c cmd.

Although using -i with -c does not seem very useful, it seems inappropriate
to read commands from the terminal in this case.

Side effect: if the -s -c extension is used and the -s option is turned off
using 'set +s' during the interactive part, the shell now exits after an
error or interrupt. Note that POSIX only specifies -s as option to sh, not
to set.

See also Austin Group issue #718.


249407 12-Apr-2013 jilles

sh: Don't modify exit status when break/continue/return passes !.

This matches what would happen if ! P were to be replaced with
if P; then false; else true; fi.

Example:
f() { ! return 0; }; f


245383 13-Jan-2013 jilles

sh: Add some testcases related to subshells.

These failed in earlier attempts to execute more subshells without forking.
The patches are uncommitted.


223283 19-Jun-2011 jilles

sh: Add test for r223282.


222907 09-Jun-2011 jilles

sh: Do parameter expansion before printing PS4 (set -x).

The function name expandstr() and the general idea of doing this kind of
expansion by treating the text as a here document without end marker is from
dash.

All variants of parameter expansion and arithmetic expansion also work (the
latter is not required by POSIX but it does not take extra code and many
other shells also allow it).

Command substitution is prevented because I think it causes too much code to
be re-entered (for example creating an unbounded recursion of trace lines).

Unfortunately, our LINENO is somewhat crude, otherwise PS4='$LINENO+ ' would
be quite useful.


222882 08-Jun-2011 jilles

sh: Add simple tests for set -x and PS4.


222676 04-Jun-2011 jilles

sh: Honour -n while processing -c string.


222661 03-Jun-2011 jilles

sh: Add tests for -n flag. These already pass.


221027 25-Apr-2011 jilles

sh: Set $? to 0 for background commands.

For backgrounded pipelines and subshells, the previous value of $? was being
preserved, which is incorrect.

For backgrounded simple commands containing a command substitution, the
status of the last command substitution was returned instead of 0.

If fork() fails, this is an error.


220978 23-Apr-2011 jilles

sh: Allow EV_EXIT through function calls, make {...} <redir more consistent.

If EV_EXIT causes an exit, use the exception mechanism to unwind
redirections and local variables. This way, if the final command is a
redirected command, an EXIT trap now executes without the redirections.

Because of these changes, EV_EXIT can now be inherited by the body of a
function, so do so. This means that a function no longer prevents a fork
before an exec being skipped, such as in
f() { head -1 /etc/passwd; }; echo $(f)

Wrapping a single builtin in a function may still cause an otherwise
unnecessary fork with command substitution, however.

An exit command or -e failure still invokes the EXIT trap with the
original redirections and local variables in place.

Note: this depends on SHELLPROC being gone. A SHELLPROC depended on
keeping the redirections and local variables and only cleaning up the
state to restore them.


218850 19-Feb-2011 jilles

sh: Make execution/fork1.0 work even if the basename of ${SH} is not "sh".


218325 05-Feb-2011 jilles

sh: Fix two things about {(...)} <redir:

* In {(...) <redir1;} <redir2, do not drop redir1.
* Maintain the difference between (...) <redir and {(...)} <redir:
In (...) <redir, the redirection is performed in the child, while in
{(...)} <redir it should be performed in the parent (like {(...); :;}
<redir)


218323 05-Feb-2011 jilles

sh: Forget all cached command locations on any PATH change.

POSIX requires this and it is simpler than the previous code that remembered
command locations when appending directories to PATH.

In particular,
PATH=$PATH
is no longer a no-op but discards all cached command locations.


218205 02-Feb-2011 jilles

sh: Add test for shell script without '#!'.


218105 30-Jan-2011 jilles

sh: Send messages about signals to stderr.

This is required by POSIX and seems to make more sense.

See also r217557.


217557 18-Jan-2011 jilles

sh: Fix signal messages being sent to the wrong file sometimes.

When a foreground job exits on a signal, a message is printed to stdout
about this. The buffer was not flushed after this which could result in the
message being written to the wrong file if the next command was a builtin
and had stdout redirected.

Example:
sh -c 'kill -9 $$'; : > foo; echo FOO:; cat foo

Reported by: gcooper
MFC after: 1 week


217206 09-Jan-2011 jilles

sh: Remove special %builtin PATH entry.
All builtins are now always found before a PATH search.

Most ash derivatives have an undocumented feature where the presence of an
entry "%builtin" in $PATH will cause builtins to be checked at that point of
the PATH search, rather than before looking at any directories as documented
in the man page (very old versions do document this feature).

I am removing this feature from sh, as it complicates the code, may violate
expectations (for example, /usr/bin/alias is very close to a forkbomb with
PATH=/usr/bin:%builtin, only /usr/bin/builtin not being another link saves
it) and appears to be unused (all the %builtin google code search finds is
in some sort of ash source code).

Note that aliases and functions took and take precedence above builtins.
Because aliases work on a lexical level they can only ever be overridden on
a lexical level (quoting or preceding 'builtin' or 'command'). Allowing
override of functions via PATH does not really fit in the model of sh and it
would work differently from %builtin if implemented.

Note: POSIX says special builtins are found before functions. We comply to
this because we do not allow functions with the same name as a special
builtin.

Silence from: freebsd-hackers@ (message sent 20101225)
Discussed with: dougb


216398 12-Dec-2010 jilles

sh: Fix some tests that used sh instead of ${SH}
so they tested the wrong sh.

This was caused because these tests were committed after the sh -> ${SH}
change but were created before.


214304 24-Oct-2010 jilles

sh: Do not allow overriding a special builtin with a function.
This is a syntax error.

POSIX does not say explicitly whether defining a function with the same name
as a special builtin is allowed, but it does say that it is impossible to
call such a function.

A special builtin can still be overridden with an alias.

This commit is part of a set of changes that will ensure that when
something looks like a special builtin to the parser, it is one. (Not the
other way around, as it remains possible to call a special builtin named
by a variable or other substitution.)

Exp-run done by: pav (with some other sh(1) changes)


214290 24-Oct-2010 jilles

sh: Check whether dup2 was successful for >&FD and <&FD.

A failure (usually caused by FD not being open) is a redirection error.

Exp-run done by: pav (with some other sh(1) changes)


214289 24-Oct-2010 jilles

sh: Add a test trying to close a descriptor that is not open.

In stable/8 and older, this fails. Some of the redirection changes in head
have fixed it.


213738 12-Oct-2010 obrien

Allow one to regression test 'sh' changes without having to install
a potentially bad /bin/sh first.


212467 11-Sep-2010 jilles

sh: Apply variable assignments left-to-right in bltinlookup().

Example:
HOME=foo HOME=bar cd


211408 16-Aug-2010 jilles

sh: Reduce unnecessary testsuite failures with other shells.


211399 16-Aug-2010 jilles

sh: Get rid of unnecessary non-standard empty lists.

POSIX does not allow constructs like:
if cmd; then fi
{ }
Add a colon dummy command, except in a test that verifies that such empty
lists do not cause crashes when used as a function definition.


199953 29-Nov-2009 jilles

Fix some cases where file descriptors from redirections leak to programs.

- Redirecting fds that were not open before kept two copies of the
redirected file.
sh -c '{ :; } 7>/dev/null; fstat -p $$; true'
(both fd 7 and 10 remained open)
- File descriptors used to restore things after redirection were not
set close-on-exec, instead they were explicitly closed before executing
a program normally and before executing a shell procedure. The latter
must remain but the former is replaced by close-on-exec.
sh -c 'exec 7</; { exec fstat -p $$; } 7>/dev/null; true'
(fd 10 remained open)

The examples above are simpler than the testsuite because I do not want to
use fstat or procstat in the testsuite.


197820 06-Oct-2009 jilles

sh: Send the "xyz: not found" message to redirected fd 2.
This also fixes that trying to execute a non-regular file with a command
name without '/' returns 127 instead of 126.
The fix is rather simplistic: treat CMDUNKNOWN as if the command were found
as an external program. The resulting fork is a bit wasteful but executing
unknown commands should not be very frequent.

PR: bin/137659


196634 28-Aug-2009 jilles

sh: Fix crash with empty functions (f() { }) introduced in r196483

Empty pairs of braces are represented by a NULL node pointer, just like
empty lines at the top level.

Support for empty pairs of braces may be removed later. They make the code
more complex, have inconsistent behaviour (may or may not change $?), are
not specified by POSIX and are not allowed by some other shells like bash,
dash and ksh93.

Reported by: kan


196483 23-Aug-2009 jilles

sh: Fix crash when undefining or redefining a currently executing function.

Add a reference count to function definitions.
Memory may leak if multiple SIGINTs arrive in interactive mode,
this will be fixed later by changing SIGINT handling.

PR: bin/137640


194775 23-Jun-2009 jilles

Add tests for r194774.

Approved by: ed (mentor) (implicit)


194196 14-Jun-2009 jilles

Add tests for r194127 and r194128.

Approved by: ed (mentor)