From: ira.weiny@intel.com
To: fstests@vger.kernel.org, Eryu Guan <guaneryu@gmail.com>
Cc: john.hubbard@gmail.com, Dave Chinner <david@fromorbit.com>,
Jan Kara <jack@suse.cz>, Jason Gunthorpe <jgg@ziepe.ca>,
dan.j.williams@intel.com, Jeff Layton <jlayton@kernel.org>,
Ira Weiny <ira.weiny@intel.com>
Subject: [PATCH V2 11/16] src/locktest: Add run() function
Date: Mon, 23 Sep 2019 10:51:59 -0700 [thread overview]
Message-ID: <20190923175204.2139-12-ira.weiny@intel.com> (raw)
In-Reply-To: <20190923175204.2139-1-ira.weiny@intel.com>
From: Ira Weiny <ira.weiny@intel.com>
Separate the functionality of main() into socket set up and run(). Pass
the test information to run() rather than have it be gloabal. This is
in preparation for adding a separate lease test array.
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Changes from V1:
New patch for this series
src/locktest.c | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/locktest.c b/src/locktest.c
index 3dc74947f100..076781badaa1 100644
--- a/src/locktest.c
+++ b/src/locktest.c
@@ -146,7 +146,7 @@ static char *get_cmd_str(int cmd)
* (or vice versa)
*/
-char *descriptions[] = {
+char *lock_descriptions[] = {
/* 1 */"Add a lock to an empty lock list",
/* 2 */"Add a lock to the start and end of a list - no overlaps",
/* 3 */"Add a lock to the middle of a list - no overlap",
@@ -183,7 +183,7 @@ char *descriptions[] = {
#endif
};
-static int64_t tests[][6] =
+static int64_t lock_tests[][6] =
/* test # Action [offset|flags] length expected server/client */
{
/* Various simple tests exercising the list */
@@ -673,7 +673,7 @@ int do_close(void)
return PASS;
}
-static void init_ctl(int32_t index)
+static void init_ctl(int64_t tests[][6], int32_t index)
{
ctl.test= (int32_t)tests[index][TEST_NUM];
ctl.command = (int32_t)tests[index][COMMAND];
@@ -765,6 +765,9 @@ cleanup(void)
PLATFORM_CLEANUP();
}
+int
+run(int64_t tests[][6], char *descriptions[]);
+
int
main(int argc, char *argv[])
{
@@ -778,7 +781,7 @@ main(int argc, char *argv[])
char *p;
extern char *optarg;
extern int optind;
- int fail_count = 0;;
+ int fail_count = 0;
atexit(cleanup);
@@ -962,7 +965,13 @@ main(int argc, char *argv[])
*
* real work is in here ...
*/
- i = 0;
+ fail_count = run(lock_tests, lock_descriptions);
+
+ exit(fail_count);
+ /*NOTREACHED*/
+}
+
+int run(int64_t tests[][6], char *descriptions[])
{
int index = 0;
int end = 0;
@@ -970,6 +979,7 @@ main(int argc, char *argv[])
int last_test = 0;
int test_count = -1;
int fail_flag = 0;
+ int fail_count = 0;
while(!end) {
if (server) {
if(testnumber > 0) {
@@ -1033,7 +1043,7 @@ main(int argc, char *argv[])
end=1;
}
/* get the client to do something */
- init_ctl(index);
+ init_ctl(tests, index);
if(debug)
fprintf(stderr, "Sending command to client (%d) - %s - %lld:%lld\n",
index,
@@ -1134,10 +1144,6 @@ main(int argc, char *argv[])
}
}
fprintf(stderr, "%d tests run, %d failed\n", test_count, fail_count);
-}
-
- exit(fail_count);
- /*NOTREACHED*/
-}
-
+ return fail_count;
+}
--
2.20.1
next prev parent reply other threads:[~2019-09-23 17:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-23 17:51 [PATCH V2 00/16] Fix locktest and add lease testing to it ira.weiny
2019-09-23 17:51 ` [PATCH V2 01/16] src/locktest: Remove unnecessary sleep ira.weiny
2019-09-23 17:51 ` [PATCH V2 02/16] src/locktest: Remove OPEN macro ira.weiny
2019-09-23 17:51 ` [PATCH V2 03/16] src/locktest: Change command macro names ira.weiny
2019-09-23 17:51 ` [PATCH V2 04/16] src/locktest: Add get_cmd_str ira.weiny
2019-09-23 17:51 ` [PATCH V2 05/16] src/locktest.c: Clean up client command passing ira.weiny
2019-09-23 17:51 ` [PATCH V2 06/16] src/locktest.c: Fix return code if last test fails ira.weiny
2019-09-23 17:51 ` [PATCH V2 07/16] generic/131: Clean up pid variables ira.weiny
2019-09-23 17:51 ` [PATCH V2 08/16] generic/131: Save stderr for debugging ira.weiny
2019-09-23 17:51 ` [PATCH V2 09/16] src/locktest: Clean up error output ira.weiny
2019-09-23 17:51 ` [PATCH V2 10/16] src/locktest: Audit all debug output ira.weiny
2019-09-23 17:51 ` ira.weiny [this message]
2019-09-23 17:58 ` [PATCH V2 00/16] Fix locktest and add lease testing to it Ira Weiny
-- strict thread matches above, loose matches on Subject: below --
2019-09-23 17:53 ira.weiny
2019-09-23 17:53 ` [PATCH V2 11/16] src/locktest: Add run() function ira.weiny
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=20190923175204.2139-12-ira.weiny@intel.com \
--to=ira.weiny@intel.com \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=guaneryu@gmail.com \
--cc=jack@suse.cz \
--cc=jgg@ziepe.ca \
--cc=jlayton@kernel.org \
--cc=john.hubbard@gmail.com \
/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.