blob: 3d51ac05603809fd0f05cff4fc55ee96b2b4d034 [file] [log] [blame]
Pascal Brandc639ac82015-07-02 08:53:34 +02001/*
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 Chaumontc3b6c282015-09-25 03:05:18 +020015#include <stdlib.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020016#include <string.h>
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020017#include <unistd.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020018
19#include <adbg.h>
20#include "xtest_test.h"
21#include "xtest_helpers.h"
Igor Opaniuk136644a2016-09-13 13:40:56 +030022
23/* include here shandalone tests */
Igor Opaniukf9b7fd22016-09-16 16:22:34 +030024#include "crypto_common.h"
Igor Opaniuk136644a2016-09-13 13:40:56 +030025
Pascal Brandc639ac82015-07-02 08:53:34 +020026
Jens Wiklander74abfe32017-01-03 14:17:47 +010027ADBG_SUITE_DEFINE(regression);
28ADBG_SUITE_DEFINE(benchmark);
Igor Opaniuk136644a2016-09-13 13:40:56 +030029
Jens Wiklander2190cdc2015-03-31 13:37:09 +020030char *_device = NULL;
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020031unsigned int level = 0;
32static const char glevel[] = "0";
James Kung35b352d2015-09-07 18:01:16 +080033static const char gsuitename[] = "regression";
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020034
35void usage(char *program);
36
37void usage(char *program)
38{
39 printf("Usage: %s <options> <test_id>\n", program);
40 printf("\n");
41 printf("options:\n");
Jens Wiklander2190cdc2015-03-31 13:37:09 +020042 printf("\t-d <device-type> default not set, use any\n");
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020043 printf("\t-l <level> test suite level: [0-15]\n");
Jens Wiklander569b8622015-12-03 11:23:09 +010044 printf("\t-t <test_suite> available test suite: regression, benchmark\n");
James Kung35b352d2015-09-07 18:01:16 +080045 printf("\t default value = %s\n", gsuitename);
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020046 printf("\t-h show usage\n");
Igor Opaniuk136644a2016-09-13 13:40:56 +030047 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 Chaumontc3b6c282015-09-25 03:05:18 +020050 printf("\n");
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030051 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 Chaumontc3b6c282015-09-25 03:05:18 +020054}
Pascal Brandc639ac82015-07-02 08:53:34 +020055
56int main(int argc, char *argv[])
57{
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020058 int opt;
59 int index;
60 int ret;
61 char *p = (char *)glevel;
James Kung35b352d2015-09-07 18:01:16 +080062 char *test_suite = (char *)gsuitename;
Pascal Brandc639ac82015-07-02 08:53:34 +020063
James Kung35b352d2015-09-07 18:01:16 +080064 opterr = 0;
65
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030066 if (argc > 1 && !strcmp(argv[1], "--sha-perf"))
Igor Opaniuk136644a2016-09-13 13:40:56 +030067 return sha_perf_runner_cmd_parser(argc-1, &argv[1]);
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030068 else if (argc > 1 && !strcmp(argv[1], "--aes-perf"))
69 return aes_perf_runner_cmd_parser(argc-1, &argv[1]);
Igor Opaniuk136644a2016-09-13 13:40:56 +030070
James Kung35b352d2015-09-07 18:01:16 +080071 while ((opt = getopt(argc, argv, "d:l:t:h")) != -1)
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020072 switch (opt) {
73 case 'd':
74 _device = optarg;
75 break;
76 case 'l':
77 p = optarg;
78 break;
James Kung35b352d2015-09-07 18:01:16 +080079 case 't':
80 test_suite = optarg;
81 break;
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020082 case 'h':
83 usage(argv[0]);
84 return 0;
85 default:
86 usage(argv[0]);
87 return -1;
88 }
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020089
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 Brandc639ac82015-07-02 08:53:34 +020099 printf("\nTEE test application started with device [%s]\n", _device);
100
101 xtest_teec_ctx_init();
102
Jens Wiklander569b8622015-12-03 11:23:09 +0100103 if (strcmp(test_suite, "regression") == 0)
Jens Wiklander74abfe32017-01-03 14:17:47 +0100104 ret = Do_ADBG_RunSuite(&ADBG_Suite_regression,
105 argc - optind, argv + optind);
James Kung35b352d2015-09-07 18:01:16 +0800106 else if (strcmp(test_suite, "benchmark") == 0)
Jens Wiklander74abfe32017-01-03 14:17:47 +0100107 ret = Do_ADBG_RunSuite(&ADBG_Suite_benchmark,
108 argc - optind, argv + optind);
James Kung35b352d2015-09-07 18:01:16 +0800109 else {
110 fprintf(stderr, "No test suite found: %s\n", test_suite);
111 ret = -1;
112 }
Pascal Brandc639ac82015-07-02 08:53:34 +0200113
114 xtest_teec_ctx_deinit();
115
116 printf("TEE test application done!\n");
117 return ret;
118}