From f33aee7cee139631cdb4d4337a7d51865da4fc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kowalczyk?= Date: Fri, 24 Apr 2020 00:28:12 +0200 Subject: [PATCH 1/3] syscalls/{f,l,}chown: Don't pass undocumented flags to open and chmod man says that `mode` argument supports only standard mode flags. On Linux, those LTP tests seem to work by an accident, despite passing S_IFREG there - Linux masks mode with 07777 and ignores any other bits, including S_IFREG. --- testcases/kernel/syscalls/chown/chown02.c | 8 ++++---- testcases/kernel/syscalls/chown/chown03.c | 4 ++-- testcases/kernel/syscalls/chown/chown05.c | 2 +- testcases/kernel/syscalls/fchown/fchown02.c | 8 ++++---- testcases/kernel/syscalls/fchown/fchown03.c | 4 ++-- testcases/kernel/syscalls/fchown/fchown05.c | 2 +- testcases/kernel/syscalls/lchown/lchown01.c | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/testcases/kernel/syscalls/chown/chown02.c b/testcases/kernel/syscalls/chown/chown02.c index a459f092b2c..4afbfcb6554 100644 --- a/testcases/kernel/syscalls/chown/chown02.c +++ b/testcases/kernel/syscalls/chown/chown02.c @@ -81,10 +81,10 @@ #include "safe_macros.h" #include "compat_16.h" -#define FILE_MODE (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) -#define NEW_PERMS1 (S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID) -#define NEW_PERMS2 (S_IFREG|S_IRWXU|S_ISGID) -#define EXP_PERMS (S_IFREG|S_IRWXU|S_IRWXG) +#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) +#define NEW_PERMS1 (S_IRWXU|S_IRWXG|S_ISUID|S_ISGID) +#define NEW_PERMS2 (S_IRWXU|S_ISGID) +#define EXP_PERMS (S_IRWXU|S_IRWXG) #define TESTFILE1 "testfile1" #define TESTFILE2 "testfile2" diff --git a/testcases/kernel/syscalls/chown/chown03.c b/testcases/kernel/syscalls/chown/chown03.c index 2c7bcfe7d8c..5a4eef4c514 100644 --- a/testcases/kernel/syscalls/chown/chown03.c +++ b/testcases/kernel/syscalls/chown/chown03.c @@ -84,8 +84,8 @@ #include "safe_macros.h" #include "compat_16.h" -#define FILE_MODE (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) -#define NEW_PERMS (S_IFREG|S_IRWXU|S_IRWXG|S_ISUID|S_ISGID) +#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) +#define NEW_PERMS (S_IRWXU|S_IRWXG|S_ISUID|S_ISGID) #define TESTFILE "testfile" TCID_DEFINE(chown03); diff --git a/testcases/kernel/syscalls/chown/chown05.c b/testcases/kernel/syscalls/chown/chown05.c index 840558c08a3..02faefb31d2 100644 --- a/testcases/kernel/syscalls/chown/chown05.c +++ b/testcases/kernel/syscalls/chown/chown05.c @@ -79,7 +79,7 @@ #include "safe_macros.h" #include "compat_16.h" -#define FILE_MODE (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) +#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) #define TESTFILE "testfile" TCID_DEFINE(chown05); diff --git a/testcases/kernel/syscalls/fchown/fchown02.c b/testcases/kernel/syscalls/fchown/fchown02.c index 0fef74dee6c..2395eb8dc0b 100644 --- a/testcases/kernel/syscalls/fchown/fchown02.c +++ b/testcases/kernel/syscalls/fchown/fchown02.c @@ -39,10 +39,10 @@ #include "safe_macros.h" #include "compat_16.h" -#define FILE_MODE S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define NEW_PERMS1 S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID -#define NEW_PERMS2 S_IFREG | S_IRWXU | S_ISGID -#define EXP_PERMS S_IFREG | S_IRWXU | S_IRWXG +#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH +#define NEW_PERMS1 S_IRWXU | S_IRWXG | S_ISUID | S_ISGID +#define NEW_PERMS2 S_IRWXU | S_ISGID +#define EXP_PERMS S_IRWXU | S_IRWXG #define TESTFILE1 "testfile1" #define TESTFILE2 "testfile2" diff --git a/testcases/kernel/syscalls/fchown/fchown03.c b/testcases/kernel/syscalls/fchown/fchown03.c index f7fe994fdf8..43076458fcc 100644 --- a/testcases/kernel/syscalls/fchown/fchown03.c +++ b/testcases/kernel/syscalls/fchown/fchown03.c @@ -42,8 +42,8 @@ #include "safe_macros.h" #include "compat_16.h" -#define FILE_MODE (mode_t)(S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) -#define NEW_PERMS (mode_t)(S_IFREG | S_IRWXU | S_IRWXG | S_ISUID | S_ISGID) +#define FILE_MODE (mode_t)(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) +#define NEW_PERMS (mode_t)(S_IRWXU | S_IRWXG | S_ISUID | S_ISGID) #define FCHOWN_PERMS (mode_t)(NEW_PERMS & ~(S_ISUID | S_ISGID)) #define TESTFILE "testfile" diff --git a/testcases/kernel/syscalls/fchown/fchown05.c b/testcases/kernel/syscalls/fchown/fchown05.c index 1897a2e831f..e9234aba782 100644 --- a/testcases/kernel/syscalls/fchown/fchown05.c +++ b/testcases/kernel/syscalls/fchown/fchown05.c @@ -35,7 +35,7 @@ #include "safe_macros.h" #include "compat_16.h" -#define FILE_MODE S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH +#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH #define TESTFILE "testfile" TCID_DEFINE(fchown05); diff --git a/testcases/kernel/syscalls/lchown/lchown01.c b/testcases/kernel/syscalls/lchown/lchown01.c index 89c85e98774..c083392b95d 100644 --- a/testcases/kernel/syscalls/lchown/lchown01.c +++ b/testcases/kernel/syscalls/lchown/lchown01.c @@ -43,7 +43,7 @@ #include "safe_macros.h" #include "compat_16.h" -#define FILE_MODE (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) +#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) #define TESTFILE "testfile" #define SFILE "slink_file" From 66987ed1e923ff2fc110e2b5c94fcc6026b2e933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kowalczyk?= Date: Wed, 19 Aug 2020 19:48:49 +0200 Subject: [PATCH 2/3] Test ignoring of unknown bits in open/openat/openat2/chmod mode --- testcases/kernel/syscalls/chmod/.gitignore | 1 + testcases/kernel/syscalls/chmod/chmod08.c | 64 +++++++++++++++++ testcases/kernel/syscalls/open/.gitignore | 1 + testcases/kernel/syscalls/open/open15.c | 67 ++++++++++++++++++ testcases/kernel/syscalls/openat/.gitignore | 1 + testcases/kernel/syscalls/openat/openat04.c | 67 ++++++++++++++++++ testcases/kernel/syscalls/openat2/.gitignore | 7 +- testcases/kernel/syscalls/openat2/openat204.c | 68 +++++++++++++++++++ 8 files changed, 273 insertions(+), 3 deletions(-) create mode 100644 testcases/kernel/syscalls/chmod/chmod08.c create mode 100644 testcases/kernel/syscalls/open/open15.c create mode 100644 testcases/kernel/syscalls/openat/openat04.c create mode 100644 testcases/kernel/syscalls/openat2/openat204.c diff --git a/testcases/kernel/syscalls/chmod/.gitignore b/testcases/kernel/syscalls/chmod/.gitignore index 4e856df4372..170141f80b6 100644 --- a/testcases/kernel/syscalls/chmod/.gitignore +++ b/testcases/kernel/syscalls/chmod/.gitignore @@ -5,3 +5,4 @@ /chmod05 /chmod06 /chmod07 +/chmod08 diff --git a/testcases/kernel/syscalls/chmod/chmod08.c b/testcases/kernel/syscalls/chmod/chmod08.c new file mode 100644 index 00000000000..aa11c3dc2b0 --- /dev/null +++ b/testcases/kernel/syscalls/chmod/chmod08.c @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2020 Invisible Things Lab + * Michał Kowalczyk + */ + +/* + * DESCRIPTION + * Changes file access permissions using `chmod` with bits outside of 07777 in + * `mode` set and verifies if they were ignored. + * + * WARNING + * The fact that these bits are ignored is not documented (at the time of + * writing). Failure of this test doesn't necessarily mean that a regression + * in Linux was introduced, its intention is to catch accidental interface + * changes and warn kernel developers if that happens. + */ + +#include +#include +#include +#include + +#include "tst_test.h" + +#define OPEN_MODE 0644 +#define CHMOD_MODE (0777 | ~07777) +#define TESTFILE "testfile" + +void test_chmod(void) +{ + struct stat stat_buf; + + TEST(chmod(TESTFILE, CHMOD_MODE)); + if (TST_RET == -1) { + tst_res(TFAIL, "chmod(%s, %#o) failed", TESTFILE, CHMOD_MODE); + } + + if (stat(TESTFILE, &stat_buf) == -1) { + tst_brk(TFAIL | TTERRNO, "stat failed"); + } + + mode_t expected = S_IFREG | (CHMOD_MODE & 07777); + if (stat_buf.st_mode == expected) { + tst_res(TPASS, "Unknown mode bits were ignored as expected", + TESTFILE, CHMOD_MODE); + } else { + tst_res(TFAIL, "%s: Incorrect mode 0%04o, expected 0%04o", + TESTFILE, stat_buf.st_mode, expected); + } +} + +void setup(void) +{ + int fd; + + fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, OPEN_MODE); + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .needs_tmpdir = 1, + .setup = setup, + .test_all = test_chmod, +}; diff --git a/testcases/kernel/syscalls/open/.gitignore b/testcases/kernel/syscalls/open/.gitignore index 4309e3a72f4..186eb820970 100644 --- a/testcases/kernel/syscalls/open/.gitignore +++ b/testcases/kernel/syscalls/open/.gitignore @@ -13,3 +13,4 @@ /open12_child /open13 /open14 +/open15 diff --git a/testcases/kernel/syscalls/open/open15.c b/testcases/kernel/syscalls/open/open15.c new file mode 100644 index 00000000000..0fecdcd14b0 --- /dev/null +++ b/testcases/kernel/syscalls/open/open15.c @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2020 Invisible Things Lab + * Michał Kowalczyk + */ + +/* + * DESCRIPTION + * Creates a file using `open` with bits outside of 07777 in `mode` set and + * verifies if they were ignored. + * + * WARNING + * The fact that these bits are ignored is not documented (at the time of + * writing). Failure of this test doesn't necessarily mean that a regression + * in Linux was introduced, its intention is to catch accidental interface + * changes and warn kernel developers if that happens. + */ + +#include +#include +#include +#include + +#include "tst_test.h" + +#define TEST_FILE "testfile" + +static int fd; + +static struct tcase { + char *filename; + int flags; + mode_t mode; +} tcases[] = { + {TEST_FILE, O_RDWR | O_CREAT, 0644 | ~07777}, + {TEST_FILE, 0, ~07777} +}; + +static void verify_open(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + struct stat buf; + + TEST(open(tc->filename, tc->flags, tc->mode)); + fd = TST_RET; + if (fd == -1) { + tst_res(TFAIL, "Cannot open the file"); + } else { + tst_res(TPASS, "Unknown mode bits were ignored as expected"); + SAFE_CLOSE(fd); + } +} + +static void setup(void) +{ +} + +static void cleanup(void) +{ +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .needs_tmpdir = 1, + .setup = setup, + .cleanup = cleanup, + .test = verify_open, +}; diff --git a/testcases/kernel/syscalls/openat/.gitignore b/testcases/kernel/syscalls/openat/.gitignore index 2928dae2265..2d15872ab9f 100644 --- a/testcases/kernel/syscalls/openat/.gitignore +++ b/testcases/kernel/syscalls/openat/.gitignore @@ -2,3 +2,4 @@ /openat02 /openat02_child /openat03 +/openat04 diff --git a/testcases/kernel/syscalls/openat/openat04.c b/testcases/kernel/syscalls/openat/openat04.c new file mode 100644 index 00000000000..cf10494a575 --- /dev/null +++ b/testcases/kernel/syscalls/openat/openat04.c @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2020 Invisible Things Lab + * Michał Kowalczyk + */ + +/* + * DESCRIPTION + * Creates a file using `openat` with bits outside of 07777 in `mode` set and + * verifies if they were ignored. + * + * WARNING + * The fact that these bits are ignored is not documented (at the time of + * writing). Failure of this test doesn't necessarily mean that a regression + * in Linux was introduced, its intention is to catch accidental interface + * changes and warn kernel developers if that happens. + */ + +#include +#include +#include +#include + +#include "tst_test.h" + +#define TEST_FILE "testfile" + +static int fd; + +static struct tcase { + char *filename; + int flags; + mode_t mode; +} tcases[] = { + {TEST_FILE, O_RDWR | O_CREAT, 0644 | ~07777}, + {TEST_FILE, 0, ~07777} +}; + +static void verify_open(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + struct stat buf; + + TEST(openat(AT_FDCWD, tc->filename, tc->flags, tc->mode)); + fd = TST_RET; + if (fd == -1) { + tst_res(TFAIL, "Cannot open the file"); + } else { + tst_res(TPASS, "Unknown mode bits were ignored as expected"); + SAFE_CLOSE(fd); + } +} + +static void setup(void) +{ +} + +static void cleanup(void) +{ +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .needs_tmpdir = 1, + .setup = setup, + .cleanup = cleanup, + .test = verify_open, +}; diff --git a/testcases/kernel/syscalls/openat2/.gitignore b/testcases/kernel/syscalls/openat2/.gitignore index 5a0843a8522..490efd4e968 100644 --- a/testcases/kernel/syscalls/openat2/.gitignore +++ b/testcases/kernel/syscalls/openat2/.gitignore @@ -1,3 +1,4 @@ -openat201 -openat202 -openat203 +/openat201 +/openat202 +/openat203 +/openat204 diff --git a/testcases/kernel/syscalls/openat2/openat204.c b/testcases/kernel/syscalls/openat2/openat204.c new file mode 100644 index 00000000000..6ad9feb1142 --- /dev/null +++ b/testcases/kernel/syscalls/openat2/openat204.c @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2020 Invisible Things Lab + * Michał Kowalczyk + */ + +/* + * DESCRIPTION + * Creates a file using `openat2` with bits outside of 07777 in `mode` set and + * verifies if they were ignored. + * + * WARNING + * The fact that these bits are ignored is not documented (at the time of + * writing). Failure of this test doesn't necessarily mean that a regression + * in Linux was introduced, its intention is to catch accidental interface + * changes and warn kernel developers if that happens. + */ + +#include +#include +#include +#include + +#include "tst_test.h" +#include "lapi/openat2.h" + +#define TEST_FILE "testfile" + +static int fd; + +static struct tcase { + char *filename; + int flags; + mode_t mode; +} tcases[] = { + {TEST_FILE, O_RDWR | O_CREAT, 0644 | ~07777}, + {TEST_FILE, 0, ~07777} +}; + +static void verify_open(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + struct stat buf; + + TEST(openat2(AT_FDCWD, tc->filename, tc->flags, tc->mode)); + fd = TST_RET; + if (fd == -1) { + tst_res(TFAIL, "Cannot open the file"); + } else { + tst_res(TPASS, "Unknown mode bits were ignored as expected"); + SAFE_CLOSE(fd); + } +} + +static void setup(void) +{ +} + +static void cleanup(void) +{ +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .needs_tmpdir = 1, + .setup = setup, + .cleanup = cleanup, + .test = verify_open, +}; From 279f4faf65f653e92190f9746006358bfdb53d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kowalczyk?= Date: Wed, 23 Sep 2020 01:36:23 +0200 Subject: [PATCH 3/3] fixup! Test ignoring of unknown bits in open/openat/openat2/chmod mode --- testcases/kernel/syscalls/chmod/chmod08.c | 18 ++++---- testcases/kernel/syscalls/open/open15.c | 26 +++--------- testcases/kernel/syscalls/openat/openat04.c | 26 +++--------- testcases/kernel/syscalls/openat2/openat204.c | 42 ++++++++----------- 4 files changed, 37 insertions(+), 75 deletions(-) diff --git a/testcases/kernel/syscalls/chmod/chmod08.c b/testcases/kernel/syscalls/chmod/chmod08.c index aa11c3dc2b0..e3590b71f6a 100644 --- a/testcases/kernel/syscalls/chmod/chmod08.c +++ b/testcases/kernel/syscalls/chmod/chmod08.c @@ -26,30 +26,28 @@ #define CHMOD_MODE (0777 | ~07777) #define TESTFILE "testfile" -void test_chmod(void) +static void test_chmod(void) { struct stat stat_buf; TEST(chmod(TESTFILE, CHMOD_MODE)); if (TST_RET == -1) { - tst_res(TFAIL, "chmod(%s, %#o) failed", TESTFILE, CHMOD_MODE); + tst_res(TFAIL | TTERRNO, "chmod(%s, %#o) failed", TESTFILE, CHMOD_MODE); + return; } - if (stat(TESTFILE, &stat_buf) == -1) { - tst_brk(TFAIL | TTERRNO, "stat failed"); - } + SAFE_STAT(TESTFILE, &stat_buf); mode_t expected = S_IFREG | (CHMOD_MODE & 07777); - if (stat_buf.st_mode == expected) { - tst_res(TPASS, "Unknown mode bits were ignored as expected", - TESTFILE, CHMOD_MODE); - } else { + if (stat_buf.st_mode != expected) { tst_res(TFAIL, "%s: Incorrect mode 0%04o, expected 0%04o", TESTFILE, stat_buf.st_mode, expected); + return; } + tst_res(TPASS, "Unknown mode bits were ignored as expected"); } -void setup(void) +static void setup(void) { int fd; diff --git a/testcases/kernel/syscalls/open/open15.c b/testcases/kernel/syscalls/open/open15.c index 0fecdcd14b0..2e7cb44d662 100644 --- a/testcases/kernel/syscalls/open/open15.c +++ b/testcases/kernel/syscalls/open/open15.c @@ -17,51 +17,37 @@ #include #include -#include #include #include "tst_test.h" #define TEST_FILE "testfile" -static int fd; - static struct tcase { char *filename; int flags; mode_t mode; } tcases[] = { {TEST_FILE, O_RDWR | O_CREAT, 0644 | ~07777}, - {TEST_FILE, 0, ~07777} + {TEST_FILE, 0, ~07777}, }; static void verify_open(unsigned int n) { struct tcase *tc = &tcases[n]; - struct stat buf; TEST(open(tc->filename, tc->flags, tc->mode)); - fd = TST_RET; + int fd = TST_RET; if (fd == -1) { - tst_res(TFAIL, "Cannot open the file"); - } else { - tst_res(TPASS, "Unknown mode bits were ignored as expected"); - SAFE_CLOSE(fd); + tst_res(TFAIL | TTERRNO, "Cannot open the file"); + return; } -} - -static void setup(void) -{ -} - -static void cleanup(void) -{ + tst_res(TPASS, "Unknown mode bits were ignored as expected"); + SAFE_CLOSE(fd); } static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .needs_tmpdir = 1, - .setup = setup, - .cleanup = cleanup, .test = verify_open, }; diff --git a/testcases/kernel/syscalls/openat/openat04.c b/testcases/kernel/syscalls/openat/openat04.c index cf10494a575..4bb23c454d8 100644 --- a/testcases/kernel/syscalls/openat/openat04.c +++ b/testcases/kernel/syscalls/openat/openat04.c @@ -17,51 +17,37 @@ #include #include -#include #include #include "tst_test.h" #define TEST_FILE "testfile" -static int fd; - static struct tcase { char *filename; int flags; mode_t mode; } tcases[] = { {TEST_FILE, O_RDWR | O_CREAT, 0644 | ~07777}, - {TEST_FILE, 0, ~07777} + {TEST_FILE, 0, ~07777}, }; static void verify_open(unsigned int n) { struct tcase *tc = &tcases[n]; - struct stat buf; TEST(openat(AT_FDCWD, tc->filename, tc->flags, tc->mode)); - fd = TST_RET; + int fd = TST_RET; if (fd == -1) { - tst_res(TFAIL, "Cannot open the file"); - } else { - tst_res(TPASS, "Unknown mode bits were ignored as expected"); - SAFE_CLOSE(fd); + tst_res(TFAIL | TTERRNO, "Cannot open the file"); + return; } -} - -static void setup(void) -{ -} - -static void cleanup(void) -{ + tst_res(TPASS, "Unknown mode bits were ignored as expected"); + SAFE_CLOSE(fd); } static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .needs_tmpdir = 1, - .setup = setup, - .cleanup = cleanup, .test = verify_open, }; diff --git a/testcases/kernel/syscalls/openat2/openat204.c b/testcases/kernel/syscalls/openat2/openat204.c index 6ad9feb1142..b5cffa6bd35 100644 --- a/testcases/kernel/syscalls/openat2/openat204.c +++ b/testcases/kernel/syscalls/openat2/openat204.c @@ -17,7 +17,6 @@ #include #include -#include #include #include "tst_test.h" @@ -25,44 +24,37 @@ #define TEST_FILE "testfile" -static int fd; - static struct tcase { char *filename; - int flags; - mode_t mode; + uint64_t flags; + uint64_t mode; + uint64_t resolve; } tcases[] = { - {TEST_FILE, O_RDWR | O_CREAT, 0644 | ~07777}, - {TEST_FILE, 0, ~07777} + {TEST_FILE, O_RDWR | O_CREAT, 0644 | ~07777, 0}, + {TEST_FILE, 0, ~07777, 0}, }; static void verify_open(unsigned int n) { struct tcase *tc = &tcases[n]; - struct stat buf; - - TEST(openat2(AT_FDCWD, tc->filename, tc->flags, tc->mode)); - fd = TST_RET; + struct open_how how = { + .flags = tc->flags, + .mode = tc->mode, + .resolve = tc->resolve, + }; + + TEST(openat2(AT_FDCWD, tc->filename, &how, sizeof(how))); + int fd = TST_RET; if (fd == -1) { - tst_res(TFAIL, "Cannot open the file"); - } else { - tst_res(TPASS, "Unknown mode bits were ignored as expected"); - SAFE_CLOSE(fd); + tst_res(TFAIL | TTERRNO, "Cannot open the file"); + return; } -} - -static void setup(void) -{ -} - -static void cleanup(void) -{ + tst_res(TPASS, "Unknown mode bits were ignored as expected"); + SAFE_CLOSE(fd); } static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .needs_tmpdir = 1, - .setup = setup, - .cleanup = cleanup, .test = verify_open, };