mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-08-19 04:57:43 +00:00
Add basic check for format number validity
Because the intention is for swupd format numbers to either remain the same between LAST_VER and current, or to increase as part of a format bump, this leaves the remaining undesirable case. Add a basic check to make sure the format never decreases, and add a functional test. Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This commit is contained in:
@@ -110,6 +110,7 @@ dist_check_SCRIPTS = \
|
||||
test/functional/basic/test.bats \
|
||||
test/functional/delete-no-version-bump/test.bats \
|
||||
test/functional/file-name-blacklisted/test.bats \
|
||||
test/functional/format-no-decrement/test.bats \
|
||||
test/functional/full-run-delta/test.bats \
|
||||
test/functional/full-run/test.bats \
|
||||
test/functional/fullfiles/test.bats \
|
||||
|
||||
@@ -340,6 +340,17 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Step 2: Make a manifest for the os-core set */
|
||||
old_MoM = manifest_from_file(current_version, "MoM");
|
||||
|
||||
/* Verify that the new format is not older than the previous format. It
|
||||
* never makes sense to decrease the format number for the next build. */
|
||||
if (format < old_MoM->format) {
|
||||
LOG(NULL, "", "Current format (%llu) must be greater than or equal to previous format (%llu). Exiting",
|
||||
format, old_MoM->format);
|
||||
printf("Current format (%llu) must be greater than or equal to previous format (%llu). Exiting\n",
|
||||
format, old_MoM->format);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
new_MoM = alloc_manifest(newversion, "MoM");
|
||||
old_core = manifest_from_file(manifest_subversion(old_MoM, "os-core"), "os-core");
|
||||
new_core = sub_manifest_from_directory("os-core", newversion);
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# common functions
|
||||
load "../swupdlib"
|
||||
|
||||
setup() {
|
||||
clean_test_dir
|
||||
init_test_dir
|
||||
|
||||
init_server_ini
|
||||
set_latest_ver 0
|
||||
init_groups_ini os-core
|
||||
|
||||
set_os_release 10 os-core
|
||||
track_bundle 10 os-core
|
||||
set_os_release 20 os-core
|
||||
track_bundle 20 os-core
|
||||
|
||||
gen_file_plain 10 os-core foo
|
||||
gen_file_plain 10 os-core bar
|
||||
gen_file_plain 20 os-core foo
|
||||
gen_file_plain 20 os-core baz
|
||||
}
|
||||
|
||||
@test "ensure format numbers cannot be decremented" {
|
||||
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
|
||||
set_latest_ver 10
|
||||
|
||||
# Now, decrement the format number. Should result in an EXIT_FAILURE.
|
||||
run sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 2
|
||||
echo "$output"
|
||||
[ $status -eq 1 ]
|
||||
}
|
||||
|
||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||
Reference in New Issue
Block a user