Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Test: how to change the timeout and also disable timeout
Servers for Qt installer are currently down

Qt Test: how to change the timeout and also disable timeout

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 2.3k 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.
  • S Offline
    S Offline
    Snorkelbuckle
    wrote on 12 Mar 2020, 20:43 last edited by
    #1

    Hiya,

    Using Qt Test for first time. I have the testing framework working well with my tests. However, some of the tests require long running time. They get canceled by Qt Test due to timeout. How can I change the timeout to a very long time since I don't really know how long it will take to run.

    I'm running perft tests to enumerate possible moves from a game position to large depths of up to 23 - 30, the number of nodes can get quite large and time consuming to calculate. So far, I get timeouts at depth of 5 and this is just not going to work unless I can change the timeout or even disable.

    Is it possible to disable the timeout and allow manual cancellation? In some cases, I'd want to let the calculations to run over night.

    Thanks

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Snorkelbuckle
      wrote on 13 Mar 2020, 01:42 last edited by
      #5

      Well, I'm a dufus, there is a way to change it in Qt Creater:

      qt-test-timeout.png

      However, the maximum allowed value is 9999 seconds. Which is about 2.7 hours. I might need a bit longer, I'll let you know. Would be nice to change it to a very long time without having to go through coding gymnastics.

      How much do you know about the Qt test framework, I'm wondering if I can use the initTestCase() function, if this function is outside the timeout checks? If yes, I suppose I could use it to do the long calc stuff and then just check the returned values in the testcases but it seems to kind of defeat the purpose of the framework.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 12 Mar 2020, 20:46 last edited by
        #2

        Hi,

        Maybe qWaitFor is what you need.

        Hope it helps

        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
        0
        • S Offline
          S Offline
          Snorkelbuckle
          wrote on 12 Mar 2020, 21:25 last edited by
          #3

          I'm not exactly sure how to use this function. How would you modify this test case to use qWaitFor?

          void ChessValidator::perft_startposition()
              {
              QFETCH(QString, fen);
              QFETCH(int, depth);
              QFETCH(qint64, nodes);
              Chess chess;
              qint64 calculated_nodes = chess.Perft(depth);
              QCOMPARE(calculated_nodes, nodes);
              }
          

          I just don't understand how qWaitFor will know when Perft() is done calculating.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 12 Mar 2020, 21:39 last edited by
            #4

            Indeed it won't with that design.

            One alternative could be to use QtConcurrent::run to execute that method and the returned QFuture with qWaitFor.

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

            S 1 Reply Last reply 13 Mar 2020, 01:45
            0
            • S Offline
              S Offline
              Snorkelbuckle
              wrote on 13 Mar 2020, 01:42 last edited by
              #5

              Well, I'm a dufus, there is a way to change it in Qt Creater:

              qt-test-timeout.png

              However, the maximum allowed value is 9999 seconds. Which is about 2.7 hours. I might need a bit longer, I'll let you know. Would be nice to change it to a very long time without having to go through coding gymnastics.

              How much do you know about the Qt test framework, I'm wondering if I can use the initTestCase() function, if this function is outside the timeout checks? If yes, I suppose I could use it to do the long calc stuff and then just check the returned values in the testcases but it seems to kind of defeat the purpose of the framework.

              1 Reply Last reply
              0
              • S SGaist
                12 Mar 2020, 21:39

                Indeed it won't with that design.

                One alternative could be to use QtConcurrent::run to execute that method and the returned QFuture with qWaitFor.

                S Offline
                S Offline
                Snorkelbuckle
                wrote on 13 Mar 2020, 01:45 last edited by
                #6

                @SGaist

                Regarding using QtConcurrent::run and QFuture, I'm doubtful it would work because if I read the docs right about Qt Test, the timeout is checking the execution of the testcase, in my case, ChessValidator::perft_startposition(). So even if I spin off a concurrent process and wait for it to return, wouldn't the test case still fail at the timeout period?

                1 Reply Last reply
                0

                1/6

                12 Mar 2020, 20:43

                • Login

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