From ca12ed2b81f1a4e3ede628d9553e4e71f52e3e7e Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 17 Sep 2024 18:17:27 +0300 Subject: [PATCH] Tools: Testbench: Clean up header files Prefix macros with TB and add TESTBENCH to headers single time include control macros. Especially ifndef _TRACE_H is in risk to conflict with possible other headers. Signed-off-by: Seppo Ingalsuo --- tools/testbench/common_test_ipc3.c | 2 +- .../testbench/include/testbench/common_test.h | 22 +++++++-------- tools/testbench/include/testbench/trace.h | 6 ++-- tools/testbench/testbench.c | 28 +++++++++---------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tools/testbench/common_test_ipc3.c b/tools/testbench/common_test_ipc3.c index f4481b38a..f43b1f367 100644 --- a/tools/testbench/common_test_ipc3.c +++ b/tools/testbench/common_test_ipc3.c @@ -204,7 +204,7 @@ int tb_pipeline_params(struct testbench_prm *tp, struct ipc *ipc, struct pipelin { struct comp_dev *cd; struct sof_ipc_pcm_params params = {{0}}; - char message[DEBUG_MSG_LEN]; + char message[TB_DEBUG_MSG_LEN]; int fs_period; int period; int ret = 0; diff --git a/tools/testbench/include/testbench/common_test.h b/tools/testbench/include/testbench/common_test.h index 4960c13e2..40e7b38b1 100644 --- a/tools/testbench/include/testbench/common_test.h +++ b/tools/testbench/include/testbench/common_test.h @@ -3,8 +3,8 @@ * Copyright(c) 2018 Intel Corporation. All rights reserved. */ -#ifndef _COMMON_TEST_H -#define _COMMON_TEST_H +#ifndef _TESTBENCH_COMMON_TEST_H +#define _TESTBENCH_COMMON_TEST_H #include #include @@ -18,14 +18,14 @@ #include -#define DEBUG_MSG_LEN 1024 -#define MAX_LIB_NAME_LEN 1024 +#define TB_DEBUG_MSG_LEN 1024 +#define TB_MAX_LIB_NAME_LEN 1024 -#define MAX_INPUT_FILE_NUM 16 -#define MAX_OUTPUT_FILE_NUM 16 +#define TB_MAX_INPUT_FILE_NUM 16 +#define TB_MAX_OUTPUT_FILE_NUM 16 /* number of widgets types supported in testbench */ -#define NUM_WIDGETS_SUPPORTED 16 +#define TB_NUM_WIDGETS_SUPPORTED 16 struct tplg_context; @@ -38,12 +38,12 @@ struct tplg_context; struct testbench_prm { long long total_cycles; char *tplg_file; /* topology file to use */ - char *input_file[MAX_INPUT_FILE_NUM]; /* input file names */ - char *output_file[MAX_OUTPUT_FILE_NUM]; /* output file names */ + char *input_file[TB_MAX_INPUT_FILE_NUM]; /* input file names */ + char *output_file[TB_MAX_OUTPUT_FILE_NUM]; /* output file names */ int input_file_num; /* number of input files */ int output_file_num; /* number of output files */ char *bits_in; /* input bit format */ - int pipelines[MAX_OUTPUT_FILE_NUM]; /* output file names */ + int pipelines[TB_MAX_OUTPUT_FILE_NUM]; /* output file names */ int pipeline_num; struct tplg_context *ctx; @@ -105,4 +105,4 @@ void tb_gettime(struct timespec *td); void tb_getcycles(uint64_t *cycles); -#endif +#endif /* _TESTBENCH_COMMON_TEST_H */ diff --git a/tools/testbench/include/testbench/trace.h b/tools/testbench/include/testbench/trace.h index 66e63e217..50b4863e4 100644 --- a/tools/testbench/include/testbench/trace.h +++ b/tools/testbench/include/testbench/trace.h @@ -8,9 +8,9 @@ #include -#ifndef _TRACE_H -#define _TRACE_H +#ifndef _TESTBENCH_TRACE_H +#define _TESTBENCH_TRACE_H void tb_enable_trace(unsigned int log_level); -#endif +#endif /* _TESTBENCH_TRACE_H */ diff --git a/tools/testbench/testbench.c b/tools/testbench/testbench.c index 0f464d577..60f808534 100644 --- a/tools/testbench/testbench.c +++ b/tools/testbench/testbench.c @@ -33,7 +33,7 @@ static int parse_output_files(char *outputs, struct testbench_prm *tp) char *token = strtok_r(outputs, ",", &output_token); int index; - for (index = 0; index < MAX_OUTPUT_FILE_NUM && token; index++) { + for (index = 0; index < TB_MAX_OUTPUT_FILE_NUM && token; index++) { /* get output file name with current index */ tp->output_file[index] = strdup(token); @@ -41,10 +41,10 @@ static int parse_output_files(char *outputs, struct testbench_prm *tp) token = strtok_r(NULL, ",", &output_token); } - if (index == MAX_OUTPUT_FILE_NUM && token) { + if (index == TB_MAX_OUTPUT_FILE_NUM && token) { fprintf(stderr, "error: max output file number is %d\n", - MAX_OUTPUT_FILE_NUM); - for (index = 0; index < MAX_OUTPUT_FILE_NUM; index++) + TB_MAX_OUTPUT_FILE_NUM); + for (index = 0; index < TB_MAX_OUTPUT_FILE_NUM; index++) free(tp->output_file[index]); return -EINVAL; } @@ -63,7 +63,7 @@ static int parse_input_files(char *inputs, struct testbench_prm *tp) char *token = strtok_r(inputs, ",", &input_token); int index; - for (index = 0; index < MAX_INPUT_FILE_NUM && token; index++) { + for (index = 0; index < TB_MAX_INPUT_FILE_NUM && token; index++) { /* get input file name with current index */ tp->input_file[index] = strdup(token); @@ -71,10 +71,10 @@ static int parse_input_files(char *inputs, struct testbench_prm *tp) token = strtok_r(NULL, ",", &input_token); } - if (index == MAX_INPUT_FILE_NUM && token) { + if (index == TB_MAX_INPUT_FILE_NUM && token) { fprintf(stderr, "error: max input file number is %d\n", - MAX_INPUT_FILE_NUM); - for (index = 0; index < MAX_INPUT_FILE_NUM; index++) + TB_MAX_INPUT_FILE_NUM); + for (index = 0; index < TB_MAX_INPUT_FILE_NUM; index++) free(tp->input_file[index]); return -EINVAL; } @@ -90,7 +90,7 @@ static int parse_pipelines(char *pipelines, struct testbench_prm *tp) char *token = strtok_r(pipelines, ",", &output_token); int index; - for (index = 0; index < MAX_OUTPUT_FILE_NUM && token; index++) { + for (index = 0; index < TB_MAX_OUTPUT_FILE_NUM && token; index++) { /* get output file name with current index */ tp->pipelines[index] = atoi(token); @@ -98,9 +98,9 @@ static int parse_pipelines(char *pipelines, struct testbench_prm *tp) token = strtok_r(NULL, ",", &output_token); } - if (index == MAX_OUTPUT_FILE_NUM && token) { + if (index == TB_MAX_OUTPUT_FILE_NUM && token) { fprintf(stderr, "error: max output file number is %d\n", - MAX_OUTPUT_FILE_NUM); + TB_MAX_OUTPUT_FILE_NUM); return -EINVAL; } @@ -743,10 +743,10 @@ int main(int argc, char **argv) tp.tplg_file = NULL; tp.input_file_num = 0; tp.output_file_num = 0; - for (i = 0; i < MAX_OUTPUT_FILE_NUM; i++) + for (i = 0; i < TB_MAX_OUTPUT_FILE_NUM; i++) tp.output_file[i] = NULL; - for (i = 0; i < MAX_INPUT_FILE_NUM; i++) + for (i = 0; i < TB_MAX_INPUT_FILE_NUM; i++) tp.input_file[i] = NULL; tp.channels_in = TESTBENCH_NCH; @@ -755,7 +755,7 @@ int main(int argc, char **argv) tp.copy_check = false; tp.quiet = 0; tp.dynamic_pipeline_iterations = 1; - tp.pipeline_string = calloc(1, DEBUG_MSG_LEN); + tp.pipeline_string = calloc(1, TB_DEBUG_MSG_LEN); tp.pipelines[0] = 1; tp.pipeline_num = 1; tp.tick_period_us = 0; /* Execute fast non-real time, for 1 ms tick use -T 1000 */