From: Artem Bityutskiy <dedekind1@gmail.com>
To: MTD list <linux-mtd@lists.infradead.org>
Cc: Adrian Hunter <adrian.hunter@nokia.com>
Subject: [PATCH 17/27] fs-tests: integck: clean up test directory creation
Date: Wed, 13 Apr 2011 18:18:57 +0300 [thread overview]
Message-ID: <1302707947-6143-18-git-send-email-dedekind1@gmail.com> (raw)
In-Reply-To: <1302707947-6143-1-git-send-email-dedekind1@gmail.com>
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Move the test directory name to the fsinfo structure and do few
other cleanups while on it.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
tests/fs-tests/integrity/integck.c | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
index c21b488..ed02b56 100644
--- a/tests/fs-tests/integrity/integck.c
+++ b/tests/fs-tests/integrity/integck.c
@@ -44,6 +44,9 @@
#define MAX_RANDOM_SEED 10000000
+/* The pattern for the top directory where we run the test */
+#define TEST_DIR_PATTERN "integck_test_dir_%u"
+
/* The variables below are set by command line arguments */
static struct {
long repeat_cnt;
@@ -64,6 +67,7 @@ static struct {
* can_mmap: file-system supports share writable 'mmap()' operation
* fstype: file-system type (e.g., "ubifs")
* mount_point: tested file-system mount point path
+ * test_dir: the directory on the tested file-system where we test
*/
static struct {
int max_name_len;
@@ -73,6 +77,7 @@ static struct {
unsigned int can_mmap:1;
const char *fstype;
const char *mount_point;
+ const char *test_dir;
} fsinfo = {
.nospc_size_ok = 1,
.can_mmap = 1,
@@ -1970,27 +1975,21 @@ static void update_test_data(void)
static int integck(void)
{
- unsigned int pid;
int64_t rpt;
- char dir_name[256];
/* Make our top directory */
- pid = getpid();
- normsg("pid is %u", pid);
- CHECK(sprintf(dir_name, "integck_test_dir_%u", pid) > 0);
- if (chdir(dir_name) != -1) {
+ if (chdir(fsinfo.test_dir) != -1) {
/* Remove it if it is already there */
tests_clear_dir(".");
CHECK(chdir("..") != -1);
- CHECK(rmdir(dir_name) != -1);
+ CHECK(rmdir(fsinfo.test_dir) != -1);
}
- top_dir = dir_new(NULL, dir_name);
+ top_dir = dir_new(NULL, fsinfo.test_dir);
if (!top_dir)
return -1;
- srand(pid);
-
+ srand(getpid());
create_test_data();
if (!tests_fs_is_rootfs()) {
@@ -2019,8 +2018,8 @@ static int integck(void)
/* Tidy up by removing everything */
close_open_files();
- tests_clear_dir(dir_name);
- CHECK(rmdir(dir_name) != -1);
+ tests_clear_dir(fsinfo.test_dir);
+ CHECK(rmdir(fsinfo.test_dir) != -1);
return 0;
}
@@ -2036,6 +2035,7 @@ static void get_tested_fs_info(void)
FILE *f;
uint64_t z;
char *p;
+ unsigned int pid;
/* Remove trailing '/' symbols from the mount point */
p = dup_string(args.mount_point);
@@ -2084,6 +2084,16 @@ static void get_tested_fs_info(void)
for (z = get_free_space(); z >= 10; z /= 10)
fsinfo.log10_initial_free += 1;
+
+ /* Pick the test directory name */
+ p = malloc(sizeof(TEST_DIR_PATTERN) + 20);
+ CHECK(p != NULL);
+ pid = getpid();
+ CHECK(sprintf(p, "integck_test_dir_%u", pid) > 0);
+ fsinfo.test_dir = p;
+
+ normsg("pid %u, testing \"%s\" at \"%s\"",
+ pid, fsinfo.fstype, fsinfo.mount_point);
}
static const char doc[] = PROGRAM_NAME " version " PROGRAM_VERSION
--
1.7.2.3
next prev parent reply other threads:[~2011-04-13 15:16 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-13 15:18 [PATCH 00/27] mtd-utils: make integck test independent Artem Bityutskiy
2011-04-13 15:16 ` Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 01/27] fs-tests: integck: shrink dir_entry_info structure size Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 02/27] fs-tests: integck: shrink file_info " Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 03/27] fs-tests: integck: srink file_info structure even more Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 04/27] fs-tests: integck: abuse random_offset field nicer Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 05/27] fs-tests: integck: shrink write_info even more Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 06/27] fs-tests: integck: change tests defaults Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 07/27] fs-tests: integck: implement own parameters parsing Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 08/27] fs-tests: integck: clean-up copy_string Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 09/27] fs-tests: integck: get rid of tests_check_test_file_system Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 10/27] fs-tests: integck: make integck function return error Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 11/27] fs-tests: integck: move mem_page_size to fsinfo Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 12/27] fs-tests: integck: move more variables " Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 13/27] fs-tests: integck: add own get_free_space function Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 14/27] fs-tests: integck: move log10_initial_free to fsinfo Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 15/27] fs-tests: integck: remove trailing backslashes from mount point Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 16/27] fs-tests: integck: do not use tests_cat_pid Artem Bityutskiy
2011-04-13 15:18 ` Artem Bityutskiy [this message]
2011-04-13 15:18 ` [PATCH 18/27] fs-tests: integck: do not use tests_clear_dir Artem Bityutskiy
2011-04-13 15:18 ` [PATCH 19/27] fs-tests: integck: do not use space after cast Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 20/27] fs-tests: integck: prefer to check for success Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 21/27] fs-tests: integck: do not use tests_fs_is_rootfs Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 22/27] fs-tests: integck: do not use tests_remount Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 23/27] fs-tests: integck: do not use tests_get_total_space Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 24/27] fs-tests: integck: do not use global common variables Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 25/27] fs-tests: integck: do not use tests_random_no Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 26/27] fs-tests: integck: implement own version of CHECK Artem Bityutskiy
2011-04-13 15:19 ` [PATCH 27/27] fs-tests: integck: do not expect max name length to be 256 Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1302707947-6143-18-git-send-email-dedekind1@gmail.com \
--to=dedekind1@gmail.com \
--cc=adrian.hunter@nokia.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.