mirror of
https://gitlab.freedesktop.org/emersion/libliftoff.git
synced 2025-01-19 10:26:29 +01:00
test: add a test with a layer without any prop set
Makes sure libliftoff doesn't allocate a plane for the layer and doesn't crash. References:799f694587
("Fix segfault when FB_ID isn't set") References:53a7bfebc9
("Don't allocate planes for layers without a FB")
This commit is contained in:
parent
53a7bfebc9
commit
71200724c5
2 changed files with 37 additions and 0 deletions
|
@ -24,6 +24,7 @@ bench_exe = executable(
|
|||
tests = {
|
||||
'alloc': [
|
||||
'basic',
|
||||
'no-props',
|
||||
'empty',
|
||||
'simple-1x',
|
||||
'simple-1x-fail',
|
||||
|
|
|
@ -712,6 +712,39 @@ static void test_basic(void)
|
|||
close(drm_fd);
|
||||
}
|
||||
|
||||
/* Checks the library doesn't segfault when a layer is added without any
|
||||
* property set. */
|
||||
static void test_no_props(void)
|
||||
{
|
||||
struct liftoff_mock_plane *mock_plane;
|
||||
int drm_fd;
|
||||
struct liftoff_device *device;
|
||||
struct liftoff_output *output;
|
||||
struct liftoff_layer *layer;
|
||||
drmModeAtomicReq *req;
|
||||
bool ok;
|
||||
|
||||
mock_plane = liftoff_mock_drm_create_plane(DRM_PLANE_TYPE_PRIMARY);
|
||||
|
||||
drm_fd = liftoff_mock_drm_open();
|
||||
device = liftoff_device_create(drm_fd);
|
||||
assert(device != NULL);
|
||||
|
||||
output = liftoff_output_create(device, liftoff_mock_drm_crtc_id);
|
||||
layer = liftoff_layer_create(output);
|
||||
|
||||
liftoff_mock_plane_add_compatible_layer(mock_plane, layer);
|
||||
|
||||
req = drmModeAtomicAlloc();
|
||||
ok = liftoff_output_apply(output, req);
|
||||
assert(liftoff_mock_plane_get_layer(mock_plane, req) == NULL);
|
||||
assert(ok);
|
||||
drmModeAtomicFree(req);
|
||||
|
||||
liftoff_device_destroy(device);
|
||||
close(drm_fd);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
const char *test_name;
|
||||
size_t i;
|
||||
|
@ -727,6 +760,9 @@ int main(int argc, char *argv[]) {
|
|||
if (strcmp(test_name, "basic") == 0) {
|
||||
test_basic();
|
||||
return 0;
|
||||
} else if (strcmp(test_name, "no-props") == 0) {
|
||||
test_no_props();
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
|
||||
|
|
Loading…
Reference in a new issue