12 Commits
Author SHA1 Message Date
Castulo Martinez 56d3102ed9 Adds capability of using an ignore list in tests
The test library includes many assertions intended to validate
a command's output. These assertions take the command output and
compare it against an expected output. Some of these assertions
take a literal string and others take a string with regular
expression values. However, regardless of what king of string is
being used for the expected output, there are some common lines
in the output that are usually not important and are safe to ignore.
An example would be empty lines or lines with only dots.

This commit adds the capability for those assertions to use an
ignore file to include patterns that could be ignored/removed from
the command's output before comparing it against the expected
output. Also with this commit empty lines and lines with only dots
will be ignored by default. If the assertion needs to validate an
exact output without ignoring anything in the ignore-list nor ignoring
dots and blank lines, then the --identical option can be used with
the assertion.
2018-08-07 12:47:51 -07:00
Castulo Martinez 2fcca957da Adding new assertions to the test library
This commit include two parts.

1) It adds 6 new assertions to the test library:
- assert_is_output
- assert_is_not_output
- assert_regex_is_output
- assert_regex_is_not_output
- assert_regex_in_output
- assert_regex_not_in_output

2) It migrates the tests from the following categories to use the
new library:
- completion
- hashdump
- mirror
- search

Finally this commit changes a few test cases so they use
"assert_is_output" instead of "assert_in_output", that way
we can have a tighter control of the output we want since
assert_is_output requires the whole output to match to a
specific text instead of doing a partial match.
2018-08-07 12:47:51 -07:00
Otavio Pontes 3d8c0a727d testlib: Print the output differences using diff -u
Diff -u is used in previous test library and it has an easier to read output.
2018-07-26 08:39:24 -07:00
Castulo Martinez 611c3011c2 Add remove and install bundle functions to testlib
This commit adds the following three funtions to the test library:
- install_bundle
- remove_bundle
- clean_state_dir

These functions are useful specially when the global_setup and the
global_teardown are used instead of test_setup and test_teardown.

These functions allow the user to create all of its test resources
in the global_setup and reuse those same resources throughout all
the tests in the test script. By using the global_setup and
global_teardown functions the test execution time can be greatelly
reduced.

This commit also modifies the add-rc.bats and remove-rc.bats to
leverage the global setup and teardowns to increase the execution
speed. These times were reduced as shown:
 - bundleadd_v2/add-rc.bats from 1m50.129s -> 0m20.026s
 - bundleremove_v2/remove-rc.bats from 0m59.079s -> 0m15.446s
2018-07-25 10:52:37 -07:00
Castulo Martinez ca3a68f634 Rewriting bundle-remove and check-update tests
A new test library.bash was introduced that simplifies the creation
of test environments and test objects.

This commit rewrites all existing tests from
test/functional/bundleremove and test/functional/checkupdate but this
time using the new test library.

NOTE: Once all the tests have been rewriten to use the new lib, they
can be included in the Makefile so they are run with every patch,
and the old tests can be deleted.
2018-07-25 10:52:37 -07:00
Castulo Martinez 6496182f96 Rewriting bundle-list tests with the new testlib
A new test library.bash was introduced that simplifies the creation
of test environments and test objects.

This commit rewrites all existing tests from test/functional/bundlelist
but this time using the new test library. Once all the tests have been
rewriten to use the new lib, they can be included in the Makefile so
they are run with every patch, and the  old tests can be deleted.
2018-07-25 10:52:37 -07:00
Castulo Martinez 5d788d136d Adding the last missing tests from bundleadd
This commit adds the last rewritten tests for bundle-add, these
tests are the equivalent to the ones in the bundleadd directory
but using the new test library.
2018-07-25 10:52:37 -07:00
Castulo Martinez f5aceccab3 Including documentation for the test library
This commit adds some documentation explaining how to use the test
library to create new tests and how to run them.
2018-07-25 10:52:37 -07:00
Castulo Martinez 9aecbf4715 Adding assertions to the test library
This commit adds some assertions that can be used to validate
common things in a consistent manner among tests.

The assertions added with this commit are the following:
 - assert_status_is
 - assert_status_is_not
 - assert_dir_exists
 - assert_dir_not_exists
 - assert_file_exists
 - assert_file_not_exists
 - assert_in_output
 - assert_not_in_output

More assertions may be added as needed while migrating the rest of
the tests to use the new testlib.
2018-07-25 10:52:37 -07:00
Castulo Martinez bae14b5cc7 Add functions to test lib and migrates more tests
Functions added to the testlib with this commit:
- remove_from_manifest
- get_hash_from_manifest
- remove_from_manifest
2018-07-25 10:52:37 -07:00
Castulo Martinez f515090f6a Adding function to create empty test to testlib
There is some stuff that is common for every test file, so this
commit adds a function that generates a new test file based on a
template to facilitate test creation.
2018-07-25 10:52:37 -07:00
Castulo Martinez 8e69505ceb Add new test library testlib
The old way of creating new tests require a lot of manual steps to
create the test resources needed to run the tests. This commit is
part of a series of commits to improve the workflow for creation of
new tests.

This commit introduces a new test library that aims to replace the
old swupdlib.bash library which provides many funtions to create
new test resources easily.

The following functions were added in this commit:
- generate_random_content
- generate_random_name
- validate_path
- validate_item
- validate_param
- create_dir
- create_file
- create_link
- create_tar
- create_manifest
- add_to_manifest
- create_test_environment
- destroy_test_environment
- create_bundle
- set_env_variables
- sign_manifest

The tests in bundleadd_v2 would eventually replace those in bundleadd

Related to issue #258
2018-07-25 10:52:37 -07:00