Commit Graph

1484 Commits

Author SHA1 Message Date
Enji Cooper
b74bcac4bd - Don't use /tmp because it's outside ATF's prescribed sandbox
- Replace a hardcoded PATH_MAX value with sizeof(path)
- Use path like an array, not a pointer, and always try to unlink it in cleanup

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-11 03:18:14 +00:00
Enji Cooper
c7ded8ba9e Fix warnings and bump WARNS to 6
- Garbage collect argc/argv (-Wunused)
- sleep(3) will always return an unsigned int; don't check for return codes <0
  (-Wsign-compare)

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-11 03:13:09 +00:00
Enji Cooper
572e1f51aa - Garbage collect argc/argv (-Wunused)
- Bump WARNS to 6

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-11 02:59:45 +00:00
Enji Cooper
f6b2ef31db - Use static buffers for temporary file paths instead of strdup of constant strings
- Don't use /tmp because it's outside ATF's prescribed sandbox
- Use mkstemp instead of mktemp to eliminate warning

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-11 02:50:44 +00:00
Enji Cooper
e04e98929f Use _exit, not exit in forked process
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-10 09:37:53 +00:00
Enji Cooper
62b65008d0 Remove argc/argv (-Wunused)
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-10 09:27:23 +00:00
Enji Cooper
7d075cff6e Fix warnings
- Remove argc/argv (-Wunused)
- Mark some parameters to socket_listen_update __unused (-Wunused)

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-10 09:26:21 +00:00
Enji Cooper
cc469a3b3a Remove argc/argv (-Wunused)
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-10 09:23:00 +00:00
Enji Cooper
41119c8725 - Parameterize out the number of accept/connect attempts
- Randomize the bind port to allow 2+ consecutive calls in < 10 minutes, and
  to also not fail if (for instance) there's a server already listening on port
  8080
- Don't leak the listening socket / fds into the child process
- Fix warnings:
-- Remove argc/argv (-Wunused)
-- Mark sig __unused (-Wunused)
-- Mark quit static (-Wmissing-variable-declarations)

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-10 09:21:07 +00:00
Enji Cooper
957885bf58 Fix -Wunused warnings, bump WARNS to 6
The output is still broken if prove -rv is run and the testcase aborts
prematurely with fail_assertion (the testcase doesn't really conform to TAP
protocol properly, except when it completes fully)

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-10 08:01:49 +00:00
Enji Cooper
1aa40dada2 Fix -Wunused warnings, bump WARNS to 6
The testcase fails today on subtest # 9

The output is still broken if prove -rv is run and the testcase aborts
prematurely (the testcase doesn't really conform to TAP protocol properly,
except when it completes fully)

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-10 07:59:46 +00:00
Enji Cooper
2084db1777 Fix warnings, fix a typo in a testcase description, bump WARNS to 3
- Remove argc/argv (-Wunused)
- Cast len in comparison to size_t (-Wsign-compare)

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
2015-04-10 07:35:53 +00:00
Enji Cooper
b41853c8fe - Fix -Wsign issue
- Bump up to WARNS=6
2015-03-31 06:51:13 +00:00
Enji Cooper
b5d45f0794 Minor cleanup before converting to ATF testcases
- Remove blank (tab-only) lines.
- Fix -Wunused warnings.
- Bump up to WARNS= 6
2015-03-31 06:50:28 +00:00
Enji Cooper
76cbe329d6 Cleanup and do minor refactoring before converting testcases to ATF
- Convert errx(-1, ..) to errx(1, ..)
- Move the aio(4) checks to a single function (aio_available); use modfind(2)
  instead of depending on SIGSYS (doesn't work when aio(4) support is missing,
  not documented in the aio syscall manpages).
- Use aio_available liberally in the testcase functions
- Use mkstemp(3) + unlink(2) instead of mktemp(3)
- Fix some -Wunused warnings
- Bump WARNS to 6

MFC after: 1 week
Submitted by: mjohnston [*]
Sponsored by: EMC / Isilon Storage Division
2015-03-31 06:43:55 +00:00
Jilles Tjoelker
9d14d0aaae wordexp(): Add testcase for non-default IFS in environment.
The non-default IFS is expected to be used.

MFC after:	1 week
2015-03-29 22:00:24 +00:00
Konstantin Belousov
ab9d0c2789 Cosmetics:
- Move to ANSI definitions syntax, removing warnings about type promotions.
- Remove __P().
- Staticise everything.
- Remove warnings about unused args for signal handlers.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2015-03-18 22:05:15 +00:00
Jilles Tjoelker
6ab1d4d9c3 env: Fix crash when -S string is not empty but no operand follows.
split_spaces() set argc in main() incorrectly, which caused trouble for
getopt().

Examples:
  env -S '\c'
  env -S -i

PR:		197769
MFC after:	1 week
2015-03-08 14:12:43 +00:00
Jilles Tjoelker
aad75bd7db env: Fix testsuite for additional variables set by sh.
MFC after:	1 week
2015-03-07 13:54:44 +00:00
Enji Cooper
2decd8fc81 Make this compile with WARNS=6 and clang/gcc
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2015-01-22 09:25:31 +00:00
Enji Cooper
bf5e6a8751 Garbage collect a prove test wrapper
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division
2015-01-20 21:58:49 +00:00
Will Andrews
7a37b5fc17 Add a ${CP} alias for copying files in the build.
Some users build FreeBSD as non-root in Perforce workspaces.  By default,
Perforce sets files read-only unless they're explicitly being edited.
As a result, the -f argument must be used to cp in order to override the
read-only flag when copying source files to object directories.  Bare use of
'cp' should be avoided in the future.

Update all current users of 'cp' in the src tree.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	Spectra Logic
2015-01-16 21:39:08 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Steven Hartland
7d0c9ddcc3 Revert r273630 as the panic was fixed by r274619
The panic was caused by TRIM requests run against file based vdevs as write
requests.

PR:		191573
Sponsored by:	Multiplay
2014-11-17 11:35:30 +00:00
Enji Cooper
53cecec82e Convert tools/regression/lib/libc/stdio/test-fpclassify into an ATF testcase and
Rename as lib/libc/stdio/fpclassify2_test

Sponsored by: EMC / Isilon Storage Division
2014-11-16 20:29:57 +00:00
Enji Cooper
41a3b1244b Convert tools/regression/lib/libc/stdio/test-fmemopen into an ATF testcase and
rename as lib/libc/stdio/fmemopen2_test

