test: add a test with a zero FB_ID

References: 53a7bfebc9 ("Don't allocate planes for layers without a FB")
This commit is contained in:
Simon Ser 2019-12-19 17:54:49 +01:00
parent 71200724c5
commit 7286146341
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 11 additions and 4 deletions

View file

@ -25,6 +25,7 @@ tests = {
'alloc': [
'basic',
'no-props',
'zero-fb-id',
'empty',
'simple-1x',
'simple-1x-fail',

View file

@ -712,9 +712,9 @@ 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)
/* Checks that the library doesn't allocate a plane for a layer without a
* non-zero FB_ID set. */
static void test_no_fb(bool zero_fb_id)
{
struct liftoff_mock_plane *mock_plane;
int drm_fd;
@ -732,6 +732,9 @@ static void test_no_props(void)
output = liftoff_output_create(device, liftoff_mock_drm_crtc_id);
layer = liftoff_layer_create(output);
if (zero_fb_id) {
liftoff_layer_set_property(layer, "FB_ID", 0);
}
liftoff_mock_plane_add_compatible_layer(mock_plane, layer);
@ -761,7 +764,10 @@ int main(int argc, char *argv[]) {
test_basic();
return 0;
} else if (strcmp(test_name, "no-props") == 0) {
test_no_props();
test_no_fb(false);
return 0;
} else if (strcmp(test_name, "zero-fb-id") == 0) {
test_no_fb(true);
return 0;
}