After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 795251 - googletest detection cannot be overridden
googletest detection cannot be overridden
Status: RESOLVED OBSOLETE
Product: GnuCash
Classification: Other
Component: Build system
3.0
Other Mac OS
: Normal normal
: future
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2018-04-14 07:28 UTC by Thomas Klausner
Modified: 2018-06-30 00:08 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Thomas Klausner 2018-04-14 07:28:47 UTC
My distribution contains a googletest package. It installs the headers in ${PREFIX}/include/gmock and ${PREFIX}/include/gtest (where PREFIX is /usr/pkg in my case). However, it is not sufficient for gnucash's needs, so in the package I unpack googletest-1.8.0 and set GMOCK_ROOT and GTEST_ROOT to point to that.

However, when the googletest package is installed, the build fails:
/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc:40:25: fatal error: gmock/gmock.h: No such file or directory

I haven't completely understood the problem yet, but in effect,  the autodetected ${PREFIX}/include seems to be preferred to the GMOCK_ROOT and GTEST_ROOT (and even GMOCK_INCLUDE_DIR) variables that I pass in manually on the cmake commandline.

Verbose output from cmake + make VERBOSE=1:

With googletest package from distribution installed:

c++  -DHAVE_CONFIG_H -DHAVE_GUILE22 -I/usr/pkg/include -I/scratch/finance/gnucas
h/work/gnucash-3.0/common -I/scratch/finance/gnucash/work/gnucash-3.0/libgnucash/engine -I/scratch/finance/gnucash/work/gnucash-3.0/common/test-core -I/usr/pkg/include/glib/glib-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/guile/2.2/include/guile/2.2 -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock  -Werror -Wall -Wmissing-declarations -Wno-unused -std=gnu++11 -O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -I/usr/pkg/include/libofx -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/python3.6 -I/usr/pkg/include/glib/glib-2.0 -I/usr/pkg/include/glib/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/freetype2 -I/usr/pkg/include/libdrm -Wno-deprecated-declarations   -Wno-missing-declarations -o CMakeFiles/gmock.dir/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc.o -c /scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc

(build fails as above)

WITHOUT googletest package from distribution installed:

c++  -DHAVE_CONFIG_H -DHAVE_GUILE22 -I/usr/pkg/include -I/scratch/finance/gnucash/work/gnucash-3.0/common -I/scratch/finance/gnucash/work/gnucash-3.0/libgnucash/engine -I/scratch/finance/gnucash/work/gnucash-3.0/common/test-core -I/usr/pkg/include/glib/glib-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/guile/2.2/include/guile/2.2 -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googletest/include -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googletest -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/include -I/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock  -Werror -Wall -Wmissing-declarations -Wno-unused -std=gnu++11 -O2 -g -D_FORTIFY_SOURCE=2 -fstack-check -I/usr/pkg/include/libofx -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/python3.6 -I/usr/pkg/include/glib/glib-2.0 -I/usr/pkg/include/glib/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/freetype2 -I/usr/pkg/include/libdrm -Wno-deprecated-declarations   -Wno-missing-declarations -o CMakeFiles/gmock.dir/scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc.o -c /scratch/finance/gnucash/work/googletest-release-1.8.0/googlemock/src/gmock-all.cc

(build succeeds)

Relevant CMake flags:
-DGMOCK_ROOT=${WRKDIR}/googletest-release-1.8.0/googlemock
-DGMOCK_INCLUDE_DIR=${WRKDIR}/googletest-release-1.8.0/googlemock/include
-DGTEST_ROOT=${WRKDIR}/googletest-release-1.8.0/googletest

where WRKDIR is /scratch/finance/gnucash/work and /scratch/finance/gnucash/work/googletest-release-1.8.0 contains the unpacked source of googletest-1.8.0.
Comment 1 Geert Janssens 2018-04-16 21:43:36 UTC
Can you test with the current head of the maint branch ?

A commit has been merged recently that should allow to build against a system installed shared library version of google test/mock.
Comment 2 Thomas Klausner 2018-04-20 07:00:57 UTC
I installed googletest and ran (from the main branch as of a couple minutes ago):

CXXFLAGS=-Wno-deprecated-declarations cmake .. -DALLOW_OLD_GETTEXT=ON -DWITH_AQBANKING:BOOL=OFF -DWITH_SQL=OFF
make

The build succeeded, so that's good.

I then tried running the tests (I hadn't done that before) and it complains about lots of missing programs and fails a lot of tests. I used "make test".

E.g.
Unable to find executable:
.../gnucash/build/bin/test-transaction-voiding
.../gnucash/build/bin/test-recurrence
.../gnucash/build/bin/test-business
.../gnucash/build/bin/test-employee
.../gnucash/build/bin/test-vendor
...

Then:
24% tests passed, 78 tests failed out of 102
The following tests FAILED:
          1 - test-exp-parser (Failed)
          2 - test-link-module-app-utils (Failed)
          3 - test-print-parse-amount (Not Run)
          4 - test-scm-query-string (Failed)
          5 - test-sx (Not Run)
          9 - test-app-utils (Failed)
         10 - test-date-converting (Not Run)
         11 - test-dom-converters1 (Not Run)
         12 - test-kvp-frames (Not Run)
         13 - test-load-backend (Not Run)
         14 - test-load-xml2 (Failed)
         15 - test-load-example-account (Failed)
         16 - test-string-converters (Not Run)
         17 - test-xml-account (Not Run)
         18 - test-xml-commodity (Not Run)
         19 - test-xml-pricedb (Not Run)
         20 - test-xml-transaction (Not Run)
         21 - test-xml2-is-file (Failed)
         22 - test-real-data (Failed)
         23 - test-gnc-glib-utils (Not Run)
         24 - test-resolve-file-path (Not Run)
         25 - test-userdata-dir (Not Run)
         26 - test-userdata-dir-invalid-home (Not Run)
         27 - test-gnc-path-util (Failed)
         28 - test-link (Not Run)
         29 - test-load-engine (Not Run)
         30 - test-guid (Not Run)
         31 - test-date (Not Run)
         32 - test-object (Not Run)
         33 - test-commodities (Not Run)
         34 - test-qof (Not Run)
         35 - test-engine (Not Run)
         36 - test-account-object (Not Run)
         37 - test-group-vs-book (Not Run)
         38 - test-lots (Not Run)
         39 - test-querynew (Not Run)
         40 - test-query (Not Run)
         41 - test-split-vs-account (Not Run)
         42 - test-transaction-reversal (Not Run)
         43 - test-transaction-voiding (Not Run)
         44 - test-recurrence (Not Run)
         45 - test-business (Not Run)
         46 - test-address (Not Run)
         47 - test-customer (Not Run)
         48 - test-employee (Not Run)
         49 - test-job (Not Run)
         50 - test-vendor (Not Run)
         51 - test-numeric (Not Run)
         52 - test-gnc-guid (Not Run)
         53 - test-kvp-value (Not Run)
         54 - test-qofsession (Not Run)
         55 - test-gnc-int128 (Not Run)
         56 - test-gnc-rational (Not Run)
         57 - test-gnc-numeric (Not Run)
         58 - test-gnc-timezone (Not Run)
         59 - test-gnc-datetime (Not Run)
         60 - test-import-map (Not Run)
         61 - test-scm-query (Failed)
         66 - test-load-c (Failed)
         67 - test-modsysver (Failed)
         68 - test-incompatdep (Failed)
         69 - test-agedver (Failed)
         70 - test-dynload (Failed)
         78 - test-link-module-tax-us (Not Run)
         79 - test-link-module-gnome-utils (Failed)
         81 - test-import-parse (Failed)
         82 - test-link-generic-import (Not Run)
         83 - test-import-pending-matches (Not Run)
         84 - test-tokenizer (Failed)
         85 - test-tx_import (Not Run)
         86 - test-link-ofx (Not Run)
         87 - test-link-qif-imp (Not Run)
         88 - test-link-module-ledger-core (Not Run)
         89 - test-link-module-register-core (Not Run)
         90 - test-link-module-register-gnome (Not Run)
         91 - test-link-module-report-locale-specific-us (Not Run)
         92 - test-link-module-report-gnome (Failed)
         94 - test-link-module-report-system (Failed)

'make test-sx' succeeded. So I looked for another test target and found 'make check':

Scanning dependencies of target test-tx_import
[ 31%] Building CXX object gnucash/import-export/csv-imp/test/CMakeFiles/test-tx_import.dir/test-tx-import.cpp.o
[ 31%] Linking CXX executable ../../../../bin/test-tx_import
...
/usr/pkg/lib/libgtest_main.a(gtest_main.cc.o): In function `main':
/scratch/devel/googletest/work/googletest-release-1.8.0/googletest/src/gtest_main.cc:36: undefined reference to `testing::InitGoogleTest(int*, char**)'
/usr/pkg/lib/libgtest_main.a(gtest_main.cc.o): In function `RUN_ALL_TESTS()':
/scratch/devel/googletest/work/googletest-release-1.8.0/googletest/include/gtest/gtest.h:2233: undefined reference to `testing::UnitTest::GetInstance()'
/scratch/devel/googletest/work/googletest-release-1.8.0/googletest/include/gtest/gtest.h:2233: undefined reference to `testing::UnitTest::Run()'
*** Error code 1

make -k check is otherwise successful and I then see:

95% tests passed, 5 tests failed out of 102

Total Test time (real) = 111.00 sec

The following tests FAILED:
          1 - test-exp-parser (Failed)
         34 - test-qof (Child aborted)
         57 - test-gnc-numeric (Failed)
         58 - test-gnc-timezone (Child aborted)
         85 - test-tx_import (Not Run)
Errors while running CTest

I'll let you decide how successful this is and if and how many bug reports I should file :)

Please document the proper way to run tests.
Btw, https://wiki.gnucash.org/wiki/Testing still mentions the autotools way to add tests (in the Legacy Tests section).
Comment 3 John Ralls 2018-04-20 14:14:04 UTC
Yes, make test just runs the tests without building them first, so unless you've already run make check the bulk of the tests are expected to fail.

The link error suggests that the installed googletest library (libgtest.so?) is missing some symbols.

For the other tests, you now need to analyze the test failures and figure out if they're bugs in GnuCash or something to do with your installation. The test output is in two files in Testing/Temporary; LastTest.log is usually the more useful. The tests can also be run individually, they're all in bin. Running in the debugger (after doing a debug build, of course) is often helpful to understanding a failure.
Comment 4 Thomas Klausner 2018-04-21 10:31:44 UTC
test-exp-parser:

# bin/test-exp-parser 
Backtrace:
In ice-9/boot-9.scm:
 160: 1 [catch #t #<catch-closure 853400> ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 853400>]

ERROR: In procedure apply-smob/1:
ERROR: In procedure primitive-load-path: Unable to find file "fin" in load path

# find . -name *fin*
...
./lib/gnucash/scm/ccache/2.0/fin.go



# bin/test-qof
...
ERROR:/archive/foreign/gnucash/libgnucash/engine/test/test-gnc-date.c:1077:test_qof_print_date_buff: assertion failed (buff == "11/23/1974"): ("11/23/74" == "11/23/1974")

Run in gdb gives:

(gdb) bt
  • #0 _lwp_kill
    from /usr/lib/libc.so.12
  • #1 abort
    at /disk/6/archive/foreign/src/lib/libc/stdlib/abort.c line 74
  • #2 g_assertion_message
  • #3 g_assertion_message_cmpstr
    at gtestutils.c line 2610
  • #4 test_qof_print_date_buff
  • #5 test_case_run
    at gtestutils.c line 2255
  • #6 g_test_run_suite_internal
    at gtestutils.c line 2339
  • #0 _lwp_kill
    from /usr/lib/libc.so.12
  • #1 abort
    at /disk/6/archive/foreign/src/lib/libc/stdlib/abort.c line 74
  • #2 __gnu_cxx::__verbose_terminate_handler
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/vterminate.cc line 95
  • #3 __cxxabiv1::__terminate
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_terminate.cc line 47
  • #4 std::terminate
    at /disk/6/archive/foreign/src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/eh_terminate.cc line 57
  • #5 __cxxabiv1::__cxa_throw
  • #6 IANAParser::find_tz_file(std::string const&)
  • #7 IANAParser::IANAParser::IANAParser(std::string const&)
  • #8 TimeZoneProvider::parse_file(std::string const&)
  • #9 TimeZoneProvider::construct(std::string const&)
  • #10 TimeZoneProvider::TimeZoneProvider(std::string const&)
  • #11 TimeZoneProvider::TimeZoneProvider()
  • #12 __static_initialization_and_destruction_0
    from /archive/foreign/gnucash/build/lib/gnucash/libgncmod-engine.so
  • #13 _GLOBAL__sub_I_gnc_datetime.cpp
    from /archive/foreign/gnucash/build/lib/gnucash/libgncmod-engine.so

Comment 5 Thomas Klausner 2018-04-21 10:32:27 UTC
(The automatic trace detector put some non-trace information in the trace attachment.)
Comment 6 John Ralls 2018-04-21 14:00:13 UTC
For the first, before the backtrace there will be a dump of the command. Two variables in that dump are significant, GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH. What are they set to?

For the second, your distro has borked boost::date_time to return the wrong value for the date formatting parameter %Y, returning a 2-digit year instead of the specified 4-digit year. No need of a backtrace, the test result tells you exactly what's wrong.
Comment 7 Thomas Klausner 2018-04-21 14:49:52 UTC
For test-exp-parser: No, I pasted the complete output of starting it from the commandline directly. Should I manually set up some environment variables?


As for the second, if printing %Y was broken, all the tests would fail, not just this one, so it must be something else, perhaps locale-related.
Comment 8 John Ralls 2018-04-21 15:41:32 UTC
Yeah, the expression parser is in Scheme so it needs guile and guile needs some help finding its pieces, particularly in the build environment. The easiest way to get there is to copy the command from LastTest.log.

Ah, good point, though not "all the tests" because that's a glib test and it stops at the first failure, but it would have failed much earlier. You're right, that test is of the date format set by the locale. In that particular case it comes from /usr/share/locale/en_US/LC_TIME. On MacOS (what I have handy at the moment) it's %m/%d/%Y. That seems pretty common, but the 2.6 version of the test, which used GLib's GDateTime class, used g_date_time_format() to get the comparison value instead of hard-coding it. The test program is C rather than C++ and I took the lazy way by hard-coding the string since it works on the Linux distros that we test against as well as MacOS. I'll have to find a less-lazy way to generate the expected string.
Comment 9 John Ralls 2018-04-21 15:45:08 UTC
Back to test-tx_import: All of the other google-test based tests compiled OK and most passed, so something's up with that one test. Does <builddir>/common/test-core/libgtest.a exist?
Comment 10 Thomas Klausner 2018-04-22 06:39:58 UTC
Ah, sorry. I didn't follow your advice for looking at LastTest.log earlier.
Here's the output for test-exp-parser from that file:


1/102 Testing: test-exp-parser
1/102 Test: test-exp-parser
Command: "/usr/pkg/bin/cmake" "-E" "env" "GNC_UNINSTALLED=YES" "GNC_BUILDDIR=/archive/foreign/gnucash/build" "GNC_UNINSTALLED=yes" "GNC_BUILDDIR=/archive/foreign/gnucash/build" "GUILE_WARN_DEPRECATED=no" "LD_LIBRARY_PATH=/archive/foreign/gnucash/build/lib:/archive/foreign/gnucash/build/lib/gnucash" "GNC_MODULE_PATH=/archive/foreign/gnucash/build/lib:/archive/foreign/gnucash/build/lib/gnucash" "GUILE=/usr/pkg/bin/guile" "GUILE_LOAD_COMPILED_PATH=/archive/foreign/gnucash/build/lib/gnucash/scm/ccache/2.0" "GUILE_LOAD_PATH=/archive/foreign/gnucash/libgnucash/app-utils/test/mod-foo:/archive/foreign/gnucash/libgnucash/app-utils/test/mod-bar:/archive/foreign/gnucash/libgnucash/app-utils/test/mod-baz" "/archive/foreign/gnucash/build/bin/test-exp-parser"
Directory: /archive/foreign/gnucash/build/libgnucash/app-utils/test
"test-exp-parser" start time: Apr 20 08:55 CEST
Output:
----------------------------------------------------------
FAILURE bad expression /archive/foreign/gnucash/libgnucash/app-utils/test/test-exp-parser.c:161 wrong offset; expected 2, got 4
FAILURE bad expression /archive/foreign/gnucash/libgnucash/app-utils/test/test-exp-parser.c:162 wrong offset; expected 0, got 4

(process:21881): qof-WARNING **: 08:55:41.132: [gnc_numeric_div()] Divide by 0.
<CRITICAL> (gnc.gui) [func_op()] function eval error: [In ice-9/boot-9.scm:
 160: 6 [catch #t #<catch-closure 849a60> ...]
In unknown file:
   ?: 5 [apply-smob/1 #<catch-closure 849a60>]
In ice-9/eval.scm:
 432: 4 [eval # #]
In ice-9/boot-9.scm:
 160: 3 [catch #t #<procedure ab4c90 at ice-9/eval.scm:416:20 ()> ...]
In ice-9/eval.scm:
 432: 2 [eval # #]
 436: 1 [eval # #]
In unknown file:
   ?: 0 [+ "three" 0]

ERROR: In procedure +: Wrong type argument in position 1: "three"
]

Executed 57 tests. There were 2 failures.
<end of output>
Test time =   1.00 sec
----------------------------------------------------------
Test Failed.
"test-exp-parser" end time: Apr 20 08:55 CEST
"test-exp-parser" time elapsed: 00:00:01
----------------------------------------------------------

As for test-tx_import:
The file does not exist, no.
Comment 11 John Ralls 2018-06-30 00:08:21 UTC
GnuCash bug tracking has moved to a new Bugzilla host. The new URL for this bug is https://bugs.gnucash.org/show_bug.cgi?id=795251. Please continue processing the bug there and please update any external references or bookmarks.