Sponsored by: EMC / Isilon Storage Division
2014-11-16 19:57:47 +00:00
Enji Cooper
f1bcbd4aba Remove test-arc4random from this Makefile so others can continue to use
this as-is for the time being
2014-11-16 07:58:06 +00:00
Enji Cooper
37074d966d Convert tools/regression/lib/libc/gen/test-arc4random into an ATF testcase and
rename as lib/libc/gen/arc4random_test

Sponsored by: EMC / Isilon Storage Division
2014-11-16 07:55:28 +00:00
Stefan Farfeleder
dfdc1bec71 Remove incorrect semicolon. 2014-10-26 17:56:58 +00:00
Enji Cooper
d6738a4a17 Bail out of the script on FreeBSD due to deterministic panic issue
PR: 194589
Sponsored by: EMC / Isilon Storage Division
2014-10-25 07:20:46 +00:00
Enji Cooper
a9c092dcab Bail out of the script on FreeBSD due to deterministic panic issue
PR: 194587
Sponsored by: EMC / Isilon Storage Division
2014-10-25 06:33:00 +00:00
Enji Cooper
3f4c49b14a Bail out of the script on FreeBSD due to deterministic panic issue
PR: 194586
Sponsored by: EMC / Isilon Storage Division
2014-10-25 06:28:48 +00:00
Enji Cooper
0615e43e32 Bail out of the script on FreeBSD due to deterministic panic issue
PR: 191573
Sponsored by: EMC / Isilon Storage Division
2014-10-25 06:10:01 +00:00
Enji Cooper
fbb045e15e Move the redirection to stderr out of the cmd variable assignment
Putting 2>/dev/null in cmd= escapes the redirection operation, which causes
mdconfig to think it's a filename

MFC after: 2 weeks
X-MFC with: r273627
Sponsored by: EMC / Isilon Storage Division
2014-10-25 05:31:18 +00:00
Enji Cooper
59dee1b08b - Print out "Bail out!" in die(..) so prove terminates immediately
- Handle the output from newer versions of openssl md5, similar to what
  pjd@ did in r248304

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2014-10-25 04:52:48 +00:00
Enji Cooper
40a8ac8f62 Import pjdfstest from ^/vendor/pjdfstest/abf03c3a47745d4521b0e4aa141317553ca48f91
- Remove tools/regression/pjdfstest
- Add upgrade directions for contrib/pjdfstest
- Add a note to UPDATING for the move (the reachover Makefiles are coming
  soon)

Functional differences:
- ftruncate testcases are added from upstream (github)

Non-functional differences:
- The copyright for the project has been updated to 2012
- pjd's contact information has been updated

Discussed with: -testing, jmmv, pjd
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2014-09-24 07:00:35 +00:00
Will Andrews
08be57e51c Use 'cc' for the C compiler instead of 'gcc'.
MFC after:	1 week
Sponsored by:	Spectra Logic
MFSpectraBSD:	1079507 on 2014/07/24
2014-09-18 17:37:19 +00:00
Edward Tomasz Napierala
a3507e3bc8 Fix ACL tests to correctly work with ZFS; previous version used wrong
paths.

PR:		191545
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2014-09-12 09:50:32 +00:00
Enji Cooper
5738235523 Add diagnostic printfs and disable test # 4 on i386
Reviewed by: jmmv, rpaulo
MFC after: 3 days
Phabric: D749
PR: 191676
Sponsored by: EMC / Isilon Storage Division
2014-09-10 03:54:57 +00:00
Enji Cooper
0d1998fb9b Expand the tests structure in test_small(..) to workaround the
"initializer not constant" warning with gcc

Approved by: jmmv (mentor)
MFC after: 3 days
Phabric: D744
Sponsored by: EMC / Isilon Storage Division
2014-09-09 22:14:15 +00:00
Enji Cooper
8a3fd30740 Be ANSI-C compliant when defining CX_LIMITED_RANGE #pragma
This mutes warnings with clang

Approved by: rpaulo (mentor)
Reviewed by: das, kargl (both as part of a larger patch)
Phabric: D742
Sponsored by: EMC / Isilon Storage Division
2014-09-09 02:58:58 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Enji Cooper
5aa45fcb67 Integrate lib/libutil into the build/kyua
Remove the .t wrappers

Rename all of the TAP test applications from test-<test> to
<test>_test to match the convention described in the TestSuite
wiki page

humanize_number_test.c:

- Fix -Wformat warnings with counter variables
- Fix minor style(9) issues:
-- Header sorting
-- Variable declaration alignment/sorting in main(..)
-- Fit the lines in <80 columns
- Fix an off by one index error in the testcase output [*]
- Remove unnecessary `extern char * optarg;` (this is already provided by
  unistd.h)

Phabric: D555
Approved by: jmmv (mentor)
MFC after: 2 weeks
Obtained from: EMC / Isilon Storage Division [*]
Submitted by: Casey Peel <cpeel@isilon.com> [*]
Sponsored by: EMC / Isilon Storage Division
2014-08-13 04:56:27 +00:00
Enji Cooper
b236bcf168 Integrate lib/libnv into the build/kyua
Rename all of the TAP test applications from <test> to <test>_test
to match the convention described in the TestSuite wiki page

Phabric: D538
Approved by: jmmv (mentor)
Sponsored by: EMC / Isilon Storage Division
2014-08-05 18:41:27 +00:00
Enji Cooper
dfed135e5c Integrate lib/libmp into the build/kyua
- Remove the .t wrapper
- Fix -Wreturn-type warnings with clang

This change has been tested on amd64/i386

Phabric: D530
Reviewed by: jmmv
Approved by: jmmv (co-mentor)
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2014-08-04 22:10:07 +00:00
Xin LI
6f1ca3e41c Use the right lengths.
Submitted by:	Sascha Wildner
MFC after:	2 weeks
2014-07-25 20:54:10 +00:00
Konstantin Belousov
0ea64e38ac Make this compilable on latest Linux'es without warnings.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2014-07-08 08:11:52 +00:00
Marcel Moolenaar
e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Pietro Cerutti
ae5cb1b14b - Use strlen instead of hardcoding a number
- Terminate a sentence with a period

Approved by:	cognet
2014-06-03 07:11:22 +00:00
Pietro Cerutti
4c524a4287 - Return NULL and set errno to EINVAL if size is 0 (as required by POSIX).
Update the manpage to reflect this change.
- Always set the current position to the first null-byte when opening in append
mode. This makes the implementation compatible with glibc's. Update the test
suite.

Reported by:	pho
Approved by:	cognet
2014-06-02 13:48:57 +00:00
Simon J. Gerraty
cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Warner Losh
c6063d0da8 Use src.opts.mk in preference to bsd.own.mk except where we need stuff
from the latter.
2014-05-06 04:22:01 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Dag-Erling Smørgrav
87a6395ab8 Note that the bug was fixed, and when. 2014-04-26 12:16:40 +00:00
Warner Losh
96267df325 Remove NO_CTF, exccept as an undocumented compatibility
option. Convert all other uses to MK_CTF=no. Set MK_CTF=no rather than
the indirect WITHOUT_CDDL in filemon regression. It is expected that
NO_CTF will be removed in FreeBSD 12 entirely.
2014-04-25 19:25:00 +00:00
Jilles Tjoelker
93a65e1b5f libc/stdio: Fail fdopen() on an execute-only fd.
An execute-only fd (opened with O_EXEC) allows neither read() nor write()
and is therefore incompatible with all stdio modes. Therefore, the [EINVAL]
error applies.

Also adjust the similar check in freopen() with a NULL path, even though
this checks an fd which is already from a FILE.
2014-04-21 17:40:23 +00:00
Jilles Tjoelker
9f36ecc590 libc: Add fopen() test to regression Makefile. 2014-04-21 12:39:35 +00:00
Warner Losh
3bdf775801 NO_MAN= has been deprecated in favor of MAN= for some time, go ahead
and finish the job. ncurses is now the only Makefile in the tree that
uses it since it wasn't a simple mechanical change, and will be
addressed in a future commit.
2014-04-13 05:21:56 +00:00
Julio Merino
2111435b59 errx prepends the program name to the message; don't do it by hand. 2014-03-19 12:52:49 +00:00
Julio Merino
34ed55723a Make the priv test program exit with non-zero if any failures are detected.
And, mind you, this already returns a failure :-/
2014-03-19 12:51:40 +00:00
Julio Merino
65c3cfc1aa Migrate tools/regression/usr.bin/pkill to the new tests layout.
Interestingly, the pkill tool lives in bin, not usr.bin.  Haven't bothered
to check if this is because the tool moved or because the tests were
originally added in the wrong place.
2014-03-19 12:46:04 +00:00
Julio Merino
d525bcd959 Migrate tools/regression/usr.bin/make/ to the new tests layout.
Note that these tests are for fmake, not bmake, and thus they are not
installed nor run when bmake is selected (the default).  Yes, I have
wasted a *ton* of time on moving tests for no real reason other than
ensuring they are not left behind.

But maybe, just maybe, it was not work in vain: the majority of these
tests also work with bmake and the few that don't may point at broken
stuff.  For example, the tests for the "archive" feature do not work
with bmake, but bmake's manpage and source tree seem to imply that they
should.  So... to be investigated later; need to poke sjg@.
2014-03-19 12:29:20 +00:00
Robert Watson
b881b8be1d Update most userspace consumers of capability.h to use capsicum.h instead.
auditdistd is not updated as I will make the change upstream and then do a
vendor import sometime in the next week or two.

MFC after:	3 weeks
2014-03-16 11:04:44 +00:00
Julio Merino
3a92d97ff0 Migrate most of tools/regression/usr.bin/ to the new tests layout.
I'm starting with the easy cases.  The leftovers need to be looked at a
bit more closely.

Note that this change _does_ modify the code of the old tests.  This is
required in order to allow the code to locate the data files in the
source directory instead of the current directory, because Kyua
automatically changes the latter to a temporary directory.

Also note that at least one test is known to be broken here.  Actually,
the test is not really broken: it's marked as a TODO but unfortunately
Kyua's TAP parser currently does not understand that.  Will have to be
fixed separately.
2014-03-16 08:04:06 +00:00
Julio Merino
d14afb2adc Migrate tools/regression/{usr.bin/lastcomm,usr.sbin}/ to the new tests layout.
This change was originally going to only migrate the usr.sbin tests but, as
it turns out, the usr.sbin/sa/ tests require files from usr.bin/lastcomm/
so it's better to just also migrate the latter at the same time.  The other
usr.bin tests will be moved separately.

To make these tests work within the test suite, some of them have required
changes to prevent modifying the source directory and instead just rely on
the current directory for file manipulation.
2014-03-16 04:09:22 +00:00
Julio Merino
5bc38acbf6 Change etcupdate tests to return 1 on test failures.
This is a prerequisite for hooking these tests into the test suite.  And,
fortunately, all tests seem to pass!
2014-03-16 02:27:27 +00:00
Julio Merino
c68de7484a Migrate tools/regression/sbin/ to the new tests layout.
Pretty much all that this change does is shuffles the code around and hooks
it into the regular build.  The code of the old tests has not changed.
2014-03-16 02:07:08 +00:00
Gleb Smirnoff
45c203fce2 Remove AppleTalk support.
AppleTalk was a network transport protocol for Apple Macintosh devices
in 80s and then 90s. Starting with Mac OS X in 2000 the AppleTalk was
a legacy protocol and primary networking protocol is TCP/IP. The last
Mac OS X release to support AppleTalk happened in 2009. The same year
routing equipment vendors (namely Cisco) end their support.

Thus, AppleTalk won't be supported in FreeBSD 11.0-RELEASE.
2014-03-14 06:29:43 +00:00
Gleb Smirnoff
2c284d9395 Remove IPX support.
IPX was a network transport protocol in Novell's NetWare network operating
system from late 80s and then 90s. The NetWare itself switched to TCP/IP
as default transport in 1998. Later, in this century the Novell Open
Enterprise Server became successor of Novell NetWare. The last release
that claimed to still support IPX was OES 2 in 2007. Routing equipment
vendors (e.g. Cisco) discontinued support for IPX in 2011.

