QTest unit executed with xvfb-run can't find any resource
-
Hello, I'm developing a library to manage CAN frames around a GUI app, for reliability reasons I started coding some tests. In my computer tests run with no problem but then inside docker, executing with xvfb-run, the tests executable has no resources apparently. This is kind of a problem because the test where the error occurs is to test a class that opens .csv files and starts sending can frames at a given speed, with no files I can't test it unless I create the file live and that might work, but I find this strange because I thought all files in qt resources where embedded in the executable. Here goes prints from my local computer, ci output, print of the code and a link to the project.
Docker
Repo -
Well, I should have gone to the vm in the first place, managed to reproduce the same error. I noticed some odd behavior when qDebug() printed nothing (and still doesn't during test on linux), so I also noticed that my build was in release mode, building in debug solved the problem that appears during opening a file in resources. In macOS this was no problem, tests built in release mode worked fine...
-
Hi,
Are you sure it's not related to the fact that it is GUI test ? Did you try to run with the offscreen backend ?
-
@SGaist said in QTest unit executed with xvfb-run can't find any resource:
offscreen backend
Well I thought it wasn't a gui test because of the console configuration set in .pro file, you say it's a GUI test because of the QTEST_MAIN(TestCom) declaration? Because the classes I'm testing use no GUI.
I'm sorry but I'm a mechanical engineering student, everything I know about coding is self taught and some things I still don't know. So I didn't understood your "offscreen backend" term.
-
@DiogoPereira98 said in QTest unit executed with xvfb-run can't find any resource:
Well I thought it wasn't a gui test because of the console configuration set in .pro file, you say it's a GUI test because of the QTEST_MAIN(TestCom) declaration? Because the classes I'm testing use no GUI.
No, it will be a non-GUI test if you have neither the widgets nor the gui modules used in your lib/test/etc.
IIRC
console
has only a meaning on Windows. -
Okay so I tried -platform offscreen and the result is the same, I noticed the first message was about the lack of a Environment variable, since it's related to paths, that might be the root of my problem, dunno why this is a problem since I'm using qt's resource system. This might be related to docker and lack of user? (Sorry if I'm saying something stupid)
This print is from docker container sh.
If you don't have any ideas on how to solve this I can just put a tag in my ci script to force running tests in one of our local computers using bash, not docker, this would definitely fix the issue.
Anyway, thanks for your time!
-
If you have access to that runner and the docker image, you should try to run the test by hand. You might be more easily able to find what is going on and maybe have a more thorough backtrace.
That fatal error is pretty strange but there's not much information currently.
-
I don't have access to the runner since it is a Gitlab shared runner but this print is from the same docker image running on docker engine for macOS (10.14) and the issue reproduces itself very easily. The docker image is at formulapereira/fedoraqt5:latest if you are interested in this issue. But as I said, gitlab-runner allows me to register my computer has a ci runner and I can register as sh or docker runner, registering as sh runner will fix my problem since in macOS bash I can run tests with no problem. But continuing using the same docker for building and testing would be ideal. If I build in docker and then run tests in another machine I will probably run into library issues so I would need to either build tests separately or quit using docker altogether and use always sh.
-
Ok, I thought you were using Gitlab on premise.
Did you try to run your tests in a Linux virtual machine ?
-
In the future we will have gitlab on premise but for now we are still using regular gitlab, but we have some of our personal computers registered as runners for macOS, Windows and Linux because there are no macOS docker images and windows docker images only run on windows...
Actually I don't think so, but I'm not sure, I'll do that once I grab my vm ssd and post the results. -
Well, I should have gone to the vm in the first place, managed to reproduce the same error. I noticed some odd behavior when qDebug() printed nothing (and still doesn't during test on linux), so I also noticed that my build was in release mode, building in debug solved the problem that appears during opening a file in resources. In macOS this was no problem, tests built in release mode worked fine...
-
Ok, I thought you were using Gitlab on premise.
Did you try to run your tests in a Linux virtual machine ?
@SGaist sorry if I'm being boring but are qtests supposed to be always compiled in debug mode?
-
Hi,
AFAIR, no, there's no such limitation.