"Fossies" - the Fresh Open Source Software Archive

Member "opensaf-5.21.09/src/base/apitest/basetest.c" (14 Sep 2021, 1831 Bytes) of package /linux/misc/opensaf-5.21.09.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "basetest.c" see the Fossies "Dox" file reference documentation.

    1 /*      -*- OpenSAF  -*-
    2  *
    3  * (C) Copyright 2021 The OpenSAF Foundation
    4  *
    5  * This program is distributed in the hope that it will be useful, but
    6  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    7  * or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
    8  * under the GNU Lesser General Public License Version 2.1, February 1999.
    9  * The complete license can be accessed from the following location:
   10  * http://opensource.org/licenses/lgpl-license.php
   11  * See the Copying file included with the OpenSAF distribution for full
   12  * licensing terms.
   13  *
   14  * Author(s): Ericsson AB
   15  *
   16  */
   17 
   18 #include "base/apitest/basetest.h"
   19 #include <unistd.h>
   20 
   21 void usage(const char *progname)
   22 {
   23     printf("Usage: %s [-h] [--help] [suite [testcase]]\n\n", progname);
   24     printf("OPTIONS:\n");
   25     printf("\t-h, --help    this help\n");
   26     printf("\tsuite         suite for testing. 0 for listing all tests\n");
   27     printf("\ttestcase      test case for testing in specific suite\n");
   28 }
   29 
   30 int main(int argc, char **argv)
   31 {
   32     int suite = ALL_SUITES, tcase = ALL_TESTS;
   33     int rc = 0;
   34     int i;
   35     int index = 0;
   36     int failed = 0;
   37     char *endptr;
   38 
   39     srandom(getpid());
   40 
   41     for (i = 1; i < argc; i++) {
   42         if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
   43             usage(basename(argv[0]));
   44             return 0;
   45         } else if (index == 0) {
   46             suite = strtol(argv[i], &endptr, 10);
   47             if (endptr && *endptr) {
   48                 failed = 1;
   49             } else {
   50                 index++;
   51             }
   52         } else if (index == 1) {
   53             tcase = strtol(argv[i], &endptr, 10);
   54             if (endptr && *endptr) {
   55                 failed = 1;
   56             } else {
   57                 index++;
   58             }
   59         } else {
   60             failed = 1;
   61         }
   62 
   63         if (failed) {
   64             fprintf(stderr,
   65                 "Try '%s --help' for more information\n",
   66                 argv[0]);
   67             return EXIT_FAILURE;
   68         }
   69     }
   70 
   71     if (suite == 0) {
   72         test_list();
   73     } else {
   74         rc = test_run(suite, tcase);
   75     }
   76 
   77     return rc;
   78 }