diff options
author | dgarrett@chromium.org <dgarrett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 01:08:35 +0000 |
---|---|---|
committer | dgarrett@chromium.org <dgarrett@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 01:08:35 +0000 |
commit | bf0ece42c1ea7b3c3d572106dab09e92b0800cff (patch) | |
tree | 6d1bfe584e564b25a8493605e1c89a8eb4a4bf31 /courgette/versioning_unittest.cc | |
parent | ec817ab64e167d0a5d8c7dbae2eb322279e946e9 (diff) | |
download | chromium_src-bf0ece42c1ea7b3c3d572106dab09e92b0800cff.zip chromium_src-bf0ece42c1ea7b3c3d572106dab09e92b0800cff.tar.gz chromium_src-bf0ece42c1ea7b3c3d572106dab09e92b0800cff.tar.bz2 |
Add a basic backwards compatibility unittest.
This verifies we can still apply old patches, but does not
verify that old clients can apply new patches. That seems
important, but I'm not sure how to do it without storing
old client binaries in version control.
Also refactors a number of unit tests to allow code sharing for
reading files into memory. This is done via a new base class.
Uses test binaries submitted seperatly because of build tools problems.
BUG=None
TEST=New Unittest
Review URL: http://codereview.chromium.org/8252011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/versioning_unittest.cc')
-rw-r--r-- | courgette/versioning_unittest.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/courgette/versioning_unittest.cc b/courgette/versioning_unittest.cc new file mode 100644 index 0000000..8e2bdfe --- /dev/null +++ b/courgette/versioning_unittest.cc @@ -0,0 +1,57 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "courgette/base_test_unittest.h" + +#include <string> + +#include "base/basictypes.h" +#include "courgette/courgette.h" +#include "courgette/streams.h" + +class VersioningTest : public BaseTest { + public: + void TestApplyingOldPatch(const char* src_file, + const char* patch_file, + const char* expected_file) const; +}; + +void VersioningTest::TestApplyingOldPatch(const char* src_file, + const char* patch_file, + const char* expected_file) const { + + std::string old_buffer = FileContents(src_file); + std::string new_buffer = FileContents(patch_file); + std::string expected_buffer = FileContents(expected_file); + + courgette::SourceStream old_stream; + courgette::SourceStream patch_stream; + old_stream.Init(old_buffer); + patch_stream.Init(new_buffer); + + courgette::SinkStream generated_stream; + + courgette::Status status = + courgette::ApplyEnsemblePatch(&old_stream, + &patch_stream, + &generated_stream); + + EXPECT_EQ(status, courgette::C_OK); + + size_t expected_length = expected_buffer.size(); + size_t generated_length = generated_stream.Length(); + + EXPECT_EQ(generated_length, expected_length); + EXPECT_EQ(0, memcmp(generated_stream.Buffer(), + expected_buffer.c_str(), + expected_length)); +} + + +TEST_F(VersioningTest, All) { + TestApplyingOldPatch("setup1.exe", "setup1-setup2.v1.patch", "setup2.exe"); + + // We also need a way to test that newly generated patches are appropriately + // applicable by older clients... not sure of the best way to do that. +} |