Merge lp:~zorba-coders/zorba/zorba-tests-when-installed-fix into lp:zorba

Proposed by Ghislain Fourny
Status: Work in progress
Proposed branch: lp:~zorba-coders/zorba/zorba-tests-when-installed-fix
Merge into: lp:zorba
Diff against target: 61 lines (+14/-4)
3 files modified
cmake_modules/ZorbaModule.cmake (+1/-1)
src/context/static_context.cpp (+2/-2)
test/rbkt/Queries/CMakeLists.txt (+11/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/zorba-tests-when-installed-fix
Reviewer Review Type Date Requested Status
Chris Hillery Pending
Matthias Brantner Pending
Review via email: mp+109160@code.launchpad.net

Commit message

This fix should bring the failing tests down to 7% in case Zorba is installed on the machine.

Description of the change

This fix should bring the failing tests down to 7% in case Zorba is installed on the machine. It swaps the lib path resolution strategy from top-down to bottom-up through the static context, so that the lib path provided on the command line (in the build directory for a test) takes priority over the root static context's builtin module paths (the first one being in the install directory). Some of the remaining failing tests are probably still failing because the test executables also need to be adapted to override the lib path through their command line (so far this is done for rbkt tests only).

Normally, this fix should not lead to any regression in the case Zorba is not installed.

To post a comment you must log in.
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job zorba-tests-when-installed-fix-2012-06-07T14-49-11.936Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Pending.

Revision history for this message
Chris Hillery (ceejatec) wrote :

The two changes to add LIB_PATH to --module-path for testdriver are good and reasonable.

As Matthias said in email, I'm not sure about the major change here of putting command-line paths before built-in paths. It was originally done as it is in order to prevent exactly what you're apparently trying to do - put your own versions of Zorba core modules in place of the ones included in Zorba. We did it as a (fairly weak) security measure, as well as to ensure as much as possible that Zorba's core functionality was knowable and unbroken.

What exactly is the use-case here? Why do you need to replace core modules? (If you're not replacing core modules, I'm not sure what problem this change would solve.)

Revision history for this message
Ghislain Fourny (gislenius) wrote :

Hi Chris, thanks for your comment. The problem I am trying to solve is the following (occurring on Lion).

If Zorba is not installed ("make install" not executed) the tests (run from the build directory) pass, since the LIB_PATH taken into consideration is the third builtin path (the one in the build directory) - the first two builtin paths (both in the install dir) being nonexistent. The libraries in the build directory's LIB_PATH point back to the zorba libraries in the build directory, so everything is consistent.

If Zorba is installed ("make install" executed) many of the tests (run from the build directory) no longer pass, since the first two builtin paths (in the install directory) now exist and take over. One issue is that they do not point back to the zorba library in the build directory, but to the zorba library in the install directory. This means that two identical, albeit physically different zorba libraries are actually used side-by-side (the one in the build directory, the one in the install directory), so that two stores are instantiated, leading to a failing assertion (store2 == store).

In projects that build in top of zorba and that need "make install" for running their tests, a manual post-install dependency override is required to get all tests to pass.

Having the command-line --module-path take precedence over builtin paths would make sure that tests can specify their LIB_PATH.

I do understand the concern you raise, i.e., it might not be wise to allow this lib path override in real life usage. Would this make sense: have two lib path vectors in each static context node, one used before that of the parent, one used after the parent - it means that the lookup would be bottom-up-and-back-down. The former lib path (which takes priority over the builtin paths) could be only exposed to tests, and the latter one could be the one exposed officially. Would it make sense to you?

Revision history for this message
Chris Hillery (ceejatec) wrote :

Aha. Yes, I was aware that this was a problem on MacOS; in fact, bug 867139 discusses it. (It's a problem on Linux too, but the symptom is much less serious.)

I think before committing any questionable changes to core Zorba, I would like to explore two alternatives:

1. If you could arrange for your testing process to rm -rf build/*_PATH after you do "make install", this problem would go away. A quick "make" will restore the contents of those directories. It's not a beautiful solution, but it actually is the "right one" because it guarantees that you are testing your installed image in exactly the way it will be run on a deployed machine, without a build/ directory. (Ideally you should blow away the build/ directory in its entirety to be really sure you're testing what you ship, but I understand that has ... drawbacks.)

2. Alternately, take a look at the description of bug 867139 and then do some research. If you can give me a reliable way on MacOS to determine the filesystem location of libzorba_simplestore.dylib (or, of the zorba executable itself, but that is less preferable), then we can implement the relocatable install feature that is already working on Windows. That would fix this problem, make Zorba a little bit more efficient, and even allow people to move Zorba after installation.

I think both of these solutions are better than this proposal, because they actually address the underlying problem instead of dusting it under the carpet. Hopefully at least one of them can be implemented quickly.

Revision history for this message
Ghislain Fourny (gislenius) wrote :

Hi Chris, thanks a lot for your comments! I also think it is worth exploring a long-term solution.

I am not sure suggestion 1. would work, since the problem comes from the installation paths that take precedence - removing the build paths would probably not change this (at least in the case of running tests).

The bug report description however (suggestion 2.) makes a lot of sense to me and I agree with you that an ideal solution would include runtime path discovery. I will give it some thoughts.

Thanks again for your input!

Revision history for this message
Chris Hillery (ceejatec) wrote :

> I am not sure suggestion 1. would work, since the problem comes from the
> installation paths that take precedence - removing the build paths would
> probably not change this (at least in the case of running tests).

Ah, I either misread or mis-understood your problem. I assumed that if you were doing a "make install", then any tests you ran later would be running against the *installed* Zorba (why else do an install?). But, then, you're right - that situation should work anyway since the install locations are first on the path.

Since you're continuing to test the build directory, though, could you just re-arrange your tests so that the "make install" step is done AFTER all other testing?

Unmerged revisions

10869. By Ghislain Fourny

Added module path for internal rbkt tests.

10868. By Ghislain Fourny

Merged trunk back.

10867. By Ghislain Fourny

This fix should allow test execution even if Zorba is installed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmake_modules/ZorbaModule.cmake'
2--- cmake_modules/ZorbaModule.cmake 2012-05-30 00:33:21 +0000
3+++ cmake_modules/ZorbaModule.cmake 2012-06-07 14:46:29 +0000
4@@ -806,7 +806,7 @@
5 ADD_TEST(${TESTNAME} "${Zorba_TESTDRIVER}"
6 "--rbkt-src" "${TEST_DIR}"
7 "--module-path"
8- "${CMAKE_BINARY_DIR}/URI_PATH/${PATH_SEP}${DEPENDENCY_MODULE_PATH}"
9+ "${CMAKE_BINARY_DIR}/URI_PATH/${PATH_SEP}${CMAKE_BINARY_DIR}/LIB_PATH/${PATH_SEP}${DEPENDENCY_MODULE_PATH}"
10 "${TESTFILE}")
11
12 # On non-Windows, call EXPECTED_FAILURE() for known crashes
13
14=== modified file 'src/context/static_context.cpp'
15--- src/context/static_context.cpp 2012-05-18 22:01:56 +0000
16+++ src/context/static_context.cpp 2012-06-07 14:46:29 +0000
17@@ -1722,12 +1722,12 @@
18 ********************************************************************************/
19 void static_context::get_full_lib_path(std::vector<zstring>& path) const
20 {
21+ get_lib_path(path);
22+
23 if (theParent != NULL)
24 {
25 theParent->get_full_lib_path(path);
26 }
27-
28- get_lib_path(path);
29 }
30
31
32
33=== modified file 'test/rbkt/Queries/CMakeLists.txt'
34--- test/rbkt/Queries/CMakeLists.txt 2012-05-09 20:29:48 +0000
35+++ test/rbkt/Queries/CMakeLists.txt 2012-06-07 14:46:29 +0000
36@@ -128,6 +128,12 @@
37 FIND_PACKAGE(CURL)
38 ENDIF(ZORBA_SUPPRESS_CURL)
39
40+IF(WIN32)
41+ SET(PATH_SEP ",")
42+ELSE(WIN32)
43+ SET(PATH_SEP ":")
44+ENDIF(WIN32)
45+
46
47 FOREACH(TESTFILE ${TESTFILES})
48 # All testfile paths end in .xq or .xqx. Strip that part off to form
49@@ -195,7 +201,11 @@
50
51 IF(NOT SKIP_TEST)
52
53- ZORBA_ADD_TEST("${TESTNAME}" testdriver ${TESTFILE})
54+ ZORBA_ADD_TEST("${TESTNAME}"
55+ testdriver
56+ "--module-path"
57+ "${CMAKE_BINARY_DIR}/URI_PATH/${PATH_SEP}${CMAKE_BINARY_DIR}/LIB_PATH/"
58+ "${TESTFILE}")
59
60 MATH(EXPR TESTCOUNTER ${TESTCOUNTER}+1)
61 MATH(EXPR TESTMOD "${TESTCOUNTER}/1000")

Subscribers

People subscribed via source and target branches