11 Commits
Author SHA1 Message Date
Patrick McCarty 5342235446 Release version 1.0.2
This release enables the functional test suite by default. To disable
the ability to run the test suite and its dependency checks, pass
--disable-tests to configure for the build.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-21 13:25:41 -08:00
Patrick McCarty 8ed6fb38aa Fix distcheck
The remaining test files need to be distributed in order to run the test
suite, and export abs_builddir to the test script to point to the
binaries.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-21 13:25:41 -08:00
Patrick McCarty f23f25a43c Enable travis-ci integration
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-21 10:50:39 -08:00
Patrick McCarty 8654e611cf Use 'readlink -f' instead of 'realpath'
Some distros do not ship the coreutils 'realpath', so use 'readlink -f'
instead, which is equivalent for the usage here.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-11-21 10:48:23 -08:00
Patrick McCarty fb5ced7c2c configure: fix libcheck minimum version
TAP support was added in libcheck version 0.9.12.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-10-28 17:50:36 -07:00
Patrick McCarty 150cc28bbe configure: disable libcheck test if test build is disabled
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-10-28 17:48:22 -07:00
Patrick McCarty 8c0a87b7c9 Convert functional test suite to TAP
Automake provides a nice test harness that can parse TAP results, so
switch to using that.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-02-26 15:46:30 -08:00
Patrick McCarty 253dcbbbc0 Provide configure option to disable tests
Building the tests is enabled by default, but because the test suite
requires root privileges to run at the moment, people should have to
option to disable the tests entirely.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-02-26 15:44:21 -08:00
Patrick McCarty a11afb9d3b Cleanups for building with test coverage
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-02-26 15:42:59 -08:00
Patrick McCarty 33273c0f93 Release version 1.0.1
This release fixes a small issue with permissions on the target files
created by both bsdiff and bspatch, namely that there is no reason for
them not to be group and world readable.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-02-26 12:59:53 -08:00
Patrick McCarty 7525374a10 Open target files write-only and loosen their permissions
Because the target files are only written to, not read from, by either
bsdiff or bspatch, we can open them write-only.

Also, I don't see a reason for the file permissions to be 600, so loosen
the permissions to be 644.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2016-02-26 11:21:38 -08:00
7 changed files with 160 additions and 52 deletions
+7
View File
@@ -13,6 +13,7 @@ bsdump
bspatch
compile
configure
coverage/
depcomp
install-sh
libbsdiff.la
@@ -21,7 +22,13 @@ ltmain.sh
m4/
missing
src/.dirstamp
src/*.gcda
src/*.gcno
stamp-h1
bsdiff-*.tar.xz
test/*.diff
test/*.out
test/*.log
test/*.trs
tap-driver.sh
test-suite.log
+20
View File
@@ -0,0 +1,20 @@
sudo: required
dist: trusty
language: c
# Pre-install missing build dependencies:
# - valgrind (from the repo)
# - libcheck 0.9.10 is slightly too old, since 0.9.12 adds TAP support
before_install:
- sudo apt-get -qq update
- sudo apt-get install -y valgrind
install:
- wget http://downloads.sourceforge.net/project/check/check/0.10.0/check-0.10.0.tar.gz
- tar -xvf check-0.10.0.tar.gz
- pushd check-0.10.0 && ./configure --prefix=/usr && make -j48 && sudo make install && popd
# Ubuntu's default umask is 0002, but tests are written with the expectation of a 0022 default.
script:
- autoreconf --verbose --warnings=none --install --force && ./configure && make -j48 && sudo sh -c 'umask 0022 && make -j48 check'
after_failure: cat test-suite.log
+49 -3
View File
@@ -28,11 +28,15 @@ EXTRA_DIST = \
AUTOMAKE_OPTIONS = color-tests parallel-tests
if COVERAGE
coverage:
AM_CFLAGS += --coverage
coverage: coverage-clean
mkdir -p coverage
lcov --compat-libtool --directory . --capture --output-file coverage/report
genhtml -o coverage/ coverage/report
AM_CFLAGS += --coverage
coverage-clean:
rm -rf coverage
endif
bin_PROGRAMS = \
@@ -98,7 +102,49 @@ distclean-local:
install-exec-hook:
perl findstatic.pl */*.o | grep -v Checking ||:
check_PROGRAMS =
TEST_EXTENSIONS = .sh
EXTRA_DIST += \
test/data/5.bspatch.diff \
test/data/5.bspatch.original \
test/data/6.bspatch.diff \
test/data/6.bspatch.original \
test/data/7.bspatch.diff \
test/data/7.bspatch.original \
test/data/8.bspatch.diff \
test/data/8.bspatch.original \
test/data/9.bspatch.diff \
test/data/9.bspatch.modified \
test/data/9.bspatch.original \
test/data/10.bspatch.diff \
test/data/10.bspatch.modified \
test/data/10.bspatch.original \
test/data/11.bspatch.diff \
test/data/12.bspatch.diff \
test/data/12.bspatch.modified \
test/data/12.bspatch.original \
test/data/13.bspatch.modified \
test/data/13.bspatch.original \
test/data/14.bspatch.modified \
test/data/14.bspatch.original \
test/data/15.bspatch.modified \
test/data/15.bspatch.original \
test/data/16.bspatch.diff \
test/data/16.bspatch.original
if ENABLE_TESTS
AM_TESTS_ENVIRONMENT = \
abs_builddir=$(abs_builddir); export abs_builddir;
tap_driver = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh
LOG_DRIVER = $(tap_driver)
SH_LOG_DRIVER = $(tap_driver)
TESTS = $(dist_check_SCRIPTS)
dist_check_SCRIPTS = \
test/run.sh
endif
release:
@git rev-parse v$(PACKAGE_VERSION) &> /dev/null; \
+15 -2
View File
@@ -1,5 +1,5 @@
AC_PREREQ([2.66])
AC_INIT([bsdiff], [1.0.0], [patrick.mccarty@intel.com])
AC_INIT([bsdiff], [1.0.2], [patrick.mccarty@intel.com])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
AC_PROG_CC_STDC
@@ -14,7 +14,6 @@ AM_SILENT_RULES([yes])
LT_INIT
PKG_CHECK_MODULES([zlib], [zlib])
PKG_CHECK_MODULES([CHECK], [check >= 0.9])
AC_ARG_ENABLE([bzip2],
[AS_HELP_STRING([--disable-bzip2],[Do not use bzip2 compression (uses bzip2 by default)])])
@@ -33,6 +32,11 @@ AS_IF([test "$enable_lzma" != "no"], [
])
AM_CONDITIONAL([ENABLE_LZMA], [test "$enable_lzma" != "no"])
AC_ARG_ENABLE(
[tests],
[AS_HELP_STRING([--disable-tests], [Do not enable functional tests (enabled by default)])]
)
have_coverage=no
AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [enable test coverage]))
if test "x$enable_coverage" = "xyes" ; then
@@ -52,8 +56,17 @@ if test "x$enable_coverage" = "xyes" ; then
fi
AM_CONDITIONAL([COVERAGE], [test "$have_coverage" = "yes"])
AS_IF([test "$enable_tests" != "no"], [
PKG_CHECK_MODULES([CHECK], [check >= 0.9.12])
AC_PATH_PROG([have_valgrind], [valgrind])
AS_IF([test -z "${have_valgrind}"], [
AC_MSG_ERROR([Must have valgrind installed to run functional tests])
])
])
AM_CONDITIONAL([ENABLE_TESTS], [test "$enable_tests" != "no"])
AC_CONFIG_FILES([Makefile data/bsdiff.pc])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_OUTPUT
AC_MSG_RESULT([
+3 -3
View File
@@ -586,7 +586,7 @@ int make_bsdiff_delta(char *old_filename, char *new_filename, char *delta_filena
memset(&small_header, 0, sizeof(struct header_v21));
memcpy(&small_header.magic, BSDIFF_HDR_FULLDL, 8);
efd = open(delta_filename, O_CREAT | O_EXCL | O_RDWR, 00600);
efd = open(delta_filename, O_CREAT | O_EXCL | O_WRONLY, 00644);
if (efd < 0) {
close(fd);
return -1;
@@ -668,7 +668,7 @@ int make_bsdiff_delta(char *old_filename, char *new_filename, char *delta_filena
memset(&small_header, 0, sizeof(struct header_v21));
memcpy(&small_header.magic, BSDIFF_HDR_FULLDL, 8);
efd = open(delta_filename, O_CREAT | O_EXCL | O_RDWR, 00600);
efd = open(delta_filename, O_CREAT | O_EXCL | O_WRONLY, 00644);
if (efd < 0) {
close(fd);
munmap(old_data, oldsize);
@@ -883,7 +883,7 @@ int make_bsdiff_delta(char *old_filename, char *new_filename, char *delta_filena
/* Create the patch file */
efd = open(delta_filename, O_CREAT | O_EXCL | O_RDWR, 00600);
efd = open(delta_filename, O_CREAT | O_EXCL | O_WRONLY, 00644);
if (efd < 0) {
ret = -1;
goto fulldl_free;
+1 -1
View File
@@ -690,7 +690,7 @@ static int apply_delta_v2(int subver, FILE *f,
cfclose(&ef);
/* Write the new file */
fd = open(new_filename, O_CREAT | O_EXCL | O_WRONLY, 0600);
fd = open(new_filename, O_CREAT | O_EXCL | O_WRONLY, 00644);
if (fd < 0) {
ret = -1;
goto writeerror;
+65 -43
View File
@@ -1,57 +1,84 @@
#!/bin/bash
# $srcdir variable is set by automake environment
cd $srcdir/test
# number is incremented after running every test
testnum=0
sudo rm -f *.diff *.out
libdir="$(realpath "../.libs")"
libdir="$abs_builddir/.libs"
ldpath="LD_LIBRARY_PATH=$libdir"
BSDIFF="sudo $ldpath valgrind -q $libdir/bsdiff"
BSPATCH="sudo $ldpath valgrind -q $libdir/bspatch"
echo -n "5.."
# If exit status is 0, the test succeeded. Else it failed.
check_success() {
res=$?
[ -n "$1" ] && msg="$1" || msg=""
testnum=$(expr $testnum + 1)
if [ $res -ne 0 ]; then
echo "not ok $testnum - $msg"
else
echo "ok $testnum"
fi
}
# If exit status is 255, the test succeeded. Else it failed.
check_failure() {
res=$?
[ -n "$1" ] && msg="$1" || msg=""
testnum=$(expr $testnum + 1)
if [ $res -ne 255 ]; then
echo "not ok $testnum - $msg"
else
echo "ok $testnum"
fi
}
echo "Running test #5 ..."
$BSPATCH data/5.bspatch.original 5.out data/5.bspatch.diff
echo -n "6.."
check_success
echo "Running test #6 ..."
$BSPATCH data/6.bspatch.original 6.out data/6.bspatch.diff
echo -n "7.."
check_success
echo "Running test #7 ..."
$BSPATCH data/7.bspatch.original 7.out data/7.bspatch.diff
echo -n "8.."
check_success
echo "Running test #8 ..."
$BSPATCH data/8.bspatch.original 8.out data/8.bspatch.diff
echo -n "9.."
check_success
echo "Running test #9 ..."
$BSPATCH data/9.bspatch.original 9.out data/9.bspatch.diff
diff data/9.bspatch.modified 9.out
if [ $? -ne 0 ]
then
echo "bspatch 9 output does not match expected!!"
fi
echo -n "10.."
check_success "output does not match expected!!"
echo "Running test #10 ..."
$BSPATCH data/10.bspatch.original 10.out data/10.bspatch.diff
diff data/10.bspatch.modified 10.out
if [ $? -ne 0 ]
then
echo "bspatch 10 output does not match expected!!"
fi
check_success "output does not match expected!!"
#same as 9 but with zeros encoding
echo -n "11.."
echo "Running test #11 ..."
$BSPATCH data/9.bspatch.original 11.out data/11.bspatch.diff
diff data/9.bspatch.modified 11.out
if [ $? -ne 0 ]
then
echo "bspatch 11 output does not match expected!!"
fi
echo -n "12.."
check_success "output does not match expected!!"
echo "Running test #12 ..."
$BSPATCH data/12.bspatch.original 12.out data/12.bspatch.diff
diff data/12.bspatch.modified 12.out
if [ $? -ne 0 ]
then
echo "bspatch 12 output does not match expected!!"
fi
echo -n "13.."
check_success "output does not match expected!!"
echo "Running test #13 ..."
$BSDIFF data/13.bspatch.original data/13.bspatch.modified 13.diff any
$BSPATCH data/13.bspatch.original 13.out 13.diff
diff data/13.bspatch.modified 13.out
if [ $? -ne 0 ]
then
echo "bspatch 13 output does not match expected!!"
fi
check_success "output does not match expected!!"
# Next a very loooong running test, but one which successfully condenses the 2MB
# original file pair into a 26kB bsdiff. The bsdiff computation alone (ie:
@@ -62,26 +89,21 @@ fi
# used in a regression test run at every check-in of code changes to the bsdiff
# implementation.
#
#echo -n "14.."
#echo "Running test #14 ..."
#$BSDIFF data/14.bspatch.original data/14.bspatch.modified 14.diff any
#$BSPATCH data/14.bspatch.original 14.out 14.diff
#diff data/14.bspatch.modified 14.out
#if [ $? -ne 0 ]
#then
# echo "bspatch 14 output does not match expected!!"
#fi
#check_success "output does not match expected!!"
echo -n "15.."
echo "Running test #15 ..."
$BSDIFF data/15.bspatch.original data/15.bspatch.modified 15.diff any
# expected output: "Failed to create delta (-1)"
if [ $? -ne 255 ]
then
echo "bspatch 15 creation has memory management issue!"
fi
check_failure "patch creation has memory management issue!"
echo -n "16.."
echo "Running test #16 ..."
# any valgrind errors may indicate a buffer overflow
$BSPATCH data/16.bspatch.original 16.out data/16.bspatch.diff
check_success
# add final newline
echo ""
# For TAP support, output the plan
echo "1..${testnum}"