Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 5e60594

Browse files
William Douglasbryteise
authored andcommitted
Add new orphan tests for bundle deletes
When a bundle is removed, ensure the new orphans created are detected by bundle-list and bundle-remove. Signed-off-by: William Douglas <william.douglas@intel.com>
1 parent 48cdc5e commit 5e60594

File tree

2 files changed

+101
-0
lines changed

2 files changed

+101
-0
lines changed

test/functional/bundlelist/list-orphans.bats

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ setup_file() {
1616
create_bundle -L -n test-bundle6 -f /file6 "$TEST_NAME"
1717
add_dependency_to_manifest "$WEB_DIR"/10/Manifest.test-bundle3 test-bundle4
1818

19+
create_version -r "$TEST_NAME" 20 10
20+
remove_from_manifest "$WEB_DIR"/20/Manifest.MoM test-bundle3
21+
1922
}
2023

2124
teardown_file() {
@@ -63,3 +66,49 @@ teardown_file() {
6366
assert_is_output "$expected_output"
6467

6568
}
69+
70+
@test "LST030: Update deleting a bundle shows new orphans" {
71+
72+
run sudo sh -c "$SWUPD update $SWUPD_OPTS"
73+
assert_status_is 0
74+
expected_output=$(cat <<-EOM
75+
Update started
76+
Preparing to update from 10 to 20
77+
Downloading packs for:
78+
- os-core
79+
Finishing packs extraction...
80+
Statistics for going from version 10 to version 20:
81+
changed bundles : 1
82+
new bundles : 0
83+
deleted bundles : 1
84+
changed files : 0
85+
new files : 7
86+
deleted files : 2
87+
Validate downloaded files
88+
No extra files need to be downloaded
89+
Installing files...
90+
Update was applied
91+
Calling post-update helper scripts
92+
Update successful - System updated from version 10 to version 20
93+
EOM
94+
)
95+
assert_is_output "$expected_output"
96+
# bundle should not exist
97+
assert_file_not_exists "$TARGET_DIR"/file_3
98+
assert_file_not_exists "$TARGET_DIR"/usr/share/clear/bundles/test-bundle3
99+
100+
run sudo sh -c "$SWUPD bundle-list $SWUPD_OPTS --orphans"
101+
assert_status_is "$SWUPD_OK"
102+
expected_output=$(cat <<-EOM
103+
Loading required manifests...
104+
Orphan bundles:
105+
- test-bundle4
106+
- test-bundle5
107+
- test-bundle6
108+
Total: 3
109+
Use "swupd bundle-add BUNDLE" to no longer list BUNDLE and its dependencies as orphaned
110+
EOM
111+
)
112+
assert_is_output "$expected_output"
113+
114+
}

test/functional/bundleremove/remove-orphans.bats

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ test_setup() {
1313
create_bundle -L -n test-bundle3 -f /file3 "$TEST_NAME"
1414
create_bundle -L -n test-bundle4 -f /file4 "$TEST_NAME"
1515
create_bundle -L -n test-bundle5 -f /file5 "$TEST_NAME"
16+
sudo touch "$state_path"/bundles/os-core
1617
add_dependency_to_manifest "$WEB_DIR"/10/Manifest.test-bundle1 test-bundle2
1718
add_dependency_to_manifest "$WEB_DIR"/10/Manifest.test-bundle4 test-bundle5
1819

20+
create_version -r "$TEST_NAME" 20 10
21+
remove_from_manifest "$WEB_DIR"/20/Manifest.MoM test-bundle1
22+
1923
}
2024

2125
@test "REM030: Remove orphan bundles" {
@@ -56,3 +60,51 @@ test_setup() {
5660
assert_in_output "$expected_output"
5761

5862
}
63+
64+
@test "REM033: Update deleting bundle adds new orphans that are removed" {
65+
66+
run sudo sh -c "$SWUPD update $SWUPD_OPTS"
67+
assert_status_is 0
68+
expected_output=$(cat <<-EOM
69+
Update started
70+
Preparing to update from 10 to 20
71+
Downloading packs for:
72+
- os-core
73+
Finishing packs extraction...
74+
Statistics for going from version 10 to version 20:
75+
changed bundles : 1
76+
new bundles : 0
77+
deleted bundles : 1
78+
changed files : 0
79+
new files : 7
80+
deleted files : 2
81+
Validate downloaded files
82+
No extra files need to be downloaded
83+
Installing files...
84+
Update was applied
85+
Calling post-update helper scripts
86+
Update successful - System updated from version 10 to version 20
87+
EOM
88+
)
89+
assert_is_output "$expected_output"
90+
# bundle should not exist
91+
assert_file_not_exists "$TARGET_DIR"/file_1
92+
assert_file_not_exists "$TARGET_DIR"/usr/share/clear/bundles/test-bundle1
93+
94+
run sudo sh -c "$SWUPD bundle-remove $SWUPD_OPTS --orphans"
95+
96+
assert_status_is "$SWUPD_OK"
97+
expected_output=$(cat <<-EOM
98+
The following bundles are being removed:
99+
- test-bundle5
100+
- test-bundle4
101+
- test-bundle3
102+
- test-bundle2
103+
Deleting bundle files...
104+
Total deleted files: 8
105+
Successfully removed 4 bundles
106+
EOM
107+
)
108+
assert_is_output "$expected_output"
109+
110+
}

0 commit comments

Comments
 (0)