support for externally built vtest with libvtc_varnish.so and libvtc_builtwith.so #4406
+461
−39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the option to use an externally built vtest binary as agreed in #4398.
Demo
Install VTest2 with extension support
ext
branch from Add extension support vtest/VTest2#7 such that vtest is found in$PATH
(the example here is intended to show a "canonical" way as with external packaging, I would not normally install unter/usr
):quick check:
Build vinyl-cache in out-of-tree vtest mode"
This can be later be done by not cloning the submodule (because the TODO items are not complete, see below), but for now we simulate a missing submodule by deleting the file which we look for to determine if the submodule is present:
slink@haggis21:~/Devel/varnish-git/varnish-cache (vtest_ext_varnish)$ rm bin/varnishtest/vtest2/src/vtc_main.c
Now build as always, e.g.
All tests should succeed
Implementation / Explanation
vtest/VTest2#7 adds to VTest the option to load a shared object at runtime, which can then extend vtest functionality by registering additional commands.
Moving vinyl test functionality to
libvtc_varnish.so
The first commit changes the build to create such a shared object with the vinyl-specific test mechanics in
vtc_varnish.c
,vtc_vsm.c
andvtc_logexp.c
.With this, calling
vtest -E libvtc_varnish.so
gives us a the same functionality we had before with the static build.To keep the rest of the build simple, a wrapper program called ... (you guessed it) ...
varnishtest
is added which simply callsvtest
with the extension argument. This is used in favor of the simple shell script 2-liner which could also easily fulfill the task in order to be able to get thelibtool
wrapper script for uninstalled libraries. This in turn requires linking to an empty dummy library.Moving compile-time flag checks / macros to
libvtc_builtwith
varnishtest
already works for the most part with just the above, but we have just broken much of thefeature
functionality and thepkg_version
andpkg_branch
macros: These can only work if the respective code is built together with the code base it is supposed to reflect on - otherwise we get behavior based on howevervtest
was compiled, but not how vinyl-cache was compiled.So we apply the same idea again and move these checks to a vtest extension with we do compile each time. The outcome is a working
varnishtest
as demonstrated.Alternatives considered
We could do without the extra
libvtc_builtwith
and just move the respective code intolibvtc_varnish
, but I think this functionality might also be of general interest to other projects and I would add this as an example to VTest2 itself if we decide that we want to go this route.The
builtwith
checks could also be replaced with compile time configuration of the tests to execute. I actually have working code which moves all the-spersistent
checks to a subdirectory oftest
and includes these tests only if--with-persistent-storage
is given toconfigure
.But in particular with negated tests I think this quickly becomes really tedious, and the information which tests to run is no longer nicely contained in the tests itself (unless we add something like magic comments which we grep for...). All in all, the "feature test" way is much clearer and easier to maintain.
In general, another alternative would be to invert the sense of what is an executable and what is a library: Create a
libvtest.so
in theVTest2
project and then an executable in vinyl which only has minimal code to call the library and extend it. In my mind this simply seemed like the wrong way around and I found the extension model very clear, but opinions might vary and at this point, without having written the actual code, I would think that the alternative should also work.TODOs
A main TODO item is that that switch to the new model is not complete, and deliberately so:
For one, I think that keeping vtest bundled as a submodule will make the life for most of the developers easier. The problem to solve is to enable a build from git with an external vtest, and I see no strong reason to destroy the existing workflow.
Secondly, the vinyl specific code still needs to be checked into the vinyl-cache repo again and removed from Vtest2.
Thirdly, the
feature
tests which have now been added tobuiltwith
need to be removed from the former.But all of this only makes sense after the changes are accepted.
Notes
make dist
still requires the submodule, and rightly so: Again, this addition is to support builds from git only, not to destroy previous workflows.