Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-98879

moc fails to see tests #if'd on a define conditionally set on #if __has_include<...>

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.3
    • Build tools: moc
    • None
    • Linux/x86 with Valgrind installed.
    • Linux/X11

    Description

      If you apply patch

      diff --git a/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp b/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
      index b3cf623375d..4df96e3cb3c 100644
      --- a/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
      +++ b/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp
      @@ -39,14 +39,16 @@ class tst_BenchlibCallgrind: public QObject
           Q_OBJECT
       
       private slots:
      +#ifdef HAVE_VALGRIND_H
           void failInChildProcess();
      +#endif
       
           void twoHundredMillionInstructions();
       };
       
      +#ifdef HAVE_VALGRIND_H
       void tst_BenchlibCallgrind::failInChildProcess()
       {
      -#ifdef HAVE_VALGRIND_H
           static double f = 1.0;
           QBENCHMARK {
               for (int i = 0; i < 1000000; ++i) {
      @@ -54,10 +56,8 @@ void tst_BenchlibCallgrind::failInChildProcess()
                   if (RUNNING_ON_VALGRIND) QFAIL("Running under valgrind!");
               }
           }
      -#else
      -    QSKIP("Skipping test because I can't see <valgrind/valgrind.h> - is valgrind installed ?");
      -#endif
       }
      +#endif
       
       void tst_BenchlibCallgrind::twoHundredMillionInstructions()
       {
      

      to qtbase after https://codereview.qt-project.org/c/qt/qtbase/+/382890/3 then build and run the benchlibcallgrind test, failInChildProcess() does not appear in the output, even if you do have valgrind installed. Without the above patch, the test runs and gains

      FAIL!  : tst_BenchlibCallgrind::failInChildProcess() Running under valgrind!
         Loc: [qtbase/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp(0)]
      

      added to its output, as seen here.

      Note that the HAVE_VALGRIND_H define is controlled by a

      #if __has_include(<valgrind/valgrind.h>)
      #  include <valgrind/valgrind.h>
      #  define HAVE_VALGRIND_H
      #endif
      

      earlier in the file.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            fabiankosmale Fabian Kosmale
            Eddy Edward Welbourne
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes