Changeset c1f7f6ea in mainline


Ignore:
Timestamp:
2009-02-27T12:53:46Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c214a65
Parents:
e49e234
Message:

prettyprint help and tests

File:
1 edited

Legend:

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

    re49e234 rc1f7f6ea  
    515515int cmd_help(cmd_arg_t *argv)
    516516{
     517        spinlock_lock(&cmd_lock);
     518       
    517519        link_t *cur;
    518 
    519         spinlock_lock(&cmd_lock);
    520        
     520        size_t len = 0;
    521521        for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
    522522                cmd_info_t *hlp;
    523                
    524523                hlp = list_get_instance(cur, cmd_info_t, link);
     524               
    525525                spinlock_lock(&hlp->lock);
    526                
    527                 printf("%s - %s\n", hlp->name, hlp->description);
    528 
     526                if (strlen(hlp->name) > len)
     527                        len = strlen(hlp->name);
    529528                spinlock_unlock(&hlp->lock);
    530529        }
    531530       
     531        for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
     532                cmd_info_t *hlp;
     533                hlp = list_get_instance(cur, cmd_info_t, link);
     534               
     535                spinlock_lock(&hlp->lock);
     536                printf("%-*s %s\n", len, hlp->name, hlp->description);
     537                spinlock_unlock(&hlp->lock);
     538        }
     539       
    532540        spinlock_unlock(&cmd_lock);
    533 
     541       
    534542        return 1;
    535543}
     
    949957int cmd_tests(cmd_arg_t *argv)
    950958{
     959        size_t len = 0;
    951960        test_t *test;
     961        for (test = tests; test->name != NULL; test++) {
     962                if (strlen(test->name) > len)
     963                        len = strlen(test->name);
     964        }
    952965       
    953966        for (test = tests; test->name != NULL; test++)
    954                 printf("%-10s %s%s\n", test->name, test->desc, (test->safe ? "" : " (unsafe)"));
    955        
    956         printf("%-10s Run all safe tests\n", "*");
     967                printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
     968       
     969        printf("%-*s Run all safe tests\n", len, "*");
    957970        return 1;
    958971}
     
    960973static bool run_test(const test_t *test)
    961974{
    962         printf("%s\t\t%s\n", test->name, test->desc);
     975        printf("%s (%s)\n", test->name, test->desc);
    963976       
    964977        /* Update and read thread accounting
Note: See TracChangeset for help on using the changeset viewer.