blob: 3c02befa0a2e2d8a0adc5cc115914ddfb175272a [file] [log] [blame]
Pascal Brandc639ac82015-07-02 08:53:34 +02001/*
Jens Wiklander02389a92016-12-16 11:13:38 +01002 * Copyright (c) 2016, Linaro Limited
Pascal Brandc639ac82015-07-02 08:53:34 +02003 * 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 Wiklander02389a92016-12-16 11:13:38 +010015#include <err.h>
16#include <signal.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020017#include <stdio.h>
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020018#include <stdlib.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020019#include <string.h>
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020020#include <unistd.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020021
22#include <adbg.h>
23#include "xtest_test.h"
24#include "xtest_helpers.h"
Igor Opaniuk136644a2016-09-13 13:40:56 +030025
26/* include here shandalone tests */
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030027#include "crypto_common.h"
Igor Opaniuk136644a2016-09-13 13:40:56 +030028
Pascal Brandc639ac82015-07-02 08:53:34 +020029
Jens Wiklander74abfe32017-01-03 14:17:47 +010030ADBG_SUITE_DEFINE(regression);
31ADBG_SUITE_DEFINE(benchmark);
Igor Opaniuk136644a2016-09-13 13:40:56 +030032
Jens Wiklander2190cdc2015-03-31 13:37:09 +020033char *_device = NULL;
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020034unsigned int level = 0;
35static const char glevel[] = "0";
James Kung35b352d2015-09-07 18:01:16 +080036static const char gsuitename[] = "regression";
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020037
38void usage(char *program);
39
40void usage(char *program)
41{
42 printf("Usage: %s <options> <test_id>\n", program);
43 printf("\n");
44 printf("options:\n");
Jens Wiklander2190cdc2015-03-31 13:37:09 +020045 printf("\t-d <device-type> default not set, use any\n");
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020046 printf("\t-l <level> test suite level: [0-15]\n");
Jens Wiklander569b8622015-12-03 11:23:09 +010047 printf("\t-t <test_suite> available test suite: regression, benchmark\n");
James Kung35b352d2015-09-07 18:01:16 +080048 printf("\t default value = %s\n", gsuitename);
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020049 printf("\t-h show usage\n");
Igor Opaniuk136644a2016-09-13 13:40:56 +030050 printf("applets:\n");
51 printf("\t--sha-perf SHA performance testing tool for OP-TEE\n");
52 printf("\t--sha perf -h show usage of SHA performance testing tool\n");
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020053 printf("\n");
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030054 printf("\t--aes-perf AES performance testing tool for OP-TEE\n");
55 printf("\t--aes perf -h show usage of AES performance testing tool\n");
56 printf("\n");
Etienne Carriere41343db2017-03-17 15:38:52 +010057#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 Chaumontc3b6c282015-09-25 03:05:18 +020061}
Pascal Brandc639ac82015-07-02 08:53:34 +020062
63int main(int argc, char *argv[])
64{
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020065 int opt;
66 int index;
67 int ret;
68 char *p = (char *)glevel;
James Kung35b352d2015-09-07 18:01:16 +080069 char *test_suite = (char *)gsuitename;
Pascal Brandc639ac82015-07-02 08:53:34 +020070
James Kung35b352d2015-09-07 18:01:16 +080071 opterr = 0;
72
Jens Wiklander02389a92016-12-16 11:13:38 +010073 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 Opaniuk44aff4b2016-09-16 10:18:00 +030079 if (argc > 1 && !strcmp(argv[1], "--sha-perf"))
Igor Opaniuk136644a2016-09-13 13:40:56 +030080 return sha_perf_runner_cmd_parser(argc-1, &argv[1]);
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030081 else if (argc > 1 && !strcmp(argv[1], "--aes-perf"))
82 return aes_perf_runner_cmd_parser(argc-1, &argv[1]);
Etienne Carriere41343db2017-03-17 15:38:52 +010083#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 Opaniuk136644a2016-09-13 13:40:56 +030087
James Kung35b352d2015-09-07 18:01:16 +080088 while ((opt = getopt(argc, argv, "d:l:t:h")) != -1)
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020089 switch (opt) {
90 case 'd':
91 _device = optarg;
92 break;
93 case 'l':
94 p = optarg;
95 break;
James Kung35b352d2015-09-07 18:01:16 +080096 case 't':
97 test_suite = optarg;
98 break;
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020099 case 'h':
100 usage(argv[0]);
101 return 0;
102 default:
103 usage(argv[0]);
104 return -1;
105 }
Cedric Chaumontc3b6c282015-09-25 03:05:18 +0200106
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 Brandc639ac82015-07-02 08:53:34 +0200116 printf("\nTEE test application started with device [%s]\n", _device);
117
118 xtest_teec_ctx_init();
119
Jens Wiklander569b8622015-12-03 11:23:09 +0100120 if (strcmp(test_suite, "regression") == 0)
Jens Wiklander74abfe32017-01-03 14:17:47 +0100121 ret = Do_ADBG_RunSuite(&ADBG_Suite_regression,
122 argc - optind, argv + optind);
James Kung35b352d2015-09-07 18:01:16 +0800123 else if (strcmp(test_suite, "benchmark") == 0)
Jens Wiklander74abfe32017-01-03 14:17:47 +0100124 ret = Do_ADBG_RunSuite(&ADBG_Suite_benchmark,
125 argc - optind, argv + optind);
James Kung35b352d2015-09-07 18:01:16 +0800126 else {
127 fprintf(stderr, "No test suite found: %s\n", test_suite);
128 ret = -1;
129 }
Pascal Brandc639ac82015-07-02 08:53:34 +0200130
131 xtest_teec_ctx_deinit();
132
133 printf("TEE test application done!\n");
134 return ret;
135}