Compare commits

..
6 Commits
Author SHA1 Message Date
Patrick McCarty b6bd8bf73b Release v3.2.2
This release includes a trivial improvement for reporting paths that
contain blacklisted characters.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-29 15:23:44 -07:00
Patrick McCarty 94240130be Report full paths for files containing blacklisted characters
To better track which files are excluded from manifests because they
contain blacklisted characters, the full path is more useful to log
rather than the file basename.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-29 15:04:16 -07:00
Patrick McCarty ae299e2126 Rename main.c to create_update.c
Since the source files for entry points to the other two binaries are
named after the binaries, do the same for swupd_create_update.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-14 11:14:36 -07:00
Patrick McCarty 64e65bca92 Run functional tests in separate directories
To more easily implement tests, analyze test results, etc, store each
test in a separate directory and dump all logs and the web-dir content
there as well.

The test suite can be run with 'make check', as before, but now tests
can be run individually by directly invoking the appropriate test.bats
file (at toplevel, or within the test directory).

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-10 21:03:06 -07:00
Patrick McCarty e78ef77e06 Release v3.2.1
This release fixes a sorting issue with bundle manifests: they should be
version sorted, not filename sorted.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-05 23:51:22 -07:00
Patrick McCarty a329cc93a9 Fix sorting issue with bundle manifests
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-04-05 23:50:42 -07:00
14 changed files with 121 additions and 108 deletions
+4 -2
View File
@@ -27,7 +27,9 @@ coverage/
src/*.gcno
src/*.gcda
tap-driver.sh
test/functional/*.log
test/functional/*.trs
test/functional/*/*.log
test/functional/*/*.trs
test/functional/*/logs/
test/functional/*/web-dir/
swupd-*.log
test-suite.log
+11 -11
View File
@@ -15,6 +15,7 @@ swupd_create_update_SOURCES = \
src/analyze_fs.c \
src/chroot.c \
src/config.c \
src/create_update.c \
src/delta.c \
src/fullfiles.c \
src/globals.c \
@@ -22,7 +23,6 @@ swupd_create_update_SOURCES = \
src/helpers.c \
src/heuristics.c \
src/log.c \
src/main.c \
src/manifest.c \
src/pack.c \
src/rename.c \
@@ -96,26 +96,26 @@ noinst_HEADERS = \
include/swupd.h \
include/xattrs.h
TEST_EXTENSIONS = .sh
TEST_EXTENSIONS = .bats
if ENABLE_TESTS
tap_driver = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh
LOG_DRIVER = $(tap_driver)
SH_LOG_DRIVER = $(tap_driver)
BATS_LOG_DRIVER = $(tap_driver)
TESTS = $(dist_check_SCRIPTS)
dist_check_SCRIPTS = \
test/functional/basic.bats \
test/functional/delete-no-version-bump.bats \
test/functional/include-version-bump.bats \
test/functional/update.bats \
test/functional/fullfiles.bats \
test/functional/pack.bats \
test/functional/full-run.bats \
test/functional/full-run-delta.bats
test/functional/basic/test.bats \
test/functional/delete-no-version-bump/test.bats \
test/functional/include-version-bump/test.bats \
test/functional/update/test.bats \
test/functional/fullfiles/test.bats \
test/functional/pack/test.bats \
test/functional/full-run/test.bats \
test/functional/full-run-delta/test.bats
endif
if COVERAGE
+1 -1
View File
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.66])
AC_INIT(swupd-server, 3.2.0, timothy.c.pepper@linux.intel.com)
AC_INIT(swupd-server, 3.2.2, timothy.c.pepper@linux.intel.com)
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
AM_SILENT_RULES([yes])
AC_PROG_CC
+11 -6
View File
@@ -286,18 +286,15 @@ static bool illegal_characters(char *filename)
// these breaks the tar transform sed-like expression,
// hopefully can remove this check after moving to libtar
if (strncmp(filename, "+", 1) == 0) {
printf("WARNING: Filename %s begins with '+'! ...skipping.\n", filename);
return true;
}
if (strstr(filename, "+package+") != NULL) {
printf("WARNING: Filename %s contains \"+package+\"! ...skipping.\n", filename);
return true;
}
for (i = 0; i < BAD_CHAR_COUNT; i++) {
c = bad_chars[i];
if (strchr(filename, c) != NULL) {
printf("WARNING: Filename %s includes illegal character '%c'! ...skipping.\n", filename, c);
return true;
}
}
@@ -323,6 +320,7 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
while (dir) {
struct file *file;
char *sub_filename;
char *fullname;
entry = readdir(dir);
@@ -331,8 +329,15 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
}
if ((strcmp(entry->d_name, ".") == 0) ||
(strcmp(entry->d_name, "..") == 0) ||
(illegal_characters(entry->d_name))) {
(strcmp(entry->d_name, "..") == 0)) {
continue;
}
string_or_die(&sub_filename, "%s/%s", subpath, entry->d_name);
if (illegal_characters(entry->d_name)) {
printf("WARNING: Filename %s includes illegal character(s) ...skipping.\n", sub_filename);
free(sub_filename);
continue;
}
@@ -342,7 +347,7 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
}
file->last_change = manifest->version;
string_or_die(&file->filename, "%s/%s", subpath, entry->d_name);
file->filename = sub_filename;
string_or_die(&fullname, "%s/%s", fullpath, entry->d_name);
populate_file_struct(file, fullname);
+2 -2
View File
@@ -342,9 +342,9 @@ int main(int argc, char **argv)
/* Detect renamed files specifically for each pack */
// rename_detection(...);
old_deleted = remove_old_deleted_files(old_core, new_core);
sort_manifest_by_version(new_core);
newfiles = prune_manifest(new_core);
old_deleted = remove_old_deleted_files(old_core, new_core);
if (newfiles <= 0) {
LOG(NULL, "", "Core component has not changed (after pruning), exiting");
printf("Core component has not changed (after pruning), exiting\n");
@@ -446,10 +446,10 @@ int main(int argc, char **argv)
apply_heuristics(newm);
#warning missing rename_detection here
/* Step 6b: otherwise, write out the manifest */
old_deleted = remove_old_deleted_files(oldm, newm);
sort_manifest_by_version(newm);
type_change_detection(newm);
newfiles = prune_manifest(newm);
old_deleted = remove_old_deleted_files(oldm, newm);
if (newfiles > 0 || old_deleted > 0 || changed_includes(oldm, newm)) {
LOG(NULL, "", "%s component has changes (%d new, %d deleted), writing out new manifest", group, newfiles, old_deleted);
printf("%s component has changes (%d new, %d deleted), writing out new manifest\n", group, newfiles, old_deleted);
@@ -1,23 +1,25 @@
#!/usr/bin/env bats
load "../swupdlib"
@test "create_update help output" {
run $srcdir/swupd_create_update --help
run $CREATE_UPDATE --help
[ "$status" -eq 1 ]
run $srcdir/swupd_create_update -h
run $CREATE_UPDATE -h
[ "$status" -eq 1 ]
}
@test "make_fullfiles help output" {
run $srcdir/swupd_make_fullfiles --help
run $MAKE_FULLFILES --help
[ "$status" -eq 1 ]
run $srcdir/swupd_make_fullfiles -h
run $MAKE_FULLFILES -h
[ "$status" -eq 1 ]
}
@test "make_pack help output" {
run $srcdir/swupd_make_pack --help
run $MAKE_PACK --help
[ "$status" -eq 1 ]
run $srcdir/swupd_make_pack -h
run $MAKE_PACK -h
[ "$status" -eq 1 ]
}
@@ -1,11 +1,11 @@
#!/usr/bin/env bats
# common functions
load swupdlib
load "../swupdlib"
setup() {
DIR=$(init_web_dir "$srcdir/web-dir")
export DIR
clean_test_dir
init_test_dir
init_server_ini
set_latest_ver 0
@@ -32,21 +32,17 @@ setup() {
}
@test "delete no version bump update creation" {
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 10
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 10
set_latest_ver 10
sudo $srcdir/swupd_create_update --osversion 20 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 20
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 20
[ 1 -eq $(grep '10 /foo' $DIR/www/10/Manifest.full | wc -l) ]
[ 1 -eq $(grep '10 /foo' $DIR/www/20/Manifest.full | wc -l) ]
[ 0 -eq $(grep '20 /foo' $DIR/www/20/Manifest.full | wc -l) ]
}
teardown() {
sudo rm -rf $DIR
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -1,11 +1,11 @@
#!/usr/bin/env bats
# common functions
load swupdlib
load "../swupdlib"
setup() {
DIR=$(init_web_dir "$srcdir/web-dir")
export DIR
clean_test_dir
init_test_dir
init_server_ini
set_latest_ver 0
@@ -37,22 +37,22 @@ setup() {
@test "full run update creation with delta packs" {
# build the first version
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR --format 3
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
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 10
sudo $MAKE_PACK --statedir $DIR 0 10 os-core
sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
set_latest_ver 10
# then the second version...
sudo $srcdir/swupd_create_update --osversion 20 --statedir $DIR --format 3
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
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 20
sudo $MAKE_PACK --statedir $DIR 0 20 os-core
sudo $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
sudo $MAKE_PACK --statedir $DIR 10 20 os-core
sudo $MAKE_PACK --statedir $DIR 10 20 test-bundle
# zero packs should exist (non-zero size) for both versions
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
@@ -81,8 +81,4 @@ setup() {
[[ 4 -eq $(tar -tf $DIR/www/20/pack-test-bundle-from-0.tar | wc -l) ]]
}
teardown() {
sudo rm -rf $DIR
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -1,11 +1,11 @@
#!/usr/bin/env bats
# common functions
load swupdlib
load "../swupdlib"
setup() {
DIR=$(init_web_dir "$srcdir/web-dir")
export DIR
clean_test_dir
init_test_dir
init_server_ini
set_latest_ver 0
@@ -20,10 +20,10 @@ setup() {
}
@test "full run update creation" {
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR --format 3
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
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 10
sudo $MAKE_PACK --statedir $DIR 0 10 os-core
sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
# zero packs should exist (non-zero size) for the build
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
@@ -42,8 +42,4 @@ setup() {
[[ 9 -eq $(tar -tf $DIR/www/10/pack-os-core-from-0.tar | wc -l) ]]
}
teardown() {
sudo rm -rf $DIR
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -1,18 +1,20 @@
#!/usr/bin/env bats
load "../swupdlib"
@test "make_fullfiles required arg" {
run $srcdir/swupd_make_fullfiles
run $MAKE_FULLFILES
[ "$status" -eq 1 ]
}
@test "make_fullfiles too many arguments" {
# exactly one argument must be passed
run $srcdir/swupd_make_fullfiles foo bar
run $MAKE_FULLFILES foo bar
[ "$status" -eq 1 ]
}
@test "make_fullfiles root priv check" {
run $srcdir/swupd_make_fullfiles foo
run $MAKE_FULLFILES foo
[ "$status" -eq 1 ]
[[ "$output" =~ "not being run as root.. exiting" ]]
}
@@ -1,11 +1,11 @@
#!/usr/bin/env bats
# common functions
load swupdlib
load "../swupdlib"
setup() {
DIR=$(init_web_dir "$srcdir/web-dir")
export DIR
clean_test_dir
init_test_dir
init_server_ini
set_latest_ver 0
@@ -44,31 +44,31 @@ setup() {
@test "full run update creation with delta packs" {
# build the first version
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR --format 3
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
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 10
sudo $MAKE_PACK --statedir $DIR 0 10 os-core
sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
set_latest_ver 10
# then the second version...
sudo $srcdir/swupd_create_update --osversion 20 --statedir $DIR --format 3
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
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 included
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 included-two
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 20
sudo $MAKE_PACK --statedir $DIR 0 20 os-core
sudo $MAKE_PACK --statedir $DIR 0 20 test-bundle
sudo $MAKE_PACK --statedir $DIR 0 20 included
sudo $MAKE_PACK --statedir $DIR 0 20 included-two
set_latest_ver 20
# then the third version...
sudo $srcdir/swupd_create_update --osversion 30 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 30
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 test-bundle
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 included
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 included-two
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 included-nested
sudo $CREATE_UPDATE --osversion 30 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 30
sudo $MAKE_PACK --statedir $DIR 0 30 os-core
sudo $MAKE_PACK --statedir $DIR 0 30 test-bundle
sudo $MAKE_PACK --statedir $DIR 0 30 included
sudo $MAKE_PACK --statedir $DIR 0 30 included-two
sudo $MAKE_PACK --statedir $DIR 0 30 included-nested
# zero packs should exist (non-zero size) for both versions
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
@@ -96,8 +96,4 @@ setup() {
[[ 0 -eq $(ls $DIR/www/30/Manifest.included-two | wc -l) ]]
}
teardown() {
sudo rm -rf $DIR
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -1,24 +1,26 @@
#!/usr/bin/env bats
load "../swupdlib"
@test "make_pack required arg" {
run $srcdir/swupd_make_pack
run $MAKE_PACK
[ "$status" -eq 1 ]
}
@test "make_pack too few arguments" {
run $srcdir/swupd_make_pack foo
run $MAKE_PACK foo
[ "$status" -eq 1 ]
run $srcdir/swupd_make_pack foo bar
run $MAKE_PACK foo bar
[ "$status" -eq 1 ]
}
@test "make_pack too many arguments" {
run $srcdir/swupd_make_pack foo bar foo bar
run $MAKE_PACK foo bar foo bar
[ "$status" -eq 1 ]
}
@test "make_pack root priv check" {
run $srcdir/swupd_make_pack foo bar foo
run $MAKE_PACK foo bar foo
[ "$status" -eq 1 ]
[[ "$output" =~ "not being run as root.. exiting" ]]
}
+20 -6
View File
@@ -1,14 +1,28 @@
# NOTE: source this file from a *.bats file
init_web_dir() {
# absolute path is a hard requirement right now
local dir=$(realpath $1)
mkdir -p $dir/{image,www}
echo $dir
# The location of the swupd_* binaries
export SRCDIR="$BATS_TEST_DIRNAME/../../../"
export CREATE_UPDATE="$SRCDIR/swupd_create_update"
export MAKE_FULLFILES="$SRCDIR/swupd_make_fullfiles"
export MAKE_PACK="$SRCDIR/swupd_make_pack"
export DIR="$BATS_TEST_DIRNAME/web-dir"
init_test_dir() {
local testdir="$BATS_TEST_DIRNAME"
mkdir -p "$testdir"/logs
mkdir -p $DIR/{image,www}
# run swupd_* inside the directory to dump the logs
cd "$testdir"/logs
}
clean_test_dir() {
sudo rm -rf $DIR "$BATS_TEST_DIRNAME"/logs
}
init_server_ini() {
cp $srcdir/server.ini $DIR
cp $SRCDIR/server.ini $DIR
sed -i "s|/var/lib/update|$DIR|" $DIR/server.ini
}
@@ -1,19 +1,21 @@
#!/usr/bin/env bats
load "../swupdlib"
@test "create_update required format" {
run $srcdir/swupd_create_update
run $CREATE_UPDATE
[ "$status" -eq 1 ]
[[ "$output" =~ "Missing format parameter" ]]
}
@test "create_update required version" {
run $srcdir/swupd_create_update -F 3
run $CREATE_UPDATE -F 3
[ "$status" -eq 1 ]
[[ "$output" =~ "Missing version parameter:" ]]
}
@test "create_update root priv check" {
run $srcdir/swupd_create_update -F 3 -o 10
run $CREATE_UPDATE -F 3 -o 10
[ "$status" -eq 1 ]
[[ "$output" =~ "not being run as root.. exiting" ]]
}