Skip to content

Commit 69a747f

Browse files
committed
debug: tester: add simple DRAM execution test
Add new type of test: TESTER_MODULE_CASE_SIMPLE_DRAM_TEST This will allow to test simple dram execution scenario Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
1 parent 67ebb10 commit 69a747f

File tree

7 files changed

+109
-0
lines changed

7 files changed

+109
-0
lines changed

src/debug/tester/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
add_local_sources(tester.c)
22
add_local_sources(tester_dummy_test.c)
3+
add_local_sources(tester_simple_dram_test.c)

src/debug/tester/llext/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
sof_llext_build("tester"
55
SOURCES ../tester.c
66
../tester_dummy_test.c
7+
../tester_simple_dram_test.c
78
)

src/debug/tester/tester.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <sof/audio/sink_source_utils.h>
1717
#include "tester.h"
1818
#include "tester_dummy_test.h"
19+
#include "tester_simple_dram_test.h"
1920

2021
/**
2122
* Tester module is a framework for a runtime testing that need a special test code
@@ -76,6 +77,9 @@ static int tester_init(struct processing_module *mod)
7677
case TESTER_MODULE_CASE_DUMMY_TEST:
7778
cd->tester_case_interface = &tester_interface_dummy_test;
7879
break;
80+
case TESTER_MODULE_CASE_SIMPLE_DRAM_TEST:
81+
cd->tester_case_interface = &tester_interface_simple_dram_test;
82+
break;
7983

8084
default:
8185
comp_err(dev, "Invalid config, unknown test type");

src/debug/tester/tester.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#define TESTER_MODULE_CASE_NO_TEST 0
1717
#define TESTER_MODULE_CASE_DUMMY_TEST 1
18+
#define TESTER_MODULE_CASE_SIMPLE_DRAM_TEST 2
1819

1920
/**
2021
* API of a test case
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
//
3+
// Copyright(c) 2025 Intel Corporation. All rights reserved.
4+
//
5+
// Author: Adrian Bonislawski <adrian.bonislawski@intel.com>
6+
7+
#include "tester_simple_dram_test.h"
8+
#include <sof/audio/component.h>
9+
#include <sof/audio/module_adapter/module/generic.h>
10+
#include <sof/lib/memory.h>
11+
12+
/*
13+
* This is a simple test case for DRAM execution
14+
* The test case will copy every 2nd frame of data
15+
* by setting do_copy flag to true/false
16+
*/
17+
18+
struct tester_module_simple_dram_test_data {
19+
bool do_copy_data;
20+
};
21+
22+
static int validate_l3_memory(void *ptr)
23+
{
24+
if (!((POINTER_TO_UINT(ptr) >= L3_MEM_BASE_ADDR) &&
25+
(POINTER_TO_UINT(ptr) < L3_MEM_BASE_ADDR + L3_MEM_SIZE)))
26+
return -EINVAL;
27+
28+
return 0;
29+
}
30+
31+
__cold static int simple_dram_test_case_init(struct processing_module *mod, void **ctx)
32+
{
33+
#if !CONFIG_L3_HEAP
34+
return -EINVAL;
35+
#endif
36+
struct tester_module_simple_dram_test_data *data =
37+
rzalloc(0, 0, SOF_MEM_CAPS_L3, sizeof(*data));
38+
39+
if (!data)
40+
return -ENOMEM;
41+
42+
if (validate_l3_memory(data) != 0) {
43+
rfree(data);
44+
return -EINVAL;
45+
}
46+
47+
if (validate_l3_memory(tester_interface_simple_dram_test.init) != 0 ||
48+
validate_l3_memory(tester_interface_simple_dram_test.process) != 0 ||
49+
validate_l3_memory(tester_interface_simple_dram_test.free) != 0) {
50+
rfree(data);
51+
return -EINVAL;
52+
}
53+
54+
data->do_copy_data = false;
55+
*ctx = data;
56+
return 0;
57+
}
58+
59+
__cold static int simple_dram_test_case_process(void *ctx, struct processing_module *mod,
60+
struct sof_source **sources, int num_of_sources,
61+
struct sof_sink **sinks, int num_of_sinks,
62+
bool *do_copy)
63+
{
64+
struct tester_module_simple_dram_test_data *data = ctx;
65+
66+
/* copy every second cycle */
67+
*do_copy = data->do_copy_data;
68+
data->do_copy_data = !data->do_copy_data;
69+
70+
return 0;
71+
}
72+
73+
__cold static int simple_dram_test_free(void *ctx, struct processing_module *mod)
74+
{
75+
rfree(ctx);
76+
return 0;
77+
}
78+
79+
const struct tester_test_case_interface tester_interface_simple_dram_test = {
80+
.init = simple_dram_test_case_init,
81+
.process = simple_dram_test_case_process,
82+
.free = simple_dram_test_free
83+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
*
3+
* Copyright(c) 2025 Intel Corporation.
4+
*
5+
* Author: Adrian Bonislawski <adrian.bonislawski@intel.com>
6+
*/
7+
8+
#ifndef TESTER_SIMPLE_DRAM_TEST
9+
#define TESTER_SIMPLE_DRAM_TEST
10+
11+
#include <stddef.h>
12+
#include <stdint.h>
13+
14+
#include "tester.h"
15+
16+
extern const struct tester_test_case_interface tester_interface_simple_dram_test;
17+
18+
#endif /* TESTER_DUMMY_TEST */

zephyr/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ elseif(CONFIG_COMP_TESTER)
220220
zephyr_library_sources_ifdef(CONFIG_COMP_TESTER
221221
${SOF_DEBUG_PATH}/tester/tester.c
222222
${SOF_DEBUG_PATH}/tester/tester_dummy_test.c
223+
${SOF_DEBUG_PATH}/tester/tester_simple_dram_test.c
223224
)
224225
endif()
225226

0 commit comments

Comments
 (0)