aboutsummaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-08-21 21:16:48 -0600
committerTom Rini <trini@konsulko.com>2023-08-31 13:16:54 -0400
commitba5e3e1ed0afb3daa446d2168e5c8c9fe119cbaf (patch)
treed265d9442db79b365039fc727d5d0cbe987fbd58 /test/common
parentb81a024e4a37097d3dcffccb225850f8f6dc8277 (diff)
downloadu-boot-ba5e3e1ed0afb3daa446d2168e5c8c9fe119cbaf.zip
u-boot-ba5e3e1ed0afb3daa446d2168e5c8c9fe119cbaf.tar.gz
u-boot-ba5e3e1ed0afb3daa446d2168e5c8c9fe119cbaf.tar.bz2
event: Support a simple spy record
The current event spy is always passed the event context and the event. The context is always NULL for a static spy. The event is not often used. Introduce a 'simple' spy which takes no arguments. This allows us to drop the adaptation code that many of these spy records use. Update the event script to find these in the image. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/common')
-rw-r--r--test/common/event.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/common/event.c b/test/common/event.c
index 6037ae2..c0912a3 100644
--- a/test/common/event.c
+++ b/test/common/event.c
@@ -18,6 +18,8 @@ struct test_state {
int val;
};
+static bool called;
+
static int h_adder(void *ctx, struct event *event)
{
struct event_data_test *data = &event->data.test;
@@ -28,6 +30,14 @@ static int h_adder(void *ctx, struct event *event)
return 0;
}
+static int h_adder_simple(void)
+{
+ called = true;
+
+ return 0;
+}
+EVENT_SPY_SIMPLE(EVT_TEST, h_adder_simple);
+
static int test_event_base(struct unit_test_state *uts)
{
struct test_state state;
@@ -46,6 +56,18 @@ static int test_event_base(struct unit_test_state *uts)
}
COMMON_TEST(test_event_base, 0);
+static int test_event_simple(struct unit_test_state *uts)
+{
+ called = false;
+
+ /* Check that the handler is called */
+ ut_assertok(event_notify_null(EVT_TEST));
+ ut_assert(called);
+
+ return 0;
+}
+COMMON_TEST(test_event_simple, 0);
+
static int h_probe(void *ctx, struct event *event)
{
struct test_state *test_state = ctx;