mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 15:00:05 +01:00
test: improve event debugging a bit
Add a litest_checkpoint macro and convert a few of the litest_assert macros to make use of that - this gives us a printf of the call site in case it fails. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
This commit is contained in:
parent
721426a1be
commit
596d86ecc1
2 changed files with 86 additions and 17 deletions
|
|
@ -115,6 +115,23 @@ static void litest_setup_quirks(struct list *created_files_list,
|
|||
#define litest_vlog(...) { /* __VA_ARGS__ */ }
|
||||
#endif
|
||||
|
||||
void
|
||||
_litest_checkpoint(const char *func,
|
||||
int line,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
char buf[1024];
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
if (verbose) {
|
||||
vsnprintf(buf, sizeof(buf), format, args);
|
||||
printf(ANSI_BRIGHT_BLUE "%s():%d - " ANSI_BRIGHT_RED "%s" ANSI_NORMAL "\n", func, line, buf); \
|
||||
}
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void
|
||||
litest_backtrace(void)
|
||||
{
|
||||
|
|
@ -3371,11 +3388,15 @@ litest_assert_event_type(struct libinput_event *event,
|
|||
}
|
||||
|
||||
void
|
||||
litest_assert_empty_queue(struct libinput *li)
|
||||
_litest_assert_empty_queue(struct libinput *li,
|
||||
const char *func,
|
||||
int line)
|
||||
{
|
||||
bool empty_queue = true;
|
||||
struct libinput_event *event;
|
||||
|
||||
_litest_checkpoint(func, line, "asserting empty queue");
|
||||
|
||||
libinput_dispatch(li);
|
||||
while ((event = libinput_get_event(li))) {
|
||||
empty_queue = false;
|
||||
|
|
@ -3634,11 +3655,19 @@ litest_assert_key_event(struct libinput *li, unsigned int key,
|
|||
}
|
||||
|
||||
void
|
||||
litest_assert_button_event(struct libinput *li, unsigned int button,
|
||||
enum libinput_button_state state)
|
||||
_litest_assert_button_event(struct libinput *li, unsigned int button,
|
||||
enum libinput_button_state state,
|
||||
const char *func, int line)
|
||||
{
|
||||
struct libinput_event *event;
|
||||
|
||||
_litest_checkpoint(func,
|
||||
line,
|
||||
"asserting button event %s (%d) state %d",
|
||||
libevdev_event_code_get_name(EV_KEY, button),
|
||||
button,
|
||||
state);
|
||||
|
||||
litest_wait_for_event(li);
|
||||
event = libinput_get_event(li);
|
||||
|
||||
|
|
@ -3715,12 +3744,20 @@ litest_is_gesture_event(struct libinput_event *event,
|
|||
}
|
||||
|
||||
void
|
||||
litest_assert_gesture_event(struct libinput *li,
|
||||
_litest_assert_gesture_event(struct libinput *li,
|
||||
enum libinput_event_type type,
|
||||
int nfingers)
|
||||
int nfingers,
|
||||
const char *func,
|
||||
int line)
|
||||
{
|
||||
struct libinput_event *event;
|
||||
|
||||
_litest_checkpoint(func,
|
||||
line,
|
||||
"asserting gesture event %s %dfg",
|
||||
litest_event_type_str(type),
|
||||
nfingers);
|
||||
|
||||
litest_wait_for_event(li);
|
||||
event = libinput_get_event(li);
|
||||
|
||||
|
|
@ -4126,13 +4163,20 @@ litest_assert_axis_end_sequence(struct libinput *li,
|
|||
}
|
||||
|
||||
void
|
||||
litest_assert_only_typed_events(struct libinput *li,
|
||||
enum libinput_event_type type)
|
||||
_litest_assert_only_typed_events(struct libinput *li,
|
||||
enum libinput_event_type type,
|
||||
const char *func,
|
||||
int line)
|
||||
{
|
||||
struct libinput_event *event;
|
||||
|
||||
litest_assert(type != LIBINPUT_EVENT_NONE);
|
||||
|
||||
_litest_checkpoint(func,
|
||||
line,
|
||||
"asserting only typed events %s",
|
||||
litest_event_type_str(type));
|
||||
|
||||
libinput_dispatch(li);
|
||||
event = libinput_get_event(li);
|
||||
litest_assert_notnull(event);
|
||||
|
|
|
|||
|
|
@ -83,6 +83,13 @@ struct test_collection {
|
|||
}; \
|
||||
static void (name##_setup)(void)
|
||||
|
||||
__attribute__ ((format (printf, 3, 0)))
|
||||
void _litest_checkpoint(const char *func,
|
||||
int line,
|
||||
const char *format,
|
||||
...);
|
||||
#define litest_checkpoint(...) \
|
||||
_litest_checkpoint(__func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
/**
|
||||
* litest itself needs the user_data to store some test-suite-specific
|
||||
|
|
@ -782,8 +789,13 @@ void
|
|||
litest_assert_event_type(struct libinput_event *event,
|
||||
enum libinput_event_type want);
|
||||
|
||||
#define litest_assert_empty_queue(li_) \
|
||||
_litest_assert_empty_queue(li_, __func__, __LINE__)
|
||||
|
||||
void
|
||||
litest_assert_empty_queue(struct libinput *li);
|
||||
_litest_assert_empty_queue(struct libinput *li,
|
||||
const char *func,
|
||||
int line);
|
||||
|
||||
void
|
||||
litest_assert_touch_sequence(struct libinput *li);
|
||||
|
|
@ -872,10 +884,14 @@ void
|
|||
litest_assert_key_event(struct libinput *li, unsigned int key,
|
||||
enum libinput_key_state state);
|
||||
|
||||
#define litest_assert_button_event(li_, button_, state_) \
|
||||
_litest_assert_button_event(li_, button_, state_, __func__, __LINE__)
|
||||
|
||||
void
|
||||
litest_assert_button_event(struct libinput *li,
|
||||
_litest_assert_button_event(struct libinput *li,
|
||||
unsigned int button,
|
||||
enum libinput_button_state state);
|
||||
enum libinput_button_state state,
|
||||
const char *func, int line);
|
||||
|
||||
void
|
||||
litest_assert_switch_event(struct libinput *li,
|
||||
|
|
@ -894,9 +910,13 @@ litest_assert_axis_end_sequence(struct libinput *li,
|
|||
enum libinput_pointer_axis axis,
|
||||
enum libinput_pointer_axis_source source);
|
||||
|
||||
#define litest_assert_only_typed_events(...) \
|
||||
_litest_assert_only_typed_events(__VA_ARGS__, __func__, __LINE__)
|
||||
void
|
||||
litest_assert_only_typed_events(struct libinput *li,
|
||||
enum libinput_event_type type);
|
||||
_litest_assert_only_typed_events(struct libinput *li,
|
||||
enum libinput_event_type type,
|
||||
const char *func,
|
||||
int line);
|
||||
|
||||
void
|
||||
litest_assert_only_axis_events(struct libinput *li,
|
||||
|
|
@ -928,10 +948,15 @@ litest_assert_pad_key_event(struct libinput *li,
|
|||
unsigned int key,
|
||||
enum libinput_key_state state);
|
||||
|
||||
#define litest_assert_gesture_event(...) \
|
||||
_litest_assert_gesture_event(__VA_ARGS__, __func__, __LINE__)
|
||||
|
||||
void
|
||||
litest_assert_gesture_event(struct libinput *li,
|
||||
_litest_assert_gesture_event(struct libinput *li,
|
||||
enum libinput_event_type type,
|
||||
int nfingers);
|
||||
int nfingers,
|
||||
const char *func,
|
||||
int line);
|
||||
|
||||
struct libevdev_uinput *
|
||||
litest_create_uinput_device(const char *name,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue