467 Commits
Author SHA1 Message Date
John Akre aa544293c2 Add functional tests for statedir-cache
This change adds tests for the statedir-cache with and without a network
connection.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-20 14:45:34 -07:00
Otavio Pontes 0696de4435 curl: Initialize curl as needed
Instead of initializing curl library on start, initialize it only when needed.
The advantage of this approach is that we can run some commands offline, if
there's no file to download.

Fixes #801
Fixes #895
Fixes #277

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Castulo Martinez a41bea9fd5 Show the real latest version using check-update
When running the check-update command we get the latest version for the
format we are currently in, but we really want to get the latest version
regardless of the format.

This commit fixes the issue.

Closes #482

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-14 14:31:33 -07:00
Otavio Pontes f19e8dce06 search-file: Don't estimate the total download size for manifest
Estimating the total download size is almost as slow as downloading the
manifests. So just don't do it.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 13:04:23 -07:00
Otavio Pontes 299977fec4 update: Download search-files indexes on update
If --update-search-file-index flag is used on update, all search-file indexes, i.e.
all Manifests will be downloaded on update. This shouldn't be used if you have
disk or network restrictions, but it shouldn't be very download intensive after the
first usage because delta manifests are going to be used.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 13:04:23 -07:00
Otavio Pontes 7f37684920 test: Always run real content tests with --no-progress
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 12:29:32 -07:00
John Akre 970f3a257a bundle.c: Return included manifest loading errors
Previously, when adding included manifests errors were thrown away which
resulted in swupd operations that could succeed, even when failing to
load an included manifest. Now when an included manifest fails to load,
swupd will return a failure.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-12 14:38:34 -07:00
Otavio Pontes 74dd1686ad test: Don't check the hashes twice on real tests
Diagnose picky behavior has changed so now we can use just one call
to swupd to verify if there's no extra file and no corruption.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-07 15:51:10 -07:00
John Akre 031c06776e os-install: Add download flag
When the --download flag is set for the os-install command, update
content will be downloaded to the statedir and no content will be
installed.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-07 14:12:34 -07:00
John Akre 30cb21260a testlib: Enable validate_item to check statedir
Sudo is needed to validate items in the statedir.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-07 14:12:34 -07:00
Castulo Martinez 6a4b15b430 Fixing message when using repair and --picky
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-07 09:43:41 -07:00
Otavio Pontes a22f621a5e log: Print download sizes in MB and not Mb
MB stands for Megabyte and Mb stands for Megabit, so use the correct
unit.

Fixes #1044

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-05 16:10:02 -07:00
Castulo Martinez 5608930be5 Fixing a bug using ignore-ilst files in tests
When using testlib to create tests, ignore lists can be used which
include lines of output that should be ignored when running tests.

The ignore lists can exist at three different levels:
- an ignore file that applies to all tests
- an ignore file that applies to all files of one theme
- an ignore file that applies to all tests within the same file

There was a bug in this last one that was causing ignore-list files to
be unrecognized unless the test number was also used as part of the
ignore-list name. This was causing issues because the test number
can change depending on how you run the test.

This commit fixes the issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-02 14:17:19 -07:00
Otavio Pontes 45762e7eab real_content: Properly remove the cache directory used by the test
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-02 12:38:52 -07:00
Otavio Pontes f94d13a122 real_tests: repair doesn't support -B anymore, so use verify --fix
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-01 13:36:47 -07:00
Castulo Martinez 476cfe14f6 Warn users when using "swupd verify -B"
Using the -B option with verify can have some undesired side effects
since the option is usually missused by users.

This commit adds a warning explaining what are the possible side effects
of using the "-B" option.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez 93662e4d81 Improve the flag restrictions for repair
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez a65fe6804e Print only one warning for verify
When using the "verify" command, we show a warning saying the command
has been superseded by "diagnose". But if the user also uses the
"--install" or "--fix" options with "verify" we show another warning
saying those options have been superseded.

We only want to show one warning depending on the options chosen by the
user so we suggest them to either use "diagnose", "repair" or
"os-install" instead.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez b81a3edaae Improve the flag restrictions for verify/diagnose
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez 2e3a584558 Removing --bundle flag from repair
The -B/--bundle option is confusing and causing users to wipe out their
systems. This option was really just meant for os-install, so this
commit removes it from "swupd repair".

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez c0b340bbd2 Fixes a bug when deleting extra files
When swupd repair is run with --picky or --extra-files-only it attempts
to remove all those files that are in the picky tree and that are not
mentioned in any manifest (from installed bundles). If swupd
encounters an error removing any of these files or directories, it
prints a message showing the failure. This message was wrong since it
was not showing the whole path to the file being deleted when the path
included a prefix.

This commit fixes the issue by appending the prefix to the path so it
shows correctly.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 13:43:49 -07:00
Otavio Pontes 277fc0284e mirror: Handle global parameters properly on mirror set
We have 2 global parameters to change content and version url that
were confusing when using mirror. For example user's didn't know what
to expect from:

$ swupd mirror --content-url https://new_url

or

$ swupd mirror --set https://new_url1 --content-url https://new_url2

