Subversion Repositories HelenOS

Rev

Rev 4347 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4347 Rev 4348
Line 62... Line 62...
62
#include <proc/scheduler.h>
62
#include <proc/scheduler.h>
63
#include <proc/thread.h>
63
#include <proc/thread.h>
64
#include <proc/task.h>
64
#include <proc/task.h>
65
#include <ipc/ipc.h>
65
#include <ipc/ipc.h>
66
#include <ipc/irq.h>
66
#include <ipc/irq.h>
67
#include <event/event.h>
67
#include <ipc/event.h>
68
#include <symtab.h>
68
#include <symtab.h>
69
#include <errno.h>
69
#include <errno.h>
70
 
70
 
71
#ifdef CONFIG_TEST
71
#ifdef CONFIG_TEST
72
#include <test.h>
72
#include <test.h>
Line 511... Line 511...
511
int cmd_help(cmd_arg_t *argv)
511
int cmd_help(cmd_arg_t *argv)
512
{
512
{
513
    spinlock_lock(&cmd_lock);
513
    spinlock_lock(&cmd_lock);
514
   
514
   
515
    link_t *cur;
515
    link_t *cur;
516
    size_t len = 0;
516
    count_t len = 0;
517
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
517
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
518
        cmd_info_t *hlp;
518
        cmd_info_t *hlp;
519
        hlp = list_get_instance(cur, cmd_info_t, link);
519
        hlp = list_get_instance(cur, cmd_info_t, link);
520
       
520
       
521
        spinlock_lock(&hlp->lock);
521
        spinlock_lock(&hlp->lock);
522
        if (strlen(hlp->name) > len)
522
        if (str_length(hlp->name) > len)
523
            len = strlen(hlp->name);
523
            len = str_length(hlp->name);
524
        spinlock_unlock(&hlp->lock);
524
        spinlock_unlock(&hlp->lock);
525
    }
525
    }
526
   
526
   
