There is a missing line break that shows up When running
the "swupd verify" command and there is a hash mismatch.
The output looks like this:
$ sudo swupd verify
Verifying version 25590
Verifying files
...1%Hash mismatch for file: /usr/bin/tmux
...100%
Inspected 292278 files
1 files did not match
Verify successful
This commit fixes the issue by adding a line break at the
beginning of the output.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The list is missing a "\" at the end of one test which is causing
a group of tests to be ignored by the makefile, therefore they are
not being run.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Every test should include a unique ID, so it is necessary to have
a way of knowing what is the next available ID for the group of
tests.
This commit helps with that issue by implementing the following
features in the test library:
- Adds the function get_test_list which can be used to print a
list of tests in a specific group directory.
- Adds the function get_next_available_id which return the next
test ID that can be used in a new test.
- When using the generate_test function to generate an empty test
the next available ID will be used for the template.
This commit also adds the ID to a bundle-add test that was missing it.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Shellcheck is a shell script static analysis tool that looks for errors and
programming pitfalls in shell scripts.
Fixing errors reported by running that tool on bats scripts
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
When running tests, there is the possibility of preserving your
test environment for debugging purposes.
We were preserving the environment by skipping the execution of
the destroy_test_environment function when the DEBUG_TEST env
variable was set. This had one limitation, this was being done in
the default teardown function, so if the user would define his own
teardown then the DEBUG_TEST had no effect, the same if the user
used global_teardown instead. Another limitation the current
implementation had was that when an environment had been preserved
if the user would forget to clean it up manually before re-running
the test it would cause unexpected results in the test.
This commit removes both limitations by looking for the DEBUG_TEST
variable directly within the destroy_test_environment function so
the env will be preserved regardless of where the function is called
from and removes the environment at the beginning of the test if it
exists.
Closes#651
Signed-off-by: Castulo Martinez <castulo.martinez@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>
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>
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>
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>
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>
Soon, a minversion header field will be included in the MoM. This change
updates the test library to add a minversion header field to MoMs and adds
functions to create a minversion update. Also, the skip-verified-fullfiles
test was replaced by the update-minversion test. The update-minversion test
verifies that unchanged files with a version bump caused by a minversion
update are skipped during an update.
Signed-off-by: John Akre <john.w.akre@intel.com>
This commit adds a couple of tests meant to validate adding bundles
using zero-packs or falling back to using full-files.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The test library contains a few assertions meant to verify the
existence or non existence of files and directories. In the case
of swupd, it is sometimes common that these files can be in directories
that are not readable by non root users, which is the case of the state
directory.
This commit makes a change so these assertions use root for testing
the existence of these files and directories so we don't get false
positives in the tests.
The commit also adds one more env variable with the --keepcache
option so we can use it in tests that require the state directory
to be persisted.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old update and verify tests used the swupdlib.bash library that
was replaced by testlib.bash.
This commit replaces those old update and verify tests with new
versions of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old search tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old search tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old mirror tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old mirror tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old hashdump tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old hashdump tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old completion tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old completion tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old checkupdate tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old checkupdate tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old bundleremove tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old bundleremove tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old bundlelist tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old bundlelist tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The old bundleadd tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old bundleadd tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When a user wants to print to the terminal from a test that
is using the bats framework, it is necessary to use file descriptor
3.
This commit provides a wrapper function called print so it is
easier for user to print to terminal from tests.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When updating the manifest version we were replacing any line with the word
version to "version: new_version". This is a problem now that we are adding
a minversion field to the manifest. That could be a problem too when there
was a file named version.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit adds the iterative manifests (to-manifest) and the delta
manifest (from-manifest) when creating a bundle update. This manifests
should contain only those files that changed in the latest version.
Closes issue #557
There are some cases in the library where sed or awk is used to find
certain lines within files. To match these lines we use a pattern.
In some cases this pattern should be anchored to the beginning of the
line, in case a string with that pattern appears in a file (for example
in a bundle manifest name) in the last field. This is unlikely, but
it's better to avoid unintentional matches.
When a user creates a new version in a test environment and uses
the -r option an updated version of the os-release and format files
are added to the files directory. This is useful for some tests
like update tests.
This commit adds a second step of adding the updated files to the
os-core bundle so it is easier to create updates. With this commit
if using the option -r it means the new version will include an
update to the os-core bundle.
To support clients that need to authenticate with a web server
containing protected swupd content, an SSL certificate should be
presented if defined. This commit enables client certificate
authentication with swupd and adds relevant tests.
credit: gtkramer implemented client certificates in swupd
Signed-off-by: John Akre <john.w.akre@intel.com>
This commit adds the following test objects to testlib:
- start_web_server
- destroy_web_server
This change moves the implementation of web server creation and
destruction from individual tests to the test library.
Signed-off-by: John Akre <john.w.akre@intel.com>
This commit adds functions to testlib for the following:
- generate_certificate
- create_trusted_cacert
- destroy_trusted_cacert
These functions are used to create a self-signed public/private key
pair, create a trusted key store for the test environment with a public
key, and to delete the trusted key store. For the test environment to use
the trusted key store, swupd must be configured using
--with-fallback-capaths=<path to key store>. This configuration option
has been added to autogen and travis.
Signed-off-by: John Akre <john.w.akre@intel.com>
When "uninstalling" a bundle in web-dir it is better not to
remove all files in the bundle's manifest because they may be used
by another bundle, and checking every manifest would be too expensive
for this test task. Removing the bundle manifest and its packs is
enough for testing purposes.
Some functions from the test library can be used by end users to
modify some object from their test environment, for example using
the add_dependency_to_manifest they can add one or many dependencies
to a bundle's manifest. After modifying a bundle's manifest, many
subsequent actions need to occur in order for the objects to still be
valid, the manifest's tar needs to be re-created, since the manifest's
hash changed, the MoM needs to be updated with this new hash, etc.
To minimize the actions an end user needs to do, most of these
activities are automatically performed by most library functions.
However if the function is being called by another function which
expects to perform many actions in the same object, it may not be the
best option to be re-creating those tars and updating the MoM many times
for the same object since it could affect the performance.
This commit adds a -p flag to some functions to tell the functions you only
want a partial update, meaning that you plan on making more changes to the
test object so all those unnecessary changes are not performed.
Normal test environments come with a minimal version of os-core
bundle by default (only one file and the tracking file). Users
also have the option of not having os-core at all with the -e
"empty" option.
This commit adds another option "-r" for creating a test environment
that includes a more complete version of the os-core bundle,
with a couple of useful files: os-release and format. This type
of bundle can be useful when working with some type of tests like
updates.
Use download.c parallel download api to download packs in parallel,
the same way we do for fullfiles.
Some changes were necessary in update/slow-server test. As we are using the
parallel download api to download packs the resume strategy is now the same
described in b07285. Because of that download resume is only enables when the
download is interrupted in the first try. So we force a download fail and a
download retry in server.py to check if swupd is trying to resume the download.
Because of this change the update/slow-server test is performing 2 retries
(first downloaded is interrupted to force a resume and the second is interrupted
because the slow-server don't support download resumes) and this adds a 30 seconds
delay to the test execution. This delay isn't going to slow down the test execution
considerably, but the ideal is in the future to support running tests with 0s
timeouts. For this reason update/slow-server is being skip when not running in
travis ci.