793 Commits

Author SHA1 Message Date
William Douglas acad8c47b0 Add format information to update output
The current format is very useful information to get from bug reports
so add it as default output to swupd update.

Signed-off-by: William Douglas <william.douglas@intel.com>
2025-04-24 14:20:58 -07:00
William Douglas dd3e0f3d81 Update copyright years
Signed-off-by: William Douglas <william.douglas@intel.com>
2025-04-24 14:20:58 -07:00
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 ee42901d83 Update output for bundle-list --orphans
Add informational line for how to cleanup orphan bundles to
bundle-list --orphans.

Signed-off-by: William Douglas <william.douglas@intel.com>
2025-03-12 11:39:23 -07:00
William Douglas 5e605943f5 Add new orphan tests for bundle deletes
When a bundle is removed, ensure the new orphans created are detected
by bundle-list and bundle-remove.

Signed-off-by: William Douglas <william.douglas@intel.com>
2025-03-12 11:39:23 -07:00
William Douglas 48cdc5e04c Enable bundle delete during non-format bump updates
Signed-off-by: William Douglas <william.douglas@intel.com>
2025-03-12 11:39:23 -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 6df531ffc8 Add --incremental support for update
Allow users to update by stepping through each release between their
current version and the latest. This option is primarily for cases
where update is failing due to memory or disk space running out when
updating normally.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-11-18 10:18:06 -08:00
William Douglas e02cab570c Add support for an alternative swupd certificate
Enable an alternative swupd certificate location (the location of the
default or given cert with an ".alt" appended to it). The purpose of
this change is to allow more reliable and flexible key rotations.

If either the main cert or alt cert fails when doing content
verification then the other will be tried (and be used for the next
operation). In this way, as long as both certs don't fail for the same
content verification, progress can be made with either cert.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-08-29 11:58:59 -07:00
William Douglas 0d1591ff8f Update server.py ssl wrapping
The previous method for wrapping ssl was removed so update to the
replacement version.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-08-28 16:40:12 -07:00
William Douglas e0a4ed89c1 Add missing test teardown skips as needed 2024-08-28 16:40:12 -07:00
Brett T. Warden 2c45294461 Add sudo to commands to backup/restore Swupd_Root.pem 2024-08-28 15:22:35 -07:00
Brett T. Warden e170bfd3b1 Skip tests that require two builds in a format when there's only one
We already detect and report that certain tests require at least two
builds within the current format, but only one exists. Change that from
a test *failure* to a *skip*.

Example:
 We need at least 2 versions in format 38 to continue with this test
 Test teardown complete.
 not ok 2 RCT002: Repair a big system
 # (from function `test_setup' in file test/real_content/real_content_lib.bash, line 144,
 #  from function `setup' in test file test/real_content/../functional/testlib.bash, line 4647)
 #   `test_setup' failed
 #

becomes:
 ok 2 RCT002: Repair a big system # skip We need at least 2 versions in format 38 to continue with this test
2024-08-28 14:26:07 -07:00
Brett T. Warden 695417dca0 Protect the Swupd_Root.pem certificate file
This test creates an alternate swupd root certificate. If one already
exists, back it up, and restore it when the test is done. Previously,
this test just blindly deleted the certificate if it existed.
2024-08-27 12:02:07 -07:00
Brett T. Warden 6a43ac73aa Quell shellcheck error on sourcing file with variable path 2024-08-26 15:45:58 -07:00
Brett T. Warden 964ebcc12d Fix shellcheck for $lines 2024-08-26 14:08:36 -07:00
Brett T. Warden b1bbef06f9 Fixup bundle counting in real_content test library
Eliminate some uses of wc -l that don't help. Take advantage of lines
array to count bundles.
Separate STDERR messages from $output and ${lines[@]} that are used for
bundles.
2024-08-26 13:25:12 -07:00
Brett T. Warden 8742b3a168 Redirect URL override messages to STDERR
Previously, these messages were printed to STDOUT:
Overriding version and content URLs with...
Overriding content URL with...
Overriding version URL with...

But especially with --quiet, the output to STDOUT should be strictly the
requested data. So print these as warnings instead.
2024-08-26 13:25:12 -07:00
William Douglas 9fdf88c74b Test fixups and update for newer systemd
systemctl reports that the timer file is missing now as a return code
4 so update the unknown start number.

Also with this change SWUPD_NO is no longer always returned so add a
new helper to check if a status is one of multiple options.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-07-29 11:46:45 -07:00
William Douglas 5fe01a7211 Ignore a shell check issue
The specific issue isn't impactful since the file is already scanned.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-04-08 10:25:50 -07:00
William Douglas 02d276564d Rework content deletion handling
Currently sys_rm_recursive was used in any instance of deleting swupd
content from the system (update, repair and bundle-remove). This can
cause user data loss when unkown files are in directories that swupd
is deleting.

To prevent this, this patch changes how deleting content in swupd
operates. Swupd content removal is now done with sys_rm and the return
value is checked in case the removal failed due to a directory that
still had files in it. When this specific failure occurs, the
directory is added to a new list for reprocessing removals as it is
expected once the rest of the deletes on the system occur the failures
will go away as the directories will be empty (these deletes are
processed in alphabetical reverse order so leaf directories are
processed first). If the removal fails again it is presumed the
contents of the directory are not files swupd knows about and as such
should be kept somewhere else.

For handling the retention of user data, directories (with only the
content unknown to swupd) are renamed (currently using a
.deleted.$timestamp. prefix of the old name) and stored at the same
directory level they were previously found with one exception. The
exception is for nested deleted content best illustrated with an
example:

/swupd-dir1/user-file1
/swupd-dir1/swupd-dir2/user-file2

When swupd tries to remove the /swupd-dir1 content, it will store the
user files as follows:

/.deleted.$timestamp1.swupd-dir1/user-file1
/.deleted.$timestamp1.swupd-dir1/.deleted.$timestamp1.swupd-dir2/user-file2

To demarcate what was part of swupd content vs user content.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-04-05 10:28:41 -07:00
William Douglas 5ebfce069e Update pemfile
Generated with:
openssl req -x509 -newkey rsa:4096 -out pemfile -sha256 -days 3650 \
-nodes -subj "/CN=localhost"

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-01-22 06:50:40 -08:00
William Douglas 0d2d11d0fc Add APX flag support
Add support for new APX optimization level. Change increases the
maximim potential optimization level but does not yet allow the files
to be used (installed). get_opt_level_mask still needs to be updated
to account for system supporting the new optimization level (and
adding APX_SKIP_FILE support) before the APX files can be installed.

This change is being done at this time to allow mixer to create these
files without swupd error messages during updates.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-01-22 06:50:40 -08:00
William Douglas e01b473251 Switch to clang-format as a github action
Instead of having this be a local test, have a format target for the
Makefile and use a github action for clang-format to avoid differences
between developer systems clang-format and runner clang-format
versions.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-04-25 14:44:10 -07:00
William Douglas ce82b5da51 Enable use of optimized manifest files beyond SSE
Allow the usage of non-SSE files from manifests. This involves testing
what the currently running system supports for optimized content and
installing the best matching available binary the manifest provides.

There is an exception for operations where the prefix is set to
something other than the rootfs where SSE binaries will be used in all
cases.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-04-25 14:44:10 -07:00
William Douglas a9aac28ae7 Update opt_mask handling to match mixer-tools
mixer-tools populates the optimized mask based on a matrix of values
where the mask includes both the optimization of the file on the line
but also the combined masks of all matching files.

This means a file mask needs to be translaed from the mask to what its
actual optimization level is and what other optimizations levels are
available to be useful. This change adds 2 new elements to the file
struct. The opt_level stores a files optimization level and
available_levels stores a bitwise or of the different optimization
levels that can be found in the file list for the same file.

For instance an AVX2_3 mask indicates the file is AVX2 with both SSE
and AVX512 files also available (SSE | AVX2 | AVX512 == 3).

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-04-11 12:20:25 -07:00
William Douglas 5ecf766ba8 Fix typo in OPTIMIZED_BITMASKS
Remove duplicate '9' in string for generating OPTIMIZED_BITMASKS array
and regenerate. This also requires an additional element is added to
the array to get to the 64 characters usable in the map.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-03-03 10:11:00 -08:00
William Douglas 77f16b0120 Add new handling for modifier field
The modifier field will be a character that translates roughly into a
base64 encoded bitmask. The first 3 bytes are the optimization level
and the last three are the max optimization level any files with that
same filename can have.

For now though skip all lines that don't match SSE_OPT (the previous
values the modifier field would have: 'b', 's' and 'C' all map to
the SSE_OPT bitmask).

Also rework the manifest unit tests a bit more. Noticed the exported
flag was wrong in the data and the X flag for the 3rd field was
completely unchecked for in swupd code. Added testing for the ignored
'b', 's' and 'C' values of the modifier field and checked the non-sse
is in fact skipped as a file for now.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-03-02 12:35:32 -08:00
William Douglas a011f9429a Remove logic for flag not in use
The logic is testing a flag that mixer does not set and would like
to change the purpose of in a new version. Remove the test (needs a
format bump before mixer can use the flag) for the flag.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-28 13:25:05 -08:00
William Douglas 6896d8f155 Rework output checking in test
The disk space check was trying to match exact number of download
attempt messages which was not working consistently.

Move to simply detecting the failure messages once.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-22 00:04:12 -08:00
William Douglas 98a3362ae9 Rework clear linux docker container for test runs
Also skips a few tests that do not run well with docker (changing date
and disk filling have a hard time). Adding comment for how to run
docker (needs the --cap-add LINUX_IMMUTABLE option passed).

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-22 00:04:12 -08:00
William Douglas a9608851ee Move packs to download synchronously
There are some problems with how we are using multiplexed curl causing
huge slowdowns (2-5 times slower).

For now rather than rework the multiplexed curl code, switch to using
the synchronous code path.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-21 23:26:19 -08:00
William Douglas 3338cb2c66 Rework clean-old-statedir test output checking
The order of files in this test aren't very completely stable so make
do with looking at output chunks that seem to be reasonably consistent
across different environments.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 7f59817a43 Improve tests for container
Detect docker container usage when running test to handle cases where
systemd is unlikely to be running.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 776f8c92b0 Update use bats setup and teardown features
Instead of relying on a custom global_setup and global_teardown
functions, migrate to the use of bats' setup_file and teardown_file
functions.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas eddf0dc2a4 Fix shellcheck SC2048 error
Correctly quote arrays.

Also improve some commands getting the array content (fixes space
issues with quoting).

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 6a6a907b06 Move no space tests to CI only
These tests fill up the disk and can be quite annoying to run on a dev
system normally.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas e55e33afef Fix shellcheck SC2269 error
Remove useless assignment.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas ffb1590909 Update shellcheck exceptions
Shellcheck changed its detection for a few file sourcing errors from
1090 to 1091. Update the disables accordingly.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 436fb503c6 Don't version clang-format
clang-format changing output between versions is painful so might need
to be reconsidered at some point.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 7e00e0a20b Switch off of string n functions
These functions lead to spurious errors and warnings for our use
cases.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-07 12:51:05 -07:00
William Douglas 49adbbd18f Add additional shellcheck directives
Signed-off-by: William Douglas <william.r.douglas@gmail.com>
2022-10-06 14:34:40 -07:00
Brett T. Warden 0e0cc9b969 Update offline installation tests with URL override
Offline installation tests also override the installation URL, so we
must update the expected output to contain the new message about URL
override.
2022-10-05 11:08:47 -07:00
Brett T. Warden db4ceb85b8 Update tests for swupd mirror commands
Mirror tests specifically invoke the URL override options that trigger
the new text output I've added, so the tests' expected output needs to
be updated to match.
2022-10-05 11:08:47 -07:00
William Douglas 3d611782ab Move to a static pemfile
There is something going wrong with installing the generated pemfile.
The file is created but not yet valid, this is not a problem for
local testing for some reason. To work around this issue, use a static
pemfile that is already valid and force install it.

Signed-off-by: William Douglas <william.r.douglas@gmail.com>
2022-10-04 17:25:31 -07:00
William Douglas dbfce4b218 Skip the timesyncd stop and start
As these are CI only tests, the container image currently appears to
have the service masked so stop trying to modify it.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-04 17:25:31 -07:00
William Douglas 685ed470c4 Use regex match for size comparison
The exact size difference changed for some reason but shouldn't cause
the tests to fail as it isn't the point of this test.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-04 17:25:31 -07:00
William Douglas e778dc2ede Update test based on size
The test requires an exact size reporting, fix the size but consider
using a regex match instead.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-04 17:25:31 -07:00
Castulo Martinez 935053fdbe Testlib: refactoring setup to load correctly
The setup() function is run at the beginning of each test by the BATS
system, we leverage this function to implement a global_setup() and a
test_setup().

This commit refactors the function to make it easier to understand, also
makes sure it loads the environment variables correctly for tests.
2020-06-16 11:42:13 -07:00
Castulo Martinez 838022f36b Testlib: making variables available to all tests
Variables are available just after being exported, however variables are
not kept between tests since the process that orchestrate the tests of a
test file is a parent process and child processes cannot set variables
of a parent process. This is problematic because we were loosing some
variables (like all third party variables) when running multiple tests
using a global_setup().

This commit fixes the issue by making all the environment variables
available to all tests in a test file regardless of if they use
test_setup() o global_setup().

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00