Fix #941

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-25 14:06:27 -07:00
Otavio Pontes a7807abcf7 test: support DEBUG_TEST flag
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-24 15:49:47 -07:00
Otavio Pontes 8a2b2e200e test: Print extra information
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-24 15:49:47 -07:00
Otavio Pontes 2ce9e9eace test: Use the lastest_version file to get last format
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-24 15:49:47 -07:00
Otavio Pontes db7b1e4b9e test: Removing test because coverage is in all other tests
We now use os-install to install bundles, so this test is already covered.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-24 15:49:47 -07:00
Otavio Pontes 99b6f8fd2c test: Improve fullfile tests by using only repair
We don't need to update to test the fullfile downloader.
Just a repair

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-24 15:49:47 -07:00
Otavio Pontes 54aa2a72b1 real_content: Use os-install instead of bundle add to install bundles
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-24 15:49:47 -07:00
Otavio Pontes e2629167b6 real_content: Fix old TODO that was depending on a bug fix
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-24 15:49:47 -07:00
Otavio Pontes 8a20146460 test: Fix the destination of real_content tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-24 15:49:47 -07:00
Otavio Pontes 0968948389 test: Rename the name of the distro for tests
We don't need to have a real distribution name for tests. Use a swupd
specific value.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-19 14:20:00 -07:00
Castulo Martinez 6a0849646d Adding --extra-files-only flag to diagnose/repair
Since --picky was made a superset of diagnose/repair, there is the need
of a new flag that only finds/repairs the extra files that are not in
any manifest.

Many things were included in this commit:
- This commit adds the new flag --extra-files-only for this purpose.
- The commit also refactors the verify function to simplify its workflow
and remove code duplication
- It also adds some validations for flags that are mutually exclusive in
verify/diagnose/repair
- Updates the documentation

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-19 10:46:20 -07:00
Castulo Martinez e0256bee24 Make "diagnose --picky" a superset of "diagnose"
Running "swupd diagnose --picky" result in only identifying the extra
files in the system, but doesn't run the other standard checks that a
"swupd diagnose" do. "swupd diagnose --picky" should do everything
"swupd diagnose" does plus searching for the extra files.

This commit fixes the issue by making diagnose --picky a superset of
diagnose. The commit also makes some changes in the output of --picky so
it is consistent with the rest of the diagnose output.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-19 10:46:20 -07:00
Brandon Hong d0494ba47e Update test case MIR008 for the new swupd info output
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
2019-07-19 10:10:10 -07:00
Brandon Hong b09bdddabe Update testcases to reflect new info format
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
2019-07-19 10:10:10 -07:00
Otavio Pontes 0a84e15aac test: Don't run config file tests on developers machine
config file tests require one special configuration on build time, so
skiping this unless we are running on travis.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-18 14:56:32 -07:00
Castulo Martinez 069ec11ca8 Fix format of do_staging when reporting progress
The function do_staging is regularly used within a loop to stage all the
files for a given bundle-add or update, repair, etc. However when the
loop contains a progress report (with a percentage), if there are errors
in the do_staging function, they get printed in the same line as the
percentage, messing up the output. Like this:

...22%Warning: Update target directory does not exist: some_file...

This commit fixes that output by adding a carriage return at the
beginning of each message do_staging could print so it would overlap
with the percentage value effectively deleting it.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-17 14:24:01 -07:00
Otavio Pontes cd1aac63f1 style: Removing all prints that ends with a '.'
It was defined to not use period at the end of output messages.
Removing the left over cases

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-17 14:16:56 -07:00
Castulo Martinez a6f03caf2e Include also-add circular reference in test
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-15 17:24:12 -07:00
Otavio Pontes 7f0bee1f6f bundle: Support circular includes/also-adds
Circular includes shoudn't exist, but we can handle that without crashing.
Also-add circular includes are common and expected. So we just add the
first occurence found.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-15 17:24:12 -07:00
Otavio Pontes 43034997f5 test: Fix test name
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-15 16:23:50 -07:00
Otavio Pontes e148456c8a test: Shellcheck tests should return an error on fails
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-12 16:32:18 -07:00
Otavio Pontes 382c1d782f also-add: Update, diagnose and repair shoudn't consider the also-add bundles
In the case that we have a bundle installed as also-add and removed later,
repair shouldn't reinstall that bundle. The same is valid for diagnose and update.
Os-install is the only exception. We should always install all bundles that are
listed as also-add in os-install.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-12 15:44:25 -07:00
Otavio Pontes 6bf50db9bf test: Add missing NULL parameter to run_command() call
Last parameter was missing on a run_command() call and tests were breaking for some specific configurations.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-12 11:17:13 -07:00
Castulo Martinez a61eed9bb7 Fix bug in mirror-allow-http.bats test
This test is yielding different results depending on if it is being run
in a system that has a proxy set up o there is no proxy.
This is happening because when usnig a non existing  server, if
there is a proxy set up, the proxy does respond during curl
initialization instead of the specified server, which allows swupd to
initialize only to fail further down the process when requesting the MoM
to the server. If the system where the test is run doesn't have a proxy
set up, curl fails to initialize since it gets no reply from the server,
which causes swupd to fail initialization, so swupd exits earlier in the
process and with different exit code.

This commit fixes the ambiguity of the test by not checking for an exit
code explicitelly but only making sure it does get an error code.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-10 13:37:01 -07:00
Otavio Pontes f337da5b9c bundleadd: Rename flag from optional to also-add
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-08 13:58:24 -07:00
Castulo Martinez 515c7c71fe Checking mirror status only if necessary
When doing an update, we check to see if a mirror is stale, this only
needs to be done if there is a mirror set and if the upstream server is
up and reachable.

This commit checks to see if a mirror is set and there is an upstream
server to compare against, and only then it checks to see if it is stale.

Closes #922

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-03 16:10:46 -07:00
Otavio Pontes 659d12aa82 test: Fix typo in test
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-03 15:05:42 -07:00
Castulo Martinez c5ba016331 bundle-add skips optional bundles if specified
Swupd will install optional bundles on bundle-add by default,
but will skip them if specified by the user by using the
--skip-optional / -o flag..

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-03 14:59:47 -07:00
Castulo Martinez 9924bf7ee2 bundle-add installs optional bundles by default
An optional bundle is not required to be installed in the system while
included bundles are. Swupd will install optional bundles on bundle-add
by default.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-03 14:59:47 -07:00