test: print environment details before test suites

Log display backend, metrics, screen size, fontconfig matches and font ids once so CI failures can be compared against the local environment.
This commit is contained in:
Liu
2026-11-21 15:13:53 +08:00
parent 03aef4fed3
commit cf111c4a90
2 changed files with 43 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
#include <LCUI.h>
#include <ctest-custom.h>
void test_environment(void)
{
char *mono, *sans, *serif;
const char *display = getenv("DISPLAY");
const char *wayland = getenv("WAYLAND_DISPLAY");
lcui_init();
mono = pd_font_find_path("monospace");
sans = pd_font_find_path("sans-serif");
serif = pd_font_find_path("serif");
printf("[env] version: %s\n", lcui_get_version());
printf("[env] display: DISPLAY=%s WAYLAND_DISPLAY=%s\n",
display ? display : "(unset)", wayland ? wayland : "(unset)");
printf("[env] metrics: dpi=%.2f scale=%.2f density=%.2f "
"scaled_density=%.2f\n",
ui_metrics.dpi, ui_metrics.scale, ui_metrics.density,
ui_metrics.scaled_density);
printf("[env] screen: %dx%d\n", ptk_screen_get_width(),
ptk_screen_get_height());
printf("[env] font monospace: %s\n", mono ? mono : "(none)");
printf("[env] font sans-serif: %s\n", sans ? sans : "(none)");
printf("[env] font serif: %s\n", serif ? serif : "(none)");
printf("[env] font ids: monospace=%d sans-serif=%d serif=%d\n",
pd_font_get_id("monospace", PD_FONT_STYLE_NORMAL,
PD_FONT_WEIGHT_NORMAL),
pd_font_get_id("sans-serif", PD_FONT_STYLE_NORMAL,
PD_FONT_WEIGHT_NORMAL),
pd_font_get_id("serif", PD_FONT_STYLE_NORMAL,
PD_FONT_WEIGHT_NORMAL));
free(mono);
free(sans);
free(serif);
lcui_destroy();
}
+2
View File
@@ -73,9 +73,11 @@ extern void test_breadcrumb(void);
extern void test_input_group(void);
extern void test_window_restore(void);
extern void test_window_api(void);
extern void test_environment(void);
extern void test_window_events(void);
static const ctest_suite_t suites[] = {
{ "environment", test_environment },
{ "settings", test_settings },
{ "clipboard", test_clipboard },
{ "mainloop", test_mainloop },