85 Commits
Author SHA1 Message Date
Matthew Johnson a2f9759e11 Add functional tests for verify version mismatch and override
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-12 11:48:44 -07:00
Matthew Johnson f9180d3f43 Fix several hash mismatches in bundleadd tests
Now that bundleadd verifies each file it downloads the incorrect hashes
cause test failures. Update these hashes to be correct.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-12 11:46:29 -07:00
Matthew Johnson ac7345318c Add functional tests for bundle-list --deps
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson c83c4ce78f Add functional tests for bundle-list --has-deps
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson ee06e85931 Add --has-dep argument to bundle list
The --has-dep=BUNDLE argument will display a tree representing all
installed bundles that recursively include BUNDLE.

One may pass the --all argument as well to list the dependency tree for
BUNDLE including all installable bundles available on the server.

**Example output without --all:**

Installed bundles that have os-installer as a dependency:
format:
 # * is-required-by
 #   |-- is-required-by
 # * is-also-required-by
 # ...

  * mixer
    |-- os-clr-on-clr

**Example output with --all:**

Attempting to download version string to memory
All installable and installed bundles that have os-installer as a dependency:
format:
 # * is-required-by
 #   |-- is-required-by
 # * is-also-required-by
 # ...

  * clr-devops
  * mixer
    |-- os-clr-on-clr
        |-- os-clr-on-clr-dev
    |-- clr-devops
    |-- os-clr-on-clr-dev

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson 6108f50bb9 Print bundle dependencies when failing to remove
A bundle will fail to be removed from the filesystem when other bundles
require that bundle as a dependency. Print a list of each of these
bundles along with the error message.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Patrick McCarty 485ab31f22 Add functional tests for verify format mismatch and override
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-08-30 11:12:50 -07:00
Matthew Johnson d274f3aede Add "Applying update" print as a progress header
Since this step can take a while print a header to give an indication of
what the progress percentage is tracking. Update functional tests to
include new output.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-17 15:37:15 -07:00
Matthew Johnson 7f7e5b6416 Add progress updates for redirected output
Add a progress indication for redirected output such as for logging,
testing, or third-party software such as ister.

For every 10 files or steps completed a dot (".") is printed to the
screen.

Adds a few more progress indications for silent loops.

Also adds leading newlines to some existing print statements so they are
printed on their own line.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-17 15:37:15 -07:00
Icarus Sparry 3668fb5f7b Ensure state_dir is a directory and owned by root
As the state_dir (normally /var/lib/swupd) contains things like the
downloaded bundles, it is important that there is no access to
non-root users who could potentially explot races to replace files
between them being checked and them being installed.

Ensure that the state_dir is root owned, and mode 0700, as well as the
critical directories below it.

Note that a proper fix would involve using chdir to move into the
directory and only use relative paths. This would prevent faulty
permissions higher up the directory tree being exploited. It *might*
be possible to use openat(2) to prevent this exploitation.

Add a test to ensure that the enforcement is taking place.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-08-17 15:28:06 -07:00
Matthew Johnson ae011954f4 Add status checks for test swupd commands
Adds status checks for each swupd command called in the functional
tests. At this point several of these tests fail due to some successful
commands returning error statuses.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-10 15:33:59 -07:00
Matthew Johnson 2c9021289f Wait for test server to become available before testing
Check that the simple test server in the checkupdate/slow-server/ test
is available before actually running the swupd command. This check is
done by testing the return status of a curl command on the server up to
ten times until successful.

Since this is an historically touchy test, output an additional
debug.log in the test directory with much more verbose logging (using
set -x).

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-08 15:20:16 -07:00
Matthew Johnson 6f52e62854 Fix typo in clr_bundle_rm.c
succesfully -> successfully

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-07 14:23:30 -07:00
Matthew Johnson 89af564256 Convert post_update_actions to list-based approach
Instead of allowing only one "actions:" field in the Manifest.MoM, allow
for several and read each into the post_udpate_actions list. This allows
us to add more actions down the road if desired.

Currently the only use for the "actions:" field is to indicate when a
re-update is required. This is handled by checking if the string
"update" is in the post_update_actions list.

Finally, remove the warning to the user to perform the post update
action themselves, as this will be handled by swupd itself. Functional
tests updated to reflect the missing output.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-07-28 23:19:54 -07:00
Matthew Johnson d6636d7814 Add functional test for re-update with bad os-release
Adds a functional test for swupd re-update when the os-release file does
not get updated.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-07-28 23:19:54 -07:00
Matthew Johnson 1d19db4bc1 Add funtional test for swupd re-update
Adds functional test for swupd re-execs over format bumps.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-07-28 23:19:54 -07:00
Auke Kok 22cccd9a04 Differentiate between various early network failures.
We draw a hard line with error codes, such that:

Error code 16 is reserved for failures resulting from the basic
network check. Any call to check_network() that fails will
return this error code. No other error path returns this
error code.

Additionally, check_network() is called in every normal code path.

All other, possibly network related issues, return a different
error code. If the basic network check succeeds, but e.g. pack
downloads fail, we return a new (23) error code so that we
can better establish the conditions through telemetry and
determine whether the error is on the client or the server,
which is highly likely with this new error code 23.
2017-07-20 16:18:33 -07:00
Tudor Marcu 29b9d1e3a9 Retry pack downloads on bundle-add
The download_subscribed_packs() could fail for network issues or other related
problems, and because the only option for getting new packs is by downloading
zero packs or fullfiles, swupd should retry to get the packs before falling
into the verify_fix_path flow which signifies pack downloads errored out.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-04-28 14:38:53 -07:00
Tudor Marcu dac74856da Update tests for new messages being printed
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-04-19 10:12:51 -07:00
Jaime A. Garcia 6a8d36763b Accept multiple bundles at bundle-remove
This is a wrapper around remove_bundle()
to add consistency for bundle-remove
subcommand respect bundle-add that accepts
one or more bundles to be removed.

This must not be the optimal implementation
but it works fine and gives a better user
usage experience.
2017-04-04 11:50:21 -07:00
Icarus Sparry 3ec26daff7 Improved return code for bundleadd + test
Arrange for "bad names" to give non-zero exit code
Arrange for "do nothing" in particular when packages are already
installed to give a zero return code.

This means that typos in names result in failures, but that trying to
add an existing package is fine.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-04-04 11:46:19 -07:00
Tudor Marcu fd6b54d964 Try to recover from invalid certificate date
The system clock may be terribly off, especially on new hardware that has not
yet been calibrated. Updates rely on the certificate and system time being
sane to verify validity, so if a mismatch is found the certificate will
be deemed invalid and the update stopped. This patch attempts to fix the
system time to something sane using the time from the swupd binary itself,
which should not have been touched by any user except root. If the time is
normal and verification fails, the cert cannot be trusted.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-03-25 00:00:41 -07:00
Icarus Sparry 9c4c2cec08 Improved error reporting for adding bad bundle
Currently if you try and add a non existent bundle, e.g. "foo" you get
two lines of output

  foo bundle name is invalid, skipping it...
  bundle(s) already installed, exiting now

This is caused by the add_subscriptions function calling itself
recursivly but failing to pass up results in a meaningful way. This
change makes the return value of add_subscriptions be a bitmask so it
can signal errors and packages added distinctly.

I did think about changing this function to return a struct but
decided this was a step too far.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-03-24 15:27:55 -07:00
Tudor Marcu bfb26b5c40 Change certpath to be full path of certificate
The mixer and image creator treat the certpath as the full path of the
certificate filename, and swupd should too. If someone is overriding the
certificate with the cert path option, use the supplied string and don't
append a pre-defined name to it.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-02-27 11:40:11 -08:00
Ikey Doherty 6324401974 scripts: Port to the modern clr-boot-manager usage model
In the current system we depend on the legacy boot infrastructure, which
has been provided by clr-boot-manager in the way of compatibility scripts.
These scripts all do the same thing, which is to invoke clr-boot-manager
with the "update" subcommand.

Given that clr-boot-manager doesn't need to know the context of the
operation, i.e. it is able to deduce whether kernel or bootloaders need
updating, regardless, it makes little sense to use any of these scripts,
and we should begin to deprecate them.

In clr-boot-manager 2.0, we will look to remove these compat scripts
completely, however they will continue to exist until then to facilitate
necessary format bumps, etc.

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2017-02-01 17:39:23 -08:00
Mario Alfredo Carrillo Arevalo 504000ec3a Fix swupd options for bundle-list --all unit test
The swupd unit tests need a group of
options for execution environment.

Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
2017-02-01 11:03:43 -08:00
Patrick McCarty bce9fb436f test: remove unused .signed files
These files have never been used by the functional tests, so remove them
from the tree.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-31 12:39:09 -08:00
Patrick McCarty 54d494b0fb test: update swupdlib to not consume .signed files
These files are not used by swupd-client, so do not add them to the MoM
tarball.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-01-31 12:39:09 -08:00
Mario Alfredo Carrillo Arevalo b49fb6419b Update swupd unit test
"bundle-add" sub-command used to validate "list" option in a unit test,
now that option is part of "bundle-list" sub-command with a new
name: [-a, all], for this reason the test has been updated in order to
validate it using "bundle-list" sub-command.

Furthermore this test has been moved to new directory called
"bundlelist/all" this in order to keep source code integrity.

Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
2017-01-31 12:38:29 -08:00
Tudor Marcu a1c0d9995a Update swupd signature verification certificate
The current certificate used to verify the Manifest.MoM signature is also used
to verify various build artifacts, and thus should be split up into multiple,
single function certs. This introduces a new certificate that will be used
exclusively to verify signatures for updates, while the old one will be used
to verify build artifacts like the image.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-01-26 01:19:11 -08:00
Tudor Marcu a4fb9ae027 Add missing certificate attributes conf
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-12-21 12:18:08 -08:00
Tudor Marcu cd48c3f6be Add prereq file to make tests work in parallel
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-12-21 12:14:27 -08:00
Tudor Marcu a565cd0304 Update tests for mandatory signature verification
With mandatory signature verification being enabled, the tests will have
to generate a certificate and sign their Manifest.MoMs to properly run the
swupd operations.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-12-20 16:13:55 -08:00
Patrick McCarty 8a80b3422a test: update ignore list for Ubuntu support
Ubuntu's /bin/sh is Dash, which has different error strings than Bash
for equivalent errors.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-22 15:22:24 -08:00
Icarus Sparry 5d637de5be swupd-client check-update return 1 if none available
make the return code for swupd-client be 1 if there is no update
available. This follows in the tradition of grep, which returns 0 if
there are matches, 1 if there are not, and 2 for errors.

Do the same for swupd-client update --status

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2016-11-15 16:59:06 -08:00
Tudor Marcu 5f5c7dcaf2 Remove more unneeded printfs
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-11-04 16:24:50 -07:00
Tudor Marcu 26658ca8e0 Update tests for new ouput
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2016-11-04 16:24:50 -07:00
Patrick McCarty 2143fbf513 Only grep the output for search tests
It's not clear to me why the 'swupd search' output for the functional
tests is so much different than running it outside that environment, but
regardless, the most interesting output line is what is grepped for.

This output disparity needs further debugging.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-03 09:32:36 -07:00
Patrick McCarty 2b6db84fe3 Check bundle-remove exit status instead of checking output
The bundle-remove subcommand returns a unique error code for invalid
usage, so check that instead. This also avoids the need to track
bundle-remove --help output, or ignore it.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-03 09:32:36 -07:00
Patrick McCarty a55870ed51 Fix several tests with unchecked output lines
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-03 09:32:36 -07:00
Patrick McCarty c2d2e244a9 Support an output line ignore list for tests
There are several output lines that are not very interesting to check
for functional tests, so ignore those lines completely for testing by
adding some specific regular expressions for matching.

This also enables detection of unexpected error messages that may arise
when running the tests.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-03 09:32:30 -07:00
Patrick McCarty 1c23a7bea3 Remove obsolete helper function for tests
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-02 21:04:17 -07:00
Patrick McCarty 0ca1975ed5 Convert all functional tests to the new interface
This commit adds "lines-checked" files for every test that checks
swupd-client output and removes the old bash-array-style checks from
the test scripts.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-02 21:02:46 -07:00
Patrick McCarty 10dcbb5fa9 Add new interface for functional test framework
This commit adds a new helper function for functional tests that enables
a more streamlined mechanism for declaring a fixed set of output lines
to check for and to compare against the swupd-client output.

To use this new interface, lines of output to be checked for a given
test will live in the "lines-checked" file within the test directory,
with the swupd-client output dumped to "lines-output".  Each line of
"lines-checked" is either interpreted as a literal string, or as a
regular expression; regular expression lines are denoted with the
"REGEXP:" prefix, and all other lines are literal strings.

Note that swupd-client may emit more output lines than those checked for
in "lines-checked", and that the checked lines should be declared in
order.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-02 21:01:15 -07:00
Patrick McCarty 9affcd210e Updates for functional tests
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-02 11:41:00 -07:00
Patrick McCarty 2b3af5af08 Update hashdump functional tests
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-09-30 15:18:12 -07:00
William Douglas 285c18c54e Add missing update include test
This is a functional test for the fix implemented in #122.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-09-30 15:05:44 -07:00
Patrick McCarty 5cdad496c0 Fix functional tests for breaking changes
To two latest commits introduce breaking changes to the updater, so the
static server content needs to be refreshed.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-08-15 15:22:34 -07:00
Patrick McCarty 3e0fff6a47 Ignore signature verification errors in functional tests
Because signature verification is a feature that we need separate
testing for, and swupd's output may print a verification error (or not)
depending on how swupd was built, add a helper function to remove the
verification error message when swupd is built with verification
enabled. If verification is not enabled, swupd will not print any
message, and the function is a no-op.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-06-27 11:56:01 -07:00
Patrick McCarty eecd292ae4 Check more output in the 'directory-tree-deleted' test
To make the change in my next commit more uniform, make sure this test
checks for the presence of some of the initial lines printed by swupd.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-06-27 11:54:13 -07:00