Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Solved QTest unit executed with xvfb-run can't find any resource

    General and Desktop
    2
    12
    813
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DiogoPereira98
      DiogoPereira98 last edited by DiogoPereira98

      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

      1_1554840012001_Captura de ecrã 2019-04-09, às 20.37.13.jpg 0_1554840012000_Captura de ecrã 2019-04-09, às 20.36.40.jpg 0_1554840147078_Captura de ecrã 2019-04-09, às 21.01.14.jpg

      1 Reply Last reply Reply Quote 0
      • DiogoPereira98
        DiogoPereira98 last edited by

        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...

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          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 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • DiogoPereira98
            DiogoPereira98 last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              @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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 0
              • DiogoPereira98
                DiogoPereira98 last edited by DiogoPereira98

                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.
                0_1554844005492_Captura de ecrã 2019-04-09, às 22.05.48.jpg

                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!

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  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.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply Reply Quote 0
                  • DiogoPereira98
                    DiogoPereira98 last edited by DiogoPereira98

                    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.

                    1 Reply Last reply Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      Ok, I thought you were using Gitlab on premise.

                      Did you try to run your tests in a Linux virtual machine ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      DiogoPereira98 1 Reply Last reply Reply Quote 0
                      • DiogoPereira98
                        DiogoPereira98 last edited by DiogoPereira98

                        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.

                        1 Reply Last reply Reply Quote 0
                        • DiogoPereira98
                          DiogoPereira98 last edited by

                          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...

                          1 Reply Last reply Reply Quote 0
                          • DiogoPereira98
                            DiogoPereira98 @SGaist last edited by

                            @SGaist sorry if I'm being boring but are qtests supposed to be always compiled in debug mode?

                            1 Reply Last reply Reply Quote 0
                            • SGaist
                              SGaist Lifetime Qt Champion last edited by

                              Hi,

                              AFAIR, no, there's no such limitation.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post