Thus, IPX won't be supported in FreeBSD 11.0-RELEASE.
2014-03-14 02:58:48 +00:00
Julio Merino
0dc2dd5381 Remove broken tests for eui64_line.
This function is not public and brooks (initial committer adding the code)
suggests the deletion of the tests (which I don't know if they work)
instead of changing the visibility of the function.
2014-03-12 10:59:51 +00:00
Julio Merino
b83f6294d2 Make the strerror tests work without libtap.
Just replace the simple calls to the library with ad-hoc code.  We should
later rewrite these with the ATF libraries anyway, which are part of the
base system.
2014-03-12 10:45:22 +00:00
Julio Merino
23d11c12ba Turn a test precondition into a skip in the mdconfig tests.
Tests that cannot be run because a precondition is not met should be
marked as skipped, not failed.  Do this for the tests in mdconfig that
first check if the caller user is root.
2014-03-12 10:42:58 +00:00
Julio Merino
a742501181 Fix sa tests.
Small divergences in the output padding made some sa tests fail.  Just
trim all whitespace from the outputs and the golden files so comparisons
are less fragile and the tests pass again.
2014-03-12 10:41:14 +00:00
Julio Merino
03a7bb948d Only run the make tests when make is fmake.
Because bmake is the default make being built, many of the tests here
fail due to differences between the two.  Just skip the tests for now
when using fmake.
2014-03-12 10:38:32 +00:00
Julio Merino
a6a6c004f9 Fix lastcomm tests under amd64.
Force the use of TZ=UTC and adjust data files accordingly.  I have no means
to verify that the data files for the other architectures are valid.
2014-03-12 10:35:22 +00:00
Julio Merino
6f402eb3cc Fix ncal tests so that they run cleanly with prove.
Basically just make the test plan match what is actually being run.
2014-03-09 22:16:39 +00:00
Julio Merino
fb3e85e1dc Fix pkill tests so that they run cleanly with prove.
This fixes a pgrep test that assumed that PID 2 was named g_event.  This
does not seem to be the case any longer (and I don't know if it ever was
in all possible setups).

Change this test to use the idle loop instead and determine its expected
PID using ps without assuming any specific ID.
2014-03-09 22:14:20 +00:00
Julio Merino
385cd39138 Fix yacc tests so that they run cleanly with prove.
First, change the driver to run the installed yacc instead of the one from
/usr/obj (which might not be there), just as we (intend to) do with all
other tests.

Second, regenerate the expected output files from scratch.  Based on visual
inspection, the differences seem OK.  But this highlights that the tests in
here are too fragile and, possibly, useless: we should be testing the
behavior of the generated program, not the literal output.  Something to be
addressed later.
2014-03-09 22:05:23 +00:00
Julio Merino
e199cf8185 Fix sed tests so that they run cleanly with prove. 2014-03-09 21:56:29 +00:00
Julio Merino
68f5aa61eb Fix printf tests so that they run cleanly with prove. 2014-03-09 19:37:01 +00:00
Julio Merino
a3c2c920d3 Fix m4 tests so that they run cleanly with prove. 2014-03-09 19:25:53 +00:00
Christian Brueffer
bb7a82ac0d Use CAP_EVENT instead of the deprecated CAP_POLL_EVENT.
PR:		185382 (based on)
Submitted by:	Loganaden Velvindron
Reviewed by:	pjd
MFC after:	1 week
2014-02-06 21:36:14 +00:00
Gleb Smirnoff
76c1988620 Add test case for kern/181741. Right now test fails.
PR:		181741
Sponsored by:	Nginx, Inc.
2014-02-06 13:18:10 +00:00
Alan Somers
a8eb96d593 Replace the old unix_seqpacket and unix_seqpacket_exercise tests, which
were a little broken and not automatable, with unix_seqpacket_test.
It's coverage is a superset of the old tests and it uses ATF.  It
includes test cases for bugs kern/185813 and kern/185812.

PR:		kern/185812
PR:		kern/185813
Sponsored by:	Spectra Logic
MFC after:	2 weeks
2014-01-23 17:26:28 +00:00
Pawel Jakub Dawidek
b298769db3 MFp4 @1189766:
- Compile the tests with .t suffix, so prove can use them directly.
- The CHECKX() macro should increment ntest just like the CHECK() macro.
- For consistency remove # from the pwd.t output.

Submitted by:	Mariusz Zaborski <oshogbo@FreeBSD.org>
2014-01-04 09:25:27 +00:00
Julio Merino
13de33a5dc 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)
2013-12-11 04:09:17 +00:00
John Baldwin
3e920822b7 - Refresh /etc/localtime after each update using tzsetup -r.
- Regenerate /var/db/services.db when /etc/services changes.

MFC after:	1 week
2013-12-09 19:31:30 +00:00
Eitan Adler
df8fcc1468 Add regression test for recently added 'i' flag in r259132.
PR:	standards/184641
2013-12-09 19:13:16 +00:00
Pawel Jakub Dawidek
ca9aa9026b Regression tests for existing Casper services.
Sponsored by:	The FreeBSD Foundation
2013-12-02 17:01:01 +00:00
Jilles Tjoelker
1b57cec7d9 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.
2013-11-24 23:12:13 +00:00
Jilles Tjoelker
82baac5777 sh: Add more tests for the </dev/null implicit in a background command. 2013-11-24 22:45:49 +00:00
Jilles Tjoelker
c2fd50d77a sh: Add tests for the </dev/null implicit in a background command. 2013-11-22 21:50:13 +00:00
Andriy Gapon
d9b7800b54 fsx: add an option to randomly call msync(MS_INVALIDATE)
This call should be a sufficiently close approximation of what happens
when a filesystem is unmounted and remounted.  To be more specific, it
should test that the data that was in the page cache is the same data
that ends up on a stable storage or in a filesystem's internal cache,
if any.
This will catch the cases where a page with modified data is marked as
a clean page for whatever reason.

While there, make logging of the special events (open+close before
plus invalidation now) more generic and slightly better than the previous
hack.

MFC after:	10 days
2013-11-19 18:35:38 +00:00
Andriy Gapon
2f0f2d0f38 fsx: new option to disable msync(MS_SYNC) after each write via mmaped region
This option should be useful for testing if a filesystem uses the
unified buffer / page cache.
Or, if filesystem's emulation of the unified cache works as expected.
This should be the case for e.g. ZFS.

MFC after:	1 week
2013-11-19 18:35:01 +00:00
John Baldwin
8cc81f38e9 Fix a couple of issues with -F:
- Fix ALWAYS_INSTALL to take precedence over the FreeBSD ID checks.
  In particular, always install a file where the only change was
  the FreeBSD ID even if -F is specified.
- Fix the -F option in the case that the only upstream change is a
  change in the FreeBSD ID and the local file is removed.
- Add tests for these two cases.
2013-11-15 20:01:07 +00:00
Pawel Jakub Dawidek
3baf1859b4 Regression tests for the libnv library.
Sponsored by:	The FreeBSD Foundation
2013-11-12 20:31:16 +00:00
John Baldwin
21d1f635ee Add a pre-world mode of updating similar to the -p option that can be
passed to mergemaster.  In this mode, only changes to /etc/master.passwd
and /etc/group are merged to /etc.  In addition, it uses a temporary
tree to stage these changes rather than overwriting the existing
'current' and 'previous' trees so that a full update can be run after
a normal installworld has completed.

