-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test OpenWRT in CI #234
Merged
Merged
Test OpenWRT in CI #234
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently, we're hardcoding the build directory `./build` when building in CI, as the `cmake --install` command does not support loading the build directory from a cmake-preset. However, when running OpenWRT tests, the cmake-preset sets a LD_LIBRARY_PATH that points to the build directory, so we can no longer use `./build`.
Tests now work for the OpenWRT preset, even on standard Linux, as long as the LD_LIBRARY_PATH env points towards the libubox.so shared library file.
The __wrap_uwrt_init_context test library can be used to wrap uwrt_init_context() so that it loads from the ./test/data/uci folder.
The `run_ap_process()` function doesn't call `kill_process()` when WITH_HOSTAPD_UCI is defined. Additionally, no hostapd_conf_file is written, instead UCI handles writing the configuration file.
When running dnsmasq in UCI mode: - The dnsmasq_conf_path property is ignored, as UCI decides where to store the configuration - `kill_process()` is not run when running `run_dhcp_process()` - `signal_dhcp_process()` does nothing Additionally, we need to make sure that `dhcp_conf.bridge_prefix` is correctly set, otherwise you'll get a bunch of undefined memory, and your tests will work 95% of the time, and fail 5% of the time. (I think it took me about an hour to debug this)
Add `uwrt_set_property()` calls into a loop. This should also increase our code-coverage, since we'll have less lines of code.
The ifname field wasn't being set in uwrt_create_interface, which was causing the uci_wrt.c tests to fail.
aloisklink
force-pushed
the
test-openwrt
branch
from
August 12, 2022 19:38
2ee2ff6
to
0a3b8f2
Compare
Codecov Report
@@ Coverage Diff @@
## main #234 +/- ##
==========================================
- Coverage 45.63% 44.64% -0.99%
==========================================
Files 107 110 +3
Lines 14953 16393 +1440
==========================================
+ Hits 6824 7319 +495
- Misses 8129 9074 +945
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
mereacre
approved these changes
Sep 2, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Runs the OpenWRT tests in CI.
I had to slightly play around with some stuff to get OpenWRT tests working again.
Firstly, I had to add
LD_LIBRARY_PATH="${sourceDir}/build/${presetName}/lib/ubox/lib"
, see ee360eb to get OpenWRT tests working properly, since even though we set RPATH on our tests, since the tests link to libuci, libuci is the one that needs RPATH to libubox.This meant I had to modify the CI to use the presets listed in CMakePresets.json (see ci: use buildDir from CMake presets), then I had to add a preset for
openwrt
that setLD_LIBRARY_PATH
(see ci: add test config for openwrt)Then, in order to fix the tests, I needed to:
test: add __wrap_uwrt_init_context test lib
The
__wrap_uwrt_init_context
test library can be used to wrapuwrt_init_context()
so that it loads from the./test/data/uci
folder.tests(hostapd): fix WITH_HOSTAPD_UCI tests
The
run_ap_process()
function doesn't callkill_process()
when WITH_HOSTAPD_UCI is defined.Additionally, no
hostapd_conf_file
is written, instead UCI handles writing the configuration file.test: fix dnsmasq tests when using UCI mode
When running dnsmasq in UCI mode:
dnsmasq_conf_path
property is ignored, as UCI decides where to store the configurationkill_process()
is not run when runningrun_dhcp_process()
signal_dhcp_process()
does nothingAdditionally, we need to make sure that
dhcp_conf.bridge_prefix
is correctly set, otherwise you'll get a bunch of undefined memory, and your tests will work 95% of the time, and fail 5% of the time. (I think it took me about an hour to debug this)refactor: simplify uwrt_create_interface code
Some simple refactoring, just to avoid constantly doing
uwrt_set_property()
.fix: set ifname in uwrt_create_interface()
The ifname field wasn't being set in
uwrt_create_interface
, which was causing theuci_wrt.c
tests to fail.