Add a functional test that creates delta packs

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This commit is contained in:
Patrick McCarty
2016-03-08 22:23:59 -08:00
parent e653bdd50a
commit 6ba28bc7a9
3 changed files with 67 additions and 1 deletions
+2 -1
View File
@@ -112,7 +112,8 @@ dist_check_SCRIPTS = \
test/functional/update.bats \
test/functional/fullfiles.bats \
test/functional/pack.bats \
test/functional/full-run.bats
test/functional/full-run.bats \
test/functional/full-run-delta.bats
endif
if COVERAGE
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bats
# common functions
load swupdlib
setup() {
DIR=$(init_web_dir "$srcdir/web-dir")
export DIR
init_server_ini
init_latest_ver 0
init_groups_ini os-core test-bundle
set_os_release 10 os-core
track_bundle 10 os-core
track_bundle 10 test-bundle
set_os_release 20 os-core
track_bundle 20 os-core
track_bundle 20 test-bundle
gen_file_to_delta 10 4096 20 4 test-bundle
}
@test "full run update creation with delta packs" {
# build the first version
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 10
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 test-bundle
# then the second version...
sudo $srcdir/swupd_create_update --osversion 20 --statedir $DIR
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 20
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 test-bundle
# and with delta packs this time
sudo $srcdir/swupd_make_pack --statedir $DIR 10 20 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 10 20 test-bundle
}
teardown() {
sudo rm -rf $DIR
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
+19
View File
@@ -39,4 +39,23 @@ track_bundle() {
touch $DIR/image/$ver/$bundle/usr/share/clear/bundles/$bundle
}
gen_file_to_delta() {
local origver=$1
local origsize=$2
local newver=$3
local newbytes=$4
local bundle=$5
# create some random data for the original version
mkdir -p $DIR/image/$origver/$bundle
dd if=/dev/urandom of=$DIR/image/$origver/$bundle/randomfile bs=1 count=$origsize
# append more random data to the end of the file in the new version
TMP=$(mktemp foo.XXXXXX)
mkdir -p $DIR/image/$newver/$bundle
dd if=/dev/urandom of=$TMP bs=1 count=$newbytes
cat $DIR/image/$origver/$bundle/randomfile $TMP > $DIR/image/$newver/$bundle/randomfile
rm $TMP
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80