MFC after:	2 weeks
2013-11-12 19:44:18 +00:00
John Baldwin
c387a450ac Add an -s option that specifies a path to an alternate etcupdate.sh script
to test.  This allows a non-installed version of the script to be tested
more easily.
2013-11-12 19:15:06 +00:00
Jilles Tjoelker
5d4d10e3e5 sh: Properly quote alias output from command -v.
An alias should be printed by command -v as a command line; therefore, make
the alias definition suitable for re-input to the shell.
2013-11-10 23:00:39 +00:00
Jilles Tjoelker
309ad20076 sh: Add a test case for would-be assignments that are not due to quoting. 2013-11-10 18:46:59 +00:00
Pawel Jakub Dawidek
b19d096363 Make lpathconf(2) support optional to make it compile again on Linux.
Submitted by:	Hashem Nasarat @riseup.net
2013-10-31 11:38:25 +00:00
Jilles Tjoelker
efd1946c35 sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'.
If job control is not enabled, background jobs started with  ... &  ignore
SIGINT and SIGQUIT so that they are not affected by such signals that are
intended for the foreground job. However, this should not prevent
reassigning a different action for these signals (as if the shell invocation
inherited these signal actions from its parent).

Austin group issue #751

Example:
  { trap - INT; exec sleep 10; } & wait
A Ctrl+C should terminate the sleep command.
2013-10-30 21:36:15 +00:00
Edward Tomasz Napierala
d70f070a0b Revert r257385; was testing a shell script to automatically append the proper
"Sponsored by" and failed at error handling.

Sponsored by:	The FreeBSD Foundation
2013-10-30 14:48:46 +00:00
Edward Tomasz Napierala
ea6dd88f17 Sponsored by: The FreeBSD Foundation 2013-10-30 14:45:02 +00:00
Simon J. Gerraty
3caf0790a8 Merge head@256284 2013-10-13 02:35:19 +00:00
Simon J. Gerraty
4fd0d10e0f New dependencies 2013-10-13 00:22:44 +00:00
John-Mark Gurney
44f01c419d don't assert on bad args, instead return an error..
Since so many programs don't check return value, always NUL terminate
the buf...

fix rounding when using base 1024 (the bug that started it all)...

add a set of test cases so we can make sure that things don't break
in the future...

Thanks to Clifton Royston for testing and the test program...

Approved by:	re (hrs, glebius)
MFC after:	1 week
2013-10-07 22:22:57 +00:00
Edward Tomasz Napierala
009ea47eb2 Bring in the new iSCSI target and initiator.
Reviewed by:	ken (parts)
Approved by:	re (delphij)
Sponsored by:	FreeBSD Foundation
2013-09-14 15:29:06 +00:00
Ed Maste
50185946a4 Add a sendfile regression test for transmit length > file size.
This test identified the issue fixed in FreeBSD-SA-13:11.sendfile.

Sponsored by:	The FreeBSD Foundation
Approved by:	re (glebius)
2013-09-10 13:51:19 +00:00
Jilles Tjoelker
ef70de180c libc/stdio: Allow fopen/freopen modes in any order (except initial r/w/a).
Austin Group issue #411 requires 'e' to be accepted before and after 'x',
and encourages accepting the characters in any order, except the initial
'r', 'w' or 'a'.

Given that glibc accepts the characters after r/w/a in any order and that
diagnosing this problem may be hard, change our libc to behave that way as
well.
2013-09-06 13:47:16 +00:00
Jilles Tjoelker
366f0c9f45 libc/stdio: Run mkostemp test using prove. 2013-09-06 12:59:48 +00:00
Jilles Tjoelker
e32a0090d8 libc/stdio: Provide proper TAP output for fmemopen/open_[w]memstream.
A *.t file should provide Test Anything Protocol output so that it can be
run using the Perl "prove" tool.
2013-09-06 12:56:49 +00:00
Jilles Tjoelker
2935c4cc5e sh: Make return return from the closest function or dot script.
Formerly, return always returned from a function if it was called from a
function, even if there was a closer dot script. This was for compatibility
with the Bourne shell which only allowed returning from functions.

Other modern shells and POSIX return from the function or the dot script,
whichever is closest.

Git 1.8.4's rebase --continue depends on the POSIX behaviour.

Reported by:	Christoph Mallon, avg
2013-09-04 22:10:16 +00:00
Jilles Tjoelker
65519ccb4d sh: Recognize "--" as end of options in type builtin.
This implementation makes minimal changes: command names starting with "-"
(other than "--") can still be queried normally.
2013-08-30 12:09:59 +00:00
Jilles Tjoelker
ffeed88842 Fix fcntl F_GETFL F_SETFL for files opened execute-only (O_EXEC).
The FFLAGS and OFLAGS now work correctly also for files opened with O_EXEC.
Except possibly fuse, the other users pass values without O_EXEC set. fuse
appears to assume O_EXEC is handled correctly.

Although F_SETFL may not be commonly used for execute-only file descriptors,
F_GETFL may be useful to find the access mode.
2013-08-25 21:52:04 +00:00
Jilles Tjoelker
71828da5ff sh: Recognize "--" as end of options in alias builtin.
Aliases starting with "-" (which are non-POSIX) will need to be preceded by
an alias not starting with "-" or the newly added "--".
2013-08-25 11:42:53 +00:00
Jilles Tjoelker
3cfb11c41a 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.
2013-08-25 10:57:48 +00:00
Jilles Tjoelker
7e6e930d1e sh: Reject ++ and -- in arithmetic.
POSIX does not require ++ and -- in arithmetic. It is probably more useful
to reject them than to treat ++x and --x as x silently.

Note that the behaviour of increment and decrement can be obtained via
(x+=1), ((x+=1)-1), (x-=1) and ((x-=1)+1).

PR:		bin/176444
2013-08-24 20:06:00 +00:00
Jilles Tjoelker
f0ef49bbf4 sh: Recognize "--" as end of options in bg/fg/jobid builtins. 2013-08-16 13:56:43 +00:00
Jilles Tjoelker
4fe1afd789 sh: Add test for the non-standard jobid builtin. 2013-08-16 13:48:11 +00:00
Jilles Tjoelker
fcaac274c0 Add tests for dup3(). 2013-08-16 13:16:55 +00:00
Jilles Tjoelker
056fd329b9 sh: Recognize "--" as end of options in local builtin. 2013-08-14 21:59:48 +00:00
Jilles Tjoelker
adc2e8dfb4 sh: Allow a lone redirection before '|', ';;' or ';&'.
Example: </dev/null | :

PR:		181240
MFC after:	1 week
2013-08-14 19:34:13 +00:00
Jilles Tjoelker
88dae73d36 fnmatch(): Add test for r254091 (pattern with single backslash).
This test cannot be converted to an sh(1) test because the syntax would be
invalid.

