]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
add modes argument to lxc-test-concurrent
authorDwight Engen <dwight.engen@oracle.com>
Fri, 8 Nov 2013 19:00:40 +0000 (14:00 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 8 Nov 2013 21:07:34 +0000 (15:07 -0600)
- This allows testing independently the modes with/without threading

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/tests/concurrent.c

index 16e93d65623e922dcc429a11bcc44a3473f3af91..76fae875822ade3f7fc82a7fec6d03f63a56f039 100644 (file)
@@ -36,6 +36,7 @@ static struct option options[] = {
     { "iterations",  required_argument, NULL, 'i' },
     { "template",    required_argument, NULL, 't' },
     { "delay",       required_argument, NULL, 'd' },
+    { "modes",       required_argument, NULL, 'm' },
     { "quiet",       no_argument,       NULL, 'q' },
     { "help",        no_argument,       NULL, '?' },
     { 0, 0, 0, 0 },
@@ -44,13 +45,14 @@ static struct option options[] = {
 static void usage(void) {
     fprintf(stderr, "Usage: lxc-test-concurrent [OPTION]...\n\n"
         "Common options :\n"
-        "  -j, --threads=N      Threads to run concurrently\n"
-        "                       (default: 5, use 1 for no threading)\n"
-        "  -i, --iterations=N   Number times to run the test (default: 1)\n"
-        "  -t, --template=t     Template to use (default: busybox)\n"
-        "  -d, --delay=N        Delay in seconds between start and stop\n"
-        "  -q, --quiet          Don't produce any output\n"
-        "  -?, --help           Give this help list\n"
+        "  -j, --threads=N              Threads to run concurrently\n"
+        "                               (default: 5, use 1 for no threading)\n"
+        "  -i, --iterations=N           Number times to run the test (default: 1)\n"
+        "  -t, --template=t             Template to use (default: busybox)\n"
+        "  -d, --delay=N                Delay in seconds between start and stop\n"
+        "  -m, --modes=<mode,mode,...>  Modes to run (create, start, stop, destroy)\n"
+        "  -q, --quiet                  Don't produce any output\n"
+        "  -?, --help                   Give this help list\n"
         "\n"
         "Mandatory or optional arguments to long options are also mandatory or optional\n"
         "for any corresponding short options.\n\n");
@@ -135,11 +137,12 @@ int main(int argc, char *argv[]) {
     pthread_t *threads;
     struct thread_args *args;
 
-    char *modes[] = {"create", "start", "stop", "destroy", NULL};
+    char *modes_default[] = {"create", "start", "stop", "destroy", NULL};
+    char **modes = modes_default;
 
     pthread_attr_init(&attr);
 
-    while ((opt = getopt_long(argc, argv, "j:i:t:d:q", options, NULL)) != -1) {
+    while ((opt = getopt_long(argc, argv, "j:i:t:d:m:q", options, NULL)) != -1) {
         switch(opt) {
         case 'j':
             nthreads = atoi(optarg);
@@ -156,6 +159,19 @@ int main(int argc, char *argv[]) {
         case 'q':
             quiet = 1;
             break;
+        case 'm': {
+            char *mode_tok, *tok, *saveptr;
+
+            modes = NULL;
+            for (i = 0, mode_tok = optarg;
+                 (tok = strtok_r(mode_tok, ",", &saveptr));
+                i++, mode_tok = NULL) {
+                modes = realloc(modes, sizeof(*modes) * (i+2));
+                modes[i] = tok;
+           }
+            modes[i] = NULL;
+            break;
+       }
         default: /* '?' */
             usage();
             exit(EXIT_FAILURE);