527
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
527
    for (cur = cmd_head.next; cur != &cmd_head; cur = cur->next) {
528
        cmd_info_t *hlp;
528
        cmd_info_t *hlp;
Line 589... Line 589...
589
        cmd_info_t *hlp;
589
        cmd_info_t *hlp;
590
       
590
       
591
        hlp = list_get_instance(cur, cmd_info_t, link);
591
        hlp = list_get_instance(cur, cmd_info_t, link);
592
        spinlock_lock(&hlp->lock);
592
        spinlock_lock(&hlp->lock);
593
 
593
       
594
        if (strncmp(hlp->name, (const char *) argv->buffer, strlen(hlp->name)) == 0) {
594
        if (str_lcmp(hlp->name, (const char *) argv->buffer, str_length(hlp->name)) == 0) {
595
            printf("%s - %s\n", hlp->name, hlp->description);
595
            printf("%s - %s\n", hlp->name, hlp->description);
596
            if (hlp->help)
596
            if (hlp->help)
597
                hlp->help();
597
                hlp->help();
598
            spinlock_unlock(&hlp->lock);
598
            spinlock_unlock(&hlp->lock);
599
            break;
599
            break;
Line 954... Line 954...
954
{
954
{
955
    printf("The kernel will now relinquish the console.\n");
955
    printf("The kernel will now relinquish the console.\n");
956
    release_console();
956
    release_console();
957
   
957
   
958
    event_notify_0(EVENT_KCONSOLE);
958
    event_notify_0(EVENT_KCONSOLE);
-
 
959
    indev_pop_character(stdin);
959
   
960
   
960
    return 1;
961
    return 1;
961
}
962
}
962
 
963
 
963
#ifdef CONFIG_TEST
964
#ifdef CONFIG_TEST
Line 967... Line 968...
967
 *
968
 *
968
 * return Always 1.
969
 * return Always 1.
969
 */
970
 */
970
int cmd_tests(cmd_arg_t *argv)
971
int cmd_tests(cmd_arg_t *argv)
971
{
972
{
972
    size_t len = 0;
973
    count_t len = 0;
973
    test_t *test;
974
    test_t *test;
974
    for (test = tests; test->name != NULL; test++) {
975
    for (test = tests; test->name != NULL; test++) {
975
        if (strlen(test->name) > len)
976
        if (str_length(test->name) > len)
976
            len = strlen(test->name);
977
            len = str_length(test->name);
977
    }
978
    }
978
   
979
   
979
    for (test = tests; test->name != NULL; test++)
980
    for (test = tests; test->name != NULL; test++)
980
        printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
981
        printf("%-*s %s%s\n", len, test->name, test->desc, (test->safe ? "" : " (unsafe)"));
981
   
982
   
Line 994... Line 995...
994
    uint64_t t0 = task_get_accounting(TASK);
995
    uint64_t t0 = task_get_accounting(TASK);
995
    spinlock_unlock(&TASK->lock);
996
    spinlock_unlock(&TASK->lock);
996
    interrupts_restore(ipl);
997
    interrupts_restore(ipl);
997
   
998
   
998
    /* Execute the test */
999
    /* Execute the test */
-
 
1000
    test_quiet = false;
999
    char * ret = test->entry(false);
1001
    char *ret = test->entry();
1000
   
1002
   
1001
    /* Update and read thread accounting */
1003
    /* Update and read thread accounting */
1002
    ipl = interrupts_disable();
1004
    ipl = interrupts_disable();
1003
    spinlock_lock(&TASK->lock);
1005
    spinlock_lock(&TASK->lock);
1004
    uint64_t dt = task_get_accounting(TASK) - t0;
1006
    uint64_t dt = task_get_accounting(TASK) - t0;
Line 1046... Line 1048...
1046
        uint64_t t0 = task_get_accounting(TASK);
1048
        uint64_t t0 = task_get_accounting(TASK);
1047
        spinlock_unlock(&TASK->lock);
1049
        spinlock_unlock(&TASK->lock);
1048
        interrupts_restore(ipl);
1050
        interrupts_restore(ipl);
1049
       
1051
       
1050
        /* Execute the test */
1052
        /* Execute the test */
-
 
1053
        test_quiet = true;
1051
        char * ret = test->entry(true);
1054
        char * ret = test->entry();
1052
       
1055
       
1053
        /* Update and read thread accounting */
1056
        /* Update and read thread accounting */
1054
        ipl = interrupts_disable();
1057
        ipl = interrupts_disable();
1055
        spinlock_lock(&TASK->lock);
1058
        spinlock_lock(&TASK->lock);
1056
        uint64_t dt = task_get_accounting(TASK) - t0;
1059
        uint64_t dt = task_get_accounting(TASK) - t0;
Line 1094... Line 1097...
1094
 */
1097
 */
1095
int cmd_test(cmd_arg_t *argv)
1098
int cmd_test(cmd_arg_t *argv)
1096
{
1099
{
1097
    test_t *test;
1100
    test_t *test;
1098
   
1101
   
1099
    if (strcmp((char *) argv->buffer, "*") == 0) {
1102
    if (str_cmp((char *) argv->buffer, "*") == 0) {
1100
        for (test = tests; test->name != NULL; test++) {
1103
        for (test = tests; test->name != NULL; test++) {
1101
            if (test->safe) {
1104
            if (test->safe) {
1102
                printf("\n");
1105
                printf("\n");
1103
                if (!run_test(test))
1106
                if (!run_test(test))
1104
                    break;
1107
                    break;
Line 1106... Line 1109...
1106
        }
1109
        }
1107
    } else {
1110
    } else {
1108
        bool fnd = false;
1111
        bool fnd = false;
1109
       
1112
       
1110
        for (test = tests; test->name != NULL; test++) {
1113
        for (test = tests; test->name != NULL; test++) {
1111
            if (strcmp(test->name, (char *) argv->buffer) == 0) {
1114
            if (str_cmp(test->name, (char *) argv->buffer) == 0) {
1112
                fnd = true;
1115
                fnd = true;
1113
                run_test(test);
1116
                run_test(test);
1114
                break;
1117
                break;
1115
            }
1118
            }
1116
        }
1119
        }
Line 1131... Line 1134...
1131
int cmd_bench(cmd_arg_t *argv)
1134
int cmd_bench(cmd_arg_t *argv)
1132
{
1135
{
1133
    test_t *test;
1136
    test_t *test;
1134
    uint32_t cnt = argv[1].intval;
1137
    uint32_t cnt = argv[1].intval;
1135
   
1138
   
-
 
1139
    if (str_cmp((char *) argv->buffer, "*") == 0) {
-
 
1140
        for (test = tests; test->name != NULL; test++) {
-
 
1141
            if (test->safe) {
-
 
1142
                if (!run_bench(test, cnt))
-
 
1143
                    break;
-
 
1144
            }
-
 
1145
        }
-
 
1146
    } else {
1136
    bool fnd = false;
1147
        bool fnd = false;
1137
   
1148
       
1138
    for (test = tests; test->name != NULL; test++) {
1149
        for (test = tests; test->name != NULL; test++) {
1139
        if (strcmp(test->name, (char *) argv->buffer) == 0) {
1150
            if (str_cmp(test->name, (char *) argv->buffer) == 0) {
1140
            fnd = true;
1151
                fnd = true;
1141
           
1152
               
1142
            if (test->safe)
1153
                if (test->safe)
1143
                run_bench(test, cnt);
1154
                    run_bench(test, cnt);
1144
            else
1155
                else
Line 1148... Line 1159...
1148
        }
1159
            }
1149
    }
1160
        }
1150
       
1161
       
1151
    if (!fnd)
1162
        if (!fnd)
1152
        printf("Unknown test\n");
1163
            printf("Unknown test\n");
-
 
1164
    }
1153
 
1165
   
1154
    return 1;
1166
    return 1;
1155
}
1167
}
1156
 
1168
 
1157
#endif
1169
#endif