PR:		181129
MFC after:	1 week
2013-08-11 21:54:20 +00:00
Jilles Tjoelker
65ba8dff5f Add mkostemp() and mkostemps().
These are like mkstemp() and mkstemps() but allow passing open(2) flags like
O_CLOEXEC.
2013-08-09 17:24:23 +00:00
Jilles Tjoelker
8d0f6b5fc2 wordexp(): Fix syntax validation for backslashes in single-quotes. 2013-07-23 21:09:26 +00:00
Konstantin Belousov
a81c9a9468 Fix several warnings.
Fix crash in aio_pty_cleanup() by initializing the pointer before
dereferencing.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2013-07-21 19:21:18 +00:00
Kevin Lo
e32234295d Include stdint.h when use intmax_t.
Reported by:	bde
2013-07-18 06:32:19 +00:00
Kevin Lo
8ea4debe59 Replace PRId64 with "jd" in a printf call. Cast the corresponding value to
intmax_t, because the original type is off_t.

Reported by:	bde
2013-07-18 01:40:31 +00:00
Kevin Lo
2f31c8f52e Add missing headers. 2013-07-17 00:58:23 +00:00
Kevin Lo
1d35db811f Use PRId64 instead of %gd to print an int64_t. 2013-07-17 00:54:21 +00:00
Kevin Lo
e437ef394f Need to define NO_MAN here. 2013-07-16 09:40:59 +00:00
Kevin Lo
eaec55242c Use MAN= instead of NO_MAN=
For some reason it still tries to install a priv.1 when using NO_MAN,
even though there isn't one yet.
2013-07-16 09:38:51 +00:00
Kevin Lo
4b30cabddc Add missing header needed by sleep(3). 2013-07-16 09:22:50 +00:00
Jilles Tjoelker
fd7d6d8a29 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.
2013-07-12 15:29:41 +00:00
Eitan Adler
8587d5deac Restore "all rights reserved" (spelled correctly). This was actually part of the standard text of the license which I did not realize prior.
Approved by:	bushman
2013-06-17 20:27:20 +00:00
Eitan Adler
353aa3e75b Remove lines declaring "All rights reserved" or similar comments: they
are not true as the files are actually under the BSD-2 license

Approved by:	bushman
2013-06-16 19:35:01 +00:00
Jilles Tjoelker
7a3000699c sh: Add tests for 'local -' (save shell options). 2013-06-15 22:22:03 +00:00
David Schultz
7a62fe0f3e Fix some bugs in the complex trig tests so that they test both double
and float precision properly.
2013-06-10 06:03:03 +00:00
Ed Schouten
17b945433d Add testing utility for behavior of atomic ops.
This small utility performs a sequence of atomic operations with random
parameters on an atomic variable. For every type, we also create 16
variables, to ensure that we test the correctness at different
alignments.
2013-06-08 22:44:49 +00:00
Jilles Tjoelker
79b1d31887 sh: Return status 127 for unknown jobs in wait builtin.
This is required by POSIX, at least for pids that are not known child
processes.

Other problems with job specifications still cause wait to abort with
exit status 2.

PR:		176916
2013-06-05 19:40:52 +00:00
Jilles Tjoelker
a4099656c3 sh: Allow multiple operands in wait builtin.
This is only part of the PR; the behaviour for unknown/invalid pids/jobs
remains unchanged (aborts the builtin with status 2).

PR:		176916
Submitted by:	Vadim Goncharov
2013-06-05 19:08:22 +00:00
David E. O'Brien
f9d4b3926a Match the options of the kernel. 2013-06-04 06:38:01 +00:00
Ed Schouten
49111f0092 Add libiconv based versions of *c16*() and *c32*().
I initially thought wchar_t was locale independent, but this seems to be
only the case on Linux. This means that we cannot depend on the *wc*()
routines to implement *c16*() and *c32*(). Instead, use the Citrus
libiconv that is part of libc.

I'll see if there is anything I can do to make the existing functions
somewhat useful in case the system is built without libiconv in the
nearby future. If not, I'll simply remove the broken implementations.

Reviewed by:	jilles, gabor
2013-06-03 17:17:56 +00:00
David Schultz
8ffb5b838e Add more tests for log functions. A few are commented out because the
long double versions don't pass yet.  (They are rather nit-picky cases,
so there's ongoing discussion with Bruce about whether it is worth the
performance cost.)
2013-06-03 09:15:15 +00:00
David Schultz
45de1d006d Factor out some common code from the libm tests. This is a bit messy
because different tests have different ideas about what it means to be
"close enough" to the right answer, depending on the properties of the
function being tested.  In the process, I fixed some warnings and
added a few more 'volatile' hacks, which are sufficient to make all
the tests pass at -O2 with clang.
2013-06-02 04:30:03 +00:00
Jilles Tjoelker
f19825af72 test: Remove -ntXY and -otXY primaries.
This reverts commit r247274.

As maintainer of sh, I disapprove of this feature addition.

It is too specific and can be done without easily using find(1) or stat(1).
I will add some hints to the test(1) man page shortly.

In general, FreeBSD sh is not the place to invent new shell language
features. This is how it has been maintained and adding features randomly
does not work with that.

The new syntax (e.g. [ FILE1 -ntca FILE2 ]) looks cryptic to me.
2013-05-31 22:54:20 +00:00
Jilles Tjoelker
0fbff2deb9 sh: Add test cases for break outside a loop.
In most shells (including our sh), break outside a loop does nothing with
status 0, or at least does not abort. Therefore, scripts sometimes (buggily)
depend on this.
2013-05-31 14:45:25 +00:00
David E. O'Brien
85325f8942 Different approach to making all compilers happy. 2013-05-31 04:27:41 +00:00
David E. O'Brien
7b45e382d0 Allow building with clang (which is being really stupid here...). 2013-05-31 04:19:13 +00:00
David Schultz
6bba248bee Fix some harmless bugs in a test. 2013-05-30 04:47:03 +00:00
David Schultz
659a67c641 Basic tests for complex inverse trig and hyperbolic functions. 2013-05-30 04:46:36 +00:00
Tijl Coosemans
9bea689e8b Fix cexp regression tests that have an infinite real part. The signs of the
result depend on the cosine and sine of the imaginary part.
Small values are used in the new tests such that cosine and sine are well
defined.

Reviewed by:	das
2013-05-28 08:50:50 +00:00
David Schultz
7dbbb6dde3 Fix some regressions caused by the switch from gcc to clang. The fixes
are workarounds for various symptoms of the problem described in clang
bugs 3929, 8100, 8241, 10409, and 12958.

The regression tests did their job: they failed, someone brought it
up on the mailing lists, and then the issue got ignored for 6 months.
Oops. There may still be some regressions for functions we don't have
test coverage for yet.
2013-05-27 08:50:10 +00:00
Ed Schouten
5f4cd89cce Add missing #includes, to keep Clang silent. 2013-05-25 18:04:24 +00:00
Ed Schouten
50c77c6e8b Add <uchar.h>.
The <uchar.h> header, part of C11, adds a small number of utility
functions for 16/32-bit "universal" characters, which may or may not be
UTF-16/32. As our wchar_t is already ISO 10646, simply add light-weight
wrappers around wcrtomb() and mbrtowc().

While there, also add (non-yet-standard) _l functions, similar to the
ones we already have for the other locale-dependent functions.

Reviewed by:	theraven
2013-05-21 19:59:37 +00:00
Jilles Tjoelker
e9dec7758d popen(): Add 'e' mode character to set close-on-exec on the new fd.
If 'e' is used, the kernel must support the recently added pipe2() system
call.

The use of pipe2() with O_CLOEXEC also fixes race conditions between
concurrent popen() calls from different threads, even if the close-on-exec
flag on the fd of the returned FILE is later cleared (because popen() closes
all file descriptors from earlier popen() calls in the child process).
Therefore, this approach should be used in all cases when pipe2() can be
assumed present.

The old version of popen() rejects "re" and "we" but treats "r+e" like "r+".
2013-05-20 17:31:18 +00:00
Jilles Tjoelker
86b75745ad Add a test program for popen(). 2013-05-20 13:05:51 +00:00
Peter Wemm
dda759d344 Tidy up some CVS workarounds. 2013-05-12 01:53:47 +00:00
Jilles Tjoelker
60bf56fd82 Add simple testcases for fcntl(F_DUP2FD_CLOEXEC). 2013-05-11 22:13:24 +00:00
Jilles Tjoelker
7a1a8a4243 Add simple testcases for fcntl(F_DUPFD_CLOEXEC). 2013-05-11 16:31:41 +00:00
Jilles Tjoelker
316ed7ca36 Add missing argument to fcntl(F_DUPFD) in regression test. 2013-05-11 15:45:44 +00:00
Stefan Farfeleder
cd5810229d Add a few xargs tests related to -0, -n and quoting. 2013-05-04 16:41:14 +00:00
Jilles Tjoelker
14303aa889 sh: Remove racy test case for read builtin.
This test case sometimes fails because of an EINTR-related race condition.
Fixing this race condition likely requires an extra system call per byte,
which would make the read builtin even slower than it already is, or very
complicated trickery. Therefore, remove the test case for now.
2013-05-03 20:39:53 +00:00
Jilles Tjoelker
c4539460e3 sh: Improve error handling in read builtin:
* If read -t times out, return status as if interrupted by SIGALRM
  (formerly 1).
* If a trapped signal interrupts read, return status 128+sig (formerly 1).
* If [EINTR] occurs but there is no trap, retry the read (for example
  because of a SIGWINCH in interactive mode).
* If a read error occurs, write an error message and return status 2.

As before, a variable assignment error returns 2 and discards the remaining
data read.
2013-05-03 15:28:31 +00:00
Pawel Jakub Dawidek
849c495c94 Style cleanups. 2013-04-17 21:08:18 +00:00
Gabor Kovesdan
ab3f6b347e - Correct mispellings of the word occurrence
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de> (via private mail)
2013-04-17 11:40:10 +00:00
Jilles Tjoelker
6e0f89a4b4 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
2013-04-12 15:19:35 +00:00
Jilles Tjoelker
87887877ec sh: Add a variation on builtins/eval4.0 where the cmdsubst returns 0. 2013-04-06 22:30:46 +00:00
Jilles Tjoelker
70d41b5846 wordexp(): Remove wrong IFS usage.
Words in shell script are separated by spaces or tabs independent of the
value of IFS. The value of IFS is only relevant for the result of
substitutions. Therefore, there should be a space between 'wordexp' and the
words to be expanded, not an IFS character.

Paranoia might dictate that the shell ignore IFS from the environment (even
though our sh currently uses it), so do not depend on it in the new test
case.
2013-04-01 20:50:07 +00:00
Pawel Jakub Dawidek
ff96467412 Update regression tests after adding chflagsat(2).
Sponsored by:	The FreeBSD Foundation
2013-03-21 23:07:04 +00:00
Pawel Jakub Dawidek
b4b2596b97 - Make 'flags' argument to chflags(2), fchflags(2) and lchflags(2) of type
u_long. Before this change it was of type int for syscalls, but prototypes
  in sys/stat.h and documentation for chflags(2) and fchflags(2) (but not
  for lchflags(2)) stated that it was u_long. Now some related functions
  use u_long type for flags (strtofflags(3), fflagstostr(3)).
- Make path argument of type 'const char *' for consistency.

Discussed on:	arch
Sponsored by:	The FreeBSD Foundation
2013-03-21 22:44:33 +00:00
Pawel Jakub Dawidek
b48fdae147 Update the tests now that absence of the O_APPEND flag requires CAP_SEEK
capability. Add some more tests.

Sponsored by:	The FreeBSD Foundation
2013-03-16 23:13:49 +00:00
Pawel Jakub Dawidek
ac978022d3 The mode argument for open(2)/openat(2) only makes sense if the O_CREAT flag
was given.

Sponsored by:	The FreeBSD Foundation
2013-03-16 23:10:40 +00:00
Jilles Tjoelker
d70ad6f2d0 sh: Recognize "--" and explicitly reject options in wait builtin.
If syntactically invalid job identifiers are to be taken as jobs that exited
with status 127, this should not apply to options, so that we can add
options later if need be.
2013-03-15 20:29:31 +00:00
Pawel Jakub Dawidek
374b056ce8 Make file name generation to work with both new and old versions of OpenSSL.
Sponsored by:	The FreeBSD Foundation
2013-03-15 00:10:38 +00:00
Jilles Tjoelker
3fe1119f98 sh: When executing a trap, keep exit status along with evalskip.
This ensures 'return' in a trap returns the correct status to the caller.

If evalskip is not set or if it is overridden by a previous evalskip, keep
the old behaviour of restoring the exit status from before the trap.
2013-03-03 17:33:59 +00:00
Pawel Jakub Dawidek
2328a74aa8 If all ioctls are allowed, cap_ioctls_get(2) will return CAP_IOCTLS_ALL.
Update regression tests.
2013-03-02 23:40:42 +00:00
Pawel Jakub Dawidek
7099ae5f3d Add support for bindat(2) and connectat(2).
Sponsored by:	The FreeBSD Foundation
2013-03-02 21:16:40 +00:00
Pawel Jakub Dawidek
de50394176 Add regression tests for the new Capsicum system calls.
Sponsored by:	The FreeBSD Foundation
2013-03-02 01:00:26 +00:00
Pawel Jakub Dawidek
f29088987a Update existing regression tests after Capsicum overhaul. 2013-03-02 00:56:53 +00:00
John Baldwin
9240031ac6 Add an implementation of open_memstream() and open_wmemstream(). These
routines provide write-only stdio FILE objects that store their data in a
dynamically allocated buffer.  They are a string builder interface somewhat
akin to a completely dynamic sbuf.

Reviewed by:	bde, jilles (earlier versions)
MFC after:	1 month
2013-02-27 19:50:46 +00:00
Peter Jeremy
293beebc46 Enhance test(1) by adding provision to compare any combination of the
access, birth, change and modify times of two files, instead of only
being able to compare modify times.  The builtin test in sh(1) will
automagically acquire the same expansion.

Approved by:	grog
MFC after:	2 weeks
2013-02-25 19:05:40 +00:00
Jilles Tjoelker
25e0f0f577 sh: If a SIGINT or SIGQUIT interrupts "wait", return status 128+sig. 2013-02-23 22:50:57 +00:00
Jilles Tjoelker
57f00aa510 sh: Test that the exit status is 1 if read encounters EOF. 2013-02-23 15:15:41 +00:00
Sergey Kandaurov
b57181586c Major update for unix_cmsg from Andrey Simonenko.
Quoting the submitter:
- Added tests for SCM_BINTIME, LOCAL_PEERCRED, cmsghdr.cmsg_len
- Code that checks correctness of groups was corrected (getgroups(2) change)
- unix_cmsg.c was completely redesigned and simplified
- Use less timeout value in unix_cmsg.c for faster work
- Added support for not sending data in a message, not sending data and
  data array associated with a cmsghdr structure in a message
- Existent tests were improved
- unix_cmsg.t was redesigned and simplified

Correctness of unix_cmsg verified on 7.1-STABLE, 9.1-STABLE and 10-CURRENT.

PR:		bin/131567
Submitted by:	Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua>
MFC after:	2 weeks
2013-02-11 12:56:23 +00:00
Pietro Cerutti
71796d333c - Fix more style(9)-related issues (copyright header, spaces after function
names, unnecessary casts)
- Change type of boolean variable from char to bool

Suggested by:	jhb, zont, jmallett
Reviewed by:	cognet
Approved by:	cognet
2013-02-01 13:04:06 +00:00
Pietro Cerutti
646b68f04d - Remove underscores from the internal structure name, as it doesn't collide
with the user's namespace.

- Correct size and position variables type from long to size_t.

- Do not set errno to ENOMEM on malloc failure, as malloc already does so.

- Implement the concept of "buffer data length", which mandates what SEEK_END
  refers to and the allowed extent for a read.

- Use NULL as read-callback if the buffer is opened in write-only mode.
  Conversely, use NULL as write-callback when opened in read-only mode.

- Implement the handling of the ``b'' character in the mode argument. A binary
  buffer differs from a text buffer (default mode if ``b'' is omitted) in that
  NULL bytes are never appended to writes and that the "buffer data length"
  equals to the size of the buffer.

- Remove shall from the man page. Use indicative instead. Also, specify that
  the ``b'' flag does not conform with POSIX but is supported by glibc.

- Update the regression test so that the ``b'' functionality and the "buffer
  data length" concepts are tested.

- Minor style(9) corrections.

Suggested by:	jilles
Reviewed by:	cognet
Approved by:	cognet
2013-01-31 16:39:50 +00:00
Pietro Cerutti
96c95412ca Add fmemopen(3), an interface to get a FILE * from a buffer in memory, along
with the respective regression test.
See http://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html

Reviewed by:	cognet
Approved by:	cognet
2013-01-30 14:59:26 +00:00
Jilles Tjoelker
925420d09c sh: Pass $? to command substitution containing compound/multiple commands.
Example:
  false; echo $(echo $?; :)
2013-01-14 12:20:55 +00:00
Jilles Tjoelker
e1e1f0e44f sh: Add testcase that $? is preserved into a simple command substitution.
The test builtins/trap6.0 already uses this but having it separate eases
diagnosis if this would break.
2013-01-13 22:35:51 +00:00
Jilles Tjoelker
f897e827b9 sh: Add some testcases related to subshells.
These failed in earlier attempts to execute more subshells without forking.
The patches are uncommitted.
2013-01-13 19:39:13 +00:00
Jilles Tjoelker
31d396587e sh: Fix crash when parsing '{ } &'.
MFC after:	1 week
2013-01-13 19:26:33 +00:00
Jilles Tjoelker
2c090c7168 sh: Don't lose $? when backquoted command ends with semicolon or newline.
An empty simple command was added and overwrote the exit status with 0.

This affects `...` but not $(...).

Example:
  v=`false;`; echo $?
2013-01-13 19:19:40 +00:00
Eitan Adler
ad9d6ff06a Add an additional regression tests for other cases to ensure these do not get fixed by accident. 2012-12-18 21:42:45 +00:00
Eitan Adler
2f01c791e9 POSIX requires that non-existent or null arguments be treated as if a
zero argument were supplied.

Add a regression test to catch this case as well.

PR:		bin/174521
Submitted by:	Daniel Shahaf <danielsh@elego.de> (pr)
Submitted by:	Mark Johnston <markjdb@gmail.com> (initial patch)
Reviewed by:	jilles
Approved by:	cperciva (implicit)
MFC after:	3 weeks
2012-12-18 21:02:38 +00:00
Jilles Tjoelker
d6d66cfc00 sh: Detect and flag write errors on stdout in builtins.
If there is a write error on stdout, a message will be printed (to stderr)
and the exit status will be changed to 2 if it would have been 0 or 1.

PR:		bin/158206
2012-12-12 22:01:10 +00:00
Jilles Tjoelker
b731376e8c libc: Add a missing header to a test program.
Usage of dup(), mkstemp() and unlink() needs <unistd.h>.
2012-12-08 19:42:15 +00:00
Ed Maste
c153604de3 Non-void function should return a value.
Found by: clang
2012-11-20 19:23:44 +00:00
Ed Maste
f77a2d2f24 Remove unused variable. 2012-11-20 01:42:18 +00:00