diff --git a/tests/commandtest.c b/tests/commandtest.c index c313a2cec3..509c888423 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -46,10 +46,6 @@ mymain(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) #else -static char *progname; -static char *abs_srcdir; - - static int checkoutput(const char *testname) { int ret = -1; @@ -754,23 +750,11 @@ cleanup: } static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; int fd; - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return(EXIT_FAILURE); - } - if (chdir("/tmp") < 0) return(EXIT_FAILURE); diff --git a/tests/cputest.c b/tests/cputest.c index bd06958a8a..a8d28dc595 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -1,7 +1,7 @@ /* * cputest.c: Test the libvirtd internal CPU APIs * - * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2010-2011 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -39,8 +39,6 @@ #include "cpu/cpu.h" #include "cpu/cpu_map.h" -static const char *progname; -static const char *abs_srcdir; static const char *abs_top_srcdir; #define VIR_FROM_THIS VIR_FROM_CPU @@ -494,23 +492,11 @@ static const char *nomodel[] = { "nomodel" }; static const char *models[] = { "qemu64", "core2duo", "Nehalem" }; static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; char map[PATH_MAX]; - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return EXIT_FAILURE; - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); - abs_top_srcdir = getenv("abs_top_srcdir"); if (!abs_top_srcdir) abs_top_srcdir = ".."; diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c index b6bf87bd05..830f79c861 100644 --- a/tests/esxutilstest.c +++ b/tests/esxutilstest.c @@ -14,9 +14,6 @@ # include "esx/esx_util.h" # include "esx/esx_vi_types.h" -static char *progname; - - static void testQuietError(void *userData ATTRIBUTE_UNUSED, @@ -323,22 +320,10 @@ testConvertWindows1252ToUTF8(const void *data ATTRIBUTE_UNUSED) static int -mymain(int argc, char **argv) +mymain(void) { int result = 0; - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return EXIT_FAILURE; - } - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return EXIT_FAILURE; - } - virSetErrorFunc(NULL, testQuietError); # define DO_TEST(_name) \ diff --git a/tests/eventtest.c b/tests/eventtest.c index eb4b7552a9..4c458602b5 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -259,20 +259,12 @@ resetAll(void) } static int -mymain(int argc, char **argv) +mymain(void) { - char *progname; int i; pthread_t eventThread; char one = '1'; - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return EXIT_FAILURE; - } - for (i = 0 ; i < NUM_FDS ; i++) { if (pipe(handles[i].pipeFD) < 0) { fprintf(stderr, "Cannot create pipe: %d", errno); @@ -483,5 +475,4 @@ mymain(int argc, char **argv) return EXIT_SUCCESS; } - VIRT_TEST_MAIN(mymain) diff --git a/tests/hashtest.c b/tests/hashtest.c index bb3a8128df..525ae06903 100644 --- a/tests/hashtest.c +++ b/tests/hashtest.c @@ -476,8 +476,7 @@ cleanup: static int -mymain(int argc ATTRIBUTE_UNUSED, - char **argv ATTRIBUTE_UNUSED) +mymain(void) { int ret = 0; diff --git a/tests/interfacexml2xmltest.c b/tests/interfacexml2xmltest.c index 094ccf511a..fb454c1d9a 100644 --- a/tests/interfacexml2xmltest.c +++ b/tests/interfacexml2xmltest.c @@ -13,9 +13,6 @@ #include "interface_conf.h" #include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; - #define MAX_FILE 4096 @@ -57,21 +54,9 @@ static int testCompareXMLToXMLHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); #define DO_TEST(name) \ if (virtTestRun("Interface XML-2-XML " name, \ diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index 7805548630..f7489f5dbd 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -13,9 +13,6 @@ #include "network_conf.h" #include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; - #define MAX_FILE 4096 @@ -64,21 +61,9 @@ static int testCompareXMLToXMLHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); #define DO_TEST(name) \ if (virtTestRun("Network XML-2-XML " name, \ diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index 2bc67436ba..f6a1335a59 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -13,9 +13,6 @@ #include "node_device_conf.h" #include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; - #define MAX_FILE 4096 @@ -57,21 +54,9 @@ static int testCompareXMLToXMLHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); #define DO_TEST(name) \ if (virtTestRun("Node device XML-2-XML " name, \ diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c index c690403503..9a87dc09cb 100644 --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -21,9 +21,6 @@ mymain(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) #else -static char *progname; -static char *abs_srcdir; - # define MAX_FILE 4096 extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo, virNodeInfoPtr nodeinfo, @@ -89,7 +86,7 @@ static int linuxTestNodeInfo(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; int i; @@ -101,18 +98,6 @@ mymain(int argc, char **argv) "nodeinfo-5", "nodeinfo-6", }; - char cwd[PATH_MAX]; - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return(EXIT_FAILURE); - } if (virInitialize() < 0) return EXIT_FAILURE; diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c index 575177af89..a1f57fab57 100644 --- a/tests/nwfilterxml2xmltest.c +++ b/tests/nwfilterxml2xmltest.c @@ -16,9 +16,6 @@ #include "nwfilter_conf.h" #include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; - #define MAX_FILE 4096 @@ -85,21 +82,9 @@ static int testCompareXMLToXMLHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); #define DO_TEST(NAME, EXPECT_WARN) \ do { \ diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 0214db0986..60dce460f5 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -16,8 +16,6 @@ # include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; static struct qemud_driver driver; # define MAX_FILE 4096 @@ -103,21 +101,9 @@ static int testCompareXMLToArgvHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index c86c5782c5..792b5ab7f7 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -19,9 +19,6 @@ struct testInfo { unsigned int kvm_version; }; -static char *progname; -static char *abs_srcdir; - static void printMismatchedFlags(virBitmapPtr got, virBitmapPtr expect) { @@ -121,21 +118,9 @@ cleanup: } static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); # define DO_TEST(name, version, is_kvm, kvm_version, ...) \ do { \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index c06bdf6c90..ebde3a1b8d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -19,8 +19,6 @@ # include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; static const char *abs_top_srcdir; static struct qemud_driver driver; @@ -190,23 +188,11 @@ static int testCompareXMLToArgvHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; char map[PATH_MAX]; - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); - abs_top_srcdir = getenv("abs_top_srcdir"); if (!abs_top_srcdir) abs_top_srcdir = ".."; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 27330a97bc..6f51d1e065 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -15,8 +15,6 @@ # include "qemu/qemu_conf.h" # include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; static struct qemud_driver driver; # define MAX_FILE 4096 @@ -83,21 +81,9 @@ static int testCompareXMLToXMLHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); if ((driver.caps = testQemuCapsInit()) == NULL) return (EXIT_FAILURE); diff --git a/tests/qparamtest.c b/tests/qparamtest.c index a4ed1fb8a2..6dfac43615 100644 --- a/tests/qparamtest.c +++ b/tests/qparamtest.c @@ -183,8 +183,7 @@ static const struct qparamParseDataEntry params5[] = { { "foo", "one two" } }; static const struct qparamParseDataEntry params6[] = { { "foo", "one" } }; static int -mymain(int argc ATTRIBUTE_UNUSED, - char **argv ATTRIBUTE_UNUSED) +mymain(void) { int ret = 0; diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index 9f74ece1b3..091943553e 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -13,8 +13,6 @@ #include "testutils.h" #include "testutilsxen.h" -static char *progname; -static char *abs_srcdir; static virCapsPtr caps; #define MAX_FILE 4096 @@ -99,26 +97,9 @@ static int testCompareHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return(EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return(EXIT_FAILURE); - } if (!(caps = testXenCapsInit())) return(EXIT_FAILURE); diff --git a/tests/sockettest.c b/tests/sockettest.c index 2c9ff03d92..b9e37ab407 100644 --- a/tests/sockettest.c +++ b/tests/sockettest.c @@ -1,7 +1,7 @@ /* * sockettest.c: Testing for src/util/network.c APIs * - * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2010-2011 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -159,8 +159,7 @@ static int testNetmaskHelper(const void *opaque) static int -mymain(int argc ATTRIBUTE_UNUSED, - char **argv ATTRIBUTE_UNUSED) +mymain(void) { int ret = 0; /* Some of our tests deliberately test failure cases, so diff --git a/tests/statstest.c b/tests/statstest.c index 36cbea4ff3..d18bb0c06d 100644 --- a/tests/statstest.c +++ b/tests/statstest.c @@ -41,8 +41,7 @@ static int testDeviceHelper(const void *data) } static int -mymain(int argc ATTRIBUTE_UNUSED, - char **argv ATTRIBUTE_UNUSED) +mymain(void) { int ret = 0; /* Some of our tests delibrately test failure cases, so diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 2ec29e3260..6641153f51 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -13,9 +13,6 @@ #include "storage_conf.h" #include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; - #define MAX_FILE 4096 @@ -64,21 +61,9 @@ static int testCompareXMLToXMLHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); #define DO_TEST(name) \ if (virtTestRun("Storage Pool XML-2-XML " name, \ diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c index ffa5dfef38..0cd57af26f 100644 --- a/tests/storagevolxml2xmltest.c +++ b/tests/storagevolxml2xmltest.c @@ -13,9 +13,6 @@ #include "storage_conf.h" #include "testutilsqemu.h" -static char *progname; -static char *abs_srcdir; - #define MAX_FILE 4096 @@ -85,21 +82,9 @@ static int testCompareXMLToXMLHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return (EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); #define DO_TEST(pool, name) \ do { \ diff --git a/tests/testutils.c b/tests/testutils.c index 1f3b5693d4..456a73540a 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -55,6 +55,9 @@ static unsigned int testVerbose = -1; static unsigned int testOOM = 0; static unsigned int testCounter = 0; +char *progname; +char *abs_srcdir; + double virtTestCountAverage(double *items, int nitems) { @@ -472,9 +475,10 @@ virTestGetVerbose(void) { int virtTestMain(int argc, char **argv, - int (*func)(int, char **)) + int (*func)(void)) { int ret; + char cwd[PATH_MAX]; #if TEST_OOM int approxAlloc = 0; int n; @@ -485,7 +489,20 @@ int virtTestMain(int argc, int worker = 0; #endif - fprintf(stderr, "TEST: %s\n", STRPREFIX(argv[0], "./") ? argv[0] + 2 : argv[0]); + abs_srcdir = getenv("abs_srcdir"); + if (!abs_srcdir) + abs_srcdir = getcwd(cwd, sizeof(cwd)); + if (!abs_srcdir) + exit(EXIT_AM_HARDFAIL); + + progname = argv[0]; + if (STRPREFIX(progname, "./")) + progname += 2; + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", argv[0]); + return EXIT_FAILURE; + } + fprintf(stderr, "TEST: %s\n", progname); if (!virTestGetVerbose()) fprintf(stderr, " "); @@ -520,7 +537,7 @@ int virtTestMain(int argc, } /* Run once to prime any static allocations & ensure it passes */ - ret = (func)(argc, argv); + ret = (func)(); if (ret != EXIT_SUCCESS) goto cleanup; @@ -537,7 +554,7 @@ int virtTestMain(int argc, virAllocTestInit(); /* Run again to count allocs, and ensure it passes :-) */ - ret = (func)(argc, argv); + ret = (func)(); if (ret != EXIT_SUCCESS) goto cleanup; @@ -574,7 +591,7 @@ int virtTestMain(int argc, } virAllocTestOOM(n+1, oomCount); - if (((func)(argc, argv)) != EXIT_FAILURE) { + if (((func)()) != EXIT_FAILURE) { ret = EXIT_FAILURE; break; } @@ -604,7 +621,7 @@ int virtTestMain(int argc, } cleanup: #else - ret = (func)(argc, argv); + ret = (func)(); #endif virResetLastError(); diff --git a/tests/testutils.h b/tests/testutils.h index 88603a1f0b..0ea70ee82b 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -1,7 +1,7 @@ /* * utils.c: test utils * - * Copyright (C) 2005, 2008-2010 Red Hat, Inc. + * Copyright (C) 2005, 2008-2011 Red Hat, Inc. * * See COPYING.LIB for the License of this software * @@ -14,6 +14,10 @@ # include # define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */ +# define EXIT_AM_HARDFAIL 99 /* tell Automake that the framework is broken */ + +extern char *progname; +extern char *abs_srcdir; double virtTestCountAverage(double *items, int nitems); @@ -44,11 +48,12 @@ char *virtTestLogContentAndReset(void); int virtTestMain(int argc, char **argv, - int (*func)(int, char **)); + int (*func)(void)); -# define VIRT_TEST_MAIN(func) \ - int main(int argc, char **argv) { \ - return virtTestMain(argc,argv, func); \ +/* Setup, then call func() */ +# define VIRT_TEST_MAIN(func) \ + int main(int argc, char **argv) { \ + return virtTestMain(argc, argv, func); \ } #endif /* __VIT_TEST_UTILS_H__ */ diff --git a/tests/virbuftest.c b/tests/virbuftest.c index db08fc462a..0094a16eca 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -64,8 +64,7 @@ out: } static int -mymain(int argc ATTRIBUTE_UNUSED, - char **argv ATTRIBUTE_UNUSED) +mymain(void) { int ret = 0; diff --git a/tests/virshtest.c b/tests/virshtest.c index 8ec97a84e9..465d5eac52 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -8,8 +8,6 @@ #include "xml.h" #include "testutils.h" -static char *progname; -static char *abs_srcdir; #define MAX_FILE 4096 #define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493" @@ -232,30 +230,20 @@ static int testCompareEcho(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; char buffer[PATH_MAX]; - char cwd[PATH_MAX]; - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); #ifdef WIN32 exit (EXIT_AM_SKIP); #endif - snprintf(buffer, PATH_MAX-1, "test://%s/../examples/xml/test/testnode.xml", abs_srcdir); + snprintf(buffer, PATH_MAX-1, + "test://%s/../examples/xml/test/testnode.xml", abs_srcdir); buffer[PATH_MAX-1] = '\0'; - progname = argv[0]; custom_uri = buffer; - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return(EXIT_FAILURE); - } - if (virtTestRun("virsh list (default)", 1, testCompareListDefault, NULL) != 0) ret = -1; diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 5fed1c4b58..3b7e9be7c4 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -11,8 +11,6 @@ # include "testutils.h" # include "vmx/vmx.h" -static char *progname = NULL; -static char *abs_srcdir = NULL; static virCapsPtr caps = NULL; static virVMXContext ctx; @@ -181,28 +179,9 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED) } static int -mymain(int argc, char **argv) +mymain(void) { int result = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return EXIT_FAILURE; - } - - abs_srcdir = getenv("abs_srcdir"); - - if (abs_srcdir == NULL) { - abs_srcdir = getcwd(cwd, sizeof(cwd)); - } - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return EXIT_FAILURE; - } # define DO_TEST(_in, _out) \ do { \ diff --git a/tests/xencapstest.c b/tests/xencapstest.c index 7b4881252c..36946cf10c 100644 --- a/tests/xencapstest.c +++ b/tests/xencapstest.c @@ -11,9 +11,6 @@ #include "xen/xen_hypervisor.h" #include "files.h" -static char *progname; -static char *abs_srcdir; - #define MAX_FILE 4096 static int testCompareFiles(const char *hostmachine, @@ -151,21 +148,9 @@ static int testXenppc64(const void *data ATTRIBUTE_UNUSED) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return(EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); virInitialize(); diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 7d418a50a9..62d34880c8 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -1,7 +1,7 @@ /* * xmconfigtest.c: Test backend for xm_internal config file handling * - * Copyright (C) 2007, 2010 Red Hat, Inc. + * Copyright (C) 2007, 2010-2011 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -36,8 +36,6 @@ #include "testutilsxen.h" #include "memory.h" -static char *progname; -static char *abs_srcdir; static virCapsPtr caps; #define MAX_FILE 4096 @@ -174,21 +172,9 @@ static int testCompareHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return(EXIT_FAILURE); - } - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); if (!(caps = testXenCapsInit())) return(EXIT_FAILURE); diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index cf530b68d9..b258c3d58d 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -14,8 +14,6 @@ #include "testutils.h" #include "testutilsxen.h" -static char *progname; -static char *abs_srcdir; static virCapsPtr caps; #define MAX_FILE 4096 @@ -77,21 +75,9 @@ static int testCompareHelper(const void *data) { static int -mymain(int argc, char **argv) +mymain(void) { int ret = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - abs_srcdir = getenv("abs_srcdir"); - if (!abs_srcdir) - abs_srcdir = getcwd(cwd, sizeof(cwd)); - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return(EXIT_FAILURE); - } #define DO_TEST(in, out, name, version) \ do { \ diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index a5fb4f7e62..6a4b795d1d 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -11,8 +11,6 @@ # include "testutils.h" # include "vmx/vmx.h" -static char *progname = NULL; -static char *abs_srcdir = NULL; static virCapsPtr caps = NULL; static virVMXContext ctx; @@ -198,28 +196,9 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED) } static int -mymain(int argc, char **argv) +mymain(void) { int result = 0; - char cwd[PATH_MAX]; - - progname = argv[0]; - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return EXIT_FAILURE; - } - - abs_srcdir = getenv("abs_srcdir"); - - if (abs_srcdir == NULL) { - abs_srcdir = getcwd(cwd, sizeof(cwd)); - } - - if (argc > 1) { - fprintf(stderr, "Usage: %s\n", progname); - return EXIT_FAILURE; - } # define DO_TEST(_in, _out, _version) \ do { \