blob: 1b433615e7964d458fc02ef21060c42886be716e [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");
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020057}
Pascal Brandc639ac82015-07-02 08:53:34 +020058
59int main(int argc, char *argv[])
60{
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020061 int opt;
62 int index;
63 int ret;
64 char *p = (char *)glevel;
James Kung35b352d2015-09-07 18:01:16 +080065 char *test_suite = (char *)gsuitename;
Pascal Brandc639ac82015-07-02 08:53:34 +020066
James Kung35b352d2015-09-07 18:01:16 +080067 opterr = 0;
68
Jens Wiklander02389a92016-12-16 11:13:38 +010069 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
70 warn("signal(SIGPIPE, SIG_IGN)");
71
72 if (signal(SIGHUP, SIG_IGN) == SIG_ERR)
73 warn("signal(SIGPIPE, SIG_IGN)");
74
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030075 if (argc > 1 && !strcmp(argv[1], "--sha-perf"))
Igor Opaniuk136644a2016-09-13 13:40:56 +030076 return sha_perf_runner_cmd_parser(argc-1, &argv[1]);
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030077 else if (argc > 1 && !strcmp(argv[1], "--aes-perf"))
78 return aes_perf_runner_cmd_parser(argc-1, &argv[1]);
Igor Opaniuk136644a2016-09-13 13:40:56 +030079
James Kung35b352d2015-09-07 18:01:16 +080080 while ((opt = getopt(argc, argv, "d:l:t:h")) != -1)
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020081 switch (opt) {
82 case 'd':
83 _device = optarg;
84 break;
85 case 'l':
86 p = optarg;
87 break;
James Kung35b352d2015-09-07 18:01:16 +080088 case 't':
89 test_suite = optarg;
90 break;
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020091 case 'h':
92 usage(argv[0]);
93 return 0;
94 default:
95 usage(argv[0]);
96 return -1;
97 }
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020098
99 for (index = optind; index < argc; index++)
100 printf("Test ID: %s\n", argv[index]);
101
102 if (p)
103 level = atoi(p);
104 else
105 level = 0;
106 printf("Run test suite with level=%d\n", level);
107
Pascal Brandc639ac82015-07-02 08:53:34 +0200108 printf("\nTEE test application started with device [%s]\n", _device);
109
110 xtest_teec_ctx_init();
111
Jens Wiklander569b8622015-12-03 11:23:09 +0100112 if (strcmp(test_suite, "regression") == 0)
Jens Wiklander74abfe32017-01-03 14:17:47 +0100113 ret = Do_ADBG_RunSuite(&ADBG_Suite_regression,
114 argc - optind, argv + optind);
James Kung35b352d2015-09-07 18:01:16 +0800115 else if (strcmp(test_suite, "benchmark") == 0)
Jens Wiklander74abfe32017-01-03 14:17:47 +0100116 ret = Do_ADBG_RunSuite(&ADBG_Suite_benchmark,
117 argc - optind, argv + optind);
James Kung35b352d2015-09-07 18:01:16 +0800118 else {
119 fprintf(stderr, "No test suite found: %s\n", test_suite);
120 ret = -1;
121 }
Pascal Brandc639ac82015-07-02 08:53:34 +0200122
123 xtest_teec_ctx_deinit();
124
125 printf("TEE test application done!\n");
126 return ret;
127}