mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-10-04 07:58:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c28d06c580 | ||
|
|
1fa24df6d6 | ||
|
|
e84600c21d | ||
|
|
350bb54fdf | ||
|
|
15e6b1466f |
@@ -108,6 +108,7 @@ TESTS = $(dist_check_SCRIPTS)
|
||||
|
||||
dist_check_SCRIPTS = \
|
||||
test/functional/basic/test.bats \
|
||||
test/functional/contentsize-across-versions-includes/test.bats \
|
||||
test/functional/delete-no-version-bump/test.bats \
|
||||
test/functional/file-name-blacklisted/test.bats \
|
||||
test/functional/format-no-decrement/test.bats \
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.66])
|
||||
AC_INIT(swupd-server, 3.5.0, tudor.marcu@intel.com)
|
||||
AC_INIT(swupd-server, 3.6.1, matthew.johnson@intel.com)
|
||||
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
AC_PROG_CC
|
||||
|
||||
+14
-15
@@ -675,19 +675,29 @@ char *file_type_to_string(struct file *file)
|
||||
return type;
|
||||
}
|
||||
|
||||
/* Calculate the contentsize for the manifest based on file sizes.
|
||||
*
|
||||
* This should calculate the files uniquely included in this manifest, but none
|
||||
* of its submanifests, which will allow calculation of sizes of all bundles on
|
||||
* a system by adding all manifest->contentsizes of installed bundles.
|
||||
*
|
||||
* However, if two bundles not in the same include chain have overlapping
|
||||
* content, summing the include chain of each bundle in the client will result
|
||||
* in an over-estimation of the total size on the system. The more content is
|
||||
* shared, the higher the over-estimation. In reality this overlap will not be
|
||||
* large, but it is currently impossible to calculate the exact installed size
|
||||
* using just the contentsize.
|
||||
*/
|
||||
static void compute_content_size(struct manifest *manifest)
|
||||
{
|
||||
/* FIXME: this is a temporary implementation based on worst case */
|
||||
|
||||
GList *list;
|
||||
struct file *file;
|
||||
struct manifest *submanifest;
|
||||
|
||||
list = g_list_first(manifest->files);
|
||||
while (list) {
|
||||
file = list->data;
|
||||
list = g_list_next(list);
|
||||
if (!file->is_deleted && (file->last_change == manifest->version)) {
|
||||
if (!file->is_deleted) {
|
||||
if (file->is_file) {
|
||||
manifest->contentsize += file->stat.st_size;
|
||||
} else if (file->is_link) {
|
||||
@@ -697,17 +707,6 @@ static void compute_content_size(struct manifest *manifest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list = g_list_first(manifest->submanifests);
|
||||
while (list) {
|
||||
submanifest = list->data;
|
||||
list = g_list_next(list);
|
||||
|
||||
/* Do not take into account groups not included in download content */
|
||||
if (create_download_content_for_group(submanifest->component)) {
|
||||
manifest->contentsize += submanifest->contentsize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns 0 == success, -1 == failure */
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# common functions
|
||||
load "../swupdlib"
|
||||
|
||||
setup() {
|
||||
clean_test_dir
|
||||
init_test_dir
|
||||
|
||||
init_server_ini
|
||||
init_groups_ini os-core test-bundle1 test-bundle2
|
||||
|
||||
set_os_release 10 os-core
|
||||
track_bundle 10 os-core
|
||||
track_bundle 10 test-bundle1
|
||||
track_bundle 10 test-bundle2
|
||||
gen_file_plain 10 test-bundle1 foo
|
||||
gen_file_plain 10 test-bundle1 foobar
|
||||
gen_file_plain 10 test-bundle2 foo2
|
||||
gen_includes_file test-bundle2 10 test-bundle1
|
||||
|
||||
set_os_release 20 os-core
|
||||
track_bundle 20 os-core
|
||||
track_bundle 20 test-bundle1
|
||||
track_bundle 20 test-bundle2
|
||||
gen_file_plain 20 test-bundle1 foo
|
||||
gen_file_plain 20 test-bundle1 foobar
|
||||
gen_file_plain 20 test-bundle1 foobarbaz
|
||||
gen_file_plain 20 test-bundle2 foo2
|
||||
gen_file_plain 20 test-bundle2 foo2bar
|
||||
gen_includes_file test-bundle2 20 test-bundle1
|
||||
}
|
||||
|
||||
@test "correct contentsize" {
|
||||
# create a couple updates to both check that contentsize does not add included
|
||||
# bundles and to verify that files changed in previous updates are counted.
|
||||
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
|
||||
set_latest_ver 10
|
||||
|
||||
# contentsize for test-bundle2 should not include test-bundle1's contentsize
|
||||
[[ 1 -eq $(grep '^contentsize: 11$' $DIR/www/10/Manifest.test-bundle1 | wc -l) ]]
|
||||
[[ 1 -eq $(grep '^contentsize: 5$' $DIR/www/10/Manifest.test-bundle2 | wc -l) ]]
|
||||
# os-core is large because it includes /usr/*
|
||||
[[ 1 -eq $(grep '^contentsize: 5134$' $DIR/www/10/Manifest.os-core | wc -l) ]]
|
||||
# 5134 + 11 + 5 = 5150
|
||||
[[ 1 -eq $(grep '^contentsize: 5150$' $DIR/www/10/Manifest.full | wc -l) ]]
|
||||
|
||||
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
|
||||
set_latest_ver 20
|
||||
|
||||
# one new file: foobarbaz (10 bytes)
|
||||
[[ 1 -eq $(grep '^contentsize: 21$' $DIR/www/20/Manifest.test-bundle1 | wc -l) ]]
|
||||
# one new file: foo2bar (8 bytes)
|
||||
[[ 1 -eq $(grep '^contentsize: 13$' $DIR/www/20/Manifest.test-bundle2 | wc -l) ]]
|
||||
# os-core should not change size
|
||||
[[ 1 -eq $(grep '^contentsize: 5134$' $DIR/www/10/Manifest.os-core | wc -l) ]]
|
||||
# contentsize for full should be all files, including ones not changed in this release
|
||||
# two new files: foo2bar (8 bytes) and foobarbaz (10 bytes)
|
||||
# 5150 + 10 + 8 = 5168
|
||||
# 5134 + 21 + 13 = 5168
|
||||
[[ 1 -eq $(grep '^contentsize: 5168$' $DIR/www/20/Manifest.full | wc -l) ]]
|
||||
}
|
||||
|
||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||
Reference in New Issue
Block a user