forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a skeleton updater main for Windows.
This change builds an executable program on Windows, which returns a hardcoded value. The value is tested by a unit test. The updater executable contains a valid resource file and manifest. An upcoming change will hook the test with the test bots. Then, another change will implement a similar function for macOS. Bug: 925489 Change-Id: Id97f4740a2cd9e3d21c00e631a8e03c19757468a Reviewed-on: https://chromium-review.googlesource.com/c/1437266 Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Joshua Pawlicki <waffles@chromium.org> Commit-Queue: Sorin Jianu <sorin@chromium.org> Cr-Commit-Position: refs/heads/master@{#627053}
- Loading branch information
Showing
8 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright 2019 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. | ||
|
||
import("//build/config/chrome_build.gni") | ||
import("//build/config/sanitizers/sanitizers.gni") | ||
import("//testing/test.gni") | ||
|
||
group("updater") { | ||
if (is_win) { | ||
deps = [ | ||
"//chrome/updater/win", | ||
] | ||
} | ||
} | ||
|
||
source_set("updater_tests") { | ||
testonly = true | ||
if (is_win) { | ||
sources = [ | ||
"win/updater_unittest.cc", | ||
] | ||
|
||
data_deps = [ | ||
"//chrome/updater/win:updater", | ||
] | ||
} | ||
|
||
deps = [ | ||
":updater", | ||
"//base/test:test_support", | ||
"//testing/gtest", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2019 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. | ||
|
||
import("//chrome/process_version_rc_template.gni") | ||
|
||
group("win") { | ||
deps = [ | ||
":updater", | ||
] | ||
} | ||
|
||
executable("updater") { | ||
sources = [ | ||
"main.cc", | ||
"updater.rc", | ||
] | ||
|
||
configs += [ "//build/config/win:windowed" ] | ||
|
||
deps = [ | ||
":version_resources", | ||
"//build/win:default_exe_manifest", | ||
] | ||
} | ||
|
||
process_version_rc_template("version_resources") { | ||
sources = [ | ||
"updater.ver", | ||
] | ||
output = "$target_gen_dir/updater_exe.rc" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2019 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 <windows.h> | ||
|
||
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE prev, wchar_t*, int) { | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Microsoft Visual C++ generated resource script. | ||
// | ||
|
||
#define APSTUDIO_READONLY_SYMBOLS | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Generated from the TEXTINCLUDE 2 resource. | ||
// | ||
#include "winres.h" | ||
#include "verrsrc.h" | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
#undef APSTUDIO_READONLY_SYMBOLS | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// English (United States) resources | ||
|
||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) | ||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US | ||
|
||
#ifdef APSTUDIO_INVOKED | ||
///////////////////////////////////////////////////////////////////////////// | ||
// | ||
// TEXTINCLUDE | ||
// | ||
|
||
1 TEXTINCLUDE | ||
BEGIN | ||
"#include ""winres.h""\r\n" | ||
"#include ""verrsrc.h""\r\n" | ||
"\0" | ||
END | ||
|
||
#endif // APSTUDIO_INVOKED | ||
|
||
#endif // English (United States) resources | ||
|
||
///////////////////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
INTERNAL_NAME=updater_exe | ||
ORIGINAL_FILENAME=updater.exe | ||
PRODUCT_FULLNAME=updater |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2019 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 <windows.h> | ||
|
||
#include "base/command_line.h" | ||
#include "base/files/file_path.h" | ||
#include "base/process/launch.h" | ||
#include "base/process/process.h" | ||
#include "base/time/time.h" | ||
#include "build/build_config.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
// Tests the updater process returns 0 when run with no arguments. | ||
TEST(UpdaterTest, UpdaterExitCode) { | ||
base::FilePath::CharType buffer[MAX_PATH] = {0}; | ||
ASSERT_NE(0u, GetModuleFileName(0, buffer, base::size(buffer))); | ||
const base::FilePath updater = | ||
base::FilePath(buffer).DirName().Append(FILE_PATH_LITERAL("updater.exe")); | ||
base::LaunchOptions options; | ||
options.start_hidden = true; | ||
auto process = base::LaunchProcess(base::CommandLine(updater), options); | ||
ASSERT_TRUE(process.IsValid()); | ||
int exit_code = -1; | ||
EXPECT_TRUE(process.WaitForExitWithTimeout(base::TimeDelta::FromSeconds(60), | ||
&exit_code)); | ||
EXPECT_EQ(0, exit_code); | ||
} |