Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. cpputest issue with QTest to show the widget on embedded linux
Forum Updated to NodeBB v4.3 + New Features

cpputest issue with QTest to show the widget on embedded linux

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
15 Posts 2 Posters 1.7k Views 2 Watching
  • 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.
  • R Offline
    R Offline
    Ramakanth
    wrote on last edited by
    #6

    Here is the stack trace but it doesnot points to any Qt sources but only cpputest:

    #0 0x002ad996 in isInPeriod (period=mem_leak_period_checking, node=0x10, this=<optimized out>)
    at ../src/CppUTest/MemoryLeakDetector.cpp:270
    #1 MemoryLeakDetectorList::isInPeriod (this=0xe658ac, node=0x10, period=mem_leak_period_checking)
    at ../src/CppUTest/MemoryLeakDetector.cpp:268
    #2 0x002ada86 in MemoryLeakDetectorList::getTotalLeaks (this=this@entry=0xe658ac,
    period=period@entry=mem_leak_period_checking) at ../src/CppUTest/MemoryLeakDetector.cpp:354
    #3 0x002adbae in MemoryLeakDetectorTable::getTotalLeaks (this=0xe65824, period=mem_leak_period_checking)
    at ../src/CppUTest/MemoryLeakDetector.cpp:391
    #4 0x002a7e78 in MemoryLeakWarningPlugin::postTestAction (this=0xbeebfba0, test=..., result=...)
    at ../src/CppUTest/MemoryLeakWarningPlugin.cpp:551
    #5 0x002aadb0 in runAllPostTestAction (result=..., test=..., this=0xbeebfba0)
    at ../src/CppUTest/TestPlugin.cpp:60
    #6 TestPlugin::runAllPostTestAction (this=0xbeebfba0, test=..., result=...)
    at ../src/CppUTest/TestPlugin.cpp:57
    #7 0x002aada0 in TestPlugin::runAllPostTestAction (this=0xbeebfb58, test=..., result=...)
    at ../src/CppUTest/TestPlugin.cpp:59
    #8 0x002ac664 in UtestShell::runOneTestInCurrentProcess (
    this=0x63ab8c <TEST_uiNormalTestGroup_resizeEvent_NormalTest_TestShell_instance>,
    plugin=0xbeebfb58, result=...) at ../src/CppUTest/Utest.cpp:216
    #9 0x002ab65a in helperDoRunOneTestInCurrentProcess (data=<optimized out>) at ../src/CppUTest/Utest.cpp:116
    #10 0x002ac90c in PlatformSpecificSetJmpImplementation (
    function=0x2ab651 <helperDoRunOneTestInCurrentProcess(void*)>, data=0xbeebfacc)
    at ../src/Platforms/Gcc/UtestPlatform.cpp:144
    #11 0x002ab6b4 in UtestShell::runOneTest (
    this=0x63ab8c <TEST_uiSystemNormalTestGroup_resizeEvent_SystemNormalTest_TestShell_instance>,
    plugin=<optimized out>, result=...) at ../src/CppUTest/Utest.cpp:185
    #12 0x002ab4b6 in TestRegistry::runAllTests (this=0x6bd5bc TestRegistry::getCurrentRegistry()::registry,
    result=...) at ../src/CppUTest/TestRegistry.cpp:62
    #13 0x002a6668 in CommandLineTestRunner::runAllTests (this=this@entry=0xbeebfb90)
    at ../src/CppUTest/CommandLineTestRunner.cpp:119
    #14 0x002a66ee in CommandLineTestRunner::runAllTestsMain (this=this@entry=0xbeebfb90)
    at ../src/CppUTest/CommandLineTestRunner.cpp:80
    #15 0x002a6794 in CommandLineTestRunner::RunAllTests (ac=4, av=0xbeebfd44)
    at ../src/CppUTest/CommandLineTestRunner.cpp:50
    #16 0x000b243c in main (argc=4, argv=0xbeebfd44) at src/uiUnitTest.cpp:59

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #7

      Might be a silly question but are you sure that -qws parameter is passed to your QApplication instance ?

      Depending on what you want to test, you might also want to consider Qt's own QTest framework.

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

      R 1 Reply Last reply
      1
      • SGaistS SGaist

        Might be a silly question but are you sure that -qws parameter is passed to your QApplication instance ?

        Depending on what you want to test, you might also want to consider Qt's own QTest framework.

        R Offline
        R Offline
        Ramakanth
        wrote on last edited by
        #8

        @SGaist Yes running the unit test binary with -qws..As we need to do mock c libraries as well, ui unit tests are run within CPPUTEST framework and use QTEST library to execute Qt specific functionality like QSignalSpy. Any suggestion/hint if it could throw any memory leak incase widget->show() is being called on target with -qws or any known issue in Qt bug tracker in Qt 4.8?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          Did you check whether cpputest has a runner for Qt ?

          In any case, if you have so much trouble running Qt tests, the I would recommand using the QtTest framework as it will handle all Qt related features to test your GUI.

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

          R 1 Reply Last reply
          2
          • SGaistS SGaist

            Did you check whether cpputest has a runner for Qt ?

            In any case, if you have so much trouble running Qt tests, the I would recommand using the QtTest framework as it will handle all Qt related features to test your GUI.

            R Offline
            R Offline
            Ramakanth
            wrote on last edited by
            #10

            @SGaist
            Do you mean Qt testrunner in https://github.com/autosportlabs/CppUTest/blob/master/examples/qt/Main.cpp?
            As we need cpputest to test mock c libraries within UI, we donot have flexibility to use only QTest as it doesnot supports mocking. Is it possible to switch between cpputest and qtest runs as and when required?

            Apart from running app.exec() in the below, are there any other means to make event loop available or run per test as mentioned in http://blog.davidecoppola.com/2017/11/cpp-unit-testing-with-qt-test-introduction/?

            int main(int argc, char *argv[])
            {
            qputenv("QT_LOGGING_TO_CONSOLE","1");
            QApplication app( argc, argv );
            CommandLineTestRunner::RunAllTests(argc, argv);
            return 0;
            }

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #11

              Yes, that's the kind of runner I am thinking about. Did you already test it ?

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

              R 1 Reply Last reply
              0
              • SGaistS SGaist

                Yes, that's the kind of runner I am thinking about. Did you already test it ?

                R Offline
                R Offline
                Ramakanth
                wrote on last edited by
                #12

                @SGaist Nope as the runner shall not support mocking of c library functions which are required to unit test qt code.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #13

                  What do you mean by shall not support mocking ?

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

                  R 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    What do you mean by shall not support mocking ?

                    R Offline
                    R Offline
                    Ramakanth
                    wrote on last edited by
                    #14

                    @SGaist Sorry for the delayed response. I meant no in-built support for mocks creation using QTest Unlike Google mock or Cpputest support which simplifies the way mocks are created so they can be manipulated for each testcase.

                    As we need to unit test the connect statements/event filter/event callbacks (showEvent,HideEvent,resizeEvent,changeEvent etc) , could you please suggest on how to test in existing cpputest runner using QTest library? Does adding app.exec() in the below would help or any means using QSignalSpy?

                    int main(int argc, char *argv[])
                    {
                    qputenv("QT_LOGGING_TO_CONSOLE","1");
                    QApplication app( argc, argv );
                    int returnVal = app.exec();
                    CommandLineTestRunner::RunAllTests(argc, argv);
                    return returnVal ;
                    }

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #15

                      No because exec is a blocking call.

                      One thing I would try is to use a single shot QTimer with a lambda to call RunAllTests.

                      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
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved