Skip to content

Commit

Permalink
Tools: Testbench: Clean up header files
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
singalsu committed Sep 19, 2024
1 parent 63d6028 commit 7c045a1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion tools/testbench/common_test_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions tools/testbench/include/testbench/common_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdint.h>
#include <stddef.h>
Expand All @@ -18,14 +18,14 @@

#include <sof/lib/uuid.h>

#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;

Expand All @@ -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;

Expand Down Expand Up @@ -105,4 +105,4 @@ void tb_gettime(struct timespec *td);

void tb_getcycles(uint64_t *cycles);

#endif
#endif /* _TESTBENCH_COMMON_TEST_H */
6 changes: 3 additions & 3 deletions tools/testbench/include/testbench/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <stdbool.h>

#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 */
28 changes: 14 additions & 14 deletions tools/testbench/testbench.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ 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);

/* next output */
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;
}
Expand All @@ -63,18 +63,18 @@ 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);

/* next input */
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;
}
Expand All @@ -90,17 +90,17 @@ 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);

/* next output */
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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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 */
Expand Down

0 comments on commit 7c045a1

Please sign in to comment.