56 Commits

Author SHA1 Message Date
William Douglas 79717bd2cd Fix up shellcheck issues
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>
2025-03-26 16:55:13 -07:00
William Douglas 42e38325fd Add CI fixes for github's updated Ubuntu container
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>
2025-03-03 17:11:46 -08:00
William Douglas 52ae6dadc1 Update rst2man path from Ubuntu
Correct the path where the rst2man script lives for CI to find it.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas ca49f63feb Update CI scripts
Update CI scripts in attempt to get CI working with the current Ubuntu
container.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-04 17:25:31 -07:00
Otavio Pontes 076aeff0d0 target_root: Use run_commmand to execute tar|tar command
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>
2020-05-05 12:22:48 -07:00
Otavio Pontes 59d5215c91 scripts: Remove shellcheck all from standard check in build script
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 14:02:36 -07:00
Otavio Pontes ce0943982a shellcheck: Error SC2119 doesn't apply to our use cases
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>
2020-04-30 08:50:48 -07:00
Otavio Pontes a3c1f97c57 shellcheck: Unify shellcheck script
Make sure shellcheck and shellcheck bats are using the same configuration to
run shellcheck

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 08:50:48 -07:00
Otavio Pontes 455b398edd scripts: Run all tests with force-tartar build flag
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>
2020-04-24 12:03:09 -07:00
Otavio Pontes cac56264d3 compliant: Start using clang-format-10 to check for style problems
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-23 12:07:51 -07:00
Otavio Pontes 9d967e2482 scripts: Use --enable-debug to run swupd tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-21 14:20:40 -07:00
Otavio Pontes c019e11cc0 Create the UNEXPECTED() macro
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>
2020-04-13 11:18:31 -07:00
Otavio Pontes 13752fa9ca actions: Validate if all tests are going to be executed
Validate if we are really calling make check for all tests in
test/functional directory.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-10 09:58:46 -07:00
Otavio Pontes ea5f362f6c scripts: Don't run shellcheck if BUILD_ONLY is used 2020-04-10 08:11:19 -07:00
Otavio Pontes 4277838297 scripts: Use more parameters used in a release to run tests 2020-04-10 08:11:19 -07:00
Otavio Pontes 2fe40faf10 test: Group tests that can be run only on in CI
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>
2020-04-01 08:38:15 -07:00
Otavio Pontes 819f4d1b6a swupd_init: Make sure swupd is always runnin in an existing path
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>
2020-03-30 13:59:43 -07:00
Otavio Pontes e9739d9eb3 actions: cache dependencies for swupd
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.
2020-03-27 15:34:41 -07:00
Otavio Pontes 5a8b431eeb scripts: Run shellcheck-all just once
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-27 10:45:15 -07:00
Otavio Pontes b1a6b1e15c scripts: Use shellcheck-all on test script
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-26 18:58:37 -07:00
Otavio Pontes 3019a7adaa actions: group scripts that are only relevant to github actions
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-26 15:44:04 -07:00
Otavio Pontes b3e18c8325 curl: Using same progress function used on async to sync downloads
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>
2020-03-19 08:55:02 -07:00
Otavio Pontes 80a0a3676a scripts: Support parameters on build_and_run
Add 2 parameters, one for numbers of jobs and other to skip tests execution

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-17 13:32:14 -07:00
Otavio Pontes 422cd13df8 script: Check for third-party flag after build
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-17 13:32:14 -07:00
Otavio Pontes db08520ed9 scripts: Don't use FORTIFY_SOURCE when optimizations are disabled
Both arguments were incompatible and warnings were being displayed for
this combination

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-17 13:32:14 -07:00
Otavio Pontes 6afe772d7e scripts: Don't add system CFLAGS on build script
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>
2020-03-17 13:32:14 -07:00
Otavio Pontes 616878929e scripts: Add a script to run swupd basic tests
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>
2020-03-13 14:49:57 -07:00
Otavio Pontes 96234f998d 3rd-party: Make 3rd-party default in the build
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>
2020-03-10 10:57:31 -07:00
Castulo Martinez 68de707c04 Implementing the 3rd-party info command
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>
2020-03-06 14:54:23 -08:00
Otavio Pontes d61288464d tests: Auto rebalance tests based on how long they take to long
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>
2020-02-20 13:22:31 -08:00
Otavio Pontes 0d93686356 test: Reduce build time of bats test
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>
2020-02-19 13:31:16 -08:00
Karthik Prabhu Vinod 6caae35301 autoupdate: adding auto-update test back
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>
2020-01-22 13:01:52 -08:00
Castulo Martinez ca98b3a7db Adding "3rd-party clean" command
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>
2019-12-20 16:38:41 -08:00
Castulo Martinez 24de99dfcc Housekeeping on 3rd-party commands
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>
2019-12-20 12:14:08 -08:00
Castulo Martinez d96b6f6d92 Implementing the "3rd-party diagnose" command
This commit adds the ability to diagnose bundles from 3rd-party repos.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 10:57:37 -08:00
Castulo Martinez f48c58e737 Implementing 3rd-party update command
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>
2019-12-12 08:41:45 -08:00
Castulo Martinez 33b4e9ea52 Implementation of 3rd-party bundle-info command
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>
2019-12-12 08:17:55 -08:00
Castulo Martinez 2a2018744e Fixing flag_validator to work with 3rd-party
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>
2019-12-06 08:21:49 -08:00
Otavio Pontes 019a90819c actions: Build dependencies to support swupd builds
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-11-11 16:26:46 -08:00
Castulo Martinez e63dc805cf Adding flag validation to the swupd build process
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>
2019-07-12 14:28:05 -07:00
Otavio Pontes 3fdb077ec8 Remove gen-manifest-hash.sh script
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>
2018-12-13 12:18:03 -08:00
Otavio Pontes c8b203504b Removing unused script
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>
2018-12-13 12:18:03 -08:00
David Klimesh bcabe0e48a Update verify to include purpose for cert check
Newer versions of openssl require a valid purpose so
pass this in for the cert check.

Signed-off-by: David Klimesh <david.j.klimesh@intel.com>
2018-11-29 12:58:00 -08:00
Icarus Sparry 6d452a824d Fix findstatic warnings
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>
2018-05-22 15:08:38 -07:00
Icarus Sparry bc5cae81dc Update swupd completion code
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>
2018-03-26 11:23:04 -07:00
Icarus Sparry bbb9774703 Fix generation of swupd.bash
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>
2017-11-02 09:06:57 -07:00
Icarus Sparry 92a6fcaf76 Make the backward compatability check work
Use the correct variable BASH_VERSINFO, rather than BASH_VERSION

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-03-27 13:55:52 -07:00
Icarus Sparry cc7544dfb8 Allow for bash versions before 4.4
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>
2017-03-22 18:32:37 -07:00
Icarus Sparry 611d858797 Reinstate the script which writes the completion function
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>
2017-03-22 18:32:37 -07:00
Icarus Sparry 9a8fd39bee Add package names to completion
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>
2017-03-22 18:32:37 -07:00