Files
Castulo Martinez 7dd6fc221a Testlib: renaming variables for consistency
Environment variables are used everywhere in testilb. This environment
variables are global variables that define the way testlib behaves.
However is was confusing to use the variables because they were
inconsistent between each other, for example some variables that define
paths would have absolute paths while other would have relative paths,
making it error prone while using them.

This commit makes the environment variables more consistent by following
a name convention for each type of variable, as an example, variables
that define absolute paths follow this convention ABS_<path_name>_DIR,
while variables that define relative paths are defined like this
<path_name>_DIR.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-06-16 11:42:13 -07:00

98 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bats
# Author: Castulo Martinez
# Email: castulo.martinez@intel.com
load "../testlib"
test_setup() {
create_test_environment -e "$TEST_NAME" 10
create_bundle -n os-core -f /core "$TEST_NAME"
}
@test "INS001: Basic OS install" {
# os-install will install a basic OS that has only os-core if nothing
# else is specified
run sudo sh -c "$SWUPD os-install $SWUPD_OPTS_NO_PATH $TARGET_DIR"
assert_status_is "$SWUPD_OK"
expected_output=$(cat <<-EOM
Installing OS version 10 (latest)
Downloading missing manifests...
Downloading packs for:
- os-core
Finishing packs extraction...
Checking for corrupt files
Validate downloaded files
No extra files need to be downloaded
Installing base OS and selected bundles
Inspected 2 files
2 files were missing
2 of 2 missing files were installed
0 of 2 missing files were not installed
Calling post-update helper scripts
Installation successful
EOM
)
assert_is_output "$expected_output"
assert_file_exists "$TARGET_DIR"/usr/share/clear/bundles/os-core
assert_file_exists "$TARGET_DIR"/core
}
@test "INS002: An OS install can use --path to specify installation path" {
# os-install will install a basic OS that has only os-core if nothing
# else is specified
run sudo sh -c "$SWUPD os-install $SWUPD_OPTS_NO_PATH --path $TARGET_DIR"
assert_status_is "$SWUPD_OK"
expected_output=$(cat <<-EOM
Installing OS version 10 (latest)
Downloading missing manifests...
Downloading packs for:
- os-core
Finishing packs extraction...
Checking for corrupt files
Validate downloaded files
No extra files need to be downloaded
Installing base OS and selected bundles
Inspected 2 files
2 files were missing
2 of 2 missing files were installed
0 of 2 missing files were not installed
Calling post-update helper scripts
Installation successful
EOM
)
assert_is_output "$expected_output"
assert_file_exists "$TARGET_DIR"/usr/share/clear/bundles/os-core
assert_file_exists "$TARGET_DIR"/core
}
@test "INS003: An OS install cannot use PATH and --path at the same time when installing" {
# the swupd os-install command requires the path for the installation
# to be provided by either using the --path option or simply specifying
# it with no option, but not both
run sudo sh -c "$SWUPD os-install $SWUPD_OPTS_NO_PATH --path $TARGET_DIR $TARGET_DIR"
assert_status_is "$SWUPD_INVALID_OPTION"
expected_output=$(cat <<-EOM
Error: cannot specify a PATH and use the --path option at the same time
EOM
)
assert_in_output "$expected_output"
assert_file_not_exists "$TARGET_DIR"/usr/share/clear/bundles/os-core
assert_file_not_exists "$TARGET_DIR"/core
}
#WEIGHT=4