summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xdelta3/testing/regtest.cc3
-rwxr-xr-xxdelta3/testing/xdelta3-regtest.py2
-rw-r--r--xdelta3/xdelta3.c19
-rw-r--r--xdelta3/xdelta3.h15
4 files changed, 28 insertions, 11 deletions
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc
index f0b7a42..7a9884d 100644
--- a/xdelta3/testing/regtest.cc
+++ b/xdelta3/testing/regtest.cc
@@ -825,6 +825,7 @@ void TestMergeCommand2() {
825 825
826#define TEST(x) cerr << #x << "..." << endl; regtest.x() 826#define TEST(x) cerr << #x << "..." << endl; regtest.x()
827 827
828// These tests are primarily tests of the testing framework itself.
828template <class T> 829template <class T>
829void UnitTest() { 830void UnitTest() {
830 Regtest<T> regtest; 831 Regtest<T> regtest;
@@ -839,6 +840,7 @@ void UnitTest() {
839 TEST(TestOverwriteMutator); 840 TEST(TestOverwriteMutator);
840} 841}
841 842
843// These are Xdelta tests.
842template <class T> 844template <class T>
843void MainTest() { 845void MainTest() {
844 Regtest<T> regtest; 846 Regtest<T> regtest;
@@ -852,6 +854,7 @@ void MainTest() {
852 854
853#undef TEST 855#undef TEST
854 856
857// Run the unittests, followed by xdelta tests for various constants.
855int main(int argc, char **argv) { 858int main(int argc, char **argv) {
856 UnitTest<SmallBlock>(); 859 UnitTest<SmallBlock>();
857 MainTest<SmallBlock>(); 860 MainTest<SmallBlock>();
diff --git a/xdelta3/testing/xdelta3-regtest.py b/xdelta3/testing/xdelta3-regtest.py
index 94f527e..d0a602f 100755
--- a/xdelta3/testing/xdelta3-regtest.py
+++ b/xdelta3/testing/xdelta3-regtest.py
@@ -31,7 +31,7 @@ import xdelta3
31 31
32#RCSDIR = '/Users/jmacd/src/ftp.kernel.org/pub/scm/linux/kernel/bkcvs/linux-2.4/net/x25' 32#RCSDIR = '/Users/jmacd/src/ftp.kernel.org/pub/scm/linux/kernel/bkcvs/linux-2.4/net/x25'
33#RCSDIR = '/Users/jmacd/src/ftp.kernel.org/pub/scm/linux/kernel/bkcvs/linux-2.4/fs' 33#RCSDIR = '/Users/jmacd/src/ftp.kernel.org/pub/scm/linux/kernel/bkcvs/linux-2.4/fs'
34RCSDIR = '/Users/jmacd/src/kernel.org' 34RCSDIR = '/Users/jmacd/src/ftp.kernel.org'
35 35
36# 36#
37MIN_SIZE = 0 37MIN_SIZE = 0
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c
index 6d014aa..20bffdb 100644
--- a/xdelta3/xdelta3.c
+++ b/xdelta3/xdelta3.c
@@ -2513,7 +2513,7 @@ usize_t xd3_bytes_on_srcblk (xd3_source *src, xoff_t blkno)
2513} 2513}
2514 2514
2515/* This function interfaces with the client getblk function, checks 2515/* This function interfaces with the client getblk function, checks
2516 * its results, updates frontier_blkno, max_blkno, onlastblk. */ 2516 * its results, updates frontier_blkno, max_blkno, onlastblk, eof_known. */
2517static int 2517static int
2518xd3_getblk (xd3_stream *stream, xoff_t blkno) 2518xd3_getblk (xd3_stream *stream, xoff_t blkno)
2519{ 2519{
@@ -2547,7 +2547,8 @@ xd3_getblk (xd3_stream *stream, xoff_t blkno)
2547 { 2547 {
2548 source->frontier_blkno = blkno + 1; 2548 source->frontier_blkno = blkno + 1;
2549 2549
2550 IF_DEBUG2 (DP(RINT "[getblk] full source blkno %"Q"u: source length unknown %"Q"u\n", 2550 IF_DEBUG2 (DP(RINT "[getblk] full source blkno %"Q"u: "
2551 "source length unknown %"Q"u\n",
2551 blkno, 2552 blkno,
2552 xd3_source_eof (source))); 2553 xd3_source_eof (source)));
2553 } 2554 }
@@ -2555,7 +2556,8 @@ xd3_getblk (xd3_stream *stream, xoff_t blkno)
2555 { 2556 {
2556 if (!source->eof_known) 2557 if (!source->eof_known)
2557 { 2558 {
2558 IF_DEBUG2 (DP(RINT "[getblk] eof block has %d bytes; source length known %"Q"u\n", 2559 IF_DEBUG2 (DP(RINT "[getblk] eof block has %d bytes; "
2560 "source length known %"Q"u\n",
2559 xd3_bytes_on_srcblk (source, blkno), 2561 xd3_bytes_on_srcblk (source, blkno),
2560 xd3_source_eof (source))); 2562 xd3_source_eof (source)));
2561 source->eof_known = 1; 2563 source->eof_known = 1;
@@ -4364,9 +4366,14 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos)
4364 } 4366 }
4365 4367
4366 /* Implement srcwin_maxsz, which prevents the encoder from seeking 4368 /* Implement srcwin_maxsz, which prevents the encoder from seeking
4367 * back further than the LRU cache maintaining FIFO discipline, 4369 * back further than the LRU cache maintaining FIFO discipline, (to
4368 * which causes terrible performance. */ 4370 * avoid seeking). */
4369 frontier_pos = stream->src->frontier_blkno * stream->src->blksize; 4371 frontier_pos = stream->src->eof_known ?
4372 xd3_source_eof (stream->src) :
4373 (stream->src->frontier_blkno * stream->src->blksize);
4374 IF_DEBUG1(DP(RINT "[match_setup] frontier_pos %"Q"u, srcpos %"Q"u, "
4375 "srcwin_maxsz %u\n",
4376 frontier_pos, srcpos, stream->srcwin_maxsz));
4370 XD3_ASSERT (frontier_pos >= srcpos); 4377 XD3_ASSERT (frontier_pos >= srcpos);
4371 if (frontier_pos - srcpos > stream->srcwin_maxsz) { 4378 if (frontier_pos - srcpos > stream->srcwin_maxsz) {
4372 IF_DEBUG1(DP(RINT "[match_setup] rejected due to srcwin_maxsz " 4379 IF_DEBUG1(DP(RINT "[match_setup] rejected due to srcwin_maxsz "
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h
index f417dcf..c831ac1 100644
--- a/xdelta3/xdelta3.h
+++ b/xdelta3/xdelta3.h
@@ -752,10 +752,17 @@ struct _xd3_source
752 xoff_t getblkno; /* request block number: xd3 sets 752 xoff_t getblkno; /* request block number: xd3 sets
753 current getblk request */ 753 current getblk request */
754 754
755 xoff_t max_blkno; 755 /* See xd3_getblk() */
756 xoff_t frontier_blkno; 756 xoff_t max_blkno; /* Maximum block, if eof is known,
757 usize_t onlastblk; 757 * otherwise, equals frontier_blkno
758 int eof_known; 758 * (initially 0). */
759 xoff_t frontier_blkno; /* If eof is unknown, the next
760 * source position to be read.
761 * Otherwise, equal to
762 * max_blkno. */
763 usize_t onlastblk; /* Number of bytes on max_blkno */
764 int eof_known; /* Set to true when the first
765 * partial block is read. */
759}; 766};
760 767
761/* The primary xd3_stream object, used for encoding and decoding. You 768/* The primary xd3_stream object, used for encoding and decoding. You