Rev 2030 | Rev 2042 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2030 | Rev 2039 | ||
|---|---|---|---|
| Line 54... | Line 54... | ||
| 54 | #include <debug.h> |
54 | #include <debug.h> |
| 55 | #include <symtab.h> |
55 | #include <symtab.h> |
| 56 | #include <cpu.h> |
56 | #include <cpu.h> |
| 57 | #include <mm/tlb.h> |
57 | #include <mm/tlb.h> |
| 58 | #include <arch/mm/tlb.h> |
58 | #include <arch/mm/tlb.h> |
| - | 59 | #include <mm/as.h> |
|
| 59 | #include <mm/frame.h> |
60 | #include <mm/frame.h> |
| 60 | #include <main/version.h> |
61 | #include <main/version.h> |
| 61 | #include <mm/slab.h> |
62 | #include <mm/slab.h> |
| 62 | #include <proc/scheduler.h> |
63 | #include <proc/scheduler.h> |
| 63 | #include <proc/thread.h> |
64 | #include <proc/thread.h> |
| Line 856... | Line 857... | ||
| 856 | 857 | ||
| 857 | printf("*\t\tRun all safe tests\n"); |
858 | printf("*\t\tRun all safe tests\n"); |
| 858 | return 1; |
859 | return 1; |
| 859 | } |
860 | } |
| 860 | 861 | ||
| 861 | static bool run_test(const test_t * test) |
862 | static void test_wrapper(void *arg) |
| 862 | { |
863 | { |
| 863 | printf("%s\t\t%s\n", test->name, test->desc); |
864 | test_t *test = (test_t *) arg; |
| 864 | 865 | ||
| 865 | /* Update and read thread accounting |
866 | /* Update and read thread accounting |
| 866 | for benchmarking */ |
867 | for benchmarking */ |
| 867 | ipl_t ipl = interrupts_disable(); |
868 | ipl_t ipl = interrupts_disable(); |
| 868 | spinlock_lock(&THREAD->lock); |
869 | spinlock_lock(&TASK->lock); |
| 869 | thread_update_accounting(); |
870 | uint64_t t0 = task_get_accounting(TASK); |
| 870 | uint64_t t0 = THREAD->cycles; |
- | |
| 871 | spinlock_unlock(&THREAD->lock); |
871 | spinlock_unlock(&TASK->lock); |
| 872 | interrupts_restore(ipl); |
872 | interrupts_restore(ipl); |
| 873 | 873 | ||
| 874 | /* Execute the test */ |
874 | /* Execute the test */ |
| 875 | char * ret = test->entry(); |
875 | char * ret = test->entry(); |
| 876 | 876 | ||
| 877 | /* Update and read thread accounting */ |
877 | /* Update and read thread accounting */ |
| 878 | ipl = interrupts_disable(); |
878 | ipl = interrupts_disable(); |
| 879 | spinlock_lock(&THREAD->lock); |
879 | spinlock_lock(&TASK->lock); |
| 880 | thread_update_accounting(); |
- | |
| 881 | uint64_t dt = THREAD->cycles - t0; |
880 | uint64_t dt = task_get_accounting(TASK) - t0; |
| 882 | spinlock_unlock(&THREAD->lock); |
881 | spinlock_unlock(&TASK->lock); |
| 883 | interrupts_restore(ipl); |
882 | interrupts_restore(ipl); |
| 884 | 883 | ||
| 885 | printf("Time: %llu cycles\n", dt); |
884 | printf("Time: %llu cycles\n", dt); |
| 886 | 885 | ||
| 887 | if (ret == NULL) { |
886 | if (ret == NULL) { |
| 888 | printf("Test passed\n"); |
887 | printf("Test passed\n"); |
| 889 | return true; |
888 | // return true; |
| - | 889 | return; |
|
| 890 | } |
890 | } |
| 891 | 891 | ||
| 892 | printf("%s\n", ret); |
892 | printf("%s\n", ret); |
| - | 893 | // return false; |
|
| - | 894 | } |
|
| - | 895 | ||
| - | 896 | static bool run_test(const test_t *test) |
|
| - | 897 | { |
|
| - | 898 | printf("%s\t\t%s\n", test->name, test->desc); |
|
| - | 899 | ||
| - | 900 | /* Create separate task and thread |
|
| - | 901 | for the test */ |
|
| - | 902 | task_t *ta = task_create(AS_KERNEL, "test"); |
|
| - | 903 | if (ta == NULL) { |
|
| - | 904 | printf("Unable to create test task\n"); |
|
| 893 | return false; |
905 | return false; |
| - | 906 | } |
|
| - | 907 | ||
| - | 908 | thread_t *t = thread_create(test_wrapper, (void *) test, ta, 0, "test_main"); |
|
| - | 909 | if (t == NULL) { |
|
| - | 910 | printf("Unable to create test main thread\n"); |
|
| - | 911 | task_destroy(ta); |
|
| - | 912 | return false; |
|
| - | 913 | } |
|
| - | 914 | ||
| - | 915 | /* Run the test */ |
|
| - | 916 | thread_ready(t); |
|
| - | 917 | thread_join(t); |
|
| - | 918 | thread_detach(t); |
|
| - | 919 | ||
| - | 920 | return true; |
|
| 894 | } |
921 | } |
| 895 | 922 | ||
| 896 | /** Command for returning kernel tests |
923 | /** Command for returning kernel tests |
| 897 | * |
924 | * |
| 898 | * @param argv Argument vector. |
925 | * @param argv Argument vector. |