简体   繁体   English

在 SSH 上运行 Qt 单元测试

[英]Running Qt unit tests over SSH

I've written a number of unit tests for a Qt application using QTest which are packaged into a separate executable and can be run from a terminal.我使用 QTest 为 Qt 应用程序编写了许多单元测试,它们被打包到单独的可执行文件中,可以从终端运行。 Both executables can be compiled and run fine from both my desktop and my Jenkins server.这两个可执行文件都可以在我的桌面和我的 Jenkins 服务器上编译和运行。

However, when I try to run these unit tests via a job on Jenkins using SSH, I receive the following error:但是,当我尝试使用 SSH 通过 Jenkins 上的作业运行这些单元测试时,我收到以下错误:

qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

I assume that this is an issue with SSH not supporting graphical interfaces, but I would assume Qt must have a way of running unit tests over SSH for continuous integration?我认为这是 SSH 不支持图形界面的问题,但我认为 ZE8801102A40AD89DDCFCFDCAEBF008D25Z 必须有一种在 SSH 上运行单元测试以进行持续集成的方法? Or is this not possible?或者这是不可能的? This uses version 6.2.2 of Qt.这使用版本 6.2.2 的 Qt。

Qt applications are graphical. Qt 应用程序是图形化的。 When you are SSH-ing into the Jenkins server you shell on the server will not have a properly configured DISPLAY variable.当您通过 SSH 连接到 Jenkins 服务器时,服务器上的 shell 将没有正确配置的 DISPLAY 变量。

What does a DISPLAY variable do? DISPLAY 变量有什么作用?

The default now is :0 , which is short for connect to the server at IP address 127.0.0.1 using the first display (0).现在的默认值为:0 ,它是使用第一个显示 (0) 连接到 IP 地址 127.0.0.1 的服务器的缩写。

The display server in your case is likely the system you are logged into at the time you SSH to the Jenkins server.在您的情况下,显示服务器可能是您在 SSH 到 Jenkins 服务器时登录的系统。 So you will need to work out the IP address of your system.因此,您需要计算出系统的 IP 地址。 That is usually as easy as running who : risner pts/0 2022-09-05 06:50 (203.0.113.2)这通常就像运行who一样简单:risner pts/0 2022-09-05 06:50 (203.0.113.2)

Set your DISPLAY variable:设置您的 DISPLAY 变量:

export DISPLAY=203.0.113.2:0 for zsh/bash/sh/ksh为 zsh/bash/sh/ksh export DISPLAY=203.0.113.2:0

setenv DISPLAY 203.0.113.2:0 for csh/tcsh setenv DISPLAY 203.0.113.2:0用于 csh/tcsh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM