This release fixes a series of bugs and includes improvements into tests and testlibrary API.
Bug fixes:
- Better exit codes and failure messages for swupd commands
- Documentation improvement adding information about os-format in manpages and
systemd unitdir build option in swupd -v
- Using a more robust string to integer conversion in order to prevent overflows
- Report files removed by --picky in verify summary
- Fix verify --fix bug when downgrading to a version with missing bundles.
- Fix memory leaks and invalid memory access when using time report (-t)
- Adding more probes to time report (report total time and post-install script
execution.
- Removing deprecated code for handling the deprecated and unused manifest
deltas
Tests:
- Improvement in testlib documentation
- Adding more tests
- Bug fixes in testlib API
- Support for running tests in a proxy environment
- Webserver consolidation
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Add a timer counter to print how long run_scripts() take on verify and
bundle-add commands. Note that this is already in place for update.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Also fixes the following problems
- Make timelist independent from swupd specific code
- Don't free memory on timelist_print_stats(). Instead create a free function for that
- Fix memory leak on bundle-add (#575)
- Improve function names
If the timer on the top of the tail was completed grabtime stop was stopping
all timers on the tail instead of closing just the latest open timer.
For example this code:
timelist times;
times = init_timelist();
grabtime_start(×, "1");
grabtime_start(×, "2");
grabtime_start(×, "3");
grabtime_start(×, "4");
grabtime_start(×, "5");
sleep(1);
grabtime_stop(×);
sleep(1);
grabtime_stop(×);
sleep(1);
grabtime_stop(×);
sleep(1);
grabtime_stop(×);
sleep(1);
grabtime_stop(×);
Would produce this output:
Raw elapsed time stats:
2000.30 ms: 1
2000.30 ms: 2
2000.18 ms: 3
2000.18 ms: 4
1000.10 ms: 5
CPU process time stats:
0.20 ms: 1
0.19 ms: 2
0.07 ms: 3
0.07 ms: 4
0.05 ms: 5
Not it's printing:
Raw elapsed time stats:
5000.48 ms: 1
4000.41 ms: 2
3000.34 ms: 3
2000.27 ms: 4
1000.15 ms: 5
CPU process time stats:
0.15 ms: 1
0.13 ms: 2
0.11 ms: 3
0.09 ms: 4
0.06 ms: 5
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
As part of the effort of having the functional tests better
organized and have traceability we are adding unique IDs to
every test.
This commit adds the IDs to the bundle-add tests. It also
changes the description of some of them to make them clearer,
and removes duplicates.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Some functionality was added to the test library to allow printing
function availability plus usage information.
This commit adds that info to the readme of the library to keep it
accurate. It also adds a table of groups for the tests which will
be useful soon when we start using IDs in the tests.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When you do a "verify --fix --picky -m older_version", and one
or more of the currently installed bundles didn't exist back then,
a non useful error message was being used, and the verify operation
would fail.
This commit makes the following changes.
1) With this commit, if the mentioned situation happens, the verify
operation will still be stopped, but a useful message will now be
displayed to inform the user of the situation, and he/she will be
presented with an alternative to proceed using the --force option.
2) If the user uses the --force option, the user will still be warned
but the verify operation will continue and the offending bundles will
be removed from the system.
Closes#608
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Only files that were orphaned were being counted as files being removed
from the system, files removed because of the picky options were not being
counted. This commit changes that so files removed by picky are also
counted.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Various functions, like strtol, were used to convert strings to numbers.
Frequently, the results of these conversion functions were stored in
variables with types that did not match the function return value. As a
result, there was a potential risk that an overflow would occur when
type casting the string conversion function result to store it in a
mismatched type.
The most common case is to convert a string to an int, so this commit
creates the strtoi_err function which converts a string to an int and
provides error handling. Also, the error checking for other string to
number conversions was improved by adding error handling with errno.
Fixes#601
Signed-off-by: John Akre <john.w.akre@intel.com>
When mixing variables and targets make was attributing some variables as
targets. Because of that make install was running some tests defined in TEST
variable. Reordering all variable definitions to make sure all are defined
before first target definition.
Also removing line:
- test/functional/completion/completion-basic.bats: swupd.bash
because swupd.bash isn't autogenerated anymore, so it will always be ready
for the test.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Previously, the only way to get a return code of 0 (success) during
a bundle-add operation was if everything that was attempted to be
added had been successful. That means that bundle-add command was
returning EBUNDLE_INSTALL whenever it would try to add a bundle that
was already installed.
This commit changes the return code of such operation since it was
determined that it is a more appropriate behavior to consider an
attempt to add a bundle that is already added as successful, even when
no bundle was added during the operation.
Closes#510
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
There were two web server implementations in the functional tests and the
test library's slow server implementation was not functional. These issues
were addressed by the following changes:
- Consolidate test web server implementations into test library
- Add partial download support to start_web_server test library function
- Fix test library slow server functionality.
Signed-off-by: John Akre <john.w.akre@intel.com>
Print the compile-time configuration systemdsystemunitdir.
Option was incorrectly removed on 74b2d526 so it didn't get into commit
that added extra information to --version (204e2a4b)
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit adds a few improvements to the test template that aim to
make easier to track tests.
As we are trying to organize the swupd tests better, it is useful to
have an easy way to identify who the original author of the test was
in case there are questions regarding the purpose of the test.
It is also useful sometimes to add a long description to a complex
test, so people reading the test understand what the test is attempting
to verify, and why is useful or different.
Lastly, it is a good practice to add a unique ID to every test case,
this makes it easier to track it, and to refer to it.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
I see the checkupdate/chk-update-slow-server test fail when the
http_proxy env variable is set, but no_proxy is not set.
Resolve the issue by adding "localhost" to no_proxy if needed, since the
test web servers run on localhost.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Some time ago the "-u" option of the create_test_environment and
create_version functions was renamed to "-r". Four of the verify
tests were not updated, so they were crashing during the setup,
while trying to create the test environment, so the test would not
be run since the setup failed but the teardown would still run and
the teardown would attempt to delete a non existent test environment
which would cause the destroy_test_environment to exit the script
causing an inconclusive test result.
This commit fixes the issue by doing the following actions:
- Fixes the tests by using the correct option "-r".
- Modifies the destroy_test_environment function so it does not exit
if a test environment doesn't exist, but instead it just returns a non
zero code and warns the user so the teardown works as expected.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When performing an update, if one or more files fail to be downloaded
the update process continues and the user is not notified of any
failure in the update.
This commit forces the update to abort if one or more files could not
be downloaded and informs the user about the failed update.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When doing an update if an update is not successful it does not
show a message saying the update was successful but it does show
other messages that could make you believe the update was successful
even when it was not.
This commit changes the logic so certain messages are only shown if
the update was successful and so an explicit failure message is
displayed in the case the update failed.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The function load_mom was returning the requested MoM if found or
NULL if not found.
This commit removes the load_mom_err function and adds the capability
of returning the error code to the load_mom function.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Linux programs return code should be a number between 0 and 255, so 404 is an
invalid return code. Removing it from docs and from swupd-error.h file.
As it wasn't being used, this won't be a problem.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit adds a menu of the functions that are available for
users when writing tests or just using the library to create
resources to test their code.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Delta manifests are no longer used, so removing support for them. This
change removes the try_delta_manifest_download function which was used
to download manifest deltas. After removing this function, the 'current'
and 'file' parameters were no longer used by the retrieve_manifests
function. This had a ripple effect that removed unused parameters from
a variety of other functions.
Signed-off-by: John Akre <john.w.akre@intel.com>
Fix a bug in swupd autoupdate --enabled. If the swupd autoupdate time unit
was already loaded with the status of 'active', the unit needs to be restarted
and not just started again.
Problem reported and fixed by Auke Kok <auke-jan.h.kok@intel.com>
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Fix bug in v3.18.0. Autoupdate was disabled on systems because of an option
removed from configure.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This release includes:
- Multiple fixes to memory leaks and invalid memory access
- Improvements in clean command, removing more unnecessary Manifests
- Adds new flags, keepcache, that keeps all staged cache after an update and
max-parallel-downloads (renamed from max-pack-parallel-downloads) that lets
user set the number of parallel downloads for packs and fullfiles.
- Major improvements in swupd test library. Porting to new testlib was
concluded and all tests from old library was ported.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
max-parallel-pack-downloads was renamed to max-parallel-downloads
and documentation needs to be fixed
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
read_versions is a function that attempts to read the current version
of the target system and the server version, but if there is an error
reading any of those values no action was performed so it was necessary
to validate these values wherever the function was being used,
duplicating code.
This commit adds a verification to make sure the current version of the
target system and the server version was able to be identified.
Closes#589
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
If the -t parameter is set for a given empty directory, then
the time queue will be empty causing that the TAILQ_FOREACH_REVERSE
macro segfaults.
The proposed solution is to check if the head is NULL at the beginning
of the print_time_stats function.
Fixes#600
Signed-off-by: Erich Cordoba <erich.cm@yandex.com>
Fixes#484
The manifest files with their hashes appended to the filename in the
cache are used internally to prevent swupd from re-calculating manifest
hashes every time they are opened. These should only persist for the
duration of the update and should not persist afterwards to prevent
root-priveleged owners from modifying internally-used data. This patch
causes swupd to remove them by default without having to pass --all. The
files will be automatically removed upon update.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
When invoking swupd --version print more information about compile-time
configuration. This feature was requested after a bug was introduced to
an unreleased Clear Linux build when swupd was built with the wrong
format ID. This allows QA to determine exactly which compile-time
options were set during runtime without inspecting the binary.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
After running an update, the state directory is cleaned up.
Sometimes it is useful to be able to peek at the state directory
after an update, this is specially true when testing updates,
this way tests can verify what manifests were downloaded during
the update.
This commit adds the --keepcache option to swupd update so it can
be used when writing tests for updates.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>