Skip to content

Commit

Permalink
Add test descriptions to ioctl01.c
Browse files Browse the repository at this point in the history
Signed-off-by: Marius Kittler <[email protected]>
Reviewed-by: Cyril Hrubis <[email protected]>
  • Loading branch information
Martchus authored and metan-ucw committed Sep 11, 2023
1 parent a244f1c commit de8d826
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions testcases/kernel/syscalls/ioctl/ioctl01.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,32 @@ static struct termio termio;
static struct termios termios;

static struct tcase {
const char *desc;
int *fd;
int request;
void *s_tio;
int error;
} tcases[] = {
/* file descriptor is invalid */
{&bfd, TCGETA, &termio, EBADF},
{&bfd, TCGETS, &termios, EBADF},
/* termio address is invalid */
{&fd, TCGETA, (struct termio *)-1, EFAULT},
{&fd, TCGETS, (struct termios *)-1, EFAULT},
// /* command is invalid */
{"File descriptor is invalid (termio)", &bfd, TCGETA, &termio, EBADF},
{"File descriptor is invalid (termios)", &bfd, TCGETS, &termios, EBADF},
{"Termio address is invalid", &fd, TCGETA, (struct termio *)-1, EFAULT},
{"Termios address is invalid", &fd, TCGETS, (struct termios *)-1, EFAULT},
/* This errno value was changed from EINVAL to ENOTTY
* by kernel commit 07d106d0 and bbb63c51
*/
{&fd, INVAL_IOCTL, &termio, ENOTTY},
/* file descriptor is for a regular file */
{&fd_file, TCGETA, &termio, ENOTTY},
{&fd_file, TCGETS, &termios, ENOTTY},
/* termio is NULL */
{&fd, TCGETA, NULL, EFAULT},
{&fd, TCGETS, NULL, EFAULT}
{"Command is invalid", &fd, INVAL_IOCTL, &termio, ENOTTY},
{"File descriptor is for a regular file (termio)", &fd_file, TCGETA, &termio, ENOTTY},
{"File descriptor is for a regular file (termios)", &fd_file, TCGETS, &termios, ENOTTY},
{"Termio is NULL", &fd, TCGETA, NULL, EFAULT},
{"Termios is NULL", &fd, TCGETS, NULL, EFAULT}
};

static char *device;

static void verify_ioctl(unsigned int i)
{
TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
tcases[i].error);
tcases[i].error, "%s", tcases[i].desc);
}

static void setup(void)
Expand Down

0 comments on commit de8d826

Please sign in to comment.