* [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup
@ 2014-02-26 12:32 Xiaoguang Wang
2014-02-26 12:32 ` [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests Xiaoguang Wang
2014-02-27 5:58 ` [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup Wanlong Gao
0 siblings, 2 replies; 5+ messages in thread
From: Xiaoguang Wang @ 2014-02-26 12:32 UTC (permalink / raw)
To: ltp-list
Delete some useless comment.
Move the test body from main() to mknod_verify().
Some cleanup.
Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
testcases/kernel/syscalls/mknod/mknod07.c | 160 ++++++++++--------------------
1 file changed, 50 insertions(+), 110 deletions(-)
diff --git a/testcases/kernel/syscalls/mknod/mknod07.c b/testcases/kernel/syscalls/mknod/mknod07.c
index 6cdf980..ea17eef 100644
--- a/testcases/kernel/syscalls/mknod/mknod07.c
+++ b/testcases/kernel/syscalls/mknod/mknod07.c
@@ -1,6 +1,7 @@
/*
*
* Copyright (c) International Business Machines Corp., 2001
+ * 07/2001 Ported by Wayne Boyer
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -13,12 +14,11 @@
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
- * Test Name: mknod07
*
* Test Description:
* Verify that,
@@ -27,44 +27,6 @@
* 2) mknod(2) returns -1 and sets errno to EACCES if parent directory
* does not allow write permission to the process.
*
- * Expected Result:
- * mknod() should fail with return value -1 and set expected errno.
- *
- * Algorithm:
- * Setup:
- * Setup signal handling.
- * Create temporary directory.
- * Pause for SIGUSR1 if option specified.
- *
- * Test:
- * Loop if the proper options are given.
- * Execute system call
- * Check return code, if system call failed (return=-1)
- * if errno set == expected errno
- * Issue sys call fails with expected return value and errno.
- * Otherwise,
- * Issue sys call fails with unexpected errno.
- * Otherwise,
- * Issue sys call returns unexpected value.
- *
- * Cleanup:
- * Print errno log and/or timing stats if options given
- * Delete the temporary directory(s)/file(s) created.
- *
- * Usage: <for command-line>
- * mknod07 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
- * where, -c n : Run n copies concurrently.
- * -e : Turn on errno logging.
- * -i n : Execute test n times.
- * -I x : Execute test for x seconds.
- * -P x : Pause for x seconds between iterations.
- * -t : Turn on syscall timing.
- *
- * HISTORY
- * 07/2001 Ported by Wayne Boyer
- *
- * RESTRICTIONS:
- * This test should be executed by non-super-user only.
*/
#include <stdio.h>
@@ -79,125 +41,103 @@
#include "test.h"
#include "usctest.h"
+#include "safe_macros.h"
-#define MODE_RWX S_IFIFO | S_IRWXU | S_IRWXG | S_IRWXO
-#define NEWMODE S_IFIFO | S_IRUSR | S_IRGRP | S_IROTH
-#define SOCKET_MODE S_IFSOCK| S_IRWXU | S_IRWXG | S_IRWXO
-#define DIR_TEMP "testdir_1"
+#define DIR_TEMP "testdir_1"
+#define DIR_TEMP_MODE (S_IRUSR | S_IXUSR)
-void setup2(); /* setup function to test mknod for EACCES */
+#define FIFO_MODE (S_IFIFO | S_IRUSR | S_IRGRP | S_IROTH)
+#define SOCKET_MODE (S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO)
+#define CHR_MODE (S_IFCHR | S_IRUSR | S_IWUSR)
+#define BLK_MODE (S_IFBLK | S_IRUSR | S_IWUSR)
-struct test_case_t { /* test case struct. to hold ref. test cond's */
+static struct test_case_t {
char *pathname;
int mode;
int exp_errno;
- void (*setupfunc) (void);
} test_cases[] = {
- {
- "tnode_1", SOCKET_MODE, EACCES, NULL}, {
-"tnode_2", NEWMODE, EACCES, setup2},};
+ { "testdir_1/tnode_1", SOCKET_MODE, EACCES },
+ { "testdir_1/tnode_2", FIFO_MODE, EACCES },
+ { "tnode_3", CHR_MODE, EPERM },
+ { "tnode_4", BLK_MODE, EPERM },
+};
char *TCID = "mknod07";
-int TST_TOTAL = 2;
-int exp_enos[] = { EPERM, EACCES, 0 };
-
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+static int exp_enos[] = { EPERM, EACCES, 0 };
-void setup(); /* setup function for the tests */
-void cleanup(); /* cleanup function for the tests */
+static void setup(void);
+static void mknod_verify(const struct test_case_t *test_case);
+static void cleanup(void);
int main(int ac, char **av)
{
int lc;
char *msg;
- char *node_name; /* ptr. for node name created */
int i;
- int mode; /* creation mode for the node created */
- if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
+ msg = parse_opts(ac, av, NULL, NULL);
+ if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
- TEST_EXP_ENOS(exp_enos);
-
for (lc = 0; TEST_LOOPING(lc); lc++) {
-
tst_count = 0;
- for (i = 0; i < TST_TOTAL; i++) {
- node_name = test_cases[i].pathname;
- mode = test_cases[i].mode;
-
- TEST(mknod(node_name, mode, 0));
-
- if (TEST_RETURN != -1) {
- tst_resm(TFAIL, "mknod succeeded unexpectedly");
- continue;
- }
-
- if (TEST_ERRNO == test_cases[i].exp_errno)
- tst_resm(TPASS | TTERRNO,
- "mknod failed as expected");
- else
- tst_resm(TFAIL | TTERRNO,
- "mknod failed unexpectedly; expected: "
- "%d - %s", test_cases[i].exp_errno,
- strerror(test_cases[i].exp_errno));
- }
-
+ for (i = 0; i < TST_TOTAL; i++)
+ mknod_verify(&test_cases[i]);
}
cleanup();
tst_exit();
}
-void setup()
+static void setup(void)
{
- int i;
+ struct passwd *ltpuser;
tst_require_root(NULL);
tst_sig(NOFORK, DEF_HANDLER, cleanup);
- ltpuser = getpwnam(nobody_uid);
- if (ltpuser == NULL)
- tst_brkm(TBROK | TERRNO, NULL, "getpwnam failed");
- if (seteuid(ltpuser->pw_uid) == -1)
- tst_brkm(TBROK | TERRNO, NULL, "setuid failed");
-
- TEST_PAUSE;
+ TEST_EXP_ENOS(exp_enos);
tst_tmpdir();
- if (mkdir(DIR_TEMP, MODE_RWX) < 0)
- tst_brkm(TBROK | TERRNO, cleanup, "mkdir failed");
-
- if (chmod(DIR_TEMP, MODE_RWX) < 0)
- tst_brkm(TBROK | TERRNO, cleanup, "chmod failed");
+ TEST_PAUSE;
- if (chdir(DIR_TEMP) < 0)
- tst_brkm(TBROK | TERRNO, cleanup, "chdir failed");
+ ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
+ SAFE_SETEUID(cleanup, ltpuser->pw_uid);
- for (i = 0; i < TST_TOTAL; i++)
- if (test_cases[i].setupfunc != NULL)
- test_cases[i].setupfunc();
+ SAFE_MKDIR(cleanup, DIR_TEMP, DIR_TEMP_MODE);
}
-void setup2()
+static void mknod_verify(const struct test_case_t *test_case)
{
- if (chmod(".", NEWMODE) < 0)
- tst_brkm(TBROK, cleanup, "chmod failed");
+ TEST(mknod(test_case->pathname, test_case->mode, 0));
+
+ if (TEST_RETURN != -1) {
+ tst_resm(TFAIL, "mknod succeeded unexpectedly");
+ return;
+ }
+
+ if (TEST_ERRNO == test_case->exp_errno) {
+ tst_resm(TPASS | TTERRNO, "mknod failed as expected");
+ } else {
+ tst_resm(TFAIL | TTERRNO,
+ "mknod failed unexpectedly; expected: "
+ "%d - %s", test_case->exp_errno,
+ strerror(test_case->exp_errno));
+ }
}
-void cleanup()
+static void cleanup(void)
{
TEST_CLEANUP;
if (seteuid(0) == -1)
- tst_resm(TBROK, "seteuid(0) failed");
+ tst_resm(TWARN | TERRNO, "seteuid(0) failed");
tst_rmdir();
-
}
--
1.8.2.1
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread* [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests
2014-02-26 12:32 [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup Xiaoguang Wang
@ 2014-02-26 12:32 ` Xiaoguang Wang
2014-02-26 12:39 ` Xiaoguang Wang
2014-02-27 5:58 ` Wanlong Gao
2014-02-27 5:58 ` [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup Wanlong Gao
1 sibling, 2 replies; 5+ messages in thread
From: Xiaoguang Wang @ 2014-02-26 12:32 UTC (permalink / raw)
To: ltp-list
Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
runtest/ltplite | 2 +-
runtest/stress.part3 | 2 +-
runtest/syscalls | 2 +-
testcases/kernel/syscalls/mknod/mknod07.c | 64 ++++++++++++++++++++++++++++++-
4 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/runtest/ltplite b/runtest/ltplite
index 4bd1c53..f7127fe 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -431,7 +431,7 @@ mknod03 mknod03
mknod04 mknod04
mknod05 mknod05
mknod06 mknod06
-mknod07 mknod07
+mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
mknod08 mknod08
mknod09 mknod09
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index d631c19..2f31e93 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -364,7 +364,7 @@ mknod03 mknod03
mknod04 mknod04
mknod05 mknod05
mknod06 mknod06
-mknod07 mknod07
+mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
mknod08 mknod08
mknod09 mknod09
diff --git a/runtest/syscalls b/runtest/syscalls
index 49e3e79..f6b00d9 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -553,7 +553,7 @@ mknod03 mknod03
mknod04 mknod04
mknod05 mknod05
mknod06 mknod06
-mknod07 mknod07
+mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
mknod08 mknod08
mknod09 mknod09
diff --git a/testcases/kernel/syscalls/mknod/mknod07.c b/testcases/kernel/syscalls/mknod/mknod07.c
index ea17eef..8b4d494 100644
--- a/testcases/kernel/syscalls/mknod/mknod07.c
+++ b/testcases/kernel/syscalls/mknod/mknod07.c
@@ -26,6 +26,10 @@
* the caller is not super-user.
* 2) mknod(2) returns -1 and sets errno to EACCES if parent directory
* does not allow write permission to the process.
+ * 3) mknod(2) returns -1 and sets errno to EROFS if pathname refers to
+ * a file on a read-only file system.
+ * 4) mknod(2) returns -1 and sets errno to ELOOP if too many symbolic
+ * links were encountered in resolving pathname.
*
*/
@@ -38,6 +42,7 @@
#include <pwd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/mount.h>
#include "test.h"
#include "usctest.h"
@@ -45,12 +50,29 @@
#define DIR_TEMP "testdir_1"
#define DIR_TEMP_MODE (S_IRUSR | S_IXUSR)
+#define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
+ S_IXGRP|S_IROTH|S_IXOTH)
+#define MNT_POINT "mntpoint"
#define FIFO_MODE (S_IFIFO | S_IRUSR | S_IRGRP | S_IROTH)
#define SOCKET_MODE (S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO)
#define CHR_MODE (S_IFCHR | S_IRUSR | S_IWUSR)
#define BLK_MODE (S_IFBLK | S_IRUSR | S_IWUSR)
+#define ELOPFILE "/test_eloop"
+
+static char elooppathname[sizeof(ELOPFILE) * 43] = ".";
+
+static char *fstype = "ext2";
+static char *device;
+static int mount_flag;
+
+static option_t options[] = {
+ {"T:", NULL, &fstype},
+ {"D:", NULL, &device},
+ {NULL, NULL, NULL},
+};
+
static struct test_case_t {
char *pathname;
int mode;
@@ -60,15 +82,18 @@ static struct test_case_t {
{ "testdir_1/tnode_2", FIFO_MODE, EACCES },
{ "tnode_3", CHR_MODE, EPERM },
{ "tnode_4", BLK_MODE, EPERM },
+ { "mntpoint/tnode_5", SOCKET_MODE, EROFS },
+ { elooppathname, FIFO_MODE, ELOOP },
};
char *TCID = "mknod07";
int TST_TOTAL = ARRAY_SIZE(test_cases);
-static int exp_enos[] = { EPERM, EACCES, 0 };
+static int exp_enos[] = { EPERM, EACCES, EROFS, ELOOP, 0 };
static void setup(void);
static void mknod_verify(const struct test_case_t *test_case);
static void cleanup(void);
+static void help(void);
int main(int ac, char **av)
{
@@ -76,10 +101,15 @@ int main(int ac, char **av)
char *msg;
int i;
- msg = parse_opts(ac, av, NULL, NULL);
+ msg = parse_opts(ac, av, options, help);
if (msg != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ if (!device) {
+ tst_brkm(TBROK, NULL, "you must specify the device "
+ "used for mounting with -D option");
+ }
+
setup();
for (lc = 0; TEST_LOOPING(lc); lc++) {
@@ -95,10 +125,13 @@ int main(int ac, char **av)
static void setup(void)
{
+ int i;
struct passwd *ltpuser;
tst_require_root(NULL);
+ tst_mkfs(NULL, device, fstype, NULL);
+
tst_sig(NOFORK, DEF_HANDLER, cleanup);
TEST_EXP_ENOS(exp_enos);
@@ -107,10 +140,27 @@ static void setup(void)
TEST_PAUSE;
+ /* mount a read-only file system for EROFS test */
+ SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
+ if (mount(device, MNT_POINT, fstype, MS_RDONLY, NULL) < 0) {
+ tst_brkm(TBROK | TERRNO, cleanup,
+ "mount device:%s failed", device);
+ }
+ mount_flag = 1;
+
ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
SAFE_SETEUID(cleanup, ltpuser->pw_uid);
SAFE_MKDIR(cleanup, DIR_TEMP, DIR_TEMP_MODE);
+
+ /*
+ * NOTE: the ELOOP test is written based on that the consecutive
+ * symlinks limits in kernel is hardwired to 40.
+ */
+ SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
+ SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
+ for (i = 0; i < 43; i++)
+ strcat(elooppathname, ELOPFILE);
}
static void mknod_verify(const struct test_case_t *test_case)
@@ -139,5 +189,15 @@ static void cleanup(void)
if (seteuid(0) == -1)
tst_resm(TWARN | TERRNO, "seteuid(0) failed");
+ if (mount_flag && umount(MNT_POINT) < 0)
+ tst_resm(TWARN | TERRNO, "umount device:%s failed", device);
+
tst_rmdir();
}
+
+static void help(void)
+{
+ printf("-T type : specifies the type of filesystem to be mounted. "
+ "Default ext2.\n");
+ printf("-D device : device used for mounting.\n");
+}
--
1.8.2.1
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests
2014-02-26 12:32 ` [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests Xiaoguang Wang
@ 2014-02-26 12:39 ` Xiaoguang Wang
2014-02-27 5:58 ` Wanlong Gao
1 sibling, 0 replies; 5+ messages in thread
From: Xiaoguang Wang @ 2014-02-26 12:39 UTC (permalink / raw)
To: LTP
Hi,
Please review this patch, fix some issues Cyril pointed out in fchownat()'s patch.
Thanks,
Xiaoguang Wang
On 02/26/2014 08:32 PM, Xiaoguang Wang wrote:
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
> runtest/ltplite | 2 +-
> runtest/stress.part3 | 2 +-
> runtest/syscalls | 2 +-
> testcases/kernel/syscalls/mknod/mknod07.c | 64 ++++++++++++++++++++++++++++++-
> 4 files changed, 65 insertions(+), 5 deletions(-)
>
> diff --git a/runtest/ltplite b/runtest/ltplite
> index 4bd1c53..f7127fe 100644
> --- a/runtest/ltplite
> +++ b/runtest/ltplite
> @@ -431,7 +431,7 @@ mknod03 mknod03
> mknod04 mknod04
> mknod05 mknod05
> mknod06 mknod06
> -mknod07 mknod07
> +mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
> mknod08 mknod08
> mknod09 mknod09
>
> diff --git a/runtest/stress.part3 b/runtest/stress.part3
> index d631c19..2f31e93 100644
> --- a/runtest/stress.part3
> +++ b/runtest/stress.part3
> @@ -364,7 +364,7 @@ mknod03 mknod03
> mknod04 mknod04
> mknod05 mknod05
> mknod06 mknod06
> -mknod07 mknod07
> +mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
> mknod08 mknod08
> mknod09 mknod09
>
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 49e3e79..f6b00d9 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -553,7 +553,7 @@ mknod03 mknod03
> mknod04 mknod04
> mknod05 mknod05
> mknod06 mknod06
> -mknod07 mknod07
> +mknod07 mknod07 -D $LTP_DEV -T $LTP_DEV_FS_TYPE
> mknod08 mknod08
> mknod09 mknod09
>
> diff --git a/testcases/kernel/syscalls/mknod/mknod07.c b/testcases/kernel/syscalls/mknod/mknod07.c
> index ea17eef..8b4d494 100644
> --- a/testcases/kernel/syscalls/mknod/mknod07.c
> +++ b/testcases/kernel/syscalls/mknod/mknod07.c
> @@ -26,6 +26,10 @@
> * the caller is not super-user.
> * 2) mknod(2) returns -1 and sets errno to EACCES if parent directory
> * does not allow write permission to the process.
> + * 3) mknod(2) returns -1 and sets errno to EROFS if pathname refers to
> + * a file on a read-only file system.
> + * 4) mknod(2) returns -1 and sets errno to ELOOP if too many symbolic
> + * links were encountered in resolving pathname.
> *
> */
>
> @@ -38,6 +42,7 @@
> #include <pwd.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> +#include <sys/mount.h>
>
> #include "test.h"
> #include "usctest.h"
> @@ -45,12 +50,29 @@
>
> #define DIR_TEMP "testdir_1"
> #define DIR_TEMP_MODE (S_IRUSR | S_IXUSR)
> +#define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
> + S_IXGRP|S_IROTH|S_IXOTH)
> +#define MNT_POINT "mntpoint"
>
> #define FIFO_MODE (S_IFIFO | S_IRUSR | S_IRGRP | S_IROTH)
> #define SOCKET_MODE (S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO)
> #define CHR_MODE (S_IFCHR | S_IRUSR | S_IWUSR)
> #define BLK_MODE (S_IFBLK | S_IRUSR | S_IWUSR)
>
> +#define ELOPFILE "/test_eloop"
> +
> +static char elooppathname[sizeof(ELOPFILE) * 43] = ".";
> +
> +static char *fstype = "ext2";
> +static char *device;
> +static int mount_flag;
> +
> +static option_t options[] = {
> + {"T:", NULL, &fstype},
> + {"D:", NULL, &device},
> + {NULL, NULL, NULL},
> +};
> +
> static struct test_case_t {
> char *pathname;
> int mode;
> @@ -60,15 +82,18 @@ static struct test_case_t {
> { "testdir_1/tnode_2", FIFO_MODE, EACCES },
> { "tnode_3", CHR_MODE, EPERM },
> { "tnode_4", BLK_MODE, EPERM },
> + { "mntpoint/tnode_5", SOCKET_MODE, EROFS },
> + { elooppathname, FIFO_MODE, ELOOP },
> };
>
> char *TCID = "mknod07";
> int TST_TOTAL = ARRAY_SIZE(test_cases);
> -static int exp_enos[] = { EPERM, EACCES, 0 };
> +static int exp_enos[] = { EPERM, EACCES, EROFS, ELOOP, 0 };
>
> static void setup(void);
> static void mknod_verify(const struct test_case_t *test_case);
> static void cleanup(void);
> +static void help(void);
>
> int main(int ac, char **av)
> {
> @@ -76,10 +101,15 @@ int main(int ac, char **av)
> char *msg;
> int i;
>
> - msg = parse_opts(ac, av, NULL, NULL);
> + msg = parse_opts(ac, av, options, help);
> if (msg != NULL)
> tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
>
> + if (!device) {
> + tst_brkm(TBROK, NULL, "you must specify the device "
> + "used for mounting with -D option");
> + }
> +
> setup();
>
> for (lc = 0; TEST_LOOPING(lc); lc++) {
> @@ -95,10 +125,13 @@ int main(int ac, char **av)
>
> static void setup(void)
> {
> + int i;
> struct passwd *ltpuser;
>
> tst_require_root(NULL);
>
> + tst_mkfs(NULL, device, fstype, NULL);
> +
> tst_sig(NOFORK, DEF_HANDLER, cleanup);
>
> TEST_EXP_ENOS(exp_enos);
> @@ -107,10 +140,27 @@ static void setup(void)
>
> TEST_PAUSE;
>
> + /* mount a read-only file system for EROFS test */
> + SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
> + if (mount(device, MNT_POINT, fstype, MS_RDONLY, NULL) < 0) {
> + tst_brkm(TBROK | TERRNO, cleanup,
> + "mount device:%s failed", device);
> + }
> + mount_flag = 1;
> +
> ltpuser = SAFE_GETPWNAM(cleanup, "nobody");
> SAFE_SETEUID(cleanup, ltpuser->pw_uid);
>
> SAFE_MKDIR(cleanup, DIR_TEMP, DIR_TEMP_MODE);
> +
> + /*
> + * NOTE: the ELOOP test is written based on that the consecutive
> + * symlinks limits in kernel is hardwired to 40.
> + */
> + SAFE_MKDIR(cleanup, "test_eloop", DIR_MODE);
> + SAFE_SYMLINK(cleanup, "../test_eloop", "test_eloop/test_eloop");
> + for (i = 0; i < 43; i++)
> + strcat(elooppathname, ELOPFILE);
> }
>
> static void mknod_verify(const struct test_case_t *test_case)
> @@ -139,5 +189,15 @@ static void cleanup(void)
> if (seteuid(0) == -1)
> tst_resm(TWARN | TERRNO, "seteuid(0) failed");
>
> + if (mount_flag && umount(MNT_POINT) < 0)
> + tst_resm(TWARN | TERRNO, "umount device:%s failed", device);
> +
> tst_rmdir();
> }
> +
> +static void help(void)
> +{
> + printf("-T type : specifies the type of filesystem to be mounted. "
> + "Default ext2.\n");
> + printf("-D device : device used for mounting.\n");
> +}
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests
2014-02-26 12:32 ` [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests Xiaoguang Wang
2014-02-26 12:39 ` Xiaoguang Wang
@ 2014-02-27 5:58 ` Wanlong Gao
1 sibling, 0 replies; 5+ messages in thread
From: Wanlong Gao @ 2014-02-27 5:58 UTC (permalink / raw)
To: Xiaoguang Wang; +Cc: ltp-list
On 02/26/2014 08:32 PM, Xiaoguang Wang wrote:
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
> runtest/ltplite | 2 +-
> runtest/stress.part3 | 2 +-
> runtest/syscalls | 2 +-
> testcases/kernel/syscalls/mknod/mknod07.c | 64 ++++++++++++++++++++++++++++++-
> 4 files changed, 65 insertions(+), 5 deletions(-)
Applied, thank you.
Wanlong Gao
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup
2014-02-26 12:32 [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup Xiaoguang Wang
2014-02-26 12:32 ` [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests Xiaoguang Wang
@ 2014-02-27 5:58 ` Wanlong Gao
1 sibling, 0 replies; 5+ messages in thread
From: Wanlong Gao @ 2014-02-27 5:58 UTC (permalink / raw)
To: Xiaoguang Wang; +Cc: ltp-list
On 02/26/2014 08:32 PM, Xiaoguang Wang wrote:
> Delete some useless comment.
> Move the test body from main() to mknod_verify().
> Some cleanup.
>
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
> testcases/kernel/syscalls/mknod/mknod07.c | 160 ++++++++++--------------------
> 1 file changed, 50 insertions(+), 110 deletions(-)
Applied, thank you.
Wanlong Gao
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-02-27 5:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-26 12:32 [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup Xiaoguang Wang
2014-02-26 12:32 ` [LTP] [PATCH v3 2/2] mknod/mknod07.c: add EROFS and ELOOP error value tests Xiaoguang Wang
2014-02-26 12:39 ` Xiaoguang Wang
2014-02-27 5:58 ` Wanlong Gao
2014-02-27 5:58 ` [LTP] [PATCH v3 1/2] mknod/mknod07.c: cleanup Wanlong Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox