diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-01 02:25:11 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-01 02:25:11 +0000 |
commit | 87ba2e6056bfe771ddc6ce540cf3d4e413d4e6f4 (patch) | |
tree | fabaa7bfcd986c6ea6481d571e7ccad4afc74ced /chrome/installer/test | |
parent | 35c96084eb0abf809bb86c9c95c74ac4e6284fe5 (diff) | |
download | chromium_src-87ba2e6056bfe771ddc6ce540cf3d4e413d4e6f4.zip chromium_src-87ba2e6056bfe771ddc6ce540cf3d4e413d4e6f4.tar.gz chromium_src-87ba2e6056bfe771ddc6ce540cf3d4e413d4e6f4.tar.bz2 |
Add an integration test for Chrome Frame's DllRedirector class.
Fix a bug in the DllRedirector module loading code.
Expand the alternate version generator code to provide a function for generating new versions of single modules.
Remove the LI SACL from the shared memory lock for Win XP.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/6600001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76338 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/test')
-rw-r--r-- | chrome/installer/test/alternate_version_generator.cc | 93 | ||||
-rw-r--r-- | chrome/installer/test/alternate_version_generator.h | 7 |
2 files changed, 78 insertions, 22 deletions
diff --git a/chrome/installer/test/alternate_version_generator.cc b/chrome/installer/test/alternate_version_generator.cc index c6416ef..7af5cc6 100644 --- a/chrome/installer/test/alternate_version_generator.cc +++ b/chrome/installer/test/alternate_version_generator.cc @@ -45,7 +45,6 @@ #include "chrome/installer/test/resource_loader.h" #include "chrome/installer/test/resource_updater.h" #include "chrome/installer/util/lzma_util.h" -#include "testing/gtest/include/gtest/gtest.h" namespace { @@ -148,10 +147,14 @@ class MappedFile { MappedFile::~MappedFile() { if (view_ != NULL) { - EXPECT_NE(0, UnmapViewOfFile(view_)); + if (UnmapViewOfFile(view_) == 0) { + PLOG(DFATAL) << "MappedFile failed to unmap view."; + } } if (mapping_ != NULL) { - EXPECT_NE(0, CloseHandle(mapping_)); + if (CloseHandle(mapping_) == 0) { + PLOG(DFATAL) << "Could not close file mapping handle."; + } } } @@ -211,17 +214,17 @@ bool RunProcessAndWait(const wchar_t* exe_path, const std::wstring& cmdline, return result; } -// Retrieves the version number of setup.exe in |work_dir| from its version +// Retrieves the version number of |pe_file| from its version // resource, placing the value in |version|. Returns true on success. -bool GetSetupExeVersion(const FilePath& work_dir, ChromeVersion* version) { +bool GetFileVersion(const FilePath& pe_file, ChromeVersion* version) { DCHECK(version); bool result = false; - upgrade_test::ResourceLoader setup; + upgrade_test::ResourceLoader pe_file_loader; std::pair<const uint8*, DWORD> version_info_data; - if (setup.Initialize(work_dir.Append(&kSetupExe[0])) && - setup.Load(VS_VERSION_INFO, reinterpret_cast<WORD>(RT_VERSION), - &version_info_data)) { + if (pe_file_loader.Initialize(pe_file) && + pe_file_loader.Load(VS_VERSION_INFO, reinterpret_cast<WORD>(RT_VERSION), + &version_info_data)) { const VS_FIXEDFILEINFO* fixed_file_info; UINT ver_info_len; if (VerQueryValue(version_info_data.first, L"\\", @@ -240,6 +243,13 @@ bool GetSetupExeVersion(const FilePath& work_dir, ChromeVersion* version) { return result; } +// Retrieves the version number of setup.exe in |work_dir| from its version +// resource, placing the value in |version|. Returns true on success. +bool GetSetupExeVersion(const FilePath& work_dir, ChromeVersion* version) { + return GetFileVersion(work_dir.Append(&kSetupExe[0]), version); +} + + // Replace all occurrences in the sequence [|dest_first|, |dest_last) that // equals [|src_first|, |src_last) with the sequence at |replacement_first| of // the same length. Returns true on success. If non-NULL, |replacements_made| @@ -343,6 +353,27 @@ bool UpdateVersionIfMatch(const FilePath& image_file, return result; } +bool IncrementNewVersion(upgrade_test::Direction direction, + VisitResourceContext* ctx) { + DCHECK(ctx); + + // Figure out a past or future version with the same string length as this one + // by decrementing or incrementing each component. + LONGLONG incrementer = (direction == upgrade_test::PREVIOUS_VERSION ? -1 : 1); + + do { + if (incrementer == 0) { + LOG(DFATAL) << "Improbable version at the cusp of complete rollover"; + return false; + } + ctx->new_version.set_value(ctx->current_version.value() + incrementer); + ctx->new_version_str = ctx->new_version.ToString(); + incrementer <<= 16; + } while (ctx->new_version_str.size() != ctx->current_version_str.size()); + + return true; +} + // Raises or lowers the version of all .exe and .dll files in |work_dir| as well // as the |work-dir|\Chrome-bin\w.x.y.z directory. |original_version| and // |new_version|, when non-NULL, are given the original and new version numbers @@ -357,19 +388,9 @@ bool ApplyAlternateVersion(const FilePath& work_dir, } ctx.current_version_str = ctx.current_version.ToString(); - // Figure out a past or future version with the same string length as this one - // by decrementing or incrementing each component. - LONGLONG incrementer = (direction == upgrade_test::PREVIOUS_VERSION ? -1 : 1); - - do { - if (incrementer == 0) { - LOG(DFATAL) << "Improbable version at the cusp of complete rollover"; - return false; - } - ctx.new_version.set_value(ctx.current_version.value() + incrementer); - ctx.new_version_str = ctx.new_version.ToString(); - incrementer <<= 16; - } while (ctx.new_version_str.size() != ctx.current_version_str.size()); + if (!IncrementNewVersion(direction, &ctx)) { + return false; + } // Modify all .dll and .exe files with the current version. bool doing_great = true; @@ -590,4 +611,32 @@ bool GenerateAlternateVersion(const FilePath& original_installer_path, return file_util::Move(mini_installer, target_path); } +bool GenerateAlternatePEFileVersion(const FilePath& original_file, + const FilePath& target_file, + Direction direction) { + // First copy original_file to target_file. + if (!file_util::CopyFile(original_file, target_file)) { + LOG(DFATAL) << "Failed copying \"" << original_file.value() + << "\" to \"" << target_file.value() << "\""; + return false; + } + + VisitResourceContext ctx; + if (!GetFileVersion(target_file, &ctx.current_version)) { + LOG(DFATAL) << "Failed reading version from \"" << target_file.value() + << "\""; + return false; + } + ctx.current_version_str = ctx.current_version.ToString(); + + if (!IncrementNewVersion(direction, &ctx) || + !UpdateVersionIfMatch(target_file, &ctx)) { + LOG(DFATAL) << "Failed to update version in \"" << target_file.value() + << "\""; + return false; + } + + return true; +} + } // namespace upgrade_test diff --git a/chrome/installer/test/alternate_version_generator.h b/chrome/installer/test/alternate_version_generator.h index cce83b0..43ef9f4 100644 --- a/chrome/installer/test/alternate_version_generator.h +++ b/chrome/installer/test/alternate_version_generator.h @@ -31,6 +31,13 @@ bool GenerateAlternateVersion(const FilePath& original_installer_path, std::wstring* original_version, std::wstring* new_version); +// Given a path to a PEImage in |original_file|, copy that file to +// |target_file|, modifying the version of the copy according to |direction|. +// Any previous file at |target_file| is clobbered. Returns true on success. +bool GenerateAlternatePEFileVersion(const FilePath& original_file, + const FilePath& target_file, + Direction direction); + } // namespace upgrade_test #endif // CHROME_INSTALLER_TEST_ALTERNATE_VERSION_GENERATOR_H_ |