Igor Opaniuk | 136644a | 2016-09-13 13:40:56 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015, Linaro Limited |
| 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> |
| 15 | #include <stdlib.h> |
| 16 | #include <string.h> |
| 17 | |
| 18 | #include "xtest_test.h" |
| 19 | #include "xtest_helpers.h" |
| 20 | |
| 21 | #include <sha_perf.h> |
| 22 | #include <util.h> |
| 23 | |
| 24 | #define SHA_PERF_COUNT 5000 /* Number of measurements */ |
| 25 | #define SHA_PERF_WARMUP 2 /* Start with a 2-second busy loop */ |
| 26 | #define SHA_PERF_LOOPS 1 /* Inner loops */ |
| 27 | #define SHA_PERF_RANDOM_IN 1 /* Get input data from /dev/urandom */ |
| 28 | #define SHA_PERF_VERBOSITY 0 |
| 29 | |
| 30 | |
| 31 | |
| 32 | static void xtest_tee_benchmark_2001(ADBG_Case_t *Case_p); |
| 33 | static void xtest_tee_benchmark_2002(ADBG_Case_t *Case_p); |
| 34 | |
| 35 | static void xtest_tee_benchmark_2001(ADBG_Case_t *c) |
| 36 | { |
| 37 | UNUSED(c); |
| 38 | |
| 39 | int algo = TA_SHA_SHA1; /* Algorithm */ |
| 40 | size_t size = 1024; /* Buffer size */ |
| 41 | int offset = 0; /* Buffer offset wrt. alloc'ed address */ |
| 42 | |
| 43 | sha_perf_run_test(algo, size, SHA_PERF_COUNT, |
| 44 | SHA_PERF_LOOPS, SHA_PERF_RANDOM_IN, offset, |
| 45 | SHA_PERF_WARMUP, SHA_PERF_VERBOSITY); |
| 46 | |
| 47 | } |
| 48 | |
| 49 | static void xtest_tee_benchmark_2002(ADBG_Case_t *c) |
| 50 | { |
| 51 | UNUSED(c); |
| 52 | |
| 53 | int algo = TA_SHA_SHA256; /* Algorithm */ |
| 54 | size_t size = 4096; /* Buffer size */ |
| 55 | int offset = 0; /* Buffer offset wrt. alloc'ed address */ |
| 56 | |
| 57 | sha_perf_run_test(algo, size, SHA_PERF_COUNT, |
| 58 | SHA_PERF_LOOPS, SHA_PERF_RANDOM_IN, offset, |
| 59 | SHA_PERF_WARMUP, SHA_PERF_VERBOSITY); |
| 60 | |
| 61 | } |
| 62 | |
| 63 | ADBG_CASE_DEFINE(XTEST_TEE_BENCHMARK_2001, xtest_tee_benchmark_2001, |
| 64 | /* Title */ |
| 65 | "TEE SHA Performance test (TA_SHA_SHA1)", |
| 66 | /* Short description */ |
| 67 | "Hashing 1024 bytes buffer with SHA1 algo, offset = 0", |
| 68 | /* Requirement IDs */ "", |
| 69 | /* How to implement */ "" |
| 70 | ); |
| 71 | |
| 72 | ADBG_CASE_DEFINE(XTEST_TEE_BENCHMARK_2002, xtest_tee_benchmark_2002, |
| 73 | /* Title */ |
| 74 | "TEE SHA Performance test (TA_SHA_SHA226)", |
| 75 | /* Short description */ |
| 76 | "Hashing 4096 bytes buffer with SHA256 algo, offset = 0", |
| 77 | /* Requirement IDs */ "", |
| 78 | /* How to implement */ "" |
| 79 | ); |
| 80 | |