Blame gnulib-tests/test-dup.c
|
Packit |
9e4112 |
/* Test duplicating a file descriptor.
|
|
Packit |
9e4112 |
Copyright (C) 2011-2018 Free Software Foundation, Inc.
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
This program is free software: you can redistribute it and/or modify
|
|
Packit |
9e4112 |
it under the terms of the GNU General Public License as published by
|
|
Packit |
9e4112 |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
9e4112 |
(at your option) any later version.
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
This program is distributed in the hope that it will be useful,
|
|
Packit |
9e4112 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
9e4112 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
9e4112 |
GNU General Public License for more details.
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
You should have received a copy of the GNU General Public License
|
|
Packit |
9e4112 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
#include <config.h>
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
#include <unistd.h>
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
#include "signature.h"
|
|
Packit |
9e4112 |
SIGNATURE_CHECK (dup, int, (int));
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
#include <errno.h>
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
#include "macros.h"
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
int
|
|
Packit |
9e4112 |
main (void)
|
|
Packit |
9e4112 |
{
|
|
Packit |
9e4112 |
/* Test behaviour for invalid file descriptors. */
|
|
Packit |
9e4112 |
{
|
|
Packit |
9e4112 |
errno = 0;
|
|
Packit |
9e4112 |
ASSERT (dup (-1) == -1);
|
|
Packit |
9e4112 |
ASSERT (errno == EBADF);
|
|
Packit |
9e4112 |
}
|
|
Packit |
9e4112 |
{
|
|
Packit |
9e4112 |
close (99);
|
|
Packit |
9e4112 |
errno = 0;
|
|
Packit |
9e4112 |
ASSERT (dup (99) == -1);
|
|
Packit |
9e4112 |
ASSERT (errno == EBADF);
|
|
Packit |
9e4112 |
}
|
|
Packit |
9e4112 |
|
|
Packit |
9e4112 |
return 0;
|
|
Packit |
9e4112 |
}
|