Skip to content

Commit

Permalink
Fix uninitialized use of PangoContext in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bynect committed Apr 19, 2024
1 parent f38a60a commit bc36132
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ test: test/test clean-coverage-run
test-valgrind: test/test
${VALGRIND} \
--suppressions=.valgrind.suppressions \
--track-origins=yes \
--leak-check=full \
--show-leak-kinds=definite \
--errors-for-leak-kinds=definite \
Expand Down
27 changes: 21 additions & 6 deletions test/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cairo_t *c;
double get_dummy_scale(void) { return 1; }

const struct screen_info* noop_screen(void) {
static struct screen_info i;
static struct screen_info i = {0};
return &i;
}

Expand Down Expand Up @@ -267,15 +267,18 @@ TEST test_layout_render_no_gaps(void)
dim = calculate_dimensions(layouts);
image_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);

enum corner_pos corners = C_TOP | _C_FIRST;
enum corner_pos corners = (settings.corners & C_TOP) | _C_FIRST;
for (GSList *iter = layouts; iter; iter = iter->next) {

struct colored_layout *cl_this = iter->data;
struct colored_layout *cl_next = iter->next ? iter->next->data : NULL;

if (!cl_next)
corners |= C_BOT | _C_LAST;
dim = layout_render(image_surface, cl_this, cl_next, dim, corners);
if (settings.gap_size)
corners = settings.corners;
else if (!cl_next)
corners |= (settings.corners & C_BOT) | _C_LAST;

dim = layout_render(image_surface, cl_this, cl_next, dim, corners);
corners &= ~(C_TOP | _C_FIRST);
}

Expand Down Expand Up @@ -311,11 +314,19 @@ TEST test_layout_render_gaps(void)
dim = calculate_dimensions(layouts);
image_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);

enum corner_pos corners = (settings.corners & C_TOP) | _C_FIRST;
for (GSList *iter = layouts; iter; iter = iter->next) {

struct colored_layout *cl_this = iter->data;
struct colored_layout *cl_next = iter->next ? iter->next->data : NULL;

dim = layout_render(image_surface, cl_this, cl_next, dim, C_ALL);
if (settings.gap_size)
corners = settings.corners;
else if (!cl_next)
corners |= (settings.corners & C_BOT) | _C_LAST;

dim = layout_render(image_surface, cl_this, cl_next, dim, corners);
corners &= ~(C_TOP | _C_FIRST);
}

expected_y = get_expected_dimension_y_offset(layout_count);
Expand All @@ -336,6 +347,10 @@ SUITE(suite_draw)
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
c = cairo_create(s);

// XXX: This variable should not be accessed like this
extern PangoContext *pango_ctx;
pango_ctx = pango_cairo_create_context(c);

SHUFFLE_TESTS(time(NULL), {
RUN_TEST(test_layout_from_notification);
RUN_TEST(test_layout_from_notification_icon_off);
Expand Down

0 comments on commit bc36132

Please sign in to comment.