Compare commits

...
4 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
14 changed files with 119 additions and 106 deletions
+4 -2
View File
@@ -27,7 +27,9 @@ coverage/
src/*.gcno src/*.gcno
src/*.gcda src/*.gcda
tap-driver.sh tap-driver.sh
test/functional/*.log test/functional/*/*.log
test/functional/*.trs test/functional/*/*.trs
test/functional/*/logs/
test/functional/*/web-dir/
swupd-*.log swupd-*.log
test-suite.log test-suite.log
+11 -11
View File
@@ -15,6 +15,7 @@ swupd_create_update_SOURCES = \
src/analyze_fs.c \ src/analyze_fs.c \
src/chroot.c \ src/chroot.c \
src/config.c \ src/config.c \
src/create_update.c \
src/delta.c \ src/delta.c \
src/fullfiles.c \ src/fullfiles.c \
src/globals.c \ src/globals.c \
@@ -22,7 +23,6 @@ swupd_create_update_SOURCES = \
src/helpers.c \ src/helpers.c \
src/heuristics.c \ src/heuristics.c \
src/log.c \ src/log.c \
src/main.c \
src/manifest.c \ src/manifest.c \
src/pack.c \ src/pack.c \
src/rename.c \ src/rename.c \
@@ -96,26 +96,26 @@ noinst_HEADERS = \
include/swupd.h \ include/swupd.h \
include/xattrs.h include/xattrs.h
TEST_EXTENSIONS = .sh TEST_EXTENSIONS = .bats
if ENABLE_TESTS if ENABLE_TESTS
tap_driver = env AM_TAP_AWK='$(AWK)' $(SHELL) \ tap_driver = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh $(top_srcdir)/tap-driver.sh
LOG_DRIVER = $(tap_driver) LOG_DRIVER = $(tap_driver)
SH_LOG_DRIVER = $(tap_driver) BATS_LOG_DRIVER = $(tap_driver)
TESTS = $(dist_check_SCRIPTS) TESTS = $(dist_check_SCRIPTS)
dist_check_SCRIPTS = \ dist_check_SCRIPTS = \
test/functional/basic.bats \ test/functional/basic/test.bats \
test/functional/delete-no-version-bump.bats \ test/functional/delete-no-version-bump/test.bats \
test/functional/include-version-bump.bats \ test/functional/include-version-bump/test.bats \
test/functional/update.bats \ test/functional/update/test.bats \
test/functional/fullfiles.bats \ test/functional/fullfiles/test.bats \
test/functional/pack.bats \ test/functional/pack/test.bats \
test/functional/full-run.bats \ test/functional/full-run/test.bats \
test/functional/full-run-delta.bats test/functional/full-run-delta/test.bats
endif endif
if COVERAGE if COVERAGE
+1 -1
View File
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ([2.66]) AC_PREREQ([2.66])
AC_INIT(swupd-server, 3.2.1, 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_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
AC_PROG_CC 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, // these breaks the tar transform sed-like expression,
// hopefully can remove this check after moving to libtar // hopefully can remove this check after moving to libtar
if (strncmp(filename, "+", 1) == 0) { if (strncmp(filename, "+", 1) == 0) {
printf("WARNING: Filename %s begins with '+'! ...skipping.\n", filename);
return true; return true;
} }
if (strstr(filename, "+package+") != NULL) { if (strstr(filename, "+package+") != NULL) {
printf("WARNING: Filename %s contains \"+package+\"! ...skipping.\n", filename);
return true; return true;
} }
for (i = 0; i < BAD_CHAR_COUNT; i++) { for (i = 0; i < BAD_CHAR_COUNT; i++) {
c = bad_chars[i]; c = bad_chars[i];
if (strchr(filename, c) != NULL) { if (strchr(filename, c) != NULL) {
printf("WARNING: Filename %s includes illegal character '%c'! ...skipping.\n", filename, c);
return true; return true;
} }
} }
@@ -323,6 +320,7 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
while (dir) { while (dir) {
struct file *file; struct file *file;
char *sub_filename;
char *fullname; char *fullname;
entry = readdir(dir); entry = readdir(dir);
@@ -331,8 +329,15 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
} }
if ((strcmp(entry->d_name, ".") == 0) || if ((strcmp(entry->d_name, ".") == 0) ||
(strcmp(entry->d_name, "..") == 0) || (strcmp(entry->d_name, "..") == 0)) {
(illegal_characters(entry->d_name))) { 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; continue;
} }
@@ -342,7 +347,7 @@ static void iterate_directory(struct manifest *manifest, char *pathprefix,
} }
file->last_change = manifest->version; 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); string_or_die(&fullname, "%s/%s", fullpath, entry->d_name);
populate_file_struct(file, fullname); populate_file_struct(file, fullname);
View File
@@ -1,23 +1,25 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load "../swupdlib"
@test "create_update help output" { @test "create_update help output" {
run $srcdir/swupd_create_update --help run $CREATE_UPDATE --help
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
run $srcdir/swupd_create_update -h run $CREATE_UPDATE -h
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@test "make_fullfiles help output" { @test "make_fullfiles help output" {
run $srcdir/swupd_make_fullfiles --help run $MAKE_FULLFILES --help
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
run $srcdir/swupd_make_fullfiles -h run $MAKE_FULLFILES -h
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@test "make_pack help output" { @test "make_pack help output" {
run $srcdir/swupd_make_pack --help run $MAKE_PACK --help
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
run $srcdir/swupd_make_pack -h run $MAKE_PACK -h
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@@ -1,11 +1,11 @@
#!/usr/bin/env bats #!/usr/bin/env bats
# common functions # common functions
load swupdlib load "../swupdlib"
setup() { setup() {
DIR=$(init_web_dir "$srcdir/web-dir") clean_test_dir
export DIR init_test_dir
init_server_ini init_server_ini
set_latest_ver 0 set_latest_ver 0
@@ -32,21 +32,17 @@ setup() {
} }
@test "delete no version bump update creation" { @test "delete no version bump update creation" {
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR --format 3 sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 10 sudo $MAKE_FULLFILES --statedir $DIR 10
set_latest_ver 10 set_latest_ver 10
sudo $srcdir/swupd_create_update --osversion 20 --statedir $DIR --format 3 sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 20 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/10/Manifest.full | wc -l) ]
[ 1 -eq $(grep '10 /foo' $DIR/www/20/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) ] [ 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 # vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -1,11 +1,11 @@
#!/usr/bin/env bats #!/usr/bin/env bats
# common functions # common functions
load swupdlib load "../swupdlib"
setup() { setup() {
DIR=$(init_web_dir "$srcdir/web-dir") clean_test_dir
export DIR init_test_dir
init_server_ini init_server_ini
set_latest_ver 0 set_latest_ver 0
@@ -37,22 +37,22 @@ setup() {
@test "full run update creation with delta packs" { @test "full run update creation with delta packs" {
# build the first version # build the first version
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR --format 3 sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 10 sudo $MAKE_FULLFILES --statedir $DIR 10
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 os-core sudo $MAKE_PACK --statedir $DIR 0 10 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 test-bundle sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
set_latest_ver 10 set_latest_ver 10
# then the second version... # then the second version...
sudo $srcdir/swupd_create_update --osversion 20 --statedir $DIR --format 3 sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 20 sudo $MAKE_FULLFILES --statedir $DIR 20
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 os-core sudo $MAKE_PACK --statedir $DIR 0 20 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 test-bundle sudo $MAKE_PACK --statedir $DIR 0 20 test-bundle
# and with delta packs this time # and with delta packs this time
sudo $srcdir/swupd_make_pack --statedir $DIR 10 20 os-core sudo $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 test-bundle
# zero packs should exist (non-zero size) for both versions # zero packs should exist (non-zero size) for both versions
[ -s $DIR/www/10/pack-os-core-from-0.tar ] [ -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) ]] [[ 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 # vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -1,11 +1,11 @@
#!/usr/bin/env bats #!/usr/bin/env bats
# common functions # common functions
load swupdlib load "../swupdlib"
setup() { setup() {
DIR=$(init_web_dir "$srcdir/web-dir") clean_test_dir
export DIR init_test_dir
init_server_ini init_server_ini
set_latest_ver 0 set_latest_ver 0
@@ -20,10 +20,10 @@ setup() {
} }
@test "full run update creation" { @test "full run update creation" {
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR --format 3 sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 10 sudo $MAKE_FULLFILES --statedir $DIR 10
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 os-core sudo $MAKE_PACK --statedir $DIR 0 10 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 test-bundle sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
# zero packs should exist (non-zero size) for the build # zero packs should exist (non-zero size) for the build
[ -s $DIR/www/10/pack-os-core-from-0.tar ] [ -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) ]] [[ 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 # vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -1,18 +1,20 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load "../swupdlib"
@test "make_fullfiles required arg" { @test "make_fullfiles required arg" {
run $srcdir/swupd_make_fullfiles run $MAKE_FULLFILES
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@test "make_fullfiles too many arguments" { @test "make_fullfiles too many arguments" {
# exactly one argument must be passed # exactly one argument must be passed
run $srcdir/swupd_make_fullfiles foo bar run $MAKE_FULLFILES foo bar
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@test "make_fullfiles root priv check" { @test "make_fullfiles root priv check" {
run $srcdir/swupd_make_fullfiles foo run $MAKE_FULLFILES foo
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[[ "$output" =~ "not being run as root.. exiting" ]] [[ "$output" =~ "not being run as root.. exiting" ]]
} }
@@ -1,11 +1,11 @@
#!/usr/bin/env bats #!/usr/bin/env bats
# common functions # common functions
load swupdlib load "../swupdlib"
setup() { setup() {
DIR=$(init_web_dir "$srcdir/web-dir") clean_test_dir
export DIR init_test_dir
init_server_ini init_server_ini
set_latest_ver 0 set_latest_ver 0
@@ -44,31 +44,31 @@ setup() {
@test "full run update creation with delta packs" { @test "full run update creation with delta packs" {
# build the first version # build the first version
sudo $srcdir/swupd_create_update --osversion 10 --statedir $DIR --format 3 sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 10 sudo $MAKE_FULLFILES --statedir $DIR 10
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 os-core sudo $MAKE_PACK --statedir $DIR 0 10 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 10 test-bundle sudo $MAKE_PACK --statedir $DIR 0 10 test-bundle
set_latest_ver 10 set_latest_ver 10
# then the second version... # then the second version...
sudo $srcdir/swupd_create_update --osversion 20 --statedir $DIR --format 3 sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 20 sudo $MAKE_FULLFILES --statedir $DIR 20
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 os-core sudo $MAKE_PACK --statedir $DIR 0 20 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 test-bundle sudo $MAKE_PACK --statedir $DIR 0 20 test-bundle
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 included sudo $MAKE_PACK --statedir $DIR 0 20 included
sudo $srcdir/swupd_make_pack --statedir $DIR 0 20 included-two sudo $MAKE_PACK --statedir $DIR 0 20 included-two
set_latest_ver 20 set_latest_ver 20
# then the third version... # then the third version...
sudo $srcdir/swupd_create_update --osversion 30 --statedir $DIR --format 3 sudo $CREATE_UPDATE --osversion 30 --statedir $DIR --format 3
sudo $srcdir/swupd_make_fullfiles --statedir $DIR 30 sudo $MAKE_FULLFILES --statedir $DIR 30
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 os-core sudo $MAKE_PACK --statedir $DIR 0 30 os-core
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 test-bundle sudo $MAKE_PACK --statedir $DIR 0 30 test-bundle
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 included sudo $MAKE_PACK --statedir $DIR 0 30 included
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 included-two sudo $MAKE_PACK --statedir $DIR 0 30 included-two
sudo $srcdir/swupd_make_pack --statedir $DIR 0 30 included-nested sudo $MAKE_PACK --statedir $DIR 0 30 included-nested
# zero packs should exist (non-zero size) for both versions # zero packs should exist (non-zero size) for both versions
[ -s $DIR/www/10/pack-os-core-from-0.tar ] [ -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) ]] [[ 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 # vi: ft=sh ts=8 sw=2 sts=2 et tw=80
@@ -1,24 +1,26 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load "../swupdlib"
@test "make_pack required arg" { @test "make_pack required arg" {
run $srcdir/swupd_make_pack run $MAKE_PACK
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@test "make_pack too few arguments" { @test "make_pack too few arguments" {
run $srcdir/swupd_make_pack foo run $MAKE_PACK foo
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
run $srcdir/swupd_make_pack foo bar run $MAKE_PACK foo bar
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@test "make_pack too many arguments" { @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 ] [ "$status" -eq 1 ]
} }
@test "make_pack root priv check" { @test "make_pack root priv check" {
run $srcdir/swupd_make_pack foo bar foo run $MAKE_PACK foo bar foo
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[[ "$output" =~ "not being run as root.. exiting" ]] [[ "$output" =~ "not being run as root.. exiting" ]]
} }
+20 -6
View File
@@ -1,14 +1,28 @@
# NOTE: source this file from a *.bats file # NOTE: source this file from a *.bats file
init_web_dir() { # The location of the swupd_* binaries
# absolute path is a hard requirement right now export SRCDIR="$BATS_TEST_DIRNAME/../../../"
local dir=$(realpath $1)
mkdir -p $dir/{image,www} export CREATE_UPDATE="$SRCDIR/swupd_create_update"
echo $dir 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() { init_server_ini() {
cp $srcdir/server.ini $DIR cp $SRCDIR/server.ini $DIR
sed -i "s|/var/lib/update|$DIR|" $DIR/server.ini sed -i "s|/var/lib/update|$DIR|" $DIR/server.ini
} }
@@ -1,19 +1,21 @@
#!/usr/bin/env bats #!/usr/bin/env bats
load "../swupdlib"
@test "create_update required format" { @test "create_update required format" {
run $srcdir/swupd_create_update run $CREATE_UPDATE
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[[ "$output" =~ "Missing format parameter" ]] [[ "$output" =~ "Missing format parameter" ]]
} }
@test "create_update required version" { @test "create_update required version" {
run $srcdir/swupd_create_update -F 3 run $CREATE_UPDATE -F 3
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[[ "$output" =~ "Missing version parameter:" ]] [[ "$output" =~ "Missing version parameter:" ]]
} }
@test "create_update root priv check" { @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 ] [ "$status" -eq 1 ]
[[ "$output" =~ "not being run as root.. exiting" ]] [[ "$output" =~ "not being run as root.. exiting" ]]
} }