Changeset 319e60e in mainline for kernel/generic/src/console/cmd.c


Ignore:
Timestamp:
2006-12-11T18:33:53Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
50661ab
Parents:
134877d
Message:

prepare for new test infrastructure

File:
1 edited

Legend:

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

    r134877d r319e60e  
    6666#include <ipc/irq.h>
    6767
     68#ifdef CONFIG_TEST
     69#include <test.h>
     70#endif
     71
    6872/* Data and methods for 'help' command. */
    6973static int cmd_help(cmd_arg_t *argv);
     
    7781static cmd_info_t exit_info = {
    7882        .name = "exit",
    79         .description ="Exit kconsole",
     83        .description = "Exit kconsole",
    8084        .argc = 0
    8185};
     
    8488static cmd_info_t continue_info = {
    8589        .name = "continue",
    86         .description ="Return console back to userspace.",
     90        .description = "Return console back to userspace.",
    8791        .func = cmd_continue,
    8892        .argc = 0
    8993};
     94
     95#ifdef CONFIG_TEST
     96static int cmd_tests(cmd_arg_t *argv);
     97static cmd_info_t tests_info = {
     98        .name = "tests",
     99        .description = "Print available kernel tests.",
     100        .func = cmd_tests,
     101        .argc = 0
     102};
     103
     104static char test_buf[MAX_CMDLINE + 1];
     105static int cmd_test(cmd_arg_t *argv);
     106static cmd_arg_t test_argv[] = {
     107        {
     108                .type = ARG_TYPE_STRING,
     109                .buffer = test_buf,
     110                .len = sizeof(test_buf)
     111        }
     112};
     113static cmd_info_t test_info = {
     114        .name = "test",
     115        .description = "Run kernel test.",
     116        .func = cmd_test,
     117        .argc = 1,
     118        .argv = test_argv
     119};
     120#endif
    90121
    91122/* Data and methods for 'description' command. */
     
    378409        &zones_info,
    379410        &zone_info,
     411#ifdef CONFIG_TEST
     412        &tests_info,
     413        &test_info,
     414#endif
    380415        NULL
    381416};
     
    806841}
    807842
     843/** Command for printing kernel tests list.
     844 *
     845 * @param argv Ignored.
     846 *
     847 * return Always 1.
     848 */
     849int cmd_tests(cmd_arg_t *argv)
     850{
     851        test_t *test;
     852       
     853        for (test = tests; test->name != NULL; test++)
     854                printf("%s\t%s\n", test->name, test->desc);
     855       
     856        return 1;
     857}
     858
     859/** Command for returning kernel tests
     860 *
     861 * @param argv Argument vector.
     862 *
     863 * return Always 1.
     864 */
     865int cmd_test(cmd_arg_t *argv)
     866{
     867        bool fnd = false;
     868        test_t *test;
     869       
     870        for (test = tests; test->name != NULL; test++) {
     871                if (strcmp(test->name, argv->buffer) == 0) {
     872                        fnd = true;
     873                        test->entry();
     874                        break;
     875                }
     876        }
     877       
     878        if (!fnd)
     879                printf("Unknown test.\n");
     880       
     881        return 1;
     882}
     883
    808884/** @}
    809885 */
Note: See TracChangeset for help on using the changeset viewer.