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