Rev 2020 | Rev 2030 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2020 | Rev 2027 | ||
---|---|---|---|
Line 67... | Line 67... | ||
67 | 67 | ||
68 | #ifdef CONFIG_TEST |
68 | #ifdef CONFIG_TEST |
69 | #include <test.h> |
69 | #include <test.h> |
70 | #endif |
70 | #endif |
71 | 71 | ||
- | 72 | #ifdef CONFIG_BENCH |
|
- | 73 | #include <arch/cycle.h> |
|
- | 74 | #endif |
|
- | 75 | ||
72 | /* Data and methods for 'help' command. */ |
76 | /* Data and methods for 'help' command. */ |
73 | static int cmd_help(cmd_arg_t *argv); |
77 | static int cmd_help(cmd_arg_t *argv); |
74 | static cmd_info_t help_info = { |
78 | static cmd_info_t help_info = { |
75 | .name = "help", |
79 | .name = "help", |
76 | .description = "List of supported commands.", |
80 | .description = "List of supported commands.", |
Line 856... | Line 860... | ||
856 | 860 | ||
857 | printf("*\t\tRun all safe tests\n"); |
861 | printf("*\t\tRun all safe tests\n"); |
858 | return 1; |
862 | return 1; |
859 | } |
863 | } |
860 | 864 | ||
- | 865 | static bool run_test(const test_t * test) |
|
- | 866 | { |
|
- | 867 | printf("%s\t\t%s\n", test->name, test->desc); |
|
- | 868 | #ifdef CONFIG_BENCH |
|
- | 869 | uint64_t t0 = get_cycle(); |
|
- | 870 | #endif |
|
- | 871 | char * ret = test->entry(); |
|
- | 872 | #ifdef CONFIG_BENCH |
|
- | 873 | uint64_t dt = get_cycle() - t0; |
|
- | 874 | printf("Time: %llu cycles\n", dt); |
|
- | 875 | #endif |
|
- | 876 | ||
- | 877 | if (ret == NULL) { |
|
- | 878 | printf("Test passed\n"); |
|
- | 879 | return true; |
|
- | 880 | } |
|
- | 881 | ||
- | 882 | printf("%s\n", ret); |
|
- | 883 | return false; |
|
- | 884 | } |
|
- | 885 | ||
861 | /** Command for returning kernel tests |
886 | /** Command for returning kernel tests |
862 | * |
887 | * |
863 | * @param argv Argument vector. |
888 | * @param argv Argument vector. |
864 | * |
889 | * |
865 | * return Always 1. |
890 | * return Always 1. |
Line 869... | Line 894... | ||
869 | test_t *test; |
894 | test_t *test; |
870 | 895 | ||
871 | if (strcmp(argv->buffer, "*") == 0) { |
896 | if (strcmp(argv->buffer, "*") == 0) { |
872 | for (test = tests; test->name != NULL; test++) { |
897 | for (test = tests; test->name != NULL; test++) { |
873 | if (test->safe) { |
898 | if (test->safe) { |
- | 899 | printf("\n"); |
|
874 | printf("\n%s\t\t%s\n\n", test->name, test->desc); |
900 | if (!run_test(test)) |
875 | test->entry(); |
901 | break; |
876 | } |
902 | } |
877 | } |
903 | } |
878 | } else { |
904 | } else { |
879 | bool fnd = false; |
905 | bool fnd = false; |
880 | 906 | ||
881 | for (test = tests; test->name != NULL; test++) { |
907 | for (test = tests; test->name != NULL; test++) { |
882 | if (strcmp(test->name, argv->buffer) == 0) { |
908 | if (strcmp(test->name, argv->buffer) == 0) { |
883 | fnd = true; |
909 | fnd = true; |
884 | test->entry(); |
910 | run_test(test); |
885 | break; |
911 | break; |
886 | } |
912 | } |
887 | } |
913 | } |
888 | 914 | ||
889 | if (!fnd) |
915 | if (!fnd) |
890 | printf("Unknown test.\n"); |
916 | printf("Unknown test\n"); |
891 | } |
917 | } |
892 | 918 | ||
893 | return 1; |
919 | return 1; |
894 | } |
920 | } |
895 | #endif |
921 | #endif |