/usr/src/spl-0.6.5.9/cmd/splat.c is in spl-dkms 0.6.5.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 | /*****************************************************************************\
* 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 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.
*
* 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 the SPL. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************
* Solaris Porting LAyer Tests (SPLAT) User Space Interface.
\*****************************************************************************/
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "splat.h"
#undef ioctl
static const char shortOpts[] = "hvlat:xc";
static const struct option longOpts[] = {
{ "help", no_argument, 0, 'h' },
{ "verbose", no_argument, 0, 'v' },
{ "list", no_argument, 0, 'l' },
{ "all", no_argument, 0, 'a' },
{ "test", required_argument, 0, 't' },
{ "exit", no_argument, 0, 'x' },
{ "nocolor", no_argument, 0, 'c' },
{ 0, 0, 0, 0 }
};
#define VERSION_SIZE 64
static List subsystems; /* Subsystem/tests */
static int splatctl_fd; /* Control file descriptor */
static char splat_version[VERSION_SIZE]; /* Kernel version string */
static char *splat_buffer = NULL; /* Scratch space area */
static int splat_buffer_size = 0; /* Scratch space size */
static void test_list(List, int);
static int dev_clear(void);
static void subsystem_fini(subsystem_t *);
static void test_fini(test_t *);
static int usage(void) {
fprintf(stderr, "usage: splat [hvla] [-t <subsystem:<tests>>]\n");
fprintf(stderr,
" --help -h This help\n"
" --verbose -v Increase verbosity\n"
" --list -l List all tests in all subsystems\n"
" --all -a Run all tests in all subsystems\n"
" --test -t <sub:test> Run 'test' in subsystem 'sub'\n"
" --exit -x Exit on first test error\n"
" --nocolor -c Do not colorize output\n");
fprintf(stderr, "\n"
"Examples:\n"
" splat -t kmem:all # Runs all kmem tests\n"
" splat -t taskq:0x201 # Run taskq test 0x201\n");
return 0;
}
static subsystem_t *subsystem_init(splat_user_t *desc)
{
subsystem_t *sub;
sub = (subsystem_t *)malloc(sizeof(*sub));
if (sub == NULL)
return NULL;
memcpy(&sub->sub_desc, desc, sizeof(*desc));
sub->sub_tests = list_create((ListDelF)test_fini);
if (sub->sub_tests == NULL) {
free(sub);
return NULL;
}
return sub;
}
static void subsystem_fini(subsystem_t *sub)
{
assert(sub != NULL);
free(sub);
}
static int subsystem_setup(void)
{
splat_cfg_t *cfg;
int i, rc, size, cfg_size;
subsystem_t *sub;
splat_user_t *desc;
/* Aquire the number of registered subsystems */
cfg_size = sizeof(*cfg);
cfg = (splat_cfg_t *)malloc(cfg_size);
if (cfg == NULL)
return -ENOMEM;
memset(cfg, 0, cfg_size);
cfg->cfg_magic = SPLAT_CFG_MAGIC;
cfg->cfg_cmd = SPLAT_CFG_SUBSYSTEM_COUNT;
rc = ioctl(splatctl_fd, SPLAT_CFG, cfg);
if (rc) {
fprintf(stderr, "Ioctl() error 0x%lx / %d: %d\n",
(unsigned long)SPLAT_CFG, cfg->cfg_cmd, errno);
free(cfg);
return rc;
}
size = cfg->cfg_rc1;
free(cfg);
/* 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);
if (cfg == NULL)
return -ENOMEM;
memset(cfg, 0, cfg_size);
cfg->cfg_magic = SPLAT_CFG_MAGIC;
cfg->cfg_cmd = SPLAT_CFG_SUBSYSTEM_LIST;
cfg->cfg_data.splat_subsystems.size = size;
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);
free(cfg);
return rc;
}
/* Add the new subsystems in to the global list */
size = cfg->cfg_rc1;
for (i = 0; i < size; i++) {
desc = &(cfg->cfg_data.splat_subsystems.descs[i]);
sub = subsystem_init(desc);
if (sub == NULL) {
fprintf(stderr, "Error initializing subsystem: %s\n",
desc->name);
free(cfg);
return -ENOMEM;
}
list_append(subsystems, sub);
}
free(cfg);
return 0;
}
static void subsystem_list(List l, int indent)
{
ListIterator i;
subsystem_t *sub;
fprintf(stdout,
"------------------------------ "
"Available SPLAT Tests "
"------------------------------\n");
i = list_iterator_create(l);
while ((sub = list_next(i))) {
fprintf(stdout, "%*s0x%0*x %-*s ---- %s ----\n",
indent, "",
4, sub->sub_desc.id,
SPLAT_NAME_SIZE + 7, sub->sub_desc.name,
sub->sub_desc.desc);
test_list(sub->sub_tests, indent + 7);
}
list_iterator_destroy(i);
}
static test_t *test_init(subsystem_t *sub, splat_user_t *desc)
{
test_t *test;
test = (test_t *)malloc(sizeof(*test));
if (test == NULL)
return NULL;
test->test_sub = sub;
memcpy(&test->test_desc, desc, sizeof(*desc));
return test;
}
static void test_fini(test_t *test)
{
assert(test != NULL);
free(test);
}
static int test_setup(subsystem_t *sub)
{
splat_cfg_t *cfg;
int i, rc, size;
test_t *test;
splat_user_t *desc;
/* Aquire the number of registered tests for the give subsystem */
cfg = (splat_cfg_t *)malloc(sizeof(*cfg));
if (cfg == NULL)
return -ENOMEM;
memset(cfg, 0, sizeof(*cfg));
cfg->cfg_magic = SPLAT_CFG_MAGIC;
cfg->cfg_cmd = SPLAT_CFG_TEST_COUNT;
cfg->cfg_arg1 = sub->sub_desc.id; /* Subsystem of interest */
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);
free(cfg);
return rc;
}
size = cfg->cfg_rc1;
free(cfg);
/* 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));
if (cfg == NULL)
return -ENOMEM;
memset(cfg, 0, sizeof(*cfg) + size * sizeof(splat_user_t));
cfg->cfg_magic = SPLAT_CFG_MAGIC;
cfg->cfg_cmd = SPLAT_CFG_TEST_LIST;
cfg->cfg_arg1 = sub->sub_desc.id; /* Subsystem of interest */
cfg->cfg_data.splat_tests.size = size;
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);
free(cfg);
return rc;
}
/* Add the new tests in to the relevant subsystems */
size = cfg->cfg_rc1;
for (i = 0; i < size; i++) {
desc = &(cfg->cfg_data.splat_tests.descs[i]);
test = test_init(sub, desc);
if (test == NULL) {
fprintf(stderr, "Error initializing test: %s\n",
desc->name);
free(cfg);
return -ENOMEM;
}
list_append(sub->sub_tests, test);
}
free(cfg);
return 0;
}
static test_t *test_copy(test_t *test)
{
return test_init(test->test_sub, &test->test_desc);
}
static void test_list(List l, int indent)
{
ListIterator i;
test_t *test;
i = list_iterator_create(l);
while ((test = list_next(i)))
fprintf(stdout, "%*s0x%0*x %-*s %s\n",
indent, "", 04, test->test_desc.id,
SPLAT_NAME_SIZE, test->test_desc.name,
test->test_desc.desc);
list_iterator_destroy(i);
}
static test_t *test_find(char *sub_str, char *test_str)
{
ListIterator si, ti;
subsystem_t *sub;
test_t *test;
__u32 sub_num, test_num;
/*
* 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 = strtoul(sub_str, NULL, 0);
test_num = strtoul(test_str, NULL, 0);
si = list_iterator_create(subsystems);
while ((sub = list_next(si))) {
if (strncmp(sub->sub_desc.name, sub_str, SPLAT_NAME_SIZE) &&
sub->sub_desc.id != sub_num)
continue;
ti = list_iterator_create(sub->sub_tests);
while ((test = list_next(ti))) {
if (!strncmp(test->test_desc.name, test_str,
SPLAT_NAME_SIZE) || test->test_desc.id==test_num) {
list_iterator_destroy(ti);
list_iterator_destroy(si);
return test;
}
}
list_iterator_destroy(ti);
}
list_iterator_destroy(si);
return NULL;
}
static int test_add(cmd_args_t *args, test_t *test)
{
test_t *tmp;
tmp = test_copy(test);
if (tmp == NULL)
return -ENOMEM;
list_append(args->args_tests, tmp);
return 0;
}
static int test_add_all(cmd_args_t *args)
{
ListIterator si, ti;
subsystem_t *sub;
test_t *test;
int rc;
si = list_iterator_create(subsystems);
while ((sub = list_next(si))) {
ti = list_iterator_create(sub->sub_tests);
while ((test = list_next(ti))) {
if ((rc = test_add(args, test))) {
list_iterator_destroy(ti);
list_iterator_destroy(si);
return rc;
}
}
list_iterator_destroy(ti);
}
list_iterator_destroy(si);
return 0;
}
static int test_run(cmd_args_t *args, test_t *test)
{
subsystem_t *sub = test->test_sub;
splat_cmd_t *cmd;
int rc, cmd_size;
dev_clear();
cmd_size = sizeof(*cmd);
cmd = (splat_cmd_t *)malloc(cmd_size);
if (cmd == NULL)
return -ENOMEM;
memset(cmd, 0, cmd_size);
cmd->cmd_magic = SPLAT_CMD_MAGIC;
cmd->cmd_subsystem = sub->sub_desc.id;
cmd->cmd_test = test->test_desc.id;
cmd->cmd_data_size = 0; /* Unused feature */
fprintf(stdout, "%*s:%-*s ",
SPLAT_NAME_SIZE, sub->sub_desc.name,
SPLAT_NAME_SIZE, test->test_desc.name);
fflush(stdout);
rc = ioctl(splatctl_fd, SPLAT_CMD, cmd);
if (args->args_do_color) {
fprintf(stdout, "%s %s\n", rc ?
COLOR_RED "Fail" COLOR_RESET :
COLOR_GREEN "Pass" COLOR_RESET,
rc ? strerror(errno) : "");
} else {
fprintf(stdout, "%s %s\n", rc ?
"Fail" : "Pass",
rc ? strerror(errno) : "");
}
fflush(stdout);
free(cmd);
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);
fflush(stdout);
}
}
return rc;
}
static int tests_run(cmd_args_t *args)
{
ListIterator i;
test_t *test;
int rc;
fprintf(stdout,
"------------------------------ "
"Running SPLAT Tests "
"------------------------------\n");
i = list_iterator_create(args->args_tests);
while ((test = list_next(i))) {
rc = test_run(args, test);
if (rc && args->args_exit_on_error) {
list_iterator_destroy(i);
return rc;
}
}
list_iterator_destroy(i);
return 0;
}
static int args_parse_test(cmd_args_t *args, char *str)
{
ListIterator si, ti;
subsystem_t *s;
test_t *t;
char *sub_str, *test_str;
int sub_num, test_num;
int sub_all = 0, test_all = 0;
int rc, flag = 0;
test_str = strchr(str, ':');
if (test_str == NULL) {
fprintf(stderr, "Test must be of the "
"form <subsystem:test>\n");
return -EINVAL;
}
sub_str = str;
test_str[0] = '\0';
test_str = test_str + 1;
sub_num = strtol(sub_str, NULL, 0);
test_num = strtol(test_str, NULL, 0);
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))
test_all = 1;
si = list_iterator_create(subsystems);
if (sub_all) {
if (test_all) {
/* Add all tests from all subsystems */
while ((s = list_next(si))) {
ti = list_iterator_create(s->sub_tests);
while ((t = list_next(ti))) {
if ((rc = test_add(args, t))) {
list_iterator_destroy(ti);
goto error_run;
}
}
list_iterator_destroy(ti);
}
} else {
/* Add a specific test from all subsystems */
while ((s = list_next(si))) {
if ((t=test_find(s->sub_desc.name,test_str))) {
if ((rc = test_add(args, t)))
goto error_run;
flag = 1;
}
}
if (!flag)
fprintf(stderr, "No tests '%s:%s' could be "
"found\n", sub_str, test_str);
}
} else {
if (test_all) {
/* Add all tests from a specific subsystem */
while ((s = list_next(si))) {
if (strncasecmp(sub_str, s->sub_desc.name,
strlen(sub_str)))
continue;
ti = list_iterator_create(s->sub_tests);
while ((t = list_next(ti))) {
if ((rc = test_add(args, t))) {
list_iterator_destroy(ti);
goto error_run;
}
}
list_iterator_destroy(ti);
}
} else {
/* Add a specific test from a specific subsystem */
if ((t = test_find(sub_str, test_str))) {
if ((rc = test_add(args, t)))
goto error_run;
} else {
fprintf(stderr, "Test '%s:%s' could not be "
"found\n", sub_str, test_str);
return -EINVAL;
}
}
}
list_iterator_destroy(si);
return 0;
error_run:
list_iterator_destroy(si);
fprintf(stderr, "Test '%s:%s' not added to run list: %d\n",
sub_str, test_str, rc);
return rc;
}
static void args_fini(cmd_args_t *args)
{
assert(args != NULL);
if (args->args_tests != NULL)
list_destroy(args->args_tests);
free(args);
}
static cmd_args_t *
args_init(int argc, char **argv)
{
cmd_args_t *args;
int c, rc;
if (argc == 1) {
usage();
return (cmd_args_t *) NULL;
}
/* Configure and populate the args structures */
args = malloc(sizeof(*args));
if (args == NULL)
return NULL;
memset(args, 0, sizeof(*args));
args->args_verbose = 0;
args->args_do_list = 0;
args->args_do_all = 0;
args->args_do_color = 1;
args->args_exit_on_error = 0;
args->args_tests = list_create((ListDelF)test_fini);
if (args->args_tests == NULL) {
args_fini(args);
return NULL;
}
while ((c = getopt_long(argc, argv, shortOpts, longOpts, NULL)) != -1){
switch (c) {
case 'v': args->args_verbose++; break;
case 'l': args->args_do_list = 1; break;
case 'a': args->args_do_all = 1; break;
case 'c': args->args_do_color = 0; break;
case 'x': args->args_exit_on_error = 1; break;
case 't':
if (args->args_do_all) {
fprintf(stderr, "Option -t <subsystem:test> is "
"useless when used with -a\n");
args_fini(args);
return NULL;
}
rc = args_parse_test(args, argv[optind - 1]);
if (rc) {
args_fini(args);
return NULL;
}
break;
case 'h':
case '?':
usage();
args_fini(args);
return NULL;
default:
fprintf(stderr, "Unknown option '%s'\n",
argv[optind - 1]);
break;
}
}
return args;
}
static int
dev_clear(void)
{
splat_cfg_t cfg;
int rc;
memset(&cfg, 0, sizeof(cfg));
cfg.cfg_magic = SPLAT_CFG_MAGIC;
cfg.cfg_cmd = SPLAT_CFG_BUFFER_CLEAR;
cfg.cfg_arg1 = 0;
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);
lseek(splatctl_fd, 0, SEEK_SET);
return rc;
}
static int
dev_size(int size)
{
splat_cfg_t cfg;
int rc;
memset(&cfg, 0, sizeof(cfg));
cfg.cfg_magic = SPLAT_CFG_MAGIC;
cfg.cfg_cmd = SPLAT_CFG_BUFFER_SIZE;
cfg.cfg_arg1 = size;
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);
return rc;
}
return cfg.cfg_rc1;
}
static void
dev_fini(void)
{
if (splat_buffer)
free(splat_buffer);
if (splatctl_fd != -1) {
if (close(splatctl_fd) == -1) {
fprintf(stderr, "Unable to close %s: %d\n",
SPLAT_DEV, errno);
}
}
}
static int
dev_init(void)
{
ListIterator i;
subsystem_t *sub;
int rc;
splatctl_fd = open(SPLAT_DEV, O_RDONLY);
if (splatctl_fd == -1) {
fprintf(stderr, "Unable to open %s: %d\n"
"Is the splat module loaded?\n", SPLAT_DEV, errno);
rc = errno;
goto error;
}
/* Determine kernel module version string */
memset(splat_version, 0, VERSION_SIZE);
if ((rc = read(splatctl_fd, splat_version, VERSION_SIZE - 1)) == -1)
goto error;
if ((rc = dev_clear()))
goto error;
if ((rc = dev_size(0)) < 0)
goto error;
splat_buffer_size = rc;
splat_buffer = (char *)malloc(splat_buffer_size);
if (splat_buffer == NULL) {
rc = -ENOMEM;
goto error;
}
memset(splat_buffer, 0, splat_buffer_size);
/* Determine available subsystems */
if ((rc = subsystem_setup()) != 0)
goto error;
/* Determine available tests for all subsystems */
i = list_iterator_create(subsystems);
while ((sub = list_next(i))) {
if ((rc = test_setup(sub)) != 0) {
list_iterator_destroy(i);
goto error;
}
}
list_iterator_destroy(i);
return 0;
error:
if (splatctl_fd != -1) {
if (close(splatctl_fd) == -1) {
fprintf(stderr, "Unable to close %s: %d\n",
SPLAT_DEV, errno);
}
}
return rc;
}
int
init(void)
{
int rc = 0;
/* Allocate the subsystem list */
subsystems = list_create((ListDelF)subsystem_fini);
if (subsystems == NULL)
rc = ENOMEM;
return rc;
}
void
fini(void)
{
list_destroy(subsystems);
}
int
main(int argc, char **argv)
{
cmd_args_t *args = NULL;
int rc = 0;
/* General init */
if ((rc = init()))
return rc;
/* Device specific init */
if ((rc = dev_init()))
goto out;
/* Argument init and parsing */
if ((args = args_init(argc, argv)) == NULL) {
rc = -1;
goto out;
}
/* Generic kernel version string */
if (args->args_verbose)
fprintf(stdout, "%s", splat_version);
/* Print the available test list and exit */
if (args->args_do_list) {
subsystem_list(subsystems, 0);
goto out;
}
/* Add all available test to the list of tests to run */
if (args->args_do_all) {
if ((rc = test_add_all(args)))
goto out;
}
/* Run all the requested tests */
if ((rc = tests_run(args)))
goto out;
out:
if (args != NULL)
args_fini(args);
dev_fini();
fini();
return rc;
}
|