Changeset 851f33a in mainline


Ignore:
Timestamp:
2010-06-24T09:07:32Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ccb426c
Parents:
9539be6
Message:

merge "tests" and "test" kconsole commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/cmd.c

    r9539be6 r851f33a  
    108108
    109109#ifdef CONFIG_TEST
    110 static int cmd_tests(cmd_arg_t *argv);
    111 static cmd_info_t tests_info = {
    112         .name = "tests",
    113         .description = "Print available kernel tests.",
    114         .func = cmd_tests,
    115         .argc = 0
    116 };
    117 
    118110static char test_buf[MAX_CMDLINE + 1];
    119111static int cmd_test(cmd_arg_t *argv);
    120112static cmd_arg_t test_argv[] = {
    121113        {
    122                 .type = ARG_TYPE_STRING,
     114                .type = ARG_TYPE_STRING_OPTIONAL,
    123115                .buffer = test_buf,
    124116                .len = sizeof(test_buf)
     
    127119static cmd_info_t test_info = {
    128120        .name = "test",
    129         .description = "Run kernel test.",
     121        .description = "Print list of kernel tests or run a test.",
    130122        .func = cmd_test,
    131123        .argc = 1,
     
    509501        &zone_info,
    510502#ifdef CONFIG_TEST
    511         &tests_info,
    512503        &test_info,
    513504        &bench_info,
     
    10661057
    10671058#ifdef CONFIG_TEST
    1068 /** Command for printing kernel tests list.
    1069  *
    1070  * @param argv Ignored.
    1071  *
    1072  * return Always 1.
    1073  */
    1074 int cmd_tests(cmd_arg_t *argv)
    1075 {
    1076         size_t len = 0;
    1077         test_t *test;
    1078         for (test = tests; test->name != NULL; test++) {
    1079                 if (str_length(test->name) > len)
    1080                         len = str_length(test->name);
    1081         }
    1082        
    1083         for (test = tests; test->name != NULL; test++)
    1084                 printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
    1085        
    1086         printf("%-*s Run all safe tests\n", len, "*");
    1087         return 1;
    1088 }
    1089 
    10901059static bool run_test(const test_t *test)
    10911060{
     
    11931162}
    11941163
    1195 /** Command for returning kernel tests
     1164static void list_tests(void)
     1165{
     1166        size_t len = 0;
     1167        test_t *test;
     1168       
     1169        for (test = tests; test->name != NULL; test++) {
     1170                if (str_length(test->name) > len)
     1171                        len = str_length(test->name);
     1172        }
     1173       
     1174        for (test = tests; test->name != NULL; test++)
     1175                printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
     1176       
     1177        printf("%-*s Run all safe tests\n", len, "*");
     1178}
     1179
     1180/** Command for listing and running kernel tests
    11961181 *
    11971182 * @param argv Argument vector.
    11981183 *
    11991184 * return Always 1.
     1185 *
    12001186 */
    12011187int cmd_test(cmd_arg_t *argv)
     
    12111197                        }
    12121198                }
    1213         } else {
     1199        } else if (str_cmp((char *) argv->buffer, "") != 0) {
    12141200                bool fnd = false;
    12151201               
     
    12241210                if (!fnd)
    12251211                        printf("Unknown test\n");
    1226         }
     1212        } else
     1213                list_tests();
    12271214       
    12281215        return 1;
Note: See TracChangeset for help on using the changeset viewer.