Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014, STMicroelectronics International N.V. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License Version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | |
| 14 | #include <stdio.h> |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 15 | #include <stdlib.h> |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 16 | #include <string.h> |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 17 | #include <unistd.h> |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 18 | |
| 19 | #include <adbg.h> |
| 20 | #include "xtest_test.h" |
| 21 | #include "xtest_helpers.h" |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 22 | |
| 23 | /* include here shandalone tests */ |
Igor Opaniuk | f9b7fd2 | 2016-09-16 16:22:34 +0300 | [diff] [blame] | 24 | #include "crypto_common.h" |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 25 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 26 | |
Jens Wiklander | 74abfe3 | 2017-01-03 14:17:47 +0100 | [diff] [blame] | 27 | ADBG_SUITE_DEFINE(regression); |
| 28 | ADBG_SUITE_DEFINE(benchmark); |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 29 | |
Jens Wiklander | 2190cdc | 2015-03-31 13:37:09 +0200 | [diff] [blame] | 30 | char *_device = NULL; |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 31 | unsigned int level = 0; |
| 32 | static const char glevel[] = "0"; |
James Kung | 35b352d | 2015-09-07 18:01:16 +0800 | [diff] [blame] | 33 | static const char gsuitename[] = "regression"; |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 34 | |
| 35 | void usage(char *program); |
| 36 | |
| 37 | void usage(char *program) |
| 38 | { |
| 39 | printf("Usage: %s <options> <test_id>\n", program); |
| 40 | printf("\n"); |
| 41 | printf("options:\n"); |
Jens Wiklander | 2190cdc | 2015-03-31 13:37:09 +0200 | [diff] [blame] | 42 | printf("\t-d <device-type> default not set, use any\n"); |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 43 | printf("\t-l <level> test suite level: [0-15]\n"); |
Jens Wiklander | 569b862 | 2015-12-03 11:23:09 +0100 | [diff] [blame] | 44 | printf("\t-t <test_suite> available test suite: regression, benchmark\n"); |
James Kung | 35b352d | 2015-09-07 18:01:16 +0800 | [diff] [blame] | 45 | printf("\t default value = %s\n", gsuitename); |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 46 | printf("\t-h show usage\n"); |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 47 | printf("applets:\n"); |
| 48 | printf("\t--sha-perf SHA performance testing tool for OP-TEE\n"); |
| 49 | printf("\t--sha perf -h show usage of SHA performance testing tool\n"); |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 50 | printf("\n"); |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 51 | printf("\t--aes-perf AES performance testing tool for OP-TEE\n"); |
| 52 | printf("\t--aes perf -h show usage of AES performance testing tool\n"); |
| 53 | printf("\n"); |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 54 | } |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 55 | |
| 56 | int main(int argc, char *argv[]) |
| 57 | { |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 58 | int opt; |
| 59 | int index; |
| 60 | int ret; |
| 61 | char *p = (char *)glevel; |
James Kung | 35b352d | 2015-09-07 18:01:16 +0800 | [diff] [blame] | 62 | char *test_suite = (char *)gsuitename; |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 63 | |
James Kung | 35b352d | 2015-09-07 18:01:16 +0800 | [diff] [blame] | 64 | opterr = 0; |
| 65 | |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 66 | if (argc > 1 && !strcmp(argv[1], "--sha-perf")) |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 67 | return sha_perf_runner_cmd_parser(argc-1, &argv[1]); |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 68 | else if (argc > 1 && !strcmp(argv[1], "--aes-perf")) |
| 69 | return aes_perf_runner_cmd_parser(argc-1, &argv[1]); |
Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 70 | |
James Kung | 35b352d | 2015-09-07 18:01:16 +0800 | [diff] [blame] | 71 | while ((opt = getopt(argc, argv, "d:l:t:h")) != -1) |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 72 | switch (opt) { |
| 73 | case 'd': |
| 74 | _device = optarg; |
| 75 | break; |
| 76 | case 'l': |
| 77 | p = optarg; |
| 78 | break; |
James Kung | 35b352d | 2015-09-07 18:01:16 +0800 | [diff] [blame] | 79 | case 't': |
| 80 | test_suite = optarg; |
| 81 | break; |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 82 | case 'h': |
| 83 | usage(argv[0]); |
| 84 | return 0; |
| 85 | default: |
| 86 | usage(argv[0]); |
| 87 | return -1; |
| 88 | } |
Cedric Chaumont | c3b6c28 | 2015-09-25 03:05:18 +0200 | [diff] [blame] | 89 | |
| 90 | for (index = optind; index < argc; index++) |
| 91 | printf("Test ID: %s\n", argv[index]); |
| 92 | |
| 93 | if (p) |
| 94 | level = atoi(p); |
| 95 | else |
| 96 | level = 0; |
| 97 | printf("Run test suite with level=%d\n", level); |
| 98 | |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 99 | printf("\nTEE test application started with device [%s]\n", _device); |
| 100 | |
| 101 | xtest_teec_ctx_init(); |
| 102 | |
Jens Wiklander | 569b862 | 2015-12-03 11:23:09 +0100 | [diff] [blame] | 103 | if (strcmp(test_suite, "regression") == 0) |
Jens Wiklander | 74abfe3 | 2017-01-03 14:17:47 +0100 | [diff] [blame] | 104 | ret = Do_ADBG_RunSuite(&ADBG_Suite_regression, |
| 105 | argc - optind, argv + optind); |
James Kung | 35b352d | 2015-09-07 18:01:16 +0800 | [diff] [blame] | 106 | else if (strcmp(test_suite, "benchmark") == 0) |
Jens Wiklander | 74abfe3 | 2017-01-03 14:17:47 +0100 | [diff] [blame] | 107 | ret = Do_ADBG_RunSuite(&ADBG_Suite_benchmark, |
| 108 | argc - optind, argv + optind); |
James Kung | 35b352d | 2015-09-07 18:01:16 +0800 | [diff] [blame] | 109 | else { |
| 110 | fprintf(stderr, "No test suite found: %s\n", test_suite); |
| 111 | ret = -1; |
| 112 | } |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 113 | |
| 114 | xtest_teec_ctx_deinit(); |
| 115 | |
| 116 | printf("TEE test application done!\n"); |
| 117 | return ret; |
| 118 | } |