Brewtarget / brewtarget

Main brewtarget source code repository.
GNU General Public License v3.0
310 stars 134 forks source link

Meson: Tests all fail with SIGABRT #771

Closed penguinpee closed 10 months ago

penguinpee commented 10 months ago

Are the tests supposed to work when run with /usr/bin/meson test?

I'm not an expert on Meson nor testing in C++. I'm relying on Meson RPM macros which expands to above command plus options specific to the build environment. I get the following result:

+ /usr/bin/meson test -C redhat-linux-build --num-processes 8 --print-errorlogs --verbose
ninja: Entering directory `/builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build'
ninja: no work to do.
1/9 Test integer sizes                   RUNNING       
>>> MALLOC_PERTURB_=20 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests pstdintTest

2/9 Test recipe calculations - all grain RUNNING       
>>> MALLOC_PERTURB_=149 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests recipeCalcTest_allGrain

3/9 Test post boil loss OG               RUNNING       
>>> MALLOC_PERTURB_=203 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests postBoilLossOgTest

4/9 Test unit conversions                RUNNING       
>>> MALLOC_PERTURB_=102 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests testUnitConversions

5/9 Test NamedParameterBundle            RUNNING       
>>> MALLOC_PERTURB_=111 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests testNamedParameterBundle

6/9 Test number display and parsing      RUNNING       
>>> MALLOC_PERTURB_=106 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests testNumberDisplayAndParsing

7/9 Test algorithms                      RUNNING       
>>> MALLOC_PERTURB_=45 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests testAlgorithms

8/9 Test type lookups                    RUNNING       
>>> MALLOC_PERTURB_=124 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests testTypeLookups

1/9 Test integer sizes                   FAIL            0.21s   killed by signal 6 SIGABRT

9/9 Test log rotation                    RUNNING       
>>> MALLOC_PERTURB_=211 /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/brewtarget_tests testLogRotation

6/9 Test number display and parsing      FAIL            0.23s   killed by signal 6 SIGABRT

5/9 Test NamedParameterBundle            FAIL            0.23s   killed by signal 6 SIGABRT

3/9 Test post boil loss OG               FAIL            0.24s   killed by signal 6 SIGABRT

4/9 Test unit conversions                FAIL            0.24s   killed by signal 6 SIGABRT

7/9 Test algorithms                      FAIL            0.22s   killed by signal 6 SIGABRT

2/9 Test recipe calculations - all grain FAIL            0.27s   killed by signal 6 SIGABRT

8/9 Test type lookups                    FAIL            0.24s   killed by signal 6 SIGABRT

9/9 Test log rotation                    FAIL            0.18s   killed by signal 6 SIGABRT

Summary of Failures:

1/9 Test integer sizes                   FAIL            0.21s   killed by signal 6 SIGABRT
6/9 Test number display and parsing      FAIL            0.23s   killed by signal 6 SIGABRT
5/9 Test NamedParameterBundle            FAIL            0.23s   killed by signal 6 SIGABRT
3/9 Test post boil loss OG               FAIL            0.24s   killed by signal 6 SIGABRT
4/9 Test unit conversions                FAIL            0.24s   killed by signal 6 SIGABRT
7/9 Test algorithms                      FAIL            0.22s   killed by signal 6 SIGABRT
2/9 Test recipe calculations - all grain FAIL            0.27s   killed by signal 6 SIGABRT
8/9 Test type lookups                    FAIL            0.24s   killed by signal 6 SIGABRT
9/9 Test log rotation                    FAIL            0.18s   killed by signal 6 SIGABRT

Ok:                 0   
Expected Fail:      0   
Fail:               9   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

Full log written to /builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/meson-logs/testlog.txt
matty0ung commented 10 months ago

Could you upload the file mentioned on the last line (/builddir/build/BUILD/brewtarget-3.0.9/redhat-linux-build/meson-logs/testlog.txt)? It usually shows the reason for the failure, or at least gives a better clue. I'd guess it's probably some shared library issue or something else environmental if all the tests failed, but let's see.

penguinpee commented 10 months ago

I didn't see anything in the file as to a hint why it failed, but here it is: testlog.txt

The inherited environment is the default build environment. If needed it can tweaked to some extend.

matty0ung commented 10 months ago

Ah, that's interesting. What happens if you run one of the tests directly from the command line? Eg, in the mbuild directory, try ./brewtarget_tests pstdintTest

penguinpee commented 10 months ago

This happens:

sh-5.2# ./brewtarget_tests pstdintTest
qt.qpa.xcb: could not connect to display 
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Aborted (core dumped)

And, of course, that's because there's no graphical session in the build environment. I'll check with folks here what I can / should do about it. I suppose all of the tests require it.

matty0ung commented 10 months ago

That would explain why it's all the tests that are failing without any log output. I don't know whether it helps, but the GitHub actions for Brewtarget (eg https://github.com/Brewtarget/brewtarget/blob/develop/.github/workflows/linux-ubuntu.yml) manage to run the tests in a (presumably) headerless environment. Not sure how that compares with the set-up you're using though.

penguinpee commented 10 months ago

That's using CMake for the tests, but that shouldn't matter.

https://github.com/Brewtarget/brewtarget/blob/e5dc7bad92c6ff27cbd96f8206ef0aa54e621733/.github/workflows/linux-ubuntu.yml#L103

I guess I need to setup the environment a bit before running the tests. I'll provide feedback once I found out.

matty0ung commented 10 months ago

We also run the tests in Meson: https://github.com/Brewtarget/brewtarget/blob/e5dc7bad92c6ff27cbd96f8206ef0aa54e621733/.github/workflows/linux-ubuntu.yml#L115

matty0ung commented 10 months ago

If you have a look at the installDependencies() function in the bt Python script (see https://github.com/Brewtarget/brewtarget/blob/e5dc7bad92c6ff27cbd96f8206ef0aa54e621733/bt#L417) it shows all the environment set-up we do on Ubuntu, Windows and Mac. Hopefully that gives good clues for what's needed on Fedora.

penguinpee commented 10 months ago

Excellent! I'll take a look. I also asked around among fellow fedora packagers.

penguinpee commented 10 months ago

I finally got around to continue on that. It seems in our very confined build chroot, the way to go is xvfb-run (in Fedora that's part of xorg-x11-server-Xvfb). which runs a command in a graphical environment. Thanks to @sanjayankur31 for pointing me in that direction.

I was able to run the tests and they all passed except for testLogRotation. Since there's no easy way, it seems, to exclude tests using meson, is there a way I can configure where the test wants to rotate log files?

matty0ung commented 10 months ago

Glad you managed to get the tests to run.

We actually ask Qt to give us a suitable temporary directory for log files etc for the unit tests. It should normally be /tmp on Linux. We then create a sub-directory inside based on the thread ID, and put all our log files in there. (This allows multiple tests to run in parallel with different thread IDs.) According to the Qt documentation, you can set the TMPDIR environment variable to tell Qt to use a different directory than /tmp so that would be the next thing to try if your build/test environment doesn't have access to /tmp, which I guess could well be the case in a chroot environment.

penguinpee commented 10 months ago

I tried with setting TMPDIR and I have seen the directory being mentioned in the log messages. Yet testLogRotation still fails. Since I've found a way [^1] of disabling this one test, I guess I won't put any more work into getting this to work.

Thanks for all your assistance! :beers:

[^1]: sed -i -e '/testLogRotation/d' meson.build - crude but effective :wink: