
This creates executable detection functions, a globally shared enum for describing an executable type, and reduces the number of classes and locations with executable specific knowledge. These changes, along with moving architecture specific classes into their own files should make it easier to produce special purpose clients that only contain the code required to apply their own form of patch. DisassemblerWin32EXE, ImagePE, CourgetteWin32X86PatchGenerator, and CourgetteWin32X86Patcher, and ensemble handling are all heavily affected here. This should have no effect on the behavior of the system yet, and is instead all prep-work. This is the same as an earlier CL, except that ParseHeader will now return an error for 64 bit PE executables, and resource only DLLs. This is because the detection factories depend on ParseHeader to decide if a given file is supported. BUG=None TEST=Unittests Review URL: http://codereview.chromium.org/7920004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103879 0039d316-1c4b-4281-b951-d872f2087c98 Review URL: http://codereview.chromium.org/8344037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106793 0039d316-1c4b-4281-b951-d872f2087c98
57 lines
1.8 KiB
C++
57 lines
1.8 KiB
C++
// 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.
|
|
}
|