Add functional tests for verify format mismatch and override

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This commit is contained in:
Patrick McCarty
2017-08-30 11:12:50 -07:00
committed by Matthew Johnson
parent e6cdcf8aa1
commit 485ab31f22
23 changed files with 194 additions and 0 deletions
+2
View File
@@ -194,6 +194,8 @@ dist_check_SCRIPTS = \
test/functional/verify/check-missing-directory/test.bats \
test/functional/verify/directory-tree-deleted/test.bats \
test/functional/verify/empty-dir-deleted/test.bats \
test/functional/verify/format-mismatch/test.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
@@ -0,0 +1,16 @@
Verifying version 20
Attempting to download version string to memory
WARNING: the force option is specified; ignoring format mismatch for verify
Starting download of remaining update content. This may take a while...
File /usr/bin was not in a pack
Finishing download of update content...
Adding any missing files
REGEXP:^Missing file: .+/target-dir/usr/bin$
fixed
Fixing modified files
Inspected 1 files
1 files were missing
1 of 1 missing files were replaced
0 of 1 missing files were not replaced
0 files found which should be deleted
Fix successful
@@ -0,0 +1 @@
VERSION_ID=10
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bats
load "../../swupdlib"
targetfile=6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e
setup() {
clean_test_dir
create_manifest_tar 10 MoM
sign_manifest_mom 10
create_manifest_tar 10 os-core
create_fullfile_tar 10 $targetfile
create_manifest_tar 20 MoM
sign_manifest_mom 20
create_manifest_tar 20 os-core
create_fullfile_tar 20 $targetfile
}
teardown() {
clean_tars 10
clean_tars 10 files
clean_tars 20
clean_tars 20 files
revert_chown_root "$DIR/web-dir/10/files/$targetfile"
revert_chown_root "$DIR/web-dir/20/files/$targetfile"
# test should succeed and therefore install this dir
sudo rmdir "$DIR/target-dir/usr/bin/"
}
@test "verify format mismatch override" {
# the -x option bypasses the fatal error
run sudo sh -c "$SWUPD verify --fix -F 1 -m 20 -x $SWUPD_OPTS_NO_FMT"
[ $status -eq 0 ]
check_lines "$output"
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -0,0 +1,8 @@
MANIFEST 1
version: 10
previous: 0
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 15d53310ea1d80c7d0045b76081f5334afb99e53efd81579e07ef869b7ab790e 10 os-core
@@ -0,0 +1,8 @@
MANIFEST 1
version: 10
previous: 0
filecount: 1
timestamp: 1451936779
contentsize: 17929151
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/bin
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
@@ -0,0 +1,8 @@
MANIFEST 2
version: 20
previous: 10
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 3ba369029c1bbfd5888d090e107ce0f5cd7ed074143e466c171ca16064532dcc 20 os-core
@@ -0,0 +1,8 @@
MANIFEST 2
version: 20
previous: 10
filecount: 1
timestamp: 1451936779
contentsize: 17929151
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 20 /usr/bin
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
@@ -0,0 +1,5 @@
Verifying version 20
Attempting to download version string to memory
ERROR: Mismatching formats detected when verifying 20 (expected: 1; actual: 2)
Latest supported version to verify: 10
Error: Fix did not fully succeed
@@ -0,0 +1 @@
VERSION_ID=10
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env bats
load "../../swupdlib"
targetfile=6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e
setup() {
clean_test_dir
create_manifest_tar 10 MoM
sign_manifest_mom 10
create_manifest_tar 10 os-core
create_fullfile_tar 10 $targetfile
create_manifest_tar 20 MoM
sign_manifest_mom 20
create_manifest_tar 20 os-core
create_fullfile_tar 20 $targetfile
}
teardown() {
clean_tars 10
clean_tars 10 files
clean_tars 20
clean_tars 20 files
revert_chown_root "$DIR/web-dir/10/files/$targetfile"
revert_chown_root "$DIR/web-dir/20/files/$targetfile"
#sudo rmdir "$DIR/target-dir/usr/bin/"
}
@test "verify format mismatch enforcement" {
run sudo sh -c "$SWUPD verify --fix -F 1 -m 20 $SWUPD_OPTS_NO_FMT"
# 14 = EMANIFEST_LOAD
[ $status -eq 14 ]
check_lines "$output"
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -0,0 +1,8 @@
MANIFEST 1
version: 10
previous: 0
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 15d53310ea1d80c7d0045b76081f5334afb99e53efd81579e07ef869b7ab790e 10 os-core
@@ -0,0 +1,8 @@
MANIFEST 1
version: 10
previous: 0
filecount: 1
timestamp: 1451936779
contentsize: 17929151
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 10 /usr/bin
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
@@ -0,0 +1,8 @@
MANIFEST 2
version: 20
previous: 10
filecount: 1
timestamp: 1451940175
contentsize: 13805671819
M... 3ba369029c1bbfd5888d090e107ce0f5cd7ed074143e466c171ca16064532dcc 20 os-core
@@ -0,0 +1,8 @@
MANIFEST 2
version: 20
previous: 10
filecount: 1
timestamp: 1451936779
contentsize: 17929151
D... 6c27df6efcd6fc401ff1bc67c970b83eef115f6473db4fb9d57e5de317eba96e 20 /usr/bin
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore