From 1a657f4a74cce1b30301b9b7ab5c128a03a49f57 Mon Sep 17 00:00:00 2001 From: pjkirner Date: Thu, 20 Oct 2005 02:13:54 +0000 Subject: [PATCH] * Added command line support for liblustre echo_test * Added "hack" to allow echo_test to build on Catamount --- lustre/liblustre/tests/echo_test.c | 67 +++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/lustre/liblustre/tests/echo_test.c b/lustre/liblustre/tests/echo_test.c index 2f4e093..f1da0f5 100644 --- a/lustre/liblustre/tests/echo_test.c +++ b/lustre/liblustre/tests/echo_test.c @@ -31,6 +31,35 @@ #include "../lutil.h" + +#ifdef CRAY_XT3 +int _sysio_lustre_init(void) +{ + /* + * This is an aweful HACK. Basically the problem is on + * Catamount, the build system links in liblustre.a to + * all the test executables, and at this point its not + * clear how to modify the build system to prevent this + * from happening. So providing our own call to + * _sysio_lustre_init() that does nothing, prevents + * liblustre.a from initializing. + * + * Why is liblustre.a initializing a problem anyway. Well + * this main() in this module calls init_obdclass(), as + * well as the llite_lib.c's _sysio_lustre_init(). Two + * calls to init_obdclass() cause an assertion. Secondly + * it doesn't even logically make sense, this is module + * does not need lustre file system functionality, it's + * just the echo_tester. + * + */ + /*lprintf("--> THIS OVERRIDES liblustre.a INITIALIZATION <--\n");*/ + return 0; +} +#endif + + + extern int class_handle_ioctl(unsigned int cmd, unsigned long arg); static int liblustre_ioctl(int dev_id, unsigned int opc, void *ptr) @@ -191,9 +220,11 @@ static int disconnect_echo_client(void) static void usage(const char *s) { - printf("Usage: %s -s ost_host_name [-n ost_name]\n", s); + printf("Usage: %s -s ost_host_name [-n ost_name] [-x lctl_options ...]\n", s); printf(" ost_host_name: the host name of echo server\n"); printf(" ost_name: ost name, default is \"obd1\"\n"); + printf(" lctl_options: options to pass to lctl.\n"); + printf(" (e.g. -x --device 1 test_getattr 10000 -5)\n"); } extern int time_ptlwait1; @@ -203,8 +234,13 @@ extern int time_ptlselect; int main(int argc, char **argv) { int c, rc; + int xindex = -1; /* index of -x option */ - while ((c = getopt(argc, argv, "s:n:")) != -1) { + /* loop until all options are consumed or we hit + * a -x option + */ + while ((c = getopt(argc, argv, "s:n:x:")) != -1 && + xindex == -1) { switch (c) { case 's': echo_server_nid = optarg; @@ -212,13 +248,20 @@ int main(int argc, char **argv) case 'n': echo_server_ostname = optarg; break; + case 'x': + xindex = optind-1; + break; default: usage(argv[0]); return 1; } } - if (optind != argc) + /* + * Only warn with usage() if the -x option isn't specificed + * because when using -x this check is not valid. + */ + if (optind != argc && xindex == -1) usage(argv[0]); if (!echo_server_nid) { @@ -231,7 +274,7 @@ int main(int argc, char **argv) liblustre_init_random(); - if (liblustre_init_current(argv[0]) || + if (liblustre_init_current(argv[0]) || init_obdclass() || init_lib_portals() || ptlrpc_init() || mdc_init() || @@ -248,7 +291,21 @@ int main(int argc, char **argv) set_ioc_handler(liblustre_ioctl); - rc = lctl_main(1, &argv[0]); + + /* + * If the -x option is not specified pass no args to lctl + * otherwise pass all the options after the "-x" to lctl + * + * HACK: in the case when the -x option is specified + * lctl sees argv[0] == "-x" and not the real argv[0] seen + * in this function. If that is a problem, a mapping will + * have to be done to fix that. However for normal functioning + * it seems to be irrelavant + */ + if( xindex == -1 ) + rc = lctl_main(1, &argv[0]); + else + rc = lctl_main(argc-xindex+1, &argv[xindex-1]); rc |= disconnect_echo_client(); -- 1.8.3.1