Integrate tools/regression/fifo into the FreeBSD test suite as tests/sys/fifo

This commit is contained in:
ngie 2015-04-12 06:18:24 +00:00
parent 3ffff028af
commit 86baa7f8f1
10 changed files with 39 additions and 78 deletions

View File

@ -354,6 +354,8 @@
..
..
sys
fifo
..
file
..
kern

View File

@ -4,6 +4,7 @@
TESTSDIR= ${TESTSBASE}/sys
TESTS_SUBDIRS+= fifo
TESTS_SUBDIRS+= file
TESTS_SUBDIRS+= kern
TESTS_SUBDIRS+= kqueue

View File

@ -75,7 +75,7 @@
* All activity occurs within a temporary directory created early in the
* test.
*/
char temp_dir[PATH_MAX];
static char temp_dir[PATH_MAX];
static void __unused
atexit_temp_dir(void)
@ -94,7 +94,7 @@ fifo_create_test(int use_mkfifo)
{
struct stat old_dirsb, dirsb, fifosb;
const char *testname;
char path[PATH_MAX];
char path[] = "testfifo";
int error;
if (use_mkfifo)
@ -106,14 +106,12 @@ fifo_create_test(int use_mkfifo)
* Sleep to make sure that the time stamp on the directory will be
* updated.
*/
if (stat(temp_dir, &old_dirsb) < 0)
if (stat(".", &old_dirsb) < 0)
err(-1, "basic_create_test: %s: stat: %s", testname,
temp_dir);
sleep(2);
snprintf(path, PATH_MAX, "%s/testfifo", temp_dir);
if (use_mkfifo) {
if (mkfifo(path, 0600) < 0)
err(-1, "basic_create_test: %s: %s", testname, path);
@ -149,7 +147,7 @@ fifo_create_test(int use_mkfifo)
err(-1, "basic_create_test: dup %s unexpected error",
testname);
if (stat(temp_dir, &dirsb) < 0) {
if (stat(".", &dirsb) < 0) {
error = errno;
(void)unlink(path);
errno = error;
@ -205,7 +203,7 @@ fifo_permission_test(int use_mkfifo)
{
const struct permission_test *ptp;
mode_t __unused old_umask;
char path[PATH_MAX];
char path[] = "testfifo";
const char *testname;
struct stat sb;
int error, i;
@ -215,7 +213,6 @@ fifo_permission_test(int use_mkfifo)
else
testname = "mknod";
snprintf(path, PATH_MAX, "%s/testfifo", temp_dir);
old_umask = umask(0022);
for (i = 0; i < permission_test_count; i++) {
ptp = &permission_test[i];
@ -256,14 +253,14 @@ fifo_permission_test(int use_mkfifo)
}
int
main(int argc, char *argv[])
main(void)
{
int i;
if (geteuid() != 0)
errx(-1, "must be run as root");
strcpy(temp_dir, "/tmp/fifo_create.XXXXXXXXXXX");
strcpy(temp_dir, "fifo_create.XXXXXXXXXXX");
if (mkdtemp(temp_dir) == NULL)
err(-1, "mkdtemp");
atexit(atexit_temp_dir);

View File

@ -88,7 +88,7 @@
* All activity occurs within a temporary directory created early in the
* test.
*/
char temp_dir[PATH_MAX];
static char temp_dir[PATH_MAX];
static void __unused
atexit_temp_dir(void)
@ -130,8 +130,7 @@ cleanfifo3(const char *fifoname, int fd1, int fd2, int fd3)
* so using non-blocking opens in order to avoid deadlocking the process.
*/
static int
openfifo(const char *fifoname, const char *testname, int *reader_fdp,
int *writer_fdp)
openfifo(const char *fifoname, int *reader_fdp, int *writer_fdp)
{
int error, fd1, fd2;
@ -155,7 +154,7 @@ openfifo(const char *fifoname, const char *testname, int *reader_fdp,
* Open one file descriptor for the fifo, supporting both read and write.
*/
static int
openfifo_rw(const char *fifoname, const char *testname, int *fdp)
openfifo_rw(const char *fifoname, int *fdp)
{
int fd;
@ -249,7 +248,7 @@ test_simpleio(void)
ssize_t len;
makefifo("testfifo", __func__);
if (openfifo("testfifo", "test_simpleio", &reader_fd, &writer_fd)
if (openfifo("testfifo", &reader_fd, &writer_fd)
< 0) {
warn("test_simpleio: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
@ -296,12 +295,12 @@ test_simpleio(void)
cleanfifo2("testfifo", reader_fd, writer_fd);
}
static int alarm_fired;
static volatile int alarm_fired;
/*
* Non-destructive SIGALRM handler.
*/
static void
sigalarm(int signum)
sigalarm(int signum __unused)
{
alarm_fired = 1;
@ -408,7 +407,7 @@ test_blocking_read_empty(void)
u_char ch;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
if (openfifo("testfifo", &reader_fd, &writer_fd)
< 0) {
warn("test_blocking_read_empty: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
@ -477,8 +476,7 @@ test_blocking_one_byte(void)
u_char ch;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
< 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_blocking: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -544,8 +542,7 @@ test_nonblocking_one_byte(void)
u_char ch;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
< 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_nonblocking: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -609,8 +606,7 @@ test_blocking_partial_write(void)
ssize_t len;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
< 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_blocking_partial_write: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -668,8 +664,7 @@ test_nonblocking_partial_write(void)
ssize_t len;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
< 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_blocking_partial_write: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -736,8 +731,7 @@ test_coalesce_big_read(void)
ssize_t len;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
< 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_coalesce_big_read: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -808,8 +802,7 @@ test_coalesce_big_write(void)
ssize_t len;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
< 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_coalesce_big_write: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -1078,7 +1071,7 @@ test_events_outofbox(void)
int kqueue_fd, reader_fd, writer_fd;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd) < 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_events_outofbox: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -1134,8 +1127,7 @@ test_events_write_read_byte(void)
u_char ch;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
< 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_events_write_read_byte: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -1227,8 +1219,7 @@ test_events_partial_write(void)
ssize_t len;
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd)
< 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("test_events_partial_write: openfifo: testfifo");
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -1313,8 +1304,7 @@ test_events_rdwr(void)
char ch;
makefifo("testfifo", __func__);
if (openfifo_rw("testfifo", __func__, &fd)
< 0) {
if (openfifo_rw("testfifo", &fd) < 0) {
warn("%s: openfifo_rw: testfifo", __func__);
cleanfifo2("testfifo", -1, -1);
exit(-1);
@ -1381,10 +1371,10 @@ test_events_rdwr(void)
}
int
main(int argc, char *argv[])
main(void)
{
strcpy(temp_dir, "/tmp/fifo_io.XXXXXXXXXXX");
strcpy(temp_dir, "fifo_io.XXXXXXXXXXX");
if (mkdtemp(temp_dir) == NULL)
err(-1, "mkdtemp");
atexit(atexit_temp_dir);

View File

@ -50,7 +50,7 @@
* All activity occurs within a temporary directory created early in the
* test.
*/
char temp_dir[PATH_MAX];
static char temp_dir[PATH_MAX];
static void __unused
atexit_temp_dir(void)
@ -79,8 +79,7 @@ cleanfifo(const char *fifoname, int fd1, int fd2)
}
static int
openfifo(const char *fifoname, const char *testname, int *reader_fdp,
int *writer_fdp)
openfifo(const char *fifoname, int *reader_fdp, int *writer_fdp)
{
int error, fd1, fd2;
@ -110,7 +109,7 @@ test_lseek(void)
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd) < 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("%s: openfifo", __func__);
cleanfifo("testfifo", -1, -1);
exit(-1);
@ -185,7 +184,7 @@ test_ioctl(void)
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd) < 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("%s: openfifo", __func__);
cleanfifo("testfifo", -1, -1);
exit(-1);
@ -237,7 +236,7 @@ test_chmodchown(void)
makefifo("testfifo", __func__);
if (openfifo("testfifo", __func__, &reader_fd, &writer_fd) < 0) {
if (openfifo("testfifo", &reader_fd, &writer_fd) < 0) {
warn("%s: openfifo", __func__);
cleanfifo("testfifo", -1, -1);
exit(-1);
@ -316,10 +315,10 @@ test_chmodchown(void)
}
int
main(int argc, char *argv[])
main(void)
{
strcpy(temp_dir, "/tmp/fifo_misc.XXXXXXXXXXX");
strcpy(temp_dir, "fifo_misc.XXXXXXXXXXX");
if (mkdtemp(temp_dir) == NULL)
err(-1, "mkdtemp");
atexit(atexit_temp_dir);

View File

@ -87,7 +87,7 @@
* All activity occurs within a temporary directory created early in the
* test.
*/
char temp_dir[PATH_MAX];
static char temp_dir[PATH_MAX];
static void __unused
atexit_temp_dir(void)
@ -453,13 +453,13 @@ test_non_blocking_writer(void)
}
int
main(int argc, char *argv[])
main(void)
{
if (geteuid() != 0)
errx(-1, "must be run as root");
strcpy(temp_dir, "/tmp/fifo_open.XXXXXXXXXXX");
strcpy(temp_dir, "fifo_open.XXXXXXXXXXX");
if (mkdtemp(temp_dir) == NULL)
err(-1, "mkdtemp");
if (chdir(temp_dir) < 0)

View File

@ -1,7 +0,0 @@
# $FreeBSD$
PROG= fifo_create
MAN=
WARNS?= 3
.include <bsd.prog.mk>

View File

@ -1,7 +0,0 @@
# $FreeBSD$
PROG= fifo_io
MAN=
WARNS?= 3
.include <bsd.prog.mk>

View File

@ -1,7 +0,0 @@
# $FreeBSD$
PROG= fifo_misc
MAN=
WARNS?= 3
.include <bsd.prog.mk>

View File

@ -1,7 +0,0 @@
# $FreeBSD$
PROG= fifo_open
MAN=
WARNS?= 3
.include <bsd.prog.mk>