]> git.proxmox.com Git - mirror_spl-debian.git/blobdiff - cmd/splat.c
New upstream version 0.6.5.10
[mirror_spl-debian.git] / cmd / splat.c
index 3fefe9739b590fcb6047b62b88aebc26b2ad4d18..92962393dd0bd9f1c5a177b3f3cd48031789b8d4 100644 (file)
@@ -1,30 +1,28 @@
-/*
- *  This file is part of the SPL: Solaris Porting Layer.
- *
- *  Copyright (c) 2008 Lawrence Livermore National Security, LLC.
- *  Produced at Lawrence Livermore National Laboratory
- *  Written by:
- *          Brian Behlendorf <behlendorf1@llnl.gov>,
- *          Herb Wartens <wartens2@llnl.gov>,
- *          Jim Garlick <garlick@llnl.gov>
+/*****************************************************************************\
+ *  Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
+ *  Copyright (C) 2007 The Regents of the University of California.
+ *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
+ *  Written by Brian Behlendorf <behlendorf1@llnl.gov>.
  *  UCRL-CODE-235197
  *
- *  This is free software; you can redistribute it and/or modify it
- *  under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
+ *  This file is part of the SPL, Solaris Porting Layer.
+ *  For details, see <http://zfsonlinux.org/>.
+ *
+ *  The SPL is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU General Public License as published by the
+ *  Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
  *
- *  This is distributed in the hope that it will be useful, but WITHOUT
+ *  The SPL is distributed in the hope that it will be useful, but WITHOUT
  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  *  for more details.
  *
  *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
- */
-
-/* Solaris Porting LAyer Tests (SPLAT) userspace interface */
+ *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
+ *****************************************************************************
+ *  Solaris Porting LAyer Tests (SPLAT) User Space Interface.
+\*****************************************************************************/
 
 #include <stdlib.h>
 #include <stddef.h>
@@ -131,8 +129,8 @@ static int subsystem_setup(void)
 
        rc = ioctl(splatctl_fd, SPLAT_CFG, cfg);
        if (rc) {
-               fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
-                       (unsigned long) SPLAT_CFG, cfg->cfg_cmd, errno);
+               fprintf(stderr, "Ioctl() error 0x%lx / %d: %d\n",
+                       (unsigned long)SPLAT_CFG, cfg->cfg_cmd, errno);
                free(cfg);
                return rc;
        }
@@ -140,7 +138,7 @@ static int subsystem_setup(void)
        size = cfg->cfg_rc1;
        free(cfg);
 
-       /* Based on the newly aquired number of subsystems allocate enough
+       /* Based on the newly acquired number of subsystems allocate
         * memory to get the descriptive information for them all. */
        cfg_size = sizeof(*cfg) + size * sizeof(splat_user_t);
        cfg = (splat_cfg_t *)malloc(cfg_size);
@@ -180,23 +178,6 @@ static int subsystem_setup(void)
        return 0;
 }
 
-/* XXX - Commented out until we sort the lists */
-#if 0
-static int subsystem_compare(const void *l_arg, const void *r_arg, void *private)
-{
-       const subsystem_t *l = l_arg;
-       const subsystem_t *r = r_arg;
-
-       if (l->sub_desc.id > r->sub_desc.id)
-               return 1;
-
-       if (l->sub_desc.id < r->sub_desc.id)
-               return -1;
-
-       return 0;
-}
-#endif
-
 static void subsystem_list(List l, int indent)
 {
        ListIterator i;
@@ -271,7 +252,7 @@ static int test_setup(subsystem_t *sub)
 
        /* Based on the newly aquired number of tests allocate enough
         * memory to get the descriptive information for them all. */
-       cfg = (splat_cfg_t *)malloc(sizeof(*cfg) + size * sizeof(splat_user_t));
+       cfg = (splat_cfg_t *)malloc(sizeof(*cfg) + size*sizeof(splat_user_t));
        if (cfg == NULL)
                return -ENOMEM;
 
@@ -309,23 +290,6 @@ static int test_setup(subsystem_t *sub)
        return 0;
 }
 
-/* XXX - Commented out until we sort the lists */
-#if 0
-static int test_compare(const void *l_arg, const void *r_arg, void *private)
-{
-       const test_t *l = l_arg;
-       const test_t *r = r_arg;
-
-       if (l->test_desc.id > r->test_desc.id)
-               return 1;
-
-       if (l->test_desc.id < r->test_desc.id)
-               return -1;
-
-       return 0;
-}
-#endif
-
 static test_t *test_copy(test_t *test)
 {
        return test_init(test->test_sub, &test->test_desc);
@@ -352,14 +316,15 @@ static test_t *test_find(char *sub_str, char *test_str)
        ListIterator si, ti;
        subsystem_t *sub;
        test_t *test;
-       int sub_num, test_num;
+       __u32 sub_num, test_num;
 
-       /* No error checking here because it may not be a number, it's
+       /*
+        * No error checking here because it may not be a number, it's
         * perfectly OK for it to be a string.  Since we're just using
         * it for comparison purposes this is all very safe.
         */
-       sub_num = strtol(sub_str, NULL, 0);
-       test_num = strtol(test_str, NULL, 0);
+       sub_num = strtoul(sub_str, NULL, 0);
+       test_num = strtoul(test_str, NULL, 0);
 
         si = list_iterator_create(subsystems);
 
@@ -374,7 +339,7 @@ static test_t *test_find(char *sub_str, char *test_str)
                while ((test = list_next(ti))) {
 
                        if (!strncmp(test->test_desc.name, test_str,
-                           SPLAT_NAME_SIZE) || test->test_desc.id == test_num) {
+                           SPLAT_NAME_SIZE) || test->test_desc.id==test_num) {
                                list_iterator_destroy(ti);
                                list_iterator_destroy(si);
                                return test;
@@ -466,8 +431,10 @@ static int test_run(cmd_args_t *args, test_t *test)
        fflush(stdout);
        free(cmd);
 
-       if (args->args_verbose) {
-               if ((rc = read(splatctl_fd, splat_buffer, splat_buffer_size - 1)) < 0) {
+       if ((args->args_verbose == 1 && rc) ||
+           (args->args_verbose >= 2)) {
+               if ((rc = read(splatctl_fd, splat_buffer,
+                              splat_buffer_size - 1)) < 0) {
                        fprintf(stdout, "Error reading results: %d\n", rc);
                } else {
                        fprintf(stdout, "\n%s\n", splat_buffer);
@@ -530,7 +497,7 @@ static int args_parse_test(cmd_args_t *args, char *str)
        if (!strncasecmp(sub_str, "all", strlen(sub_str)) || (sub_num == -1))
                sub_all = 1;
 
-       if (!strncasecmp(test_str, "all", strlen(test_str)) || (test_num == -1))
+       if (!strncasecmp(test_str,"all",strlen(test_str)) || (test_num == -1))
                test_all = 1;
 
        si = list_iterator_create(subsystems);
@@ -551,7 +518,7 @@ static int args_parse_test(cmd_args_t *args, char *str)
                } else {
                        /* Add a specific test from all subsystems */
                        while ((s = list_next(si))) {
-                               if ((t = test_find(s->sub_desc.name,test_str))) {
+                               if ((t=test_find(s->sub_desc.name,test_str))) {
                                        if ((rc = test_add(args, t)))
                                                goto error_run;
 
@@ -867,4 +834,3 @@ out:
        fini();
        return rc;
 }
-