mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
highgui test: force offscreen Qt platform to avoid CI crash
CI (Ubuntu ARM64 x2) showed the Python test suite aborting the whole process with exit code 134: on a Qt-enabled build, namedWindow() tried the "xcb" platform plugin, found no display (the Python test step, unlike the C++ gtest step, does not run under xvfb-run), and Qt aborted the process instead of raising a catchable exception -- so the existing try/except around namedWindow never got a chance to run. Fix: set QT_QPA_PLATFORM=offscreen (only if not already set) before any GUI call. "offscreen" is the platform plugin Qt ships specifically for headless/CI use, and is listed as available in the failing CI job's own log output. Verified locally: built opencv_python3 with WITH_QT=ON (real Qt6, not the WITH_QT=OFF build used in the initial verification), and confirmed that in a clean environment (no DISPLAY, no QT_QPA_PLATFORM preset), namedWindow + saveWindowParameters + loadWindowParameters all succeed with this fix, where they would previously depend on a native display backend being reachable.
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
|
||||
# Force Qt's headless-safe platform plugin when nothing else is already
|
||||
# configured. Without this, namedWindow() on a Qt-enabled build with no
|
||||
# display server available (e.g. CI workers, which do not run the Python
|
||||
# test suite under a virtual framebuffer) aborts the whole process instead
|
||||
# of raising a catchable exception -- so this must be set *before* the
|
||||
# first GUI call, and a plain try/except around namedWindow is not enough.
|
||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
import cv2 as cv
|
||||
|
||||
from tests_common import NewOpenCVTests
|
||||
|
||||
Reference in New Issue
Block a user