1 // SPDX-License-Identifier: GPL-2.0+
3 * Unit tests for event handling
5 * Copyright 2021 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
12 #include <test/common.h>
13 #include <test/test.h>
21 static int h_adder(void *ctx, struct event *event)
23 struct event_data_test *data = &event->data.test;
24 struct test_state *test_state = ctx;
26 test_state->val += data->signal;
31 static int test_event_base(struct unit_test_state *uts)
33 struct test_state state;
37 ut_assertok(event_register("wibble", EVT_TEST, h_adder, &state));
41 /* Check that the handler is called */
42 ut_assertok(event_notify(EVT_TEST, &signal, sizeof(signal)));
43 ut_asserteq(12 + 17, state.val);
47 COMMON_TEST(test_event_base, 0);