Skip to content

Commit

Permalink
Tools: Testbench: Clean up and reduce printed texts
Browse files Browse the repository at this point in the history
The previously removed command line options are removed from
help text print to avoid confusion.

The functions tb_debug_print() and tb_check_trace() are used
to reduce printing of less important messages those are still
useful when debugging issues with components or testbench
itself. Also tplg_debug() makes prints more clean looking
with "debug:" prefix.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
  • Loading branch information
singalsu authored and kv2019i committed Oct 17, 2024
1 parent b4da79a commit 735cf0a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
12 changes: 6 additions & 6 deletions tools/testbench/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ static int file_free(struct processing_module *mod)
struct copier_data *ccd = module_get_private_data(mod);
struct file_comp_data *cd = get_file_comp_data(ccd);

tb_debug_print("file_free()");
tb_debug_print("file_free()\n");

if (cd->fs.mode == FILE_READ)
fclose(cd->fs.rfh);
Expand Down Expand Up @@ -771,7 +771,7 @@ static int file_process(struct processing_module *mod,
cd->fs.copy_count++;
if (cd->fs.reached_eof || (cd->max_copies && cd->fs.copy_count >= cd->max_copies)) {
cd->fs.reached_eof = true;
tb_debug_print("file_process(): reached EOF");
tb_debug_print("file_process(): reached EOF\n");
}

if (samples) {
Expand All @@ -798,7 +798,7 @@ static int file_prepare(struct processing_module *mod,
struct comp_dev *dev = mod->dev;
struct file_comp_data *cd = get_file_comp_data(module_get_private_data(mod));

tb_debug_print("file_prepare()");
tb_debug_print("file_prepare()\n");

/* file component sink/source buffer period count */
cd->max_frames = dev->frames;
Expand Down Expand Up @@ -840,14 +840,14 @@ static int file_reset(struct processing_module *mod)
{
struct file_comp_data *cd = module_get_private_data(mod);

tb_debug_print("file_reset()");
tb_debug_print("file_reset()\n");
cd->copies_timeout_count = 0;
return 0;
}

static int file_trigger(struct comp_dev *dev, int cmd)
{
tb_debug_print("file_trigger()");
tb_debug_print("file_trigger()\n");
return comp_set_state(dev, cmd);
}

Expand All @@ -857,7 +857,7 @@ static int file_get_hw_params(struct comp_dev *dev,
struct processing_module *mod = comp_mod(dev);
struct file_comp_data *cd = get_file_comp_data(module_get_private_data(mod));

tb_debug_print("file_hw_params()");
tb_debug_print("file_hw_params()\n");
params->direction = dir;
params->rate = cd->rate;
params->channels = cd->channels;
Expand Down
12 changes: 3 additions & 9 deletions tools/testbench/testbench.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ static void print_usage(char *executable)
printf("Usage: %s <options> -i <input_file> ", executable);
printf("-o <output_file1,output_file2,...>\n\n");
printf("Options for processing:\n");
printf(" -t <topology file>\n");
printf(" -a <comp1=comp1_library,comp2=comp2_library>, override default library\n\n");
printf(" -t <topology file>\n\n");
printf("Options to control test:\n");
printf(" -d <level> Sets the traces print level:\n");
printf(" 0 all traces are suppressed\n");
Expand All @@ -128,25 +127,20 @@ static void print_usage(char *executable)
printf(" 3 shows info traces and previous\n");
printf(" 4 shows debug traces and previous, plus other testbench debug messages\n");
printf(" -p <pipeline1,pipeline2,...>\n");
printf(" -s Use real time priorities for threads (needs sudo)\n");
printf(" -C <number of copy() iterations>\n");
printf(" -D <pipeline duration in ms>\n");
printf(" -P <number of dynamic pipeline iterations>\n");
printf(" -T <microseconds for tick, 0 for batch mode>\n");
printf(" -T <microseconds for tick, 0 for batch mode>\n\n");
printf("Options for input and output format override:\n");
printf(" -b <input_format>, S16_LE, S24_LE, or S32_LE\n");
printf(" -c <input channels>\n");
printf(" -n <output channels>\n");
printf(" -r <input rate>\n");
printf(" -R <output rate>\n\n");
printf("Environment variables\n");
printf(" SOF_HOST_CORE0=<i> - Map DSP core 0..N to host i..i+N\n");
printf("Help:\n");
printf(" -h\n\n");
printf("Example Usage:\n");
printf("%s -i in.txt -o out.txt -t test.tplg ", executable);
printf("-r 48000 -R 96000 -c 2 ");
printf("-b S16_LE -a volume=libsof_volume.so\n");
printf("%s -r 48000 -c 2 -b S16_LE -i in.raw -o out.raw -t <test.tplg>\n\n", executable);
}

static int parse_input_args(int argc, char **argv, struct testbench_prm *tp)
Expand Down
12 changes: 7 additions & 5 deletions tools/testbench/topology_ipc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "testbench/utils.h"
#include "testbench/file.h"
#include "testbench/trace.h"

#include <errno.h>
#include <math.h>
Expand Down Expand Up @@ -614,9 +615,10 @@ static int tb_load_widget(struct testbench_prm *tb, struct tplg_context *ctx)
break;
/* unsupported widgets */
default:
printf("info: Widget %s id %d unsupported and skipped: size %d priv size %d\n",
ctx->widget->name, ctx->widget->id,
ctx->widget->size, ctx->widget->priv.size);
if (tb_check_trace(LOG_LEVEL_DEBUG))
printf("debug: Widget %s id %d unsupported and skipped: size %d priv size %d\n",
ctx->widget->name, ctx->widget->id,
ctx->widget->size, ctx->widget->priv.size);
break;
}

Expand Down Expand Up @@ -687,8 +689,8 @@ int tb_parse_topology(struct testbench_prm *tb)
/* read next topology header */
hdr = tplg_get_hdr(ctx);

fprintf(stdout, "type: %x, size: 0x%x count: %d index: %d\n",
hdr->type, hdr->payload_size, hdr->count, hdr->index);
tplg_debug("type: %x, size: 0x%x count: %d index: %d\n",
hdr->type, hdr->payload_size, hdr->count, hdr->index);

ctx->hdr = hdr;

Expand Down
12 changes: 7 additions & 5 deletions tools/testbench/topology_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "testbench/topology_ipc4.h"
#include "testbench/file.h"
#include "testbench/file_ipc4.h"
#include "testbench/trace.h"
#include "ipc4/pipeline.h"

#define SOF_IPC4_FW_PAGE(x) ((((x) + BIT(12) - 1) & ~(BIT(12) - 1)) >> 12)
Expand Down Expand Up @@ -1150,9 +1151,10 @@ static int tb_load_widget(struct testbench_prm *tp)

/* unsupported widgets */
default:
printf("info: Widget %s id %d unsupported and skipped: size %d priv size %d\n",
ctx->widget->name, ctx->widget->id,
ctx->widget->size, ctx->widget->priv.size);
if (tb_check_trace(LOG_LEVEL_DEBUG))
printf("Widget %s id %d unsupported and skipped: size %d priv size %d\n",
ctx->widget->name, ctx->widget->id,
ctx->widget->size, ctx->widget->priv.size);
break;
}

Expand Down Expand Up @@ -1518,7 +1520,7 @@ int tb_set_running_state(struct testbench_prm *tp)
return ret;
}

fprintf(stdout, "pipelines are set to paused state\n");
tb_debug_print("pipelines are set to paused state\n");
ret = tb_pipelines_set_state(tp, SOF_IPC4_PIPELINE_STATE_RUNNING, SOF_IPC_STREAM_PLAYBACK);
if (ret) {
fprintf(stderr, "error: failed to set state to running\n");
Expand All @@ -1529,7 +1531,7 @@ int tb_set_running_state(struct testbench_prm *tp)
if (ret)
fprintf(stderr, "error: failed to set state to running\n");

fprintf(stdout, "pipelines are set to running state\n");
tb_debug_print("pipelines are set to running state\n");
return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion tools/testbench/utils_ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ int tb_set_up_all_pipelines(struct testbench_prm *tp)
return ret;
}

fprintf(stdout, "pipelines set up complete\n");
tb_debug_print("pipelines set up complete\n");
return 0;
}

Expand Down

0 comments on commit 735cf0a

Please sign in to comment.