932 Commits
Author SHA1 Message Date
Otavio Pontes 76c5ca0bb9 Release v3.18.4
This release fixes some bugs and add tests improvements.

Bug fixes:
 - Fix support for openssl 1.1
 - Bash completion for bundle-remove wasn't complete
 - Print error message when disk is full on a tarball extration

Tests
 - Running static analysis of all bat tests automatically and reported problems
   were fixed.
 - Test Makefile was problematic and some tests were skiped
 - More tests added

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
v3.18.4
2018-11-12 19:39:00 +00:00
Otavio Pontes 63b8ce2623 curl: Don't warn about curl fd leaks
Curl isn't closing urandom and random when using openssl 1.1. As it's something
out of our control and this won't create any resource leak problems, we're not
reporting that anymore.

This fd leak report is triggered when any https download is performed by swupd

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-11-09 15:03:22 -08:00
Tudor Marcu 0f26c78c42 Fix purpose in store verification
The purpose must be set explicitly now for the verification to
succeed, and in our case we must use "any" as defined in the generated
certificate purpose.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-09 12:52:31 -08:00
Tudor Marcu 131252f1f3 Update signature verification for OpenSSL 1.1
The ERR_remove_thread_state() function is deprecated as the thread
handling and many memory management operatoins have been re-written to
be internally handled by the API. The error code should be retrieved
by the proper function now from X509 store contexts.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-09 12:52:31 -08:00
Brian J Lovin ffead6e434 archives: Add output for out of space errors
Libarchive's archive_error_string() method returns a textual
error message suitable for display.
However, this method returns only "Write Failed" if libarchive
runs out of hard disk space.

Check specifically for ENOSPC and print a correct
warning message to the user.

Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com>
2018-11-07 13:41:08 -08:00
Castulo Martinez fce640d14d Adding a missing line break in the verify command
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>
2018-11-05 10:15:59 -08:00
Castulo Martinez 765664a5e6 Fixing a bug in the test list in Makefile
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>
2018-11-05 09:11:59 -08:00
Castulo Martinez 1438148bbd Adding functions to get test IDs in testlib
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>
2018-11-02 15:25:09 -07:00
Otavio Pontes 40942956c9 configure: Remove trailing ]
Configure was printing the error:

14:13:44 ./configure: line 14047: ]: command not found

It was harmless though.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-11-02 10:07:40 -07:00
Otavio Pontes f178aa6e99 test: Check if swupd is able to perform updates in last releases
Tests added:
 - Check if bundle-list --all is working (because this affect the next tests)
 - Check if we can install an old version of clear and update interactively
   until last release
 - Check if we can install and old version and update to the most recent one

As this test takes a really long time to run, I'm not adding it to the
tests list to be executed to make check, but this can be used to validate
swupd before a release.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-11-01 10:00:59 -07:00
Otavio Pontes f03eb96996 gitignore: We aren't generating any swupd_ files, so we don't need to ignore them
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-11-01 10:00:59 -07:00
Otavio Pontes 516f8e9c34 travis: automatically run shellcheck in shellscripts
Use shellcheck to automatically verify for shell script errors

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-31 09:51:42 -07:00
Otavio Pontes 3b37d0192e test: Fix errors reported by shellcheck
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>
2018-10-31 09:51:42 -07:00
Otavio Pontes c1c7a8b4ce bash_completion: Show os-core-dev and other bundles with os-core prefix
In order to prevent bundle-remove to list the bundle os-core we were removing
all bundles with os-core in the name. Prevent this by just filtering bundles
named os-core. Also uses find instead of ls|grep because it's more robust.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-31 09:51:42 -07:00
Castulo Martinez 4633cba133 Improvements for DEBUG_TEST in test library
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>
2018-10-30 15:00:22 -07:00
Otavio Pontes c0aa200f3b Release v3.18.3
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>
v3.18.3
2018-10-30 20:35:50 +00:00
Otavio Pontes d8d163ae85 time: record time of scripts execution on verify and bundle-add
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>
2018-10-30 12:12:26 -07:00
Otavio Pontes fbf8f38beb times: Print total time of command execution when -t is supported
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
2018-10-30 10:48:21 -07:00
Otavio Pontes 0b747de48c time: move time list code to its own file
Just moving code, no significative changes

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-30 10:48:21 -07:00
Otavio Pontes 0b131aba90 globals: Remove unused variable
start_time wasn't used anywhere in the code.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-30 10:48:21 -07:00
Otavio Pontes 357621c548 time: grabtime_stop() has a behavior different from the expected
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(&times, "1");
      grabtime_start(&times, "2");
      grabtime_start(&times, "3");
      grabtime_start(&times, "4");
      grabtime_start(&times, "5");
      sleep(1);
      grabtime_stop(&times);
      sleep(1);
      grabtime_stop(&times);
      sleep(1);
      grabtime_stop(&times);
      sleep(1);
      grabtime_stop(&times);
      sleep(1);
      grabtime_stop(&times);

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>
2018-10-30 10:48:21 -07:00
Castulo Martinez 9eed3cd4d1 Adding IDs to bundle-add tests
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>
2018-10-30 09:59:56 -07:00
Castulo Martinez 8891b7fa85 Adding info about "Getting help" to testlib readme
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>
2018-10-30 09:57:26 -07:00
Castulo Martinez f6cab5d0a5 Use verify --fix --picky with older versions
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>
2018-10-30 09:49:42 -07:00
Castulo Martinez 34b0a64be6 Include files removed by picky in verify summary
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>
2018-10-30 09:49:42 -07:00
John Akre f101e3bfc4 Safely convert strings to numbers
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>
2018-10-25 13:42:12 -07:00
Otavio Pontes 2131cb919a makefile: Group variables and targets
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>
2018-10-24 14:02:04 -07:00
Castulo Martinez 12f236c906 bundle-add to return 0 if bundle already installed
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>
2018-10-24 13:04:15 -07:00
John Akre 897f5d44c8 test: consolidate test web server implementations
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>
2018-10-24 09:56:02 -07:00
Otavio Pontes 9002f69817 Add systemd unitdir to swupd --version output
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>
2018-10-24 09:54:59 -07:00
Otavio Pontes 641ed48a6a travis: Abort on compilation warnings
In order to be sure we aren't introducing compilation warnings set -Werror flag
in travis build.
2018-10-24 09:46:47 -07:00
Otavio Pontes 60f037fc43 curl: Fix warning reported by gcc in travis-ci
ctx may be uninitialized on swupd_curl_init()
2018-10-24 09:46:47 -07:00
Otavio Pontes 02546caade test: Fix flag name on certificate tests
sed s/fallback-ca-paths/with-fallback-capaths/g

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-22 16:34:48 -07:00
Castulo Martinez 6b7f2a9ac0 Adding the author and testID info to test template
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>
2018-10-22 16:22:49 -07:00
Castulo Martinez 7682f80909 Adding tests for bundle-add --nosigcheck
Adding missing tests for the --nosigcheck option in the
bundle-add command.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-10-22 15:09:17 -07:00
Matthew Johnson 48a016f001 man-pages: add os-format reference
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-10-22 14:11:43 -07:00
Patrick McCarty 69bdacb677 test: add localhost for no_proxy if not present
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>
2018-10-22 14:07:15 -07:00
Castulo Martinez 0f16013855 Fix a bug in some verify tests
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>
2018-10-22 13:06:42 -07:00
Castulo Martinez e315a8c75f Detecting download failures during updates
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>
2018-10-22 13:02:43 -07:00
Castulo Martinez 51b1379163 Show failure message if update is not successful
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>
2018-10-22 13:02:43 -07:00
Castulo Martinez 42b8faed0b Adding return code to load_mom
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>
2018-10-22 13:02:43 -07:00
Otavio Pontes 3287a87e53 Remove 404 from the list of possible swupd return codes
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>
2018-10-18 10:19:29 -07:00
Otavio Pontes e213856f22 test: Test if make install is installing all necessary files
Check if all files expected to be installed in a full installation are
really installed

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-17 16:14:29 -07:00
Castulo Martinez ad8129b481 Adding a menu of functions for testlib
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>
2018-10-17 10:57:29 -07:00
John Akre d80f1425f0 Remove manifest delta support
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>
2018-10-15 13:39:26 -07:00
Otavio Pontes d2ae96af39 Release v3.18.2
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>
v3.18.2
2018-10-13 00:19:11 +00:00
Otavio Pontes 8af7b34af8 autoupdate: Restart service on autoupdate --enable
If service is running but broken it should be restarted on a systemclt start.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-12 23:58:02 +00:00
Otavio Pontes 14e511d2cd Release v3.18.1
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>
v3.18.1
2018-10-12 19:49:03 +00:00
Otavio Pontes 22c7369b2b Revert "Removed unused configuration option"
This reverts commit 74b2d526d7.
2018-10-12 19:42:58 +00:00
Otavio Pontes 642db09aa9 hashdump: Allocate memory on stack and other minor style fixes
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-11 15:59:32 -07:00