mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-10-03 23:38:25 +00:00
3rd-party: Regenerate wrapper on template change
When the template used for creating the wrapper scripts changes, all exported binaries should have the scripts regenerated during updates regardless of if the binary changed. Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
committed by
Castulo J. Martinez
parent
8d6f2f815e
commit
d677c42fce
+221
@@ -0,0 +1,221 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Author: Castulo Martinez
|
||||
# Email: castulo.martinez@intel.com
|
||||
|
||||
load "../testlib"
|
||||
|
||||
test_setup() {
|
||||
|
||||
# create a couple of 3rd-party repos with one installed bundle that has
|
||||
# multiple binaries
|
||||
create_test_environment -r "$TEST_NAME"
|
||||
create_third_party_repo -a "$TEST_NAME" 10 staging repo1
|
||||
create_bundle -L -n test-bundle1 -f /usr/bin/binary_1,/bin/binary_2,/usr/local/bin/binary_3 -u repo1 "$TEST_NAME"
|
||||
create_third_party_repo -a "$TEST_NAME" 10 staging repo2
|
||||
create_bundle -L -n test-bundle2 -f /usr/bin/binary_4,/bin/binary_5,/usr/local/bin/binary_6 -u repo2 "$TEST_NAME"
|
||||
|
||||
# create an update that updates only one of the bundle's binaries
|
||||
create_version -r "$TEST_NAME" 20 10 staging repo1
|
||||
update_bundle "$TEST_NAME" test-bundle1 --update /bin/binary_2 repo1
|
||||
|
||||
# add an update to the current template file
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE" "\nA little update\n"
|
||||
|
||||
# let's add a line to the scripts for all binaries so we can tell if
|
||||
# they were re-generated after the update
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1 "TEST_STRING"
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2 "TEST_STRING"
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3 "TEST_STRING"
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_4 "TEST_STRING"
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_5 "TEST_STRING"
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_6 "TEST_STRING"
|
||||
|
||||
}
|
||||
|
||||
@test "TPR085: Update 3rd-party repositories that have exported binaries when the template has changed" {
|
||||
|
||||
# pre-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_4
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_5
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_6
|
||||
|
||||
# If the template file is different than that in the swupd binary,
|
||||
# all binaries should be re-generated regardless of if they were updated or not,
|
||||
# also the template file should be updated
|
||||
|
||||
run sudo sh -c "$SWUPD 3rd-party update $SWUPD_OPTS"
|
||||
|
||||
assert_status_is "$SWUPD_OK"
|
||||
expected_output=$(cat <<-EOM
|
||||
_______________________
|
||||
3rd-Party Repo: repo1
|
||||
_______________________
|
||||
Updates from a 3rd-party repository are forced to run with the --no-scripts flag for security reasons
|
||||
Update started
|
||||
Preparing to update from 10 to 20
|
||||
Downloading packs for:
|
||||
- os-core
|
||||
- test-bundle1
|
||||
Finishing packs extraction...
|
||||
Statistics for going from version 10 to version 20:
|
||||
changed bundles : 2
|
||||
new bundles : 0
|
||||
deleted bundles : 0
|
||||
changed files : 3
|
||||
new files : 0
|
||||
deleted files : 0
|
||||
Validate downloaded files
|
||||
No extra files need to be downloaded
|
||||
Validating 3rd-party bundle file permissions...
|
||||
Installing files...
|
||||
Update was applied
|
||||
Updating 3rd-party bundle binaries...
|
||||
Warning: post-update helper scripts skipped due to --no-scripts argument
|
||||
Update successful - System updated from version 10 to version 20
|
||||
_______________________
|
||||
3rd-Party Repo: repo2
|
||||
_______________________
|
||||
Updates from a 3rd-party repository are forced to run with the --no-scripts flag for security reasons
|
||||
Update started
|
||||
Version on server (10) is not newer than system version (10)
|
||||
Update complete - System already up-to-date at version 10
|
||||
The scripts that export binaries from 3rd-party repositories need to be regenerated
|
||||
_______________________
|
||||
3rd-Party Repo: repo1
|
||||
_______________________
|
||||
Regenerating scripts...
|
||||
Scripts regenerated successfully
|
||||
_______________________
|
||||
3rd-Party Repo: repo2
|
||||
_______________________
|
||||
Regenerating scripts...
|
||||
Scripts regenerated successfully
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
|
||||
# post-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_4
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_4
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_5
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_5
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_6
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_6
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
# make sure the template file exists in the system and is correct
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE"
|
||||
template_file=$(sudo cat "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE")
|
||||
template=$(echo -e "$SCRIPT_TEMPLATE")
|
||||
assert_equal "$template_file" "$template"
|
||||
|
||||
}
|
||||
|
||||
@test "TPR086: Update 3rd-party repository that has exported binaries when the template has changed using --repo" {
|
||||
|
||||
# pre-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_4
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_5
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_6
|
||||
|
||||
# If the template file is different than that in the swupd binary,
|
||||
# all binaries should be re-generated for all repositories,
|
||||
# regardless of if they were updated or not and regardless of if a
|
||||
# single repo was specified, also the template file should be updated
|
||||
|
||||
run sudo sh -c "$SWUPD 3rd-party update $SWUPD_OPTS --repo repo1"
|
||||
|
||||
assert_status_is "$SWUPD_OK"
|
||||
expected_output=$(cat <<-EOM
|
||||
Updates from a 3rd-party repository are forced to run with the --no-scripts flag for security reasons
|
||||
Update started
|
||||
Preparing to update from 10 to 20
|
||||
Downloading packs for:
|
||||
- os-core
|
||||
- test-bundle1
|
||||
Finishing packs extraction...
|
||||
Statistics for going from version 10 to version 20:
|
||||
changed bundles : 2
|
||||
new bundles : 0
|
||||
deleted bundles : 0
|
||||
changed files : 3
|
||||
new files : 0
|
||||
deleted files : 0
|
||||
Validate downloaded files
|
||||
No extra files need to be downloaded
|
||||
Validating 3rd-party bundle file permissions...
|
||||
Installing files...
|
||||
Update was applied
|
||||
Updating 3rd-party bundle binaries...
|
||||
Warning: post-update helper scripts skipped due to --no-scripts argument
|
||||
Update successful - System updated from version 10 to version 20
|
||||
The scripts that export binaries from 3rd-party repositories need to be regenerated
|
||||
_______________________
|
||||
3rd-Party Repo: repo1
|
||||
_______________________
|
||||
Regenerating scripts...
|
||||
Scripts regenerated successfully
|
||||
_______________________
|
||||
3rd-Party Repo: repo2
|
||||
_______________________
|
||||
Regenerating scripts...
|
||||
Scripts regenerated successfully
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
|
||||
# post-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_4
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_4
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_5
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_5
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_6
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_6
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
# make sure the template file exists in the system and is correct
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE"
|
||||
template_file=$(sudo cat "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE")
|
||||
template=$(echo -e "$SCRIPT_TEMPLATE")
|
||||
assert_equal "$template_file" "$template"
|
||||
|
||||
}
|
||||
+241
@@ -0,0 +1,241 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Author: Castulo Martinez
|
||||
# Email: castulo.martinez@intel.com
|
||||
|
||||
load "../testlib"
|
||||
|
||||
test_setup() {
|
||||
|
||||
# create a 3rd-party repo with one installed bundle that has
|
||||
# multiple binaries
|
||||
create_test_environment -r "$TEST_NAME"
|
||||
create_third_party_repo -a "$TEST_NAME" 10 staging repo1
|
||||
create_bundle -L -n test-bundle1 -f /usr/bin/binary_1,/bin/binary_2,/usr/local/bin/binary_3 -u repo1 "$TEST_NAME"
|
||||
|
||||
# create an update that updates only one of the bundle's binaries
|
||||
create_version -r "$TEST_NAME" 20 10 staging repo1
|
||||
update_bundle "$TEST_NAME" test-bundle1 --update /bin/binary_2 repo1
|
||||
|
||||
# let's add a line to the scripts for all binaries so we can tell if
|
||||
# they were re-generated after the update
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1 "TEST_STRING"
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2 "TEST_STRING"
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3 "TEST_STRING"
|
||||
|
||||
}
|
||||
|
||||
@test "TPR082: Update a 3rd-party bundle that has exported binaries when the template has not changed" {
|
||||
|
||||
# pre-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
|
||||
# If the template file didn't change then only the binary that was
|
||||
# udpated should be re-generated
|
||||
|
||||
run sudo sh -c "$SWUPD 3rd-party update $SWUPD_OPTS"
|
||||
|
||||
assert_status_is "$SWUPD_OK"
|
||||
expected_output=$(cat <<-EOM
|
||||
_______________________
|
||||
3rd-Party Repo: repo1
|
||||
_______________________
|
||||
Updates from a 3rd-party repository are forced to run with the --no-scripts flag for security reasons
|
||||
Update started
|
||||
Preparing to update from 10 to 20
|
||||
Downloading packs for:
|
||||
- os-core
|
||||
- test-bundle1
|
||||
Finishing packs extraction...
|
||||
Statistics for going from version 10 to version 20:
|
||||
changed bundles : 2
|
||||
new bundles : 0
|
||||
deleted bundles : 0
|
||||
changed files : 3
|
||||
new files : 0
|
||||
deleted files : 0
|
||||
Validate downloaded files
|
||||
No extra files need to be downloaded
|
||||
Validating 3rd-party bundle file permissions...
|
||||
Installing files...
|
||||
Update was applied
|
||||
Updating 3rd-party bundle binaries...
|
||||
Warning: post-update helper scripts skipped due to --no-scripts argument
|
||||
Update successful - System updated from version 10 to version 20
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
|
||||
# post-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
assert_in_output "TEST_STRING"
|
||||
|
||||
# make sure the template file exists in the system and is correct
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE"
|
||||
template_file=$(sudo cat "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE")
|
||||
template=$(echo -e "$SCRIPT_TEMPLATE")
|
||||
assert_equal "$template_file" "$template"
|
||||
|
||||
}
|
||||
|
||||
@test "TPR083: Update a 3rd-party bundle that has exported binaries when there is no template" {
|
||||
|
||||
# pre-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
|
||||
# delete the template from the system
|
||||
sudo rm "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE"
|
||||
|
||||
# If the template file is not found all binaries should be re-generated
|
||||
# regardless of if they were updated or not, also the template file
|
||||
# should be created
|
||||
|
||||
run sudo sh -c "$SWUPD 3rd-party update $SWUPD_OPTS"
|
||||
|
||||
assert_status_is "$SWUPD_OK"
|
||||
expected_output=$(cat <<-EOM
|
||||
_______________________
|
||||
3rd-Party Repo: repo1
|
||||
_______________________
|
||||
Updates from a 3rd-party repository are forced to run with the --no-scripts flag for security reasons
|
||||
Update started
|
||||
Preparing to update from 10 to 20
|
||||
Downloading packs for:
|
||||
- os-core
|
||||
- test-bundle1
|
||||
Finishing packs extraction...
|
||||
Statistics for going from version 10 to version 20:
|
||||
changed bundles : 2
|
||||
new bundles : 0
|
||||
deleted bundles : 0
|
||||
changed files : 3
|
||||
new files : 0
|
||||
deleted files : 0
|
||||
Validate downloaded files
|
||||
No extra files need to be downloaded
|
||||
Validating 3rd-party bundle file permissions...
|
||||
Installing files...
|
||||
Update was applied
|
||||
Updating 3rd-party bundle binaries...
|
||||
Warning: post-update helper scripts skipped due to --no-scripts argument
|
||||
Update successful - System updated from version 10 to version 20
|
||||
The scripts that export binaries from 3rd-party repositories need to be regenerated
|
||||
_______________________
|
||||
3rd-Party Repo: repo1
|
||||
_______________________
|
||||
Regenerating scripts...
|
||||
Scripts regenerated successfully
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
|
||||
# post-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
# make sure the template file exists in the system and is correct
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE"
|
||||
template_file=$(sudo cat "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE")
|
||||
template=$(echo -e "$SCRIPT_TEMPLATE")
|
||||
assert_equal "$template_file" "$template"
|
||||
|
||||
}
|
||||
|
||||
@test "TPR084: Update a 3rd-party bundle that has exported binaries when the template has changed" {
|
||||
|
||||
# pre-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
|
||||
# make a change to the template
|
||||
write_to_protected_file -a "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE" "random update"
|
||||
|
||||
# If the template file is different than that in the swupd binary,
|
||||
# all binaries should be re-generated regardless of if they were updated or not,
|
||||
# also the template file should be updated
|
||||
|
||||
run sudo sh -c "$SWUPD 3rd-party update $SWUPD_OPTS"
|
||||
|
||||
assert_status_is "$SWUPD_OK"
|
||||
expected_output=$(cat <<-EOM
|
||||
_______________________
|
||||
3rd-Party Repo: repo1
|
||||
_______________________
|
||||
Updates from a 3rd-party repository are forced to run with the --no-scripts flag for security reasons
|
||||
Update started
|
||||
Preparing to update from 10 to 20
|
||||
Downloading packs for:
|
||||
- os-core
|
||||
- test-bundle1
|
||||
Finishing packs extraction...
|
||||
Statistics for going from version 10 to version 20:
|
||||
changed bundles : 2
|
||||
new bundles : 0
|
||||
deleted bundles : 0
|
||||
changed files : 3
|
||||
new files : 0
|
||||
deleted files : 0
|
||||
Validate downloaded files
|
||||
No extra files need to be downloaded
|
||||
Validating 3rd-party bundle file permissions...
|
||||
Installing files...
|
||||
Update was applied
|
||||
Updating 3rd-party bundle binaries...
|
||||
Warning: post-update helper scripts skipped due to --no-scripts argument
|
||||
Update successful - System updated from version 10 to version 20
|
||||
The scripts that export binaries from 3rd-party repositories need to be regenerated
|
||||
_______________________
|
||||
3rd-Party Repo: repo1
|
||||
_______________________
|
||||
Regenerating scripts...
|
||||
Scripts regenerated successfully
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
|
||||
# post-test checks
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_1
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_2
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/binary_3
|
||||
assert_not_in_output "TEST_STRING"
|
||||
|
||||
run sudo cat "$TARGETDIR"/"$THIRD_PARTY_BIN_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE"
|
||||
assert_not_in_output "random update"
|
||||
|
||||
# make sure the template file exists in the system and is correct
|
||||
assert_file_exists "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE"
|
||||
template_file=$(sudo cat "$TARGETDIR"/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE")
|
||||
template=$(echo -e "$SCRIPT_TEMPLATE")
|
||||
assert_equal "$template_file" "$template"
|
||||
|
||||
}
|
||||
@@ -1565,6 +1565,7 @@ create_third_party_repo() { #swupd_function
|
||||
debug_msg "3rd-party repo URL: $TPURL"
|
||||
|
||||
# if requested, add the new repo to the repo.ini file
|
||||
# and the template file
|
||||
sudo mkdir -p "$env_name"/testfs/target-dir/"$THIRD_PARTY_DIR"
|
||||
if [ "$add" = true ]; then
|
||||
{
|
||||
@@ -1572,6 +1573,7 @@ create_third_party_repo() { #swupd_function
|
||||
printf 'URL=%s\n\n' "file://$TPURL"
|
||||
printf 'VERSION=%s\n\n' "$version"
|
||||
} | sudo tee -a "$env_name"/testfs/target-dir/"$THIRD_PARTY_DIR"/repo.ini > /dev/null
|
||||
write_to_protected_file "$env_name"/testfs/target-dir/"$THIRD_PARTY_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE" "$SCRIPT_TEMPLATE"
|
||||
fi
|
||||
|
||||
# every 3rd-party repo needs to have at least the special os-core bundle,
|
||||
@@ -1590,12 +1592,6 @@ create_third_party_repo() { #swupd_function
|
||||
create_bundle -n os-core -v "$version" -f /usr/lib/os-release:"$OS_RELEASE",/usr/share/clear/update-ca/Swupd_Root.pem:"$cert",/usr/share/defaults/swupd/format:"$FORMAT" -u "$repo_name" "$env_name"
|
||||
fi
|
||||
|
||||
# if requested, add the template file to the target system
|
||||
if [ "$add" = true ]; then
|
||||
sudo mkdir -p "$env_name"/testfs/target-dir/"$THIRD_PARTY_BIN_DIR"
|
||||
write_to_protected_file "$env_name"/testfs/target-dir/"$THIRD_PARTY_BIN_DIR"/"$THIRD_PARTY_SCRIPT_TEMPLATE" "$SCRIPT_TEMPLATE"
|
||||
fi
|
||||
|
||||
if [ "$TEST_ENV_ONLY" = true ]; then
|
||||
print "\nVariables for 3rd-party repo $repo_name:\n"
|
||||
print "TPURL=$TPURL"
|
||||
@@ -4639,6 +4635,10 @@ assert_equal() { # assertion
|
||||
validate_param "$val2"
|
||||
|
||||
if [ "$val1" != "$val2" ]; then
|
||||
echo "Assertion Failed"
|
||||
echo "The two items being compared are not equal"
|
||||
echo -e "Difference:\\n$sep"
|
||||
diff -u <(echo "$val1") <(echo "$val2") || true
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user