Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 6d3121c

Browse files
committed
Add test cases for orphaned renames
* test that renames from old manifests persist * test that renamed-to deleted is handled properly with the renamed-from becoming deleted. Signed-off-by: Matthew Johnson <[email protected]>
1 parent 6190894 commit 6d3121c

1 file changed

Lines changed: 44 additions & 10 deletions

File tree

test/functional/orphaned-renames/test.bats

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,25 @@ setup() {
2626
track_bundle 30 os-core
2727
track_bundle 30 test-bundle
2828

29+
set_os_release 40 os-core
30+
set_os_release 40 test-bundle
31+
track_bundle 40 os-core
32+
track_bundle 40 test-bundle
33+
34+
# /usr/lib/bar and /one will be renamed to /usr/lib/baz and /two
2935
gen_file_plain_with_content 10 test-bundle /usr/lib/bar "$(seq 100)"
36+
gen_file_plain_with_content 10 test-bundle /one "$(printf 'a%.0s' {1..200})"
37+
3038
gen_file_plain_with_content 20 test-bundle /usr/lib/baz "$(seq 100)"
39+
gen_file_plain_with_content 20 test-bundle /two "$(printf 'a%.0s' {1..200})"
40+
3141
# different content just to make sure this works with delta renames as well as
3242
# direct renames
3343
gen_file_plain_with_content 30 test-bundle /usr/lib/foo "$(seq 100) new"
44+
45+
gen_file_plain_with_content 40 test-bundle /usr/lib/foo "$(seq 100) new"
46+
# new file to force manifest generation
47+
gen_file_plain_with_content 40 test-bundle /a "testfile"
3448
}
3549

3650
@test "create updates with renamed-to file getting deleted" {
@@ -46,16 +60,36 @@ setup() {
4660

4761
sudo $CREATE_UPDATE --osversion 30 --statedir $DIR --format 3
4862
sudo $MAKE_FULLFILES --statedir $DIR 30
49-
# version 10: add file to 10
50-
[ 1 -eq $(grep 'F\.\.\. .* 10 /usr/lib/bar' $DIR/www/10/Manifest.test-bundle | wc -l) ]
51-
# version 20: rename bar to baz
52-
[ 1 -eq $(grep '\.d\.r .* 20 /usr/lib/bar' $DIR/www/20/Manifest.test-bundle | wc -l) ]
53-
[ 1 -eq $(grep 'F\.\.r .* 20 /usr/lib/baz' $DIR/www/20/Manifest.test-bundle | wc -l) ]
54-
# version 30: prune original renamed-from file (bar), baz is now a renamed-from file
55-
# Check for the new renamed-to file (foo)
56-
[ 0 -eq $(grep '/usr/lib/bar' $DIR/www/30/Manifest.test-bundle | wc -l) ]
57-
[ 1 -eq $(grep '\.d\.r .* 30 /usr/lib/baz' $DIR/www/30/Manifest.test-bundle | wc -l) ]
58-
[ 1 -eq $(grep 'F\.\.r .* 30 /usr/lib/foo' $DIR/www/30/Manifest.test-bundle | wc -l) ]
63+
64+
set_latest_ver 30
65+
66+
sudo $CREATE_UPDATE --osversion 40 --statedir $DIR --format 3
67+
sudo $MAKE_FULLFILES --statedir $DIR 40
68+
# version 10: add files to 10
69+
[ 1 -eq $(grep $'F\.\.\.\t.*\t10\t/usr/lib/bar' $DIR/www/10/Manifest.test-bundle | wc -l) ]
70+
[ 1 -eq $(grep $'F\.\.\.\t.*\t10\t/one' $DIR/www/10/Manifest.test-bundle | wc -l) ]
71+
# version 20: rename bar to baz and one to two
72+
[ 1 -eq $(grep $'\.d\.r\t.*\t20\t/one' $DIR/www/20/Manifest.test-bundle | wc -l) ]
73+
[ 1 -eq $(grep $'F\.\.r\t.*\t20\t/two' $DIR/www/20/Manifest.test-bundle | wc -l) ]
74+
[ 1 -eq $(grep $'\.d\.r\t.*\t20\t/usr/lib/bar' $DIR/www/20/Manifest.test-bundle | wc -l) ]
75+
[ 1 -eq $(grep $'F\.\.r\t.*\t20\t/usr/lib/baz' $DIR/www/20/Manifest.test-bundle | wc -l) ]
76+
# version 30: original renamed-from file (bar) is now orphaned and therefore
77+
# deleted, baz is now a renamed-from file and foo is a renamed-to file.
78+
# /two was deleted in this version, so both /one and /two should be marked as
79+
# deleted
80+
[ 1 -eq $(grep $'\.d\.\.\t0\{64\}\t20\t/one' $DIR/www/30/Manifest.test-bundle | wc -l) ]
81+
[ 1 -eq $(grep $'\.d\.\.\t0\{64\}\t30\t/two' $DIR/www/30/Manifest.test-bundle | wc -l) ]
82+
[ 1 -eq $(grep $'\.d\.\.\t0\{64\}\t20\t/usr/lib/bar' $DIR/www/30/Manifest.test-bundle | wc -l) ]
83+
[ 1 -eq $(grep $'\.d\.r\t.*\t30\t/usr/lib/baz' $DIR/www/30/Manifest.test-bundle | wc -l) ]
84+
[ 1 -eq $(grep $'F\.\.r\t.*\t30\t/usr/lib/foo' $DIR/www/30/Manifest.test-bundle | wc -l) ]
85+
86+
# version 40: the existing rename from baz -> foo must persist while all
87+
# others remain deleted
88+
[ 1 -eq $(grep $'\.d\.\.\t0\{64\}\t20\t/one' $DIR/www/40/Manifest.test-bundle | wc -l) ]
89+
[ 1 -eq $(grep $'\.d\.\.\t0\{64\}\t30\t/two' $DIR/www/40/Manifest.test-bundle | wc -l) ]
90+
[ 1 -eq $(grep $'\.d\.\.\t0\{64\}\t20\t/usr/lib/bar' $DIR/www/40/Manifest.test-bundle | wc -l) ]
91+
[ 1 -eq $(grep $'\.d\.r\t.*\t30\t/usr/lib/baz' $DIR/www/40/Manifest.test-bundle | wc -l) ]
92+
[ 1 -eq $(grep $'F\.\.r\t.*\t30\t/usr/lib/foo' $DIR/www/40/Manifest.test-bundle | wc -l) ]
5993
}
6094

6195
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80

0 commit comments

Comments
 (0)