diff options
author | openvcdiff <openvcdiff@132ac840-3546-0410-a738-d3f8764196be> | 2008-10-23 23:43:46 +0000 |
---|---|---|
committer | openvcdiff <openvcdiff@132ac840-3546-0410-a738-d3f8764196be> | 2008-10-23 23:43:46 +0000 |
commit | 83bbde0df33922d8dc6fa737cfb306d9caae13b1 (patch) | |
tree | 2c96aa0fe5333a36a9d7dc05a43d16b91e6d4487 | |
parent | 28db8079f707ebdf43ce62cdfd96eb39c8f889e0 (diff) | |
download | open-vcdiff-83bbde0df33922d8dc6fa737cfb306d9caae13b1.tar.gz |
Thu, 23 Oct 2008 09:03:56 -0700 Google Inc. <opensource@google.com>
* Issue #6: vcdiff crashes with zero-size dictionary
* Add special cases for empty dictionary file in vcdiff_main.cc.
* Issue #7: vcdiff incorrect binary I/O on Windows
* Change stdin/stdout file type to binary in vcdiff_main.cc.
* Issue #13: Add unit test for vcdiff command-line executable
* Unit test vcdiff_test.bat added for Visual Studio testing of vcdiff.exe.
Includes regression tests for issues #6 and #7.
* Issue #15: open-vcdiff fails to compile on Fedora 9
* Apply patch sent by Daniel Kegel
* Add header <string.h> to src/vcdiffengine.cc, which uses memcpy.
* Remove const qualifier from integral return types to fix gcc 4.3.1
warning.
* Add contributors' names to THANKS file.
git-svn-id: http://open-vcdiff.googlecode.com/svn/trunk@21 132ac840-3546-0410-a738-d3f8764196be
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | Makefile.in | 5 | ||||
-rw-r--r-- | THANKS | 7 | ||||
-rwxr-xr-x | configure | 20 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | packages/deb/changelog | 18 | ||||
-rw-r--r-- | src/addrcache.h | 8 | ||||
-rw-r--r-- | src/blockhash.cc | 2 | ||||
-rw-r--r-- | src/blockhash.h | 8 | ||||
-rw-r--r-- | src/vcdecoder4_test.cc | 4 | ||||
-rw-r--r-- | src/vcdiff_main.cc | 53 | ||||
-rwxr-xr-x | src/vcdiff_test.sh | 4 | ||||
-rw-r--r-- | src/vcdiffengine.cc | 1 | ||||
-rw-r--r-- | testdata/empty_file.txt | 0 | ||||
-rw-r--r-- | vsprojects/config.h | 6 | ||||
-rw-r--r-- | vsprojects/open-vcdiff.sln | 59 | ||||
-rwxr-xr-x | vsprojects/vcdiff_test.bat | 459 | ||||
-rw-r--r-- | vsprojects/vcdiff_test/vcdiff_test.vcproj | 135 |
19 files changed, 747 insertions, 63 deletions
@@ -1,3 +1,19 @@ +Thu, 23 Oct 2008 09:03:56 -0700 Google Inc. <opensource@google.com> + + * Issue #6: vcdiff crashes with zero-size dictionary + * Add special cases for empty dictionary file in vcdiff_main.cc. + * Issue #7: vcdiff incorrect binary I/O on Windows + * Change stdin/stdout file type to binary in vcdiff_main.cc. + * Issue #13: Add unit test for vcdiff command-line executable + * Unit test vcdiff_test.bat added for Visual Studio testing of vcdiff.exe. + Includes regression tests for issues #6 and #7. + * Issue #15: open-vcdiff fails to compile on Fedora 9 + * Apply patch sent by Daniel Kegel + * Add header <string.h> to src/vcdiffengine.cc, which uses memcpy. + * Remove const qualifier from integral return types to fix gcc 4.3.1 + warning. + * Add contributors' names to THANKS file. + Fri, 10 Oct 2008 11:16:23 -0700 Google Inc. <opensource@google.com> * Issue #15: open-vcdiff fails to compile on Fedora 9 diff --git a/Makefile.am b/Makefile.am index dfa4d55..1447661 100644 --- a/Makefile.am +++ b/Makefile.am @@ -211,8 +211,10 @@ EXTRA_DIST = $(check_SCRIPTS) \ packages/rpm/rpm.spec \ packages/deb.sh \ packages/deb \ + testdata/empty_file.txt \ vsprojects/config.h \ vsprojects/stdint.h \ + vsprojects/vcdiff_test.bat \ vsprojects/open-vcdiff.sln \ vsprojects/addrcache_test/addrcache_test.vcproj \ vsprojects/blockhash_test/blockhash_test.vcproj \ @@ -231,4 +233,5 @@ EXTRA_DIST = $(check_SCRIPTS) \ vsprojects/vcdenc/vcdenc.vcproj \ vsprojects/vcdiff/vcdiff.vcproj \ vsprojects/vcdiffengine_test/vcdiffengine_test.vcproj \ + vsprojects/vcdiff_test/vcdiff_test.vcproj \ vsprojects/vcencoder_test/vcencoder_test.vcproj diff --git a/Makefile.in b/Makefile.in index f3c1219..ab485a4 100644 --- a/Makefile.in +++ b/Makefile.in @@ -452,8 +452,10 @@ EXTRA_DIST = $(check_SCRIPTS) \ packages/rpm/rpm.spec \ packages/deb.sh \ packages/deb \ + testdata/empty_file.txt \ vsprojects/config.h \ vsprojects/stdint.h \ + vsprojects/vcdiff_test.bat \ vsprojects/open-vcdiff.sln \ vsprojects/addrcache_test/addrcache_test.vcproj \ vsprojects/blockhash_test/blockhash_test.vcproj \ @@ -472,6 +474,7 @@ EXTRA_DIST = $(check_SCRIPTS) \ vsprojects/vcdenc/vcdenc.vcproj \ vsprojects/vcdiff/vcdiff.vcproj \ vsprojects/vcdiffengine_test/vcdiffengine_test.vcproj \ + vsprojects/vcdiff_test/vcdiff_test.vcproj \ vsprojects/vcencoder_test/vcencoder_test.vcproj all: all-am @@ -1353,7 +1356,7 @@ check-TESTS: $(TESTS) distdir: $(DISTFILES) $(am__remove_distdir) mkdir $(distdir) - $(mkdir_p) $(distdir)/m4 $(distdir)/man $(distdir)/packages $(distdir)/packages/rpm $(distdir)/src $(distdir)/src/google $(distdir)/src/gtest $(distdir)/testdata $(distdir)/vsprojects $(distdir)/vsprojects/addrcache_test $(distdir)/vsprojects/blockhash_test $(distdir)/vsprojects/codetable_test $(distdir)/vsprojects/decodetable_test $(distdir)/vsprojects/encodetable_test $(distdir)/vsprojects/gtest $(distdir)/vsprojects/headerparser_test $(distdir)/vsprojects/instruction_map_test $(distdir)/vsprojects/output_string_test $(distdir)/vsprojects/rolling_hash_test $(distdir)/vsprojects/varint_bigendian_test $(distdir)/vsprojects/vcdcom $(distdir)/vsprojects/vcddec $(distdir)/vsprojects/vcdecoder_test $(distdir)/vsprojects/vcdenc $(distdir)/vsprojects/vcdiff $(distdir)/vsprojects/vcdiffengine_test $(distdir)/vsprojects/vcencoder_test + $(mkdir_p) $(distdir)/m4 $(distdir)/man $(distdir)/packages $(distdir)/packages/rpm $(distdir)/src $(distdir)/src/google $(distdir)/src/gtest $(distdir)/testdata $(distdir)/vsprojects $(distdir)/vsprojects/addrcache_test $(distdir)/vsprojects/blockhash_test $(distdir)/vsprojects/codetable_test $(distdir)/vsprojects/decodetable_test $(distdir)/vsprojects/encodetable_test $(distdir)/vsprojects/gtest $(distdir)/vsprojects/headerparser_test $(distdir)/vsprojects/instruction_map_test $(distdir)/vsprojects/output_string_test $(distdir)/vsprojects/rolling_hash_test $(distdir)/vsprojects/varint_bigendian_test $(distdir)/vsprojects/vcdcom $(distdir)/vsprojects/vcddec $(distdir)/vsprojects/vcdecoder_test $(distdir)/vsprojects/vcdenc $(distdir)/vsprojects/vcdiff $(distdir)/vsprojects/vcdiff_test $(distdir)/vsprojects/vcdiffengine_test $(distdir)/vsprojects/vcencoder_test @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ @@ -7,6 +7,7 @@ Many people further contributed to open-vcdiff by reporting problems, suggesting various improvements or submitting actual code. Here is a list of these people. Help me keep it complete and free of errors. +Jens Alfke Daniel Berlin Jon Butler Wiltse Carpenter @@ -14,11 +15,14 @@ Jagannadh Chukka Eric Dorland Eric Flatt David Glasser +Jeff Gustafson +Pawel Hajdan jr Bijun He Jacob Hoffman-Andrews Ashu Jain -Leonidas Kontothanassis +Daniel Kegel Michael Kleber +Leonidas Kontothanassis Wei-Hsin Lee Frank Lin Josh MacDonald @@ -28,6 +32,7 @@ Jim Morrison Alex Raikman David Rochberg Jim Roskind +Craig Schlenter Robin Shostack Adeodato Simo Ben Smith @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for open-vcdiff 0.3. +# Generated by GNU Autoconf 2.59 for open-vcdiff 0.4. # # Report bugs to <opensource@google.com>. # @@ -423,8 +423,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='open-vcdiff' PACKAGE_TARNAME='open-vcdiff' -PACKAGE_VERSION='0.3' -PACKAGE_STRING='open-vcdiff 0.3' +PACKAGE_VERSION='0.4' +PACKAGE_STRING='open-vcdiff 0.4' PACKAGE_BUGREPORT='opensource@google.com' ac_unique_file="README" @@ -954,7 +954,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures open-vcdiff 0.3 to adapt to many kinds of systems. +\`configure' configures open-vcdiff 0.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1020,7 +1020,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of open-vcdiff 0.3:";; + short | recursive ) echo "Configuration of open-vcdiff 0.4:";; esac cat <<\_ACEOF @@ -1159,7 +1159,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -open-vcdiff configure 0.3 +open-vcdiff configure 0.4 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1173,7 +1173,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by open-vcdiff $as_me 0.3, which was +It was created by open-vcdiff $as_me 0.4, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1817,7 +1817,7 @@ fi # Define the identity of the package. PACKAGE='open-vcdiff' - VERSION='0.3' + VERSION='0.4' cat >>confdefs.h <<_ACEOF @@ -21166,7 +21166,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by open-vcdiff $as_me 0.3, which was +This file was extended by open-vcdiff $as_me 0.4, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21229,7 +21229,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -open-vcdiff config.status 0.3 +open-vcdiff config.status 0.4 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index e1d9234..24fee58 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ # make sure we're interpreted by some minimal autoconf AC_PREREQ(2.57) -AC_INIT(open-vcdiff, 0.3, opensource@google.com) +AC_INIT(open-vcdiff, 0.4, opensource@google.com) AC_CONFIG_SRCDIR(README) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(src/config.h) diff --git a/packages/deb/changelog b/packages/deb/changelog index 6cfb830..8a7c781 100644 --- a/packages/deb/changelog +++ b/packages/deb/changelog @@ -1,3 +1,21 @@ +open-vcdiff (0.4-1) unstable; urgency=low + + * Issue #15: open-vcdiff fails to compile on Fedora 9 + * Apply patch sent by Daniel Kegel + * Add header <string.h> to src/vcdiffengine.cc, which uses memcpy. + * Remove const qualifier from integral return types to fix gcc 4.3.1 + warning. + * Issue #6: vcdiff crashes with zero-size dictionary + * Add special cases for empty dictionary file in vcdiff_main.cc. + * Issue #7: vcdiff incorrect binary I/O on Windows + * Change stdin/stdout file type to binary in vcdiff_main.cc. + * Issue #13: Add unit test for vcdiff command-line executable + * Unit test vcdiff_test.bat added for Visual Studio testing of vcdiff.exe. + Includes regression tests for issues #6 and #7. + * Add contributors' names to THANKS file. + + -- Google Inc. <opensource@google.com> Thu, 23 Oct 2008 09:03:56 -0700 + open-vcdiff (0.3-1) unstable; urgency=low * Issue #15: open-vcdiff fails to compile on Fedora 9 diff --git a/src/addrcache.h b/src/addrcache.h index 2974809..0aea65d 100644 --- a/src/addrcache.h +++ b/src/addrcache.h @@ -65,7 +65,7 @@ class VCDiffAddressCache { // an element of the near_addresses_ array, where a recently-referenced // address is stored. // - static const unsigned char FirstNearMode() { + static unsigned char FirstNearMode() { return VCD_FIRST_NEAR_MODE; } @@ -75,18 +75,18 @@ class VCDiffAddressCache { // 8 bits of the address are used to find the element of this block that // may match the desired address value. // - const unsigned char FirstSameMode() const { + unsigned char FirstSameMode() const { return VCD_FIRST_NEAR_MODE + near_cache_size(); } // Returns the maximum valid mode number, which happens to be // the last SAME mode. // - const unsigned char LastMode() const { + unsigned char LastMode() const { return FirstSameMode() + same_cache_size() - 1; } - static const unsigned char DefaultLastMode() { + static unsigned char DefaultLastMode() { return VCD_FIRST_NEAR_MODE + kDefaultNearCacheSize + kDefaultSameCacheSize - 1; } diff --git a/src/blockhash.cc b/src/blockhash.cc index d568d52..76461cc 100644 --- a/src/blockhash.cc +++ b/src/blockhash.cc @@ -105,7 +105,7 @@ BlockHash* BlockHash::CreateTargetHash(const char* target_data, } // Returns zero if an error occurs. -const size_t BlockHash::CalcTableSize(const size_t dictionary_size) { +size_t BlockHash::CalcTableSize(const size_t dictionary_size) { // Overallocate the hash table by making it the same size (in bytes) // as the source data. This is a trade-off between space and time: // the empty entries in the hash table will reduce the diff --git a/src/blockhash.h b/src/blockhash.h index 8b7f948..48c09fd 100644 --- a/src/blockhash.h +++ b/src/blockhash.h @@ -333,9 +333,9 @@ class BlockHash { // the dictionary_size. Will return a power of two if successful, or 0 if an // internal error occurs. Some calculations (such as GetHashTableIndex()) // depend on the table size being a power of two. - static const size_t CalcTableSize(const size_t dictionary_size); + static size_t CalcTableSize(const size_t dictionary_size); - const size_t GetNumberOfBlocks() const { + size_t GetNumberOfBlocks() const { return source_size_ / kBlockSize; } @@ -353,8 +353,8 @@ class BlockHash { static inline bool TooManyMatches(int* match_counter); - const char* const source_data() { return source_data_; } - const size_t source_size() { return source_size_; } + const char* source_data() { return source_data_; } + size_t source_size() { return source_size_; } // Adds an entry to the hash table for one block of source data of length // kBlockSize, starting at source_data_[block_number * kBlockSize], diff --git a/src/vcdecoder4_test.cc b/src/vcdecoder4_test.cc index a77aa46..fa8cb43 100644 --- a/src/vcdecoder4_test.cc +++ b/src/vcdecoder4_test.cc @@ -279,10 +279,10 @@ TEST_F(VCDiffStandardWindowDecoderTest, Decode) { // tries to allocate ~MAX_INT bytes. TEST_F(VCDiffStandardWindowDecoderTest, DecodeBreakInFourthWindowHeader) { // Parse file header + first two windows. - const int chunk_1_size = delta_file_header_.size() + 83; + const size_t chunk_1_size = delta_file_header_.size() + 83; // Parse third window, plus everything up to "Size of the target window" field // of fourth window, but do not parse complete header of fourth window. - const int chunk_2_size = 12 + 5; + const size_t chunk_2_size = 12 + 5; CHECK_EQ(VCD_TARGET, static_cast<unsigned char>(delta_file_[chunk_1_size])); CHECK_EQ(0x00, static_cast<int>(delta_file_[chunk_1_size + chunk_2_size])); string output_chunk1, output_chunk2, output_chunk3; diff --git a/src/vcdiff_main.cc b/src/vcdiff_main.cc index e8388a4..084be5d 100644 --- a/src/vcdiff_main.cc +++ b/src/vcdiff_main.cc @@ -18,6 +18,10 @@ #include <config.h> #include <assert.h> #include <errno.h> +#ifdef WIN32 +#include <fcntl.h> +#include <io.h> +#endif // WIN32 #include <stdio.h> #include <string.h> // strerror #include <memory> @@ -231,13 +235,15 @@ bool VCDiffFileBasedCoder::OpenDictionary() { return false; } dictionary_.resize(dictionary_size); - if (fread(&dictionary_[0], 1, dictionary_size, dictionary_file) - != dictionary_size) { - LOG(ERROR) << "Unable to read dictionary file '" << FLAGS_dictionary - << "': " << strerror(errno) << LOG_ENDL; - fclose(dictionary_file); - dictionary_.clear(); - return false; + if (dictionary_size > 0) { + if (fread(&dictionary_[0], 1, dictionary_size, dictionary_file) + != dictionary_size) { + LOG(ERROR) << "Unable to read dictionary file '" << FLAGS_dictionary + << "': " << strerror(errno) << LOG_ENDL; + fclose(dictionary_file); + dictionary_.clear(); + return false; + } } fclose(dictionary_file); return true; @@ -250,6 +256,9 @@ bool VCDiffFileBasedCoder::OpenFileForReading(const string& file_name, assert(buffer->empty()); size_t buffer_size = 0U; if (!*file && file_name.empty()) { +#ifdef WIN32 + _setmode(_fileno(stdin), _O_BINARY); +#endif *file = stdin; buffer_size = static_cast<size_t>(FLAGS_buffersize); } else { @@ -287,6 +296,9 @@ bool VCDiffFileBasedCoder::OpenFileForReading(const string& file_name, // whose buffer is resized as needed. bool VCDiffFileBasedCoder::OpenOutputFile() { if (output_file_name_.empty()) { +#ifdef WIN32 + _setmode(_fileno(stdout), _O_BINARY); +#endif output_file_ = stdout; } else { output_file_ = fopen(output_file_name_.c_str(), "wb"); @@ -366,8 +378,15 @@ bool VCDiffFileBasedCoder::Encode() { if (!OpenDictionary() || !OpenInputFile() || !OpenOutputFile()) { return false; } - hashed_dictionary_.reset( - new open_vcdiff::HashedDictionary(&dictionary_[0], dictionary_.size())); + // Issue 6: Visual Studio STL produces a runtime exception + // if &dictionary_[0] is attempted for an empty dictionary. + if (dictionary_.empty()) { + hashed_dictionary_.reset(new open_vcdiff::HashedDictionary("", 0)); + } else { + hashed_dictionary_.reset( + new open_vcdiff::HashedDictionary(&dictionary_[0], + dictionary_.size())); + } if (!hashed_dictionary_->Init()) { LOG(ERROR) << "Error initializing hashed dictionary" << LOG_ENDL; return false; @@ -437,7 +456,13 @@ bool VCDiffFileBasedCoder::Decode() { string output; size_t input_size = 0; size_t output_size = 0; - decoder.StartDecoding(&dictionary_[0], dictionary_.size()); + // Issue 6: Visual Studio STL produces a runtime exception + // if &dictionary_[0] is attempted for an empty dictionary. + if (dictionary_.empty()) { + decoder.StartDecoding("", 0); + } else { + decoder.StartDecoding(&dictionary_[0], dictionary_.size()); + } do { size_t bytes_read = 0; @@ -492,7 +517,13 @@ bool VCDiffFileBasedCoder::DecodeAndCompare() { string output; size_t input_size = 0; size_t output_size = 0; - decoder.StartDecoding(&dictionary_[0], dictionary_.size()); + // Issue 6: Visual Studio STL produces a runtime exception + // if &dictionary_[0] is attempted for an empty dictionary. + if (dictionary_.empty()) { + decoder.StartDecoding("", 0); + } else { + decoder.StartDecoding(&dictionary_[0], dictionary_.size()); + } do { size_t bytes_read = 0; diff --git a/src/vcdiff_test.sh b/src/vcdiff_test.sh index 19cd93d..8d474a9 100755 --- a/src/vcdiff_test.sh +++ b/src/vcdiff_test.sh @@ -15,6 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# This script tests the correctness of the vcdiff command-line executable. +# If you add a new test here, please add the same test to the Windows script +# vsprojects/vcdiff_test.bat. +# # The caller should set the environment variable $srcdir to the root directory # of the open-vcdiff package. ($srcdir is automatically provided by Automake # when this script is run by "make check".) diff --git a/src/vcdiffengine.cc b/src/vcdiffengine.cc index 1254e46..4d65439 100644 --- a/src/vcdiffengine.cc +++ b/src/vcdiffengine.cc @@ -16,6 +16,7 @@ #include <config.h> #include "vcdiffengine.h" #include <stdint.h> // uint32_t +#include <string.h> // memcpy #include "blockhash.h" #include "encodetable.h" #include "logging.h" diff --git a/testdata/empty_file.txt b/testdata/empty_file.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/testdata/empty_file.txt diff --git a/vsprojects/config.h b/vsprojects/config.h index dbdb139..688e2e2 100644 --- a/vsprojects/config.h +++ b/vsprojects/config.h @@ -45,19 +45,19 @@ #define PACKAGE_NAME "open-vcdiff" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "open-vcdiff 0.3" +#define PACKAGE_STRING "open-vcdiff 0.4" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "open-vcdiff" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.3" +#define PACKAGE_VERSION "0.4" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Version number of package */ -#define VERSION "0.3" +#define VERSION "0.4" // These functions have different names, but the same behavior, // for Visual Studio. diff --git a/vsprojects/open-vcdiff.sln b/vsprojects/open-vcdiff.sln index 24063e1..ec1defd 100644 --- a/vsprojects/open-vcdiff.sln +++ b/vsprojects/open-vcdiff.sln @@ -15,99 +15,104 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcdenc", "vcdenc\vcdenc.vcp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcdiff", "vcdiff\vcdiff.vcproj", "{D11A04C5-0B05-4E08-AAB2-8BC64DE56A84}" ProjectSection(ProjectDependencies) = postProject - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} - {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} + {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "addrcache_test", "addrcache_test\addrcache_test.vcproj", "{23DDE803-E417-41CE-9D24-B823A990D0FC}" ProjectSection(ProjectDependencies) = postProject - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "headerparser_test", "headerparser_test\headerparser_test.vcproj", "{B1995AAE-F24B-4079-8F6B-8333ED6B13A6}" ProjectSection(ProjectDependencies) = postProject - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} - {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcdecoder_test", "vcdecoder_test\vcdecoder_test.vcproj", "{BA30F970-A2B3-4D04-81D5-B5C73794BEDE}" ProjectSection(ProjectDependencies) = postProject - {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} + {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcencoder_test", "vcencoder_test\vcencoder_test.vcproj", "{CB30C697-D33C-4410-94DE-D7CC481A5284}" ProjectSection(ProjectDependencies) = postProject - {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} - {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} + {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "output_string_test", "output_string_test\output_string_test.vcproj", "{3E9B97B7-7C57-44EB-BBBC-2C3B56595F0E}" ProjectSection(ProjectDependencies) = postProject - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "blockhash_test", "blockhash_test\blockhash_test.vcproj", "{11C53677-B705-42C2-B50F-87F5E599ABF1}" ProjectSection(ProjectDependencies) = postProject - {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} + {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "codetable_test", "codetable_test\codetable_test.vcproj", "{43DD2BA4-493D-49B7-825E-10279C89F0F9}" ProjectSection(ProjectDependencies) = postProject - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "decodetable_test", "decodetable_test\decodetable_test.vcproj", "{CCA8B377-0D14-4AD3-B5D8-7DD935A2D6D8}" ProjectSection(ProjectDependencies) = postProject - {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} + {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} = {1066F2E6-3F29-4D3D-9BBA-FD1D360099DD} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "encodetable_test", "encodetable_test\encodetable_test.vcproj", "{893DCA29-2740-4C49-993F-42A9B1EF365B}" ProjectSection(ProjectDependencies) = postProject - {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} + {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rolling_hash_test", "rolling_hash_test\rolling_hash_test.vcproj", "{A9879052-0DD1-413D-B631-A82044BFCF1A}" ProjectSection(ProjectDependencies) = postProject - {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} + {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "varint_bigendian_test", "varint_bigendian_test\varint_bigendian_test.vcproj", "{9A887AB5-E053-4ED6-870B-3330A1F4ED83}" ProjectSection(ProjectDependencies) = postProject - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcdiffengine_test", "vcdiffengine_test\vcdiffengine_test.vcproj", "{890398AC-020D-48C7-A054-6E03B1403AC7}" ProjectSection(ProjectDependencies) = postProject - {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} - {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} + {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "gtest\gtest.vcproj", "{429392EB-55A9-4344-913C-DEE5F02B538D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "instruction_map_test", "instruction_map_test\instruction_map_test.vcproj", "{ABFF6897-3B7F-41FB-BB70-15E47AC81856}" ProjectSection(ProjectDependencies) = postProject - {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} - {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} = {A49D16EE-E69E-4B5D-9CB7-ABEF79BB4246} + {429392EB-55A9-4344-913C-DEE5F02B538D} = {429392EB-55A9-4344-913C-DEE5F02B538D} + {C498DA26-B014-44BD-A387-EB6C3CE16FCF} = {C498DA26-B014-44BD-A387-EB6C3CE16FCF} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcdiff_test", "vcdiff_test\vcdiff_test.vcproj", "{EDC1569F-95B3-4536-9674-6AD9A0ADAAF4}" + ProjectSection(ProjectDependencies) = postProject + {D11A04C5-0B05-4E08-AAB2-8BC64DE56A84} = {D11A04C5-0B05-4E08-AAB2-8BC64DE56A84} EndProjectSection EndProject Global @@ -188,6 +193,10 @@ Global {ABFF6897-3B7F-41FB-BB70-15E47AC81856}.Debug|Win32.Build.0 = Debug|Win32 {ABFF6897-3B7F-41FB-BB70-15E47AC81856}.Release|Win32.ActiveCfg = Release|Win32 {ABFF6897-3B7F-41FB-BB70-15E47AC81856}.Release|Win32.Build.0 = Release|Win32 + {EDC1569F-95B3-4536-9674-6AD9A0ADAAF4}.Debug|Win32.ActiveCfg = Debug|Win32 + {EDC1569F-95B3-4536-9674-6AD9A0ADAAF4}.Debug|Win32.Build.0 = Debug|Win32 + {EDC1569F-95B3-4536-9674-6AD9A0ADAAF4}.Release|Win32.ActiveCfg = Release|Win32 + {EDC1569F-95B3-4536-9674-6AD9A0ADAAF4}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/vsprojects/vcdiff_test.bat b/vsprojects/vcdiff_test.bat new file mode 100755 index 0000000..bcc9b90 --- /dev/null +++ b/vsprojects/vcdiff_test.bat @@ -0,0 +1,459 @@ +@echo off +rem Copyright 2008 Google Inc. +rem Author: Lincoln Smith +rem +rem Licensed under the Apache License, Version 2.0 (the "License"); +rem you may not use this file except in compliance with the License. +rem You may obtain a copy of the License at +rem +rem http:#www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. +rem +rem This script tests the correctness of the vcdiff.exe command-line +rem executable. It is the Windows equivalent of the src/vcdiff_test.sh +rem shell script for Unix systems, though some of the tests from that +rem script are not included here. +rem +rem If you add a new test here, please add the same test to +rem src/vcdiff_test.sh. + +rem The script should be passed one argument which is the location of the +rem vcdiff.exe executable. +if not exist %1 ^ + ( echo Must pass location of vcdiff.exe as script argument ^ + &&exit /b 1 ) +set VCDIFF=%1 + +rem These options are only needed for the encoder; +rem the decoder will recognize the interleaved and checksum formats +rem without needing to specify any options. +set TESTDATA_DIR=..\..\testdata +set VCD_OPTIONS=-interleaved -checksum +set DICTIONARY_FILE=%TESTDATA_DIR%\configure.ac.v0.1 +set TARGET_FILE=%TESTDATA_DIR%\configure.ac.v0.2 +set DELTA_FILE=%TEMP%\configure.ac.vcdiff +set OUTPUT_TARGET_FILE=%TEMP%\configure.ac.output +set MALICIOUS_ENCODING=%TESTDATA_DIR%\allocates_4gb.vcdiff +set EMPTY_FILE=%TESTDATA_DIR%\empty_file.txt + +rem vcdiff with no arguments shows usage information & error result +%VCDIFF% ^ + && ( echo vcdiff with no arguments should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 1 ok + +rem vcdiff with three arguments but without "encode" or "decode" +rem shows usage information & error result +%VCDIFF% %VCD_OPTIONS% ^ + -dictionary %DICTIONARY_FILE% -target %TARGET_FILE% -delta %DELTA_FILE% ^ + && ( echo vcdiff without operation argument should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 2 ok + +rem vcdiff with all three arguments. Verify that output file matches target file +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + || ( echo Encode with three arguments failed ^ + &&exit /b 1 ) +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + -delta %DELTA_FILE% ^ + -target %OUTPUT_TARGET_FILE% ^ + || ( echo Decode with three arguments failed ^ + &&exit /b 1 ) +fc /b %TARGET_FILE% %OUTPUT_TARGET_FILE% ^ + || ( echo Decoded target does not match original ^ + &&exit /b 1 ) +echo Test 3 ok + +del %DELTA_FILE% +del %OUTPUT_TARGET_FILE% + +rem open-vcdiff Issue 7 +rem (http://code.google.com/p/open-vcdiff/issues/detail?id=7) +rem vcdiff using stdin/stdout. Verify that output file matches target file +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + < %TARGET_FILE% ^ + > %DELTA_FILE% ^ + || ( echo Encode using stdin/stdout failed ^ + &&exit /b 1 ) +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + < %DELTA_FILE% ^ + > %OUTPUT_TARGET_FILE% ^ + || ( echo Decode using stdin/stdout failed ^ + &&exit /b 1 ) +fc /b %TARGET_FILE% %OUTPUT_TARGET_FILE% ^ + || ( echo Decoded target does not match original ^ + &&exit /b 1 ) +echo Test 4 ok + +del %DELTA_FILE% +del %OUTPUT_TARGET_FILE% + +rem vcdiff with mixed stdin/stdout. +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + > %DELTA_FILE% ^ + || ( echo Encode with mixed arguments failed ^ + &&exit /b 1 ) +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + -delta %DELTA_FILE% ^ + > %OUTPUT_TARGET_FILE% ^ + || ( echo Decode with mixed arguments failed ^ + &&exit /b 1 ) +fc /b %TARGET_FILE% %OUTPUT_TARGET_FILE% ^ + || ( echo Decoded target does not match original ^ + &&exit /b 1 ) +echo Test 5 ok + +del %DELTA_FILE% +del %OUTPUT_TARGET_FILE% + +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + < %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + || ( echo Encode with mixed arguments failed ^ + &&exit /b 1 ) +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + < %DELTA_FILE% ^ + -target %OUTPUT_TARGET_FILE% ^ + || ( echo Decode with mixed arguments failed ^ + &&exit /b 1 ) +fc /b %TARGET_FILE% %OUTPUT_TARGET_FILE% ^ + || ( echo Decoded target does not match original ^ + &&exit /b 1 ) +echo Test 6 ok + +del %OUTPUT_TARGET_FILE% +rem Don't remove %DELTA_FILE%; use it for the next test + +rem If using the wrong dictionary, and dictionary is smaller than the original +rem dictionary, vcdiff will spot the mistake and return an error. (It can't +rem detect the case where the wrong dictionary is larger than the right one.) +%VCDIFF% decode -dictionary %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -target %OUTPUT_TARGET_FILE% ^ + && ( echo Decode using larger dictionary should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 7 ok + +del %DELTA_FILE% +del %OUTPUT_TARGET_FILE% + +rem "vcdiff test" with all three arguments. +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + || ( echo vcdiff test with three arguments failed ^ + &&exit /b 1 ) +echo Test 8 ok + +del %DELTA_FILE% + +rem Dictionary file not found. +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %TEMP%\nonexistent_file ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + && ( echo vcdiff with missing dictionary file should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 9 ok + +rem Target file not found. +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + -target %TEMP%\nonexistent_file ^ + -delta %DELTA_FILE% ^ + && ( echo vcdiff with missing target file should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 10 ok + +rem Delta file not found. +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + -delta %TEMP%\nonexistent_file ^ + -target %OUTPUT_TARGET_FILE% ^ + && ( echo vcdiff with missing delta file should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 11 ok + +rem Test using -stats flag +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -stats ^ + || ( echo Encode with -stats failed ^ + &&exit /b 1 ) +%VCDIFF% -stats ^ + decode -dictionary %DICTIONARY_FILE% ^ + -delta %DELTA_FILE% ^ + -target %OUTPUT_TARGET_FILE% ^ + || ( echo Decode with -stats failed ^ + &&exit /b 1 ) +fc /b %TARGET_FILE% %OUTPUT_TARGET_FILE% ^ + || ( echo Decoded target does not match original ^ + &&exit /b 1 ) +echo Test 13 ok + +del %DELTA_FILE% +del %OUTPUT_TARGET_FILE% + +rem open-vcdiff Issue 6 +rem (http://code.google.com/p/open-vcdiff/issues/detail?id=6) +rem Using empty file as dictionary should work, but (because dictionary is empty) +rem it will not produce a small delta file. +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %EMPTY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -stats ^ + || ( echo vcdiff test with empty file as dictionary failed ^ + &&exit /b 1 ) +echo Test 14 ok + +del %DELTA_FILE% + +rem Decode using something that isn't a delta file +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + -delta %DICTIONARY_FILE% ^ + -target %OUTPUT_TARGET_FILE% ^ + && ( echo vcdiff with invalid delta file should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 17 ok + +%VCDIFF% %VCD_OPTIONS% ^ + encode -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -dictionary ^ + && ( echo -dictionary option with no file name should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 18 ok + +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + -delta %DELTA_FILE% ^ + -target ^ + && ( echo -target option with no file name should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 19 ok + +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta ^ + && ( echo -delta option with no file name should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 20 ok + +%VCDIFF% %VCD_OPTIONS% ^ + encode -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -buffersize ^ + && ( echo -buffersize option with no argument should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 21 ok + +rem Using -buffersize=1 should still work. +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -buffersize 1 ^ + -stats ^ + || ( echo vcdiff test with -buffersize=1 failed ^ + &&exit /b 1 ) +echo Test 22 ok + +del %DELTA_FILE% + +rem Using -buffersize=1 with stdin/stdout means that vcdiff +rem will create a separate target window for each byte read. +%VCDIFF% encode -dictionary %DICTIONARY_FILE% ^ + -buffersize 1 ^ + -stats ^ + < %TARGET_FILE% ^ + > %DELTA_FILE% ^ + || ( echo Encode using stdin/stdout with -buffersize=1 failed ^ + &&exit /b 1 ) +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + -buffersize 1 ^ + -stats ^ + < %DELTA_FILE% ^ + > %OUTPUT_TARGET_FILE% ^ + || ( echo Decode using stdin/stdout with -buffersize=1 failed ^ + &&exit /b 1 ) +fc /b %TARGET_FILE% %OUTPUT_TARGET_FILE% ^ + || ( echo Decoded target does not match original with -buffersize=1 ^ + &&exit /b 1 ) +echo Test 23 ok + +del %DELTA_FILE% +del %OUTPUT_TARGET_FILE% + +rem Using -buffersize=0 should fail. +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -buffersize 0 ^ + && ( echo vcdiff test with -buffersize=0 should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 24 ok + +del %DELTA_FILE% + +rem Using -buffersize=128M (larger than default maximum) should still work. +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -buffersize 134217728 ^ + -stats ^ + || ( echo vcdiff test with -buffersize=128M failed ^ + &&exit /b 1 ) +echo Test 25 ok + +del %DELTA_FILE% + +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -froobish ^ + && ( echo vdiff test with unrecognized option should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 26 ok + +%VCDIFF% %VCD_OPTIONS% ^ + encode -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + && ( echo encode with no dictionary option should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 27 ok + +%VCDIFF% decode -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + && ( echo decode with no dictionary option should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 28 ok + +rem Remove -interleaved and -checksum options +%VCDIFF% encode -dictionary %DICTIONARY_FILE% ^ + < %TARGET_FILE% ^ + > %DELTA_FILE% ^ + || ( echo Encode without -interleaved and -checksum options failed ^ + &&exit /b 1 ) +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + < %DELTA_FILE% ^ + > %OUTPUT_TARGET_FILE% ^ + || ( echo Decode non-interleaved output failed ^ + &&exit /b 1 ) +fc /b %TARGET_FILE% %OUTPUT_TARGET_FILE% ^ + || ( echo Decoded target does not match original with -interleaved ^ + &&exit /b 1 ) +echo Test 29 ok + +rem -target_matches option +%VCDIFF% encode -dictionary %DICTIONARY_FILE% ^ + -target_matches ^ + -stats ^ + < %TARGET_FILE% ^ + > %DELTA_FILE% ^ + || ( echo Encode with -target_matches option failed ^ + &&exit /b 1 ) +rem The decode operation ignores the -target_matches option. +%VCDIFF% decode -dictionary %DICTIONARY_FILE% ^ + < %DELTA_FILE% ^ + > %OUTPUT_TARGET_FILE% ^ + || ( echo Decode output failed with -target_matches ^ + &&exit /b 1 ) +fc /b %TARGET_FILE% %OUTPUT_TARGET_FILE% ^ + || ( echo Decoded target does not match original with -target_matches ^ + &&exit /b 1 ) +echo Test 30 ok + +del %DELTA_FILE% +del %OUTPUT_TARGET_FILE% + +%VCDIFF% %VCD_OPTIONS% ^ + dencode -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + && ( echo vdiff with unrecognized action should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 31 ok + +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + && ( echo vdiff test without delta option should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 32 ok + +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -delta %DELTA_FILE% ^ + && ( echo vdiff test without target option should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 33 ok + +rem open-vcdiff Issue 8 +rem (http://code.google.com/p/open-vcdiff/issues/detail?id=8) +rem A malicious encoding that tries to produce a 4GB target file made up of 64 +rem windows, each window having a size of 64MB. +%VCDIFF% %VCD_OPTIONS% ^ + decode -dictionary %DICTIONARY_FILE% ^ + -delta %MALICIOUS_ENCODING% ^ + -target %OUTPUT_TARGET_FILE% ^ + -max_target_file_size=65536 ^ + && ( echo Decoding malicious file should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 34 ok + +del %OUTPUT_TARGET_FILE% + +%VCDIFF% %VCD_OPTIONS% ^ + decode -dictionary %DICTIONARY_FILE% ^ + -delta %MALICIOUS_ENCODING% ^ + -target %OUTPUT_TARGET_FILE% ^ + -max_target_window_size=65536 ^ + && ( echo Decoding malicious file should fail, but succeeded ^ + &&exit /b 1 ) +echo Test 35 ok + +del %OUTPUT_TARGET_FILE% + +rem Decoding a small target with the -max_target_file_size option should succeed. +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -max_target_file_size=65536 ^ + || ( echo vcdiff test with -max_target_file_size failed ^ + &&exit /b 1 ) +echo Test 36 ok + +rem Decoding a small target with -max_target_window_size option should succeed. +%VCDIFF% %VCD_OPTIONS% ^ + test -dictionary %DICTIONARY_FILE% ^ + -target %TARGET_FILE% ^ + -delta %DELTA_FILE% ^ + -max_target_window_size=65536 ^ + || ( echo vcdiff test with -max_target_window_size failed ^ + &&exit /b 1 ) +echo Test 37 ok + +del %DELTA_FILE% + +echo PASS diff --git a/vsprojects/vcdiff_test/vcdiff_test.vcproj b/vsprojects/vcdiff_test/vcdiff_test.vcproj new file mode 100644 index 0000000..ad05e47 --- /dev/null +++ b/vsprojects/vcdiff_test/vcdiff_test.vcproj @@ -0,0 +1,135 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8.00" + Name="vcdiff_test" + ProjectGUID="{EDC1569F-95B3-4536-9674-6AD9A0ADAAF4}" + RootNamespace="vcdiff_test" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="10" + CharacterSet="2" + BuildLogFile="$(IntDir)\BuildLog_$(ProjectName).htm" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCPostBuildEventTool" + CommandLine="$(SolutionDir)vcdiff_test.bat $(OutDir)\vcdiff.exe" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="2" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + RuntimeLibrary="2" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + GenerateDebugInformation="true" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> |