The mechanism used to convert bats tests to something shellcheck can
verify caused a large number of failures due to the introduction of
testing for if a call is possible. Given the tests aren't called in
a normal shell script way, it is best to just ignore this error for
bats files.
Also fix an index using '$' unnecessarily.
Signed-off-by: William Douglas <william.douglas@intel.com>
Includes needed dev packages and an ignore for error messages seen on
Ubuntu's version of curl but not in Clear Linux.
Signed-off-by: William Douglas <william.douglas@intel.com>
Porting code to better way on interacting with system commands using the
run_command function. As run_command don't support multi-thread for
performance reasons, we are now using a file instead of a pipe. As tar|tar
is now a fallback, this won't have any performance impacts on any case
where with no problems and errors.
Fixes#640 and #671
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Ignoring error SC2119 because they are false positives and I don't see cases
where that would return anything useful for us.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Make sure that the tar|tar install file works because it's used as a
fallback when file failed to be installed using system tools
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
There are several points in swupd that we find conditions that should never
happen, but we try to correct them anyway to be more reliable. Because of that
we may hide programming mistakes that are corrected later.
So, to make sure we are going to catch those problems in debug mode in our development
machines and test environment, I am suggesting a UNEXPECTED() macro that aborts swupd
if --enable-debug was used to build swupd.
I am adding some examples on what we could do with that.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2 groups were created:
- slow: Tests that are very slow because of sleeps, so we can run them all
in parallel
- system: Tests that make change to the system, so they can cause problems
when running in parallel, so we run them in series.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
If the path where swupd is running is removed getcwd errors will occurs, mostly
because of multiple commands swupd executes. So move to directory "/", no mather
where swupd is going to be installed, to make sure the path is always existent.
Fixes#1078
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Some packages we need to build swupd are not available on ubunutu-latest
so we need to download and build from source. This process is slow and
caching can save us some significant time on build.
Moving from PROGRESS function to XFERINFO that is recommended by the
manual.
This fix a warning in the build, so we can turn on -Werror in tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
The reason we have a build script is that we wan't to control all
configuration arguments, so don't add any implicity CFLAGS
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Besides having a script that is used to run tests on github
actions CI, adding another script that can be used in any
system to build swupd with different configurations and
run all needed tests.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Instead of requiring an --enable-third-party, as 3rd-party was already
released, we can make it default.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Implementation of the 3rd-party info command to show the version of the
3rd-party repository along with the update URL.
Closes#1354
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This patch adds 2 scripts used to balance test execution. The weight_tests.bash
runs all tests and sets a weight to them based on how long they take to run. The
other, filter_bats_list.bash, use this information to split the tests in groups to
be executed by github actions.
When a new test is added the script will consider it with an average weight, so this
shouldn't unbalance the system right away. After some time, if we notice that the
system is not balanced anymore we can just run the weight_tests.bash again to rebalance.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
There are some build requirements that are only necessary for style check.
Reduce the build time by running them only for style check job.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This PR re-enables the failing auto-update
tests while moving from travis to github actions
Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>
This commit implements the swupd clean command for the 3rd-party bundles
so users are able to clean the cache on their state directories.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit does some housekeeping in the 3rd-party commands:
- Initialize the function "progress" only after swupd has initialized
successfully.
- Make functions that are not used outside of a file static.
- Avoid using regex or partial verifications on tests when possible.
- Add 3rd-party command flags to the default config file.
- Don't use "repo" in help menus, use the whole "repository" word.
- Add 3rd-party sub-commands to the flag_validator script.
- Add missing values from the autocompletion scripts.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit adds the ability to update the system based on the 3rd-party
repositories the user have.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit adds a new "3rd-party bundle-info" command which can be used
to show information about a bundle from a 3rd-party repository. If no
3rd-party repository is specified, the bundle is searched for in all
available repositories.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit makes changes to the flag_validator script so it works
properly with 3rd-party commands/subcommands.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
swupd supports global flags and supports local flags that are specific
to subcommands. Flags that are specific to subcommands can be reused in
a different subcommand. Global flags should be unique and should not be
reused as local flags to avoid conflicts.
This commit adds a bash script that checks that the flags currently used
in swupd are valid (have no conflicts with other flags from the same
command or with the global flags). This script will be run as part of
the build process so in case an invalid flag is found the build will be
stopped. Alternatively, the script can be used by developers to validate
a new flag during the implementation time.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This functionality was moved to testlib.bash and we don't need this
script to generate new test cases.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Script assert-certificate-validity.sh checks the validity of a signature
using openssl.
As we aren't using this to validate the signatures we generate in our tests,
I'm removing that from the repository.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Fixes#448
Make a number of functions static, and bodge around the extra symbol
that gcc adds (__gnu_lto_v1) when compiling with -flto=4
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Make swupd save a copy of the current MoM in a readable location, so
the completion code for bundle-add has access to it.
Stop generating the completion code, just use the file directly.
Remove the short option from the completion code, whilst they are
useful for an expert there is little point typing minus tab and then a
letter rather than minus and the letter.
Add crude filename completion for hashdump.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
When output was changed to stderr for user output, this broke
automatic generation of the bash completion function.
Add suitable redirection to the generation script to capture stderr.
Add test to check the generated file looks reasonable.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
bash 4.4 added the 'nosort' option for completion. Use this so the
flag options come before the bundle names.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Include feature request from IRC to not offer os-core and
os-core-update bundles as completion targets for bundle-remove.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Remove the script which creates the completion script based on the
output of swupd --help. It wasn't being used (e.g. the completion
didn't have bundle-list in it).
Restructure the completion script to use a case statement to list the
valid completion options. IMHO this makes the code easier to
understand.
Add in package name completion for bundle-add. This requires
/var/lib/swupd/XXXXX/Manifest.MoM to exist (where XXXXX is the
contents of /var/lib/swupd/version), be in the correct format
etc.
Add in package name completion for bundle-remove. This uses the
contents of /usr/share/clear/bundles to get the list of installed
bundles. It would be nice to use $(swupd bundle-list) but it aborts if
it is not being run as root, so this means you can't have completion
for "sudo swupd bundle-remove".
TODO: Fix bundle completion if --path is specified.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>