Add functional tests for ghosted renames and deletes

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This commit is contained in:
Matthew Johnson
2017-10-16 14:16:31 -07:00
parent 44cdf0c44c
commit 5aeee1bf86
60 changed files with 1081 additions and 1 deletions
+6 -1
View File
@@ -185,7 +185,9 @@ BATS = \
test/functional/update/include-old-bundle-with-tracked-file/test.bats \
test/functional/update/missing-os-core/test.bats \
test/functional/update/newest-deleted/test.bats \
test/functional/update/newest-ghosted/test.bats \
test/functional/update/rename/test.bats \
test/functional/update/rename-ghosted/test.bats \
test/functional/update/skip-verified-fullfiles/test.bats \
test/functional/update/status/test.bats \
test/functional/update/status-no-server-content/test.bats \
@@ -215,7 +217,10 @@ BATS = \
test/functional/verify/format-mismatch-override/test.bats \
test/functional/verify/install-directory/test.bats \
test/functional/verify/install-latest-directory/test.bats \
test/functional/verify/latest-missing/test.bats
test/functional/verify/latest-missing/test.bats \
test/functional/verify/ghosted/test.bats \
test/functional/verify/picky-ghosted/test.bats \
test/functional/verify/picky-ghosted-missing/test.bats
dist_check_SCRIPTS = $(BATS)
# Must be run before all other tests
@@ -0,0 +1,17 @@
Update started.
Attempting to download version string to memory
Preparing to update from 20 to 30
Extracting os-core pack for version 30
Statistics for going from version 20 to version 30:
changed bundles : 2
new bundles : 0
deleted bundles : 0
changed files : 1
new files : 0
deleted files : 1
Starting download of remaining update content. This may take a while...
Finishing download of update content...
Staging file content
Applying update
Update was applied.
Update successful. System updated from version 20 to version 30
@@ -0,0 +1 @@
should be deleted
@@ -0,0 +1 @@
VERSION_ID=20
+38
View File
@@ -0,0 +1,38 @@
#!/usr/bin/env bats
load "../../swupdlib"
os_release_file=1c1efd10467cbc1dddd8e63c3ef4d9099f36418ed5372d080a1bf0f03a49ab05
setup() {
clean_test_dir
create_manifest_tar 20 MoM
sign_manifest_mom 20
create_manifest_tar 20 os-core
create_manifest_tar 20 test-bundle2
create_manifest_tar 30 MoM
sign_manifest_mom 30
create_manifest_tar 30 os-core
create_manifest_tar 30 test-bundle2
chown_root "$DIR/web-dir/30/staged/$os_release_file"
tar -C "$DIR/web-dir/30" -cf "$DIR/web-dir/30/pack-os-core-from-20.tar" staged/$os_release_file
cp "$DIR/target-dir/testfile" "$DIR"
}
teardown() {
clean_tars 20
clean_tars 30
revert_chown_root "$DIR/web-dir/30/staged/$os_release_file"
sed -i 's/30/20/' "$DIR/target-dir/usr/lib/os-release"
mv "$DIR/testfile" "$DIR/target-dir/"
}
@test "update where the newest version of a file was ghosted" {
run sudo sh -c "$SWUPD update $SWUPD_OPTS"
[ "$status" -eq 0 ]
check_lines "$output"
[ -f "$DIR/target-dir/testfile" ]
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -0,0 +1,9 @@
MANIFEST 3
version: 20
previous: 10
filecount: 2
timestamp: 1451940175
contentsize: 13805671819
M... f7abb1fdb99a70673498212f0bfd7f110757806e7a849563b4c7f886ea6352a0 20 os-core
M... 374556e970f164bd3e72dfdbd55bbabe332fef4e8b88667a67108cba5fcf4093 20 test-bundle2
@@ -0,0 +1,14 @@
MANIFEST 3
version: 20
previous: 10
filecount: 7
timestamp: 1451936779
contentsize: 17929151
D... cde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr
D... dde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/lib
D... cde13514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share
D... cde23514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share/clear
D... cde43514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share/clear/bundles
F... b85f1dc2c2317a20f47a36d3257313b131124ffa6d4f19bb060d43014fd386b0 10 /usr/share/clear/bundles/os-core
F... fde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 20 /usr/lib/os-release
@@ -0,0 +1,9 @@
MANIFEST 3
version: 20
previous: 10
filecount: 2
timestamp: 1451936779
contentsize: 17929151
F... a85f1dc2c2317a20f47a36d3257313b131124ffa6d4f19bb060d43014fd386b0 20 /testfile
F... b85f1dc2c2317a20f47a36d3257313b131124ffa6d4f19bb060d43014fd386b0 20 /usr/share/clear/bundles/test-bundle2
@@ -0,0 +1,9 @@
MANIFEST 3
version: 30
previous: 20
filecount: 2
timestamp: 1451940175
contentsize: 13805671819
M... 1af6a129461858652689ec4aecfef82387bb3fcd340a42e2522ad94106f48cc1 30 os-core
M... 21b4370ae849732b644503ad64048388392dec1f0c4e7bf7287e70657dfab9f0 30 test-bundle2
@@ -0,0 +1,14 @@
MANIFEST 3
version: 30
previous: 20
filecount: 7
timestamp: 1451936779
contentsize: 17929151
D... cde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr
D... dde33514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/lib
D... cde13514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share
D... cde23514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share/clear
D... cde43514c151abb2b01448be290ab1d5212952571d15e3533cadc15ff82f2cd5 10 /usr/share/clear/bundles
F... b85f1dc2c2317a20f47a36d3257313b131124ffa6d4f19bb060d43014fd386b0 10 /usr/share/clear/bundles/os-core
F... 1c1efd10467cbc1dddd8e63c3ef4d9099f36418ed5372d080a1bf0f03a49ab05 30 /usr/lib/os-release
@@ -0,0 +1,9 @@
MANIFEST 3
version: 30
previous: 20
filecount: 2
timestamp: 1451936779
contentsize: 17929151
F... b85f1dc2c2317a20f47a36d3257313b131124ffa6d4f19bb060d43014fd386b0 20 /usr/share/clear/bundles/test-bundle2
.g.. 0000000000000000000000000000000000000000000000000000000000000000 30 /testfile
@@ -0,0 +1,17 @@
Update started.
Attempting to download version string to memory
Preparing to update from 10 to 20
Extracting os-core pack for version 20
Statistics for going from version 10 to version 20:
changed bundles : 1
new bundles : 0
deleted bundles : 0
changed files : 1
new files : 2
deleted files : 2
Starting download of remaining update content. This may take a while...
Finishing download of update content...
Staging file content
Applying update
Update was applied.
Update successful. System updated from version 10 to version 20
@@ -0,0 +1,100 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
@@ -0,0 +1,99 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 20
@@ -0,0 +1,99 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 10
@@ -0,0 +1,100 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
@@ -0,0 +1 @@
VERSION_ID=20
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bats
load "../../swupdlib"
setup() {
clean_state_dir
clean_target_dir
create_manifest_tar 10 MoM
sign_manifest_mom 10
create_manifest_tar 10 os-core
create_manifest_tar 20 MoM
sign_manifest_mom 20
create_manifest_tar 20 os-core
set_os_release 10
chown_root -R "$DIR/target-dir" "$DIR/web-dir"
unpack_target_from_manifest 10 MoM
unpack_target_from_manifest 10 os-core
sudo tar -C "$DIR/web-dir/20" -cf "$DIR/web-dir/20/pack-os-core-from-10.tar" delta/ staged/
}
teardown() {
revert_chown_root -R "$DIR/web-dir"
}
@test "update rename ghosted file" {
run sudo sh -c "$SWUPD update $SWUPD_OPTS"
[ $status -eq 0 ]
check_lines "$output"
# all the files should still exist, including the ghosted ones
[ -e "$DIR/target-dir/bar" ]
[ -e "$DIR/target-dir/foo" ]
[ -e "$DIR/target-dir/bat" ]
[ -e "$DIR/target-dir/baz" ]
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -0,0 +1,8 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1505693993
contentsize: 5722
M... d904b539bd1b18baf1309146e780f952851052203c1fef338b860ec0a47ac614 10 os-core
@@ -0,0 +1,17 @@
MANIFEST 3
version: 10
previous: 0
filecount: 9
timestamp: 1505693993
contentsize: 5722
status: ACTIVE
F... fdfec2695a18d214f80ef9fa6edde7b9fd64312b6be61f73429c39389e1d1334 10 /baz
F... 0c00735e7bf78ac9063de74a9c6712052cdebd05ae5d4a4b76a22c8395d6aa50 10 /foo
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/lib
F... e6b5b316f2b470fc5d7a22caf4e7f6c8384a26ac8aacd80ccde5a6bd3838e87f 10 /usr/lib/os-release
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/share
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/share/clear
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/share/clear/bundles
F... 28cb7c6cad23920f344157f48ae353caca34e9a2f5cff934a4fdaaf7509f2062 10 /usr/share/clear/bundles/os-core
@@ -0,0 +1,100 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
@@ -0,0 +1,99 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101 10
@@ -0,0 +1,8 @@
MANIFEST 3
version: 20
previous: 10
filecount: 1
timestamp: 1505693993
contentsize: 602
M... cde1ce5ec0e036b3a2d11a8c7f5a38286d3583ba8fd5e0c533307bd57cfa8e63 20 os-core
@@ -0,0 +1,19 @@
MANIFEST 3
version: 20
previous: 10
filecount: 11
timestamp: 1505693993
contentsize: 602
status: ACTIVE
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/lib
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/share
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/share/clear
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/share/clear/bundles
F... 28cb7c6cad23920f344157f48ae353caca34e9a2f5cff934a4fdaaf7509f2062 10 /usr/share/clear/bundles/os-core
F..r 0c00735e7bf78ac9063de74a9c6712052cdebd05ae5d4a4b76a22c8395d6aa50 20 /bar
F..r c21cc55db744a24867470b7343bdc6bde1c19e4b5a782fd82c84a86b55de6d54 20 /bat
.g.r c21cc55db744a24867470b7343bdc6bde1c19e4b5a782fd82c84a86b55de6d54 20 /baz
.g.r 0c00735e7bf78ac9063de74a9c6712052cdebd05ae5d4a4b76a22c8395d6aa50 20 /foo
F... 43fff5857537e90559eebe9acce089110b12e62f52b057d57ccdd310f612779a 20 /usr/lib/os-release
@@ -0,0 +1,9 @@
Verifying version 10
Starting download of remaining update content. This may take a while...
Finishing download of update content...
Adding any missing files
Fixing modified files
Inspected 0 files
0 files were missing
0 files found which should be deleted
Fix successful
@@ -0,0 +1,5 @@
.-.
(o o) boo!
| O \
\ \
`~~~'
@@ -0,0 +1,5 @@
.-.
(o o) boo!
| O \
\ \
`~~~'
@@ -0,0 +1,9 @@
NAME="Clear Linux Software for Intel Architecture"
VERSION=1
ID=clear-linux-os
VERSION_ID=10
PRETTY_NAME="Clear Linux Software for Intel Architecture"
ANSI_COLOR="1;35"
HOME_URL="https://clearlinux.org"
SUPPORT_URL="https://clearlinux.org"
BUG_REPORT_URL="https://bugs.clearlinux.org/jira"
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bats
load "../../swupdlib"
setup() {
clean_test_dir
create_manifest_tar 10 MoM
sign_manifest_mom 10
create_manifest_tar 10 os-core
chown_root -R "$DIR/target-dir"
}
teardown() {
clean_tars 10
clean_tars 10 files
sudo cp -r "$DIR/target-dir.bak/foo" "$DIR/target-dir"
}
@test "verify ghosted file skipped" {
run sudo sh -c "$SWUPD verify --fix $SWUPD_OPTS"
[ $status -eq 0 ]
check_lines "$output"
# this should exist at the end, despite being marked as "ghosted" in the
# Manifest and treated as deleted for parts of swupd-client.
[ -f "$DIR/target-dir/foo" ]
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -0,0 +1,8 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 907d96973c42eac1e5f81fad740561ac86ade5e9d342ec05274cbc15f9730760 10 os-core
@@ -0,0 +1,8 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1451936779
contentsize: 17929151
.g.. 17a3a547dc2ccfd56bf13f9ed90d086d0d5967127086f223a4a514c7c468ed19 10 /foo
@@ -0,0 +1,10 @@
Verifying version 10
Starting download of remaining update content. This may take a while...
Finishing download of update content...
Adding any missing files
Fixing modified files
REGEXP:--picky removing extra files under .*
Inspected 3 files
0 files were missing
0 files found which should be deleted
Fix successful
@@ -0,0 +1,9 @@
NAME="Clear Linux Software for Intel Architecture"
VERSION=1
ID=clear-linux-os
VERSION_ID=10
PRETTY_NAME="Clear Linux Software for Intel Architecture"
ANSI_COLOR="1;35"
HOME_URL="https://clearlinux.org"
SUPPORT_URL="https://clearlinux.org"
BUG_REPORT_URL="https://bugs.clearlinux.org/jira"
@@ -0,0 +1,9 @@
NAME="Clear Linux Software for Intel Architecture"
VERSION=1
ID=clear-linux-os
VERSION_ID=10
PRETTY_NAME="Clear Linux Software for Intel Architecture"
ANSI_COLOR="1;35"
HOME_URL="https://clearlinux.org"
SUPPORT_URL="https://clearlinux.org"
BUG_REPORT_URL="https://bugs.clearlinux.org/jira"
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bats
load "../../swupdlib"
setup() {
clean_test_dir
create_manifest_tar 10 MoM
sign_manifest_mom 10
create_manifest_tar 10 os-core
chown_root -R "$DIR/target-dir"
}
teardown() {
clean_tars 10
sudo cp -r "$DIR/target-dir.bak/usr" "$DIR/target-dir/"
}
@test "verify ghosted file not added during --picky" {
run sudo sh -c "$SWUPD verify --fix --picky $SWUPD_OPTS"
[ $status -eq 0 ]
check_lines "$output"
# this should not exist at the end, despite being marked in the Manifest as
# "ghosted". In this case ghosted files should be ignored.
[ ! -f "$DIR/target-dir/usr/foo" ]
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -0,0 +1,8 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 3adc3fb46d04589a96cbd0e6ea2f4a7aef7566daec64778b12865bd67aa160b0 10 os-core
@@ -0,0 +1,11 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1451936779
contentsize: 17929151
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr
.g.. 17a3a547dc2ccfd56bf13f9ed90d086d0d5967127086f223a4a514c7c468ed19 10 /usr/foo
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/lib
F... 8b77bb0234b3e202a8e27bc1b4d20c9ca48582519717c8379fb58078feaa5f7a 10 /usr/lib/os-release
@@ -0,0 +1,10 @@
Verifying version 10
Starting download of remaining update content. This may take a while...
Finishing download of update content...
Adding any missing files
Fixing modified files
REGEXP:--picky removing extra files under .*
Inspected 4 files
0 files were missing
0 files found which should be deleted
Fix successful
@@ -0,0 +1,5 @@
.-.
(o o) boo!
| O \
\ \
`~~~'
@@ -0,0 +1,9 @@
NAME="Clear Linux Software for Intel Architecture"
VERSION=1
ID=clear-linux-os
VERSION_ID=10
PRETTY_NAME="Clear Linux Software for Intel Architecture"
ANSI_COLOR="1;35"
HOME_URL="https://clearlinux.org"
SUPPORT_URL="https://clearlinux.org"
BUG_REPORT_URL="https://bugs.clearlinux.org/jira"
@@ -0,0 +1,5 @@
.-.
(o o) boo!
| O \
\ \
`~~~'
@@ -0,0 +1,9 @@
NAME="Clear Linux Software for Intel Architecture"
VERSION=1
ID=clear-linux-os
VERSION_ID=10
PRETTY_NAME="Clear Linux Software for Intel Architecture"
ANSI_COLOR="1;35"
HOME_URL="https://clearlinux.org"
SUPPORT_URL="https://clearlinux.org"
BUG_REPORT_URL="https://bugs.clearlinux.org/jira"
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bats
load "../../swupdlib"
setup() {
clean_test_dir
create_manifest_tar 10 MoM
sign_manifest_mom 10
create_manifest_tar 10 os-core
chown_root -R "$DIR/target-dir"
}
teardown() {
clean_tars 10
sudo cp -r "$DIR/target-dir.bak/usr" "$DIR/target-dir/"
revert_chown_root -R "$DIR/target-dir"
}
@test "verify ghosted file skipped during --picky" {
run sudo sh -c "$SWUPD verify --fix --picky $SWUPD_OPTS"
[ $status -eq 0 ]
check_lines "$output"
# this should exist at the end, despite being marked as "ghosted" in the
# Manifest. With the ghosted file existing under /usr this test is to make
# sure the ghosted files aren't removed during the --picky flow.
[ -f "$DIR/target-dir/usr/foo" ]
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -0,0 +1,8 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 5d2f97d49149d49a24091a24858f5609bfa9d6a7c8306a071d46970b4960b7cb 10 os-core
@@ -0,0 +1,11 @@
MANIFEST 3
version: 10
previous: 0
filecount: 1
timestamp: 1451936779
contentsize: 17929151
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 0 /usr
.g.. 17a3a547dc2ccfd56bf13f9ed90d086d0d5967127086f223a4a514c7c468ed19 10 /usr/foo
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 0 /usr/lib
F... 8b77bb0234b3e202a8e27bc1b4d20c9ca48582519717c8379fb58078feaa5f7a 0 /usr/lib/os-release