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. How do I test my lib?
Forum Updated to NodeBB v4.3 + New Features

How do I test my lib?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 681 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.
  • A Offline
    A Offline
    aethelnorn
    wrote on last edited by aethelnorn
    #1

    I am creating a subdirs project which will have several libs. Some of these are open source and come with tests, so I want to include the tests in the project.

    The first was simple as the source contains a command-line executable dedicated to doing a quick test. I made that into one of my sub projects.

    The next creates several command-line executables one of which is used for testing, but the testing is done by a bit of bash type script:

    check-local:
    rm -f testout
    ./djpeg -dct int -ppm -outfile testout.ppm $(srcdir)/testorig.jpg
    ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp $(srcdir)/testorig.jpg
    ./cjpeg -dct int -outfile testout.jpg $(srcdir)/testimg.ppm
    ./djpeg -dct int -ppm -outfile testoutp.ppm $(srcdir)/testprog.jpg
    ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg $(srcdir)/testimg.ppm
    ./jpegtran -outfile testoutt.jpg $(srcdir)/testprog.jpg
    cmp $(srcdir)/testimg.ppm testout.ppm
    cmp $(srcdir)/testimg.bmp testout.bmp
    cmp $(srcdir)/testimg.jpg testout.jpg
    cmp $(srcdir)/testimg.ppm testoutp.ppm
    cmp $(srcdir)/testimgp.jpg testoutp.jpg
    cmp $(srcdir)/testorig.jpg testoutt.jpg

    Can I do something like that in Qt?
    And how do I declare the resource files (*.jpg) that I will need? They will need to be copied to wherever the executable get executed.....

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by dheerendra
      #2

      What is that you wanted in Qt ? Question is not very clear. Do you want execute one by one ?give more details.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      A 1 Reply Last reply
      0
      • dheerendraD dheerendra

        What is that you wanted in Qt ? Question is not very clear. Do you want execute one by one ?give more details.

        A Offline
        A Offline
        aethelnorn
        wrote on last edited by
        #3

        @dheerendra OK thinking more clearly about this I can narrow down my requirement.... part of the problem is that I am new to this build system and so do not know the correct questions to ask.

        What I would like to do is:

        • build a command-line executable
        • run the executable on a particular file (input file)
        • compare the resulting file to a file representing the expected result (reference file), and report/throw an error if they differ.

        So I guess there are several gaps in my knowledge:

        • how do I know where my input file is - I can store it in git but the app is run in a different directory. Presumably where it is built, and that may vary. So somehow I need to make sure that my input and reference files wind up in the directory with the app.
        • How do I run a system command (in this case file compare) automatically after the app. Is this even a thing in Qt?
        • How do I flag up an error result

        I am sort of thinking of a target (subdir app) that runs and its output tells me that the lib built fine. Maybe I am expecting too much of this build system -gradle does this testing type thing, but then gradle does not give me the multiplatform support that Qt does.

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

          Hi,

          You are likely looking for the QtTest module.

          Your reference file(s) should be part of the sources. You can, for example, create a define that will contain the absolute path to your resource for the test for find it.

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

          A 1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            You are likely looking for the QtTest module.

            Your reference file(s) should be part of the sources. You can, for example, create a define that will contain the absolute path to your resource for the test for find it.

            A Offline
            A Offline
            aethelnorn
            wrote on last edited by
            #5

            @SGaist Thankyou, that looks at first glance to be exactly what I need.

            1 Reply Last reply
            0

            • Login

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