mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-03 20:21:29 +00:00
Reorganize bundle add main function to reuse more code and improve performance. Stopped using subscription code from bundles and now using a new function to recurse manifests, gaining around 30% cpu time on manifest processing. Started using staging code from update and preventing checking hashes more than once for some files on bundle-add operations gaining around of 30% CPU time too. Overall executions of this new bundle-add uses 30% less CPU time but because this operation is very IO intensitive this reflects to a gain in around 10% of total time in systems I tested.
49 lines
1.8 KiB
Bash
Executable File
49 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bats
|
|
|
|
# Author: Castulo Martinez
|
|
# Email: castulo.martinez@intel.com
|
|
|
|
load "../testlib"
|
|
|
|
test_setup() {
|
|
|
|
create_test_environment "$TEST_NAME"
|
|
|
|
# pre-create two files in /usr/bin
|
|
sudo mkdir -p "$TARGETDIR"/usr/bin
|
|
write_to_protected_file "$TARGETDIR"/usr/bin/foo "should be replaced"
|
|
write_to_protected_file "$TARGETDIR"/usr/bin/bar "should NOT be replaced"
|
|
|
|
# create a bundle with one of the existing files and install the bundle
|
|
hash=$(sudo "$SWUPD" hashdump --quiet "$TARGETDIR"/usr/bin/bar)
|
|
sudo cp "$TARGETDIR"/usr/bin/bar "$WEBDIR"/10/files/"$hash"
|
|
create_bundle -L -n test-bundle1 -f /usr/bin/bar:"$WEBDIR"/10/files/"$hash" "$TEST_NAME"
|
|
create_tar "$WEBDIR"/10/files/"$hash"
|
|
|
|
# create another bundle that includes two files:
|
|
# - /usr/bin/foo: not tracked but already existing in the target system (should be replaced)
|
|
# - /usr/bin/bar: already tracked by another installed bundle (should not be replaced)
|
|
create_bundle -n test-bundle2 -f /usr/bin/foo,/usr/bin/bar:"$WEBDIR"/10/files/"$hash" "$TEST_NAME"
|
|
|
|
create_bundle -n test-bundle3 -f /file1,/file2,/file3 "$TEST_NAME"
|
|
add_dependency_to_manifest "$WEBDIR"/10/Manifest.test-bundle2 test-bundle3
|
|
|
|
}
|
|
|
|
@test "ADD050: Adding a bundle that overwrites an existing file" {
|
|
|
|
# When swupd is installing a bundle and a file included in the bundle
|
|
# already exists in the target system, it should replace the file if the
|
|
# file is different
|
|
|
|
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle2"
|
|
|
|
assert_status_is "$SWUPD_OK"
|
|
assert_file_exists "$TARGETDIR"/usr/bin/foo
|
|
assert_not_equal "should be replaced" "$(cat "$TARGETDIR"/usr/bin/foo)"
|
|
assert_file_exists "$TARGETDIR"/usr/bin/bar
|
|
assert_equal "should NOT be replaced" "$(cat "$TARGETDIR"/usr/bin/bar)"
|
|
assert_file_exists "$TARGETDIR"/file1
|
|
|
|
}
|