Unified the acc test framework. This framework is used to run algorithm correctness. It can helps developers with feature self-testing. Only supports sec engine self-testing currently. Such as: test_sec_sva --cipher 0 --sync --optype 0 --pktlen 16 --keylen \ 16 --times 1 --multi 1 after: uadk_tool test --m sec --cipher 0 --sync --optype 0 --pktlen 16 \ --keylen 16 --times 1 --multi 1
Signed-off-by: Kai Ye yekai13@huawei.com --- configure.ac | 1 - test/Makefile.am | 3 +- test/hisi_sec_test/Makefile.am | 15 ---- test/wd_mempool_test.c | 2 +- uadk_tool/Makefile.am | 4 +- .../test/sec_template_tv.h | 6 +- .../test/test_sec.c | 42 ++++----- uadk_tool/test/test_sec.h | 7 ++ uadk_tool/test/uadk_test.c | 85 +++++++++++++++++++ uadk_tool/test/uadk_test.h | 7 ++ uadk_tool/uadk_tool.c | 7 +- 11 files changed, 136 insertions(+), 43 deletions(-) delete mode 100644 test/hisi_sec_test/Makefile.am rename test/hisi_sec_test/test_hisi_sec.h => uadk_tool/test/sec_template_tv.h (99%) rename test/hisi_sec_test/test_hisi_sec.c => uadk_tool/test/test_sec.c (98%) mode change 100755 => 100644 create mode 100644 uadk_tool/test/test_sec.h create mode 100644 uadk_tool/test/uadk_test.c create mode 100644 uadk_tool/test/uadk_test.h
diff --git a/configure.ac b/configure.ac index 3eb853f..7109d97 100644 --- a/configure.ac +++ b/configure.ac @@ -91,7 +91,6 @@ AC_CONFIG_FILES([Makefile lib/libwd_crypto.pc lib/libwd_comp.pc lib/libwd.pc test/Makefile test/hisi_hpre_test/Makefile - test/hisi_sec_test/Makefile test/hisi_zip_test/Makefile uadk_tool/Makefile sample/Makefile diff --git a/test/Makefile.am b/test/Makefile.am index 860a103..8da1afb 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -12,8 +12,7 @@ wd_mempool_test_LDADD=-L../.libs -lwd -lwd_crypto -lnuma -lpthread endif wd_mempool_test_LDFLAGS=-Wl,-rpath,'/usr/local/lib'
-SUBDIRS=. hisi_sec_test - +SUBDIRS = . if HAVE_CRYPTO SUBDIRS += hisi_hpre_test
diff --git a/test/hisi_sec_test/Makefile.am b/test/hisi_sec_test/Makefile.am deleted file mode 100644 index 9955ab1..0000000 --- a/test/hisi_sec_test/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -AM_CFLAGS=-Wall -Werror -fno-strict-aliasing -I$(top_srcdir)/include -pthread -AUTOMAKE_OPTIONS = subdir-objects - -bin_PROGRAMS=test_hisi_sec - -test_hisi_sec_SOURCES=test_hisi_sec.c - -if WD_STATIC_DRV -AM_CFLAGS+=-Bstatic -test_hisi_sec_LDADD=../../.libs/libwd.a ../../.libs/libwd_crypto.a \ - ../../.libs/libhisi_sec.a -lnuma -else -test_hisi_sec_LDADD=-L../../.libs -l:libwd.so.2 -l:libwd_crypto.so.2 -lnuma -endif -test_hisi_sec_LDFLAGS=-Wl,-rpath,'/usr/local/lib' diff --git a/test/wd_mempool_test.c b/test/wd_mempool_test.c index cf6be70..ad04636 100644 --- a/test/wd_mempool_test.c +++ b/test/wd_mempool_test.c @@ -20,7 +20,7 @@ #include <sys/mman.h> #include <sys/time.h>
-#include "hisi_sec_test/test_hisi_sec.h" +#include "../uadk_tool/test/sec_template_tv.h" #include "wd.h" #include "wd_cipher.h" #include "wd_sched.h" diff --git a/uadk_tool/Makefile.am b/uadk_tool/Makefile.am index d5b125f..6d0450e 100644 --- a/uadk_tool/Makefile.am +++ b/uadk_tool/Makefile.am @@ -14,7 +14,9 @@ uadk_tool_SOURCES=uadk_tool.c dfx/uadk_dfx.c dfx/uadk_dfx.h \ benchmark/hpre_uadk_benchmark.c benchmark/hpre_uadk_benchmark.h \ benchmark/hpre_wd_benchmark.c hpre_wd_benchmark.h \ benchmark/zip_uadk_benchmark.c benchmark/zip_uadk_benchmark.h \ - benchmark/zip_wd_benchmark.c benchmark/zip_wd_benchmark.h + benchmark/zip_wd_benchmark.c benchmark/zip_wd_benchmark.h \ + test/uadk_test.c test/uadk_test.h \ + test/test_sec.c test/test_sec.h test/sec_template_tv.h
if WD_STATIC_DRV AM_CFLAGS+=-Bstatic diff --git a/test/hisi_sec_test/test_hisi_sec.h b/uadk_tool/test/sec_template_tv.h similarity index 99% rename from test/hisi_sec_test/test_hisi_sec.h rename to uadk_tool/test/sec_template_tv.h index 8e21681..1a6f960 100644 --- a/test/hisi_sec_test/test_hisi_sec.h +++ b/uadk_tool/test/sec_template_tv.h @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright 2020-2021 Huawei Technologies Co.,Ltd. All rights reserved. */
-#ifndef TEST_HISI_SEC_H_ -#define TEST_HISI_SEC_H +#ifndef SEC_TEMPLATE_TV_H +#define SEC_TEMPLATE_TV_H
enum alg_class { CIPHER_CLASS, @@ -1840,4 +1840,4 @@ struct aead_testvec sm4_gcm_tv_template_128[] = { } };
-#endif /* TEST_HISI_SEC_H_ */ +#endif /* SEC_TEMPLATE_TV_H */ diff --git a/test/hisi_sec_test/test_hisi_sec.c b/uadk_tool/test/test_sec.c old mode 100755 new mode 100644 similarity index 98% rename from test/hisi_sec_test/test_hisi_sec.c rename to uadk_tool/test/test_sec.c index 7d5da7c..9fe007e --- a/test/hisi_sec_test/test_hisi_sec.c +++ b/uadk_tool/test/test_sec.c @@ -12,11 +12,12 @@ #include <getopt.h> #include <numa.h>
-#include "test_hisi_sec.h" -#include "wd_cipher.h" -#include "wd_digest.h" -#include "wd_aead.h" -#include "wd_sched.h" +#include "sec_template_tv.h" +#include "test_sec.h" +#include "include/wd_cipher.h" +#include "include/wd_digest.h" +#include "include/wd_aead.h" +#include "include/wd_sched.h"
#define SEC_TST_PRT printf #define HW_CTX_SIZE (24 * 1024) @@ -26,6 +27,7 @@ #define SVA_THREADS 64 #define USE_CTX_NUM 64 #define BYTES_TO_MB 20 +#define SEC_ARGV_OFFSET 3
#define SCHED_SINGLE "sched_single" #define SCHED_NULL_CTX_SIZE 4 @@ -4013,13 +4015,13 @@ out_thr: static void print_help(void) { SEC_TST_PRT("NAME\n"); - SEC_TST_PRT(" test_hisi_sec: test wd sec function,etc\n"); + SEC_TST_PRT(" uadk_tool test --m sec: test wd sec function,etc\n"); SEC_TST_PRT("USAGE\n"); - SEC_TST_PRT(" test_hisi_sec [--cipher] [--digest] [--aead] [--perf]\n"); - SEC_TST_PRT(" test_hisi_sec [--optype] [--pktlen] [--keylen] [--times]\n"); - SEC_TST_PRT(" test_hisi_sec [--multi] [--sync] [--async] [--help]\n"); - SEC_TST_PRT(" test_hisi_sec [--block] [--blknum] [--ctxnum]\n"); - SEC_TST_PRT(" numactl --cpubind=0 --membind=0,1 ./test_hisi_sec xxxx\n"); + SEC_TST_PRT(" uadk_tool test --m sec [--cipher] [--digest] [--aead] [--perf]\n"); + SEC_TST_PRT(" uadk_tool test --m sec [--optype] [--pktlen] [--keylen] [--times]\n"); + SEC_TST_PRT(" uadk_tool test --m sec [--multi] [--sync] [--async] [--help]\n"); + SEC_TST_PRT(" uadk_tool test --m sec [--block] [--blknum] [--ctxnum]\n"); + SEC_TST_PRT(" numactl --cpubind=0 --membind=0,1 ./uadk_tool test --m sec xxxx\n"); SEC_TST_PRT(" specify numa nodes for cpu and memory\n"); SEC_TST_PRT("DESCRIPTION\n"); SEC_TST_PRT(" [--cipher ]:\n"); @@ -4060,17 +4062,19 @@ static void print_help(void) SEC_TST_PRT(" the number of QP queues used by the entire test task\n"); SEC_TST_PRT(" [--stream]:\n"); SEC_TST_PRT(" set the steam mode for digest\n"); + SEC_TST_PRT(" [--sglnum]:\n"); + SEC_TST_PRT(" the number of scatterlist number used by the entire test task\n"); SEC_TST_PRT(" [--help] = usage\n"); SEC_TST_PRT("Example\n"); - SEC_TST_PRT(" ./test_hisi_sec --cipher 0 --sync --optype 0\n"); + SEC_TST_PRT(" ./uadk_tool test --m sec --cipher 0 --sync --optype 0\n"); SEC_TST_PRT("--pktlen 16 --keylen 16 --times 1 --multi 1\n"); - SEC_TST_PRT(" ./test_hisi_sec --digest 0 --sync --optype 0\n"); + SEC_TST_PRT(" ./uadk_tool test --m sec --digest 0 --sync --optype 0\n"); SEC_TST_PRT("--pktlen 16 --keylen 16 --times 1 --multi 2 --stream\n"); - SEC_TST_PRT(" ./test_hisi_sec --digest 1 --sync --optype 0\n"); + SEC_TST_PRT(" ./uadk_tool test --m sec --digest 1 --sync --optype 0\n"); SEC_TST_PRT("--pktlen 16 --keylen 16 --times 1 --multi 2 --stream\n"); - SEC_TST_PRT(" ./test_hisi_sec --perf --sync --pktlen 1024 --block 1024\n"); + SEC_TST_PRT(" ./uadk_tool test --m sec --perf --sync --pktlen 1024 --block 1024\n"); SEC_TST_PRT("--blknum 100000 --times 10000 --multi 1 --ctxnum 1\n"); - SEC_TST_PRT("UPDATE:2022-06-29\n"); + SEC_TST_PRT("UPDATE:2022-12-16\n"); }
static void test_sec_cmd_parse(int argc, char *argv[], struct test_sec_option *option) @@ -4335,7 +4339,7 @@ static int test_sec_run(__u32 sync_mode, __u32 alg_class) return ret; }
-int main(int argc, char *argv[]) +int test_sec_entry(int argc, char *argv[]) { struct test_sec_option option = {0}; int ret = 0; @@ -4343,14 +4347,14 @@ int main(int argc, char *argv[]) SEC_TST_PRT("this is a hisi sec test.\n");
g_thread_num = 1; - if (!argv[1]) { + if (!argv[1 + SEC_ARGV_OFFSET]) return test_sec_default_case(); - }
test_sec_cmd_parse(argc, argv, &option); ret = test_sec_option_convert(&option); if (ret) return ret; + if (option.algclass == PERF_CLASS) return sec_sva_test();
diff --git a/uadk_tool/test/test_sec.h b/uadk_tool/test/test_sec.h new file mode 100644 index 0000000..5ac23e6 --- /dev/null +++ b/uadk_tool/test/test_sec.h @@ -0,0 +1,7 @@ +#ifndef TEST_SEC_H +#define TEST_SEC_H + + +int test_sec_entry(int argc, char *argv[]); + +#endif /* TEST_SEC_H */ \ No newline at end of file diff --git a/uadk_tool/test/uadk_test.c b/uadk_tool/test/uadk_test.c new file mode 100644 index 0000000..61c637b --- /dev/null +++ b/uadk_tool/test/uadk_test.c @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <getopt.h> +#include <unistd.h> +#include <limits.h> +#include <sys/ipc.h> +#include <sys/shm.h> + +#include "test_sec.h" + +enum uadk_test_op_type { + DISPLAY_MODULE = 22, + DISPLAY_HELP, +}; + +int test_hpre_entry(int argc, char *argv[]) +{ + return 0; +} + +int test_zip_entry(int argc, char *argv[]) +{ + return 0; +} + +void print_test_help(void) +{ + printf("NAME\n"); + printf(" uadk_tool test : Test the correctness of the acc algorithm, etc\n"); + printf("USAGE\n"); + printf(" uadk_tool test [--m] = module name\n"); + printf(" hpre, sec, zip\n"); + printf(" uadk_tool test [--help] = usage\n"); + printf("Example\n"); + printf(" uadk_tool test --m hpre --xx\n"); + printf(" uadk_tool test --m sec --xx\n"); + printf(" uadk_tool test --m zip --xx\n"); +} + +void acc_test_run(int argc, char *argv[]) +{ + char *input_module = NULL; + int option_index = 0; + int opt; + + static struct option long_options[] = { + {"m", required_argument, 0, 22}, + {"help", no_argument, 0, 23}, + {0, 0, 0, 0} + }; + + while (1) { + opt = getopt_long(argc, argv, "", long_options, &option_index); + if (opt == -1) + break; + + switch (opt) { + case DISPLAY_MODULE: + input_module = optarg; + if (!strcmp(input_module, "hpre")) { + (void)test_hpre_entry(argc, argv); + } else if (!strcmp(input_module, "sec")) { + (void)test_sec_entry(argc, argv); + } else if (!strcmp(input_module, "zip")) { + (void)test_zip_entry(argc, argv); + } else { + print_test_help(); + printf("failed to parse module parameter!\n"); + } + break; + case DISPLAY_HELP: + print_test_help(); + break; + default: + printf("bad input parameter, exit!\n"); + print_test_help(); + break; + } + } +} \ No newline at end of file diff --git a/uadk_tool/test/uadk_test.h b/uadk_tool/test/uadk_test.h new file mode 100644 index 0000000..f9fa5fa --- /dev/null +++ b/uadk_tool/test/uadk_test.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +#ifndef UADK_TEST_H +#define UADK_TEST_H + +void print_test_help(void); +void acc_test_run(int argc, char *argv[]); +#endif \ No newline at end of file diff --git a/uadk_tool/uadk_tool.c b/uadk_tool/uadk_tool.c index ce83d7a..63e6d0f 100644 --- a/uadk_tool/uadk_tool.c +++ b/uadk_tool/uadk_tool.c @@ -2,14 +2,16 @@
#include <stdio.h> #include <string.h> -#include "dfx/uadk_dfx.h" #include "benchmark/uadk_benchmark.h" +#include "dfx/uadk_dfx.h" +#include "test/uadk_test.h"
static void print_tool_help(void) { printf("NAME\n"); printf("uadk_tool dfx : Show some information for library.\n"); printf("uadk_tool benchmark : Test UADK acc performance.\n"); + printf("uadk_tool test : Test the correctness of the acc algorithm.\n"); }
int main(int argc, char **argv) @@ -34,6 +36,9 @@ int main(int argc, char **argv) if (ret) return ret; (void)acc_benchmark_run(&option); + } else if (!strcmp("test", argv[index])) { + printf("start UADK acc algorithm test.\n"); + acc_test_run(argc, argv); } else { print_tool_help(); }