diff --git a/Makefile.am b/Makefile.am index 1e8cb02..9ed0ff1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/test/functional/full-run-delta.bats b/test/functional/full-run-delta.bats new file mode 100755 index 0000000..2e30838 --- /dev/null +++ b/test/functional/full-run-delta.bats @@ -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 diff --git a/test/functional/swupdlib.bash b/test/functional/swupdlib.bash index e424308..b01ba01 100644 --- a/test/functional/swupdlib.bash +++ b/test/functional/swupdlib.bash @@ -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