| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/python2.4 | |
| 2 # | |
| 3 # Copyright 2009-2010 Google Inc. | |
| 4 # | |
| 5 # Licensed under the Apache License, Version 2.0 (the "License"); | |
| 6 # you may not use this file except in compliance with the License. | |
| 7 # You may obtain a copy of the License at | |
| 8 # | |
| 9 # http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 # | |
| 11 # Unless required by applicable law or agreed to in writing, software | |
| 12 # distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 # See the License for the specific language governing permissions and | |
| 15 # limitations under the License. | |
| 16 # ======================================================================== | |
| 17 | |
| 18 import os | |
| 19 | |
| 20 Import('env') | |
| 21 | |
| 22 | |
| 23 def _AddCommonOptions(local_env): | |
| 24 local_env['CPPDEFINES'] += [ | |
| 25 '_ATL_FREE_THREADED', | |
| 26 'UNITTEST', | |
| 27 ] | |
| 28 | |
| 29 # A test is a console application, so we tell mk to link to | |
| 30 # main() as opposed to WinMain(). | |
| 31 local_env.FilterOut(LINKFLAGS = ['/SUBSYSTEM:WINDOWS']) | |
| 32 local_env['LINKFLAGS'] += ['/SUBSYSTEM:CONSOLE'] | |
| 33 | |
| 34 #=============omaha_unittest Dependencies====================================== | |
| 35 # TODO(omaha): Replace $STAGING_DIR with $TESTS_DIR when HAMMER_RUNS_TESTS | |
| 36 # becomes the default. | |
| 37 | |
| 38 # Install files from the testing/unittest_support/ directory. | |
| 39 unittest_support = env.Replicate('$STAGING_DIR/unittest_support/', [ | |
| 40 # Files used by the common unit tests. | |
| 41 'unittest_support/certificate-with-private-key.pfx', | |
| 42 'unittest_support/certificate-without-private-key.cer', | |
| 43 'unittest_support/declaration.txt', | |
| 44 'unittest_support/manifest.xml', | |
| 45 | |
| 46 # Installer files used by the Install Manager unit tests. | |
| 47 'unittest_support/test_foo_v1.0.101.0.msi', | |
| 48 | |
| 49 'unittest_support/GoogleUpdate_corrupted.exe', | |
| 50 'unittest_support/GoogleUpdate_now_expired_cert.exe', | |
| 51 'unittest_support/GoogleUpdate_old_signature.exe', | |
| 52 'unittest_support/GoogleUpdateHelper.msi', | |
| 53 'unittest_support/SaveArguments.exe', | |
| 54 'unittest_support/SaveArguments_different_ou.exe', | |
| 55 'unittest_support/SaveArguments_multiple_cn.exe', | |
| 56 'unittest_support/SaveArguments_no_cn.exe', | |
| 57 'unittest_support/SaveArguments_OmahaTestSigned.exe', | |
| 58 'unittest_support/SaveArguments_unsigned_no_resources.exe', | |
| 59 'unittest_support/SaveArguments_unsigned_wrong_markup_size.exe', | |
| 60 'unittest_support/SaveArguments_unsigned_wrong_markup_value.exe', | |
| 61 'unittest_support/SaveArguments_unsigned_wrong_resource_name.exe', | |
| 62 'unittest_support/SaveArguments_wrong_cn.exe', | |
| 63 | |
| 64 # Minidump file for the crash unit test. | |
| 65 'unittest_support/minidump.dmp', | |
| 66 'unittest_support/minidump.txt', | |
| 67 | |
| 68 # PAC file for testing local PAC file support. | |
| 69 'unittest_support/localproxytest.pac', | |
| 70 | |
| 71 # Files used by offline_utils_unittest. | |
| 72 'unittest_support/{CDABE316-39CD-43BA-8440-6D1E0547AEE6}.v2.gup', | |
| 73 'unittest_support/{CDABE316-39CD-43BA-8440-6D1E0547AEE6}.v3.gup', | |
| 74 ]) | |
| 75 | |
| 76 # Saved versions of Google Update for the Setup tests. | |
| 77 unittest_support += env.Replicate( | |
| 78 '$STAGING_DIR/unittest_support/omaha_1.2.131.7_shell/', [ | |
| 79 'unittest_support/omaha_1.2.131.7_shell/GoogleUpdate.exe', | |
| 80 ]) | |
| 81 unittest_support += env.Replicate( | |
| 82 '$STAGING_DIR/unittest_support/omaha_1.2.183.9_shell/', [ | |
| 83 'unittest_support/omaha_1.2.183.9_shell/GoogleUpdate.exe', | |
| 84 ]) | |
| 85 unittest_support += env.Replicate('$STAGING_DIR/unittest_support/omaha_1.2.x/', | |
| 86 'unittest_support/omaha_1.2.x/GoogleUpdate.exe' | |
| 87 ) | |
| 88 unittest_support += env.Replicate('$STAGING_DIR/unittest_support/omaha_1.3.x/', | |
| 89 [ 'unittest_support/omaha_1.3.x/GoogleUpdate.exe', | |
| 90 'unittest_support/omaha_1.3.x/goopdate.dll', | |
| 91 'unittest_support/omaha_1.3.x/goopdateres_en.dll', | |
| 92 ]) | |
| 93 | |
| 94 # Newer versions of Google Update for the Setup tests. | |
| 95 #unittest_support += env.Replicate( | |
| 96 # '$STAGING_DIR/unittest_support/omaha_1.3.x_newer/', | |
| 97 # 'unittest_support/omaha_1.2.x_newer/GoogleUpdate.exe') | |
| 98 | |
| 99 # Copy longrunning.exe to GoogleUpdate.exe for use in Setup. | |
| 100 unittest_support += env.Replicate( | |
| 101 target='$STAGING_DIR/unittest_support/does_not_shutdown/', | |
| 102 source='$MAIN_DIR/testing/unittest_support/LongRunningSilent.exe', | |
| 103 REPLICATE_REPLACE=[('LongRunningSilent\\.exe', 'GoogleUpdate.exe')], | |
| 104 ) | |
| 105 | |
| 106 # download_cache test files | |
| 107 loc_guid = 'download_cache_test/{7101D597-3481-4971-AD23-455542964072}' | |
| 108 unittest_support += env.Replicate( | |
| 109 '$STAGING_DIR/unittest_support/' + loc_guid, | |
| 110 'unittest_support/%s/livelysetup.exe' % loc_guid) | |
| 111 | |
| 112 loc_guid = 'download_cache_test/{89640431-FE64-4da8-9860-1A1085A60E13}' | |
| 113 unittest_support += env.Replicate( | |
| 114 '$STAGING_DIR/unittest_support/' + loc_guid, | |
| 115 'unittest_support/%s/gears-win32-opt.msi' % loc_guid) | |
| 116 | |
| 117 #=============General Unit Test Dependencies=================================== | |
| 118 # Many unit tests rely on string resources. omaha_unittest.cc loads them but | |
| 119 # assumes they are in the same directory as the tests. | |
| 120 # For coverage builds, use a custom command instead of Replicate() because | |
| 121 # Replicate() will cause the DLL to be re-instrumented. | |
| 122 resource_dll = '$STAGING_DIR/goopdateres_en.dll' | |
| 123 if env.IsCoverageBuild(): | |
| 124 env.CopyFileToDirectory('$TESTS_DIR', resource_dll) | |
| 125 else: | |
| 126 env.Replicate('$TESTS_DIR', resource_dll) | |
| 127 | |
| 128 #=============UnitTests======================================================== | |
| 129 | |
| 130 | |
| 131 omaha_version_info = env['omaha_versions_info'][0] | |
| 132 version_string = omaha_version_info.GetVersionString() | |
| 133 | |
| 134 run_as_invoker = env.RES('run_as_invoker.res', | |
| 135 '$MAIN_DIR/base/run_as_invoker.rc') | |
| 136 | |
| 137 # | |
| 138 # Builds omaha_unittest | |
| 139 # | |
| 140 omaha_unittest_env = env.Clone() | |
| 141 _AddCommonOptions(omaha_unittest_env) | |
| 142 | |
| 143 omaha_unittest_env.FilterOut(LINKFLAGS = ['/NODEFAULTLIB']) | |
| 144 | |
| 145 omaha_unittest_libs = [ | |
| 146 ('atls.lib', 'atlsd.lib')[omaha_unittest_env.Bit('debug')], | |
| 147 | |
| 148 '$LIB_DIR/base.lib', | |
| 149 '$LIB_DIR/breakpad.lib', | |
| 150 '$LIB_DIR/client.lib', # TODO(omaha): Might be able to make separate exe. | |
| 151 '$LIB_DIR/common.lib', | |
| 152 '$LIB_DIR/core.lib', | |
| 153 '$LIB_DIR/gmock.lib', | |
| 154 '$LIB_DIR/google_update_recovery.lib', | |
| 155 '$LIB_DIR/goopdate_lib.lib', | |
| 156 '$LIB_DIR/gtest.lib', | |
| 157 '$LIB_DIR/logging.lib', | |
| 158 '$LIB_DIR/net.lib', | |
| 159 '$LIB_DIR/omaha3_idl.lib', | |
| 160 '$LIB_DIR/security.lib', | |
| 161 '$LIB_DIR/service.lib', | |
| 162 '$LIB_DIR/setup.lib', | |
| 163 '$LIB_DIR/statsreport.lib', | |
| 164 '$LIB_DIR/ui.lib', | |
| 165 '$LIB_DIR/unittest_base_large_with_network.lib', | |
| 166 | |
| 167 'advapi32.lib', | |
| 168 'bits.lib', | |
| 169 'comctl32.lib', | |
| 170 'crypt32.lib', | |
| 171 'dbghelp.lib', | |
| 172 'delayimp.lib', # For delay loading | |
| 173 'iphlpapi.lib', | |
| 174 'msi.lib', | |
| 175 'mstask.lib', | |
| 176 'netapi32.lib', | |
| 177 'ole32.lib', | |
| 178 'oleaut32.lib', | |
| 179 'psapi.lib', | |
| 180 'rasapi32.lib', | |
| 181 'rpcns4.lib', | |
| 182 'rpcrt4.lib', | |
| 183 'shlwapi.lib', | |
| 184 'taskschd.lib', | |
| 185 'urlmon.lib', | |
| 186 'userenv.lib', | |
| 187 'version.lib', | |
| 188 'wbemuuid.lib', | |
| 189 'wininet.lib', | |
| 190 'wintrust.lib', | |
| 191 'ws2_32.lib', | |
| 192 'wtsapi32.lib', | |
| 193 ] | |
| 194 omaha_unittest_libs += omaha_unittest_env.GetAllInOneUnittestLibs() | |
| 195 | |
| 196 omaha_unittest_env.Append( | |
| 197 CPPPATH = [ | |
| 198 '$OBJ_ROOT', # Needed for the generated files | |
| 199 '$MAIN_DIR/third_party/breakpad/src', | |
| 200 '$MAIN_DIR/third_party/c99/include', # C99 inttypes.h for security | |
| 201 '$MAIN_DIR/third_party/gmock/include', | |
| 202 '$MAIN_DIR/third_party/gtest/include', | |
| 203 ], | |
| 204 CCFLAGS = [ | |
| 205 '/wd4389', # signed/unsigned mismatch | |
| 206 '/wd4510', # default constructor could not be generated | |
| 207 '/wd4610', # object 'class' can never be instantiated | |
| 208 ], | |
| 209 CPPDEFINES = [ | |
| 210 'OMAHA_BUILD_VERSION=0x%.4x%.4x%.4x%.4x' % ( | |
| 211 omaha_version_info.version_major, | |
| 212 omaha_version_info.version_minor, | |
| 213 omaha_version_info.version_build, | |
| 214 omaha_version_info.version_patch), | |
| 215 'OMAHA_BUILD_VERSION_STRING=_T(\\"%s\\")' % version_string, | |
| 216 ], | |
| 217 LIBS = omaha_unittest_libs, | |
| 218 LINKFLAGS = [ | |
| 219 '/DELAYLOAD:shlwapi.dll', | |
| 220 '/DELAYLOAD:shell32.dll', | |
| 221 '/DELAYLOAD:psapi.dll', | |
| 222 '/DELAYLOAD:netapi32.dll', | |
| 223 '/DELAYLOAD:Wtsapi32.dll', | |
| 224 ], | |
| 225 RCFLAGS = [ | |
| 226 '/DVERSION_MAJOR=%d' % omaha_version_info.version_major, | |
| 227 '/DVERSION_MINOR=%d' % omaha_version_info.version_minor, | |
| 228 '/DVERSION_BUILD=%d' % omaha_version_info.version_build, | |
| 229 '/DVERSION_PATCH=%d' % omaha_version_info.version_patch, | |
| 230 '/DVERSION_NUMBER_STRING=\\"%s\\"' % version_string, | |
| 231 '/DLANGUAGE_STRING=\\"en\\"' | |
| 232 ], | |
| 233 ) | |
| 234 | |
| 235 | |
| 236 # TODO(omaha): Separate this environment as much as appropriate. | |
| 237 unittest_base_env = omaha_unittest_env.Clone() | |
| 238 | |
| 239 unittest_base_env.Append( | |
| 240 LIBS = [ | |
| 241 '$LIB_DIR/common.lib', | |
| 242 ], | |
| 243 ) | |
| 244 | |
| 245 unittest_base_env.ComponentStaticLibrary( | |
| 246 'unittest_base', | |
| 247 [ 'omaha_unittest.cc', 'unit_test.cc', ] | |
| 248 ) | |
| 249 | |
| 250 unittest_base_env.ComponentStaticLibrary( | |
| 251 'unittest_base_large_with_network', | |
| 252 [ 'unittest_base.lib', | |
| 253 'omaha_unittest_main.cc', | |
| 254 'omaha_unittest_network.cc', | |
| 255 ] | |
| 256 ) | |
| 257 | |
| 258 unittest_base_env.ComponentStaticLibrary( | |
| 259 'unittest_base_small', | |
| 260 [ 'unittest_base.lib', 'omaha_unittest_main_small_tests.cc', ] | |
| 261 ) | |
| 262 | |
| 263 unittest_base_env.ComponentStaticLibrary( | |
| 264 'unittest_base_small_with_resources', | |
| 265 [ 'unittest_base.lib', | |
| 266 'omaha_unittest_main_small_tests_with_resources.cc', | |
| 267 ] | |
| 268 ) | |
| 269 | |
| 270 | |
| 271 # TODO(omaha3): Add tests from mainline that were removed during the integrate. | |
| 272 | |
| 273 omaha_unittest_inputs = [ | |
| 274 # Base unit tests | |
| 275 '../base/app_util_unittest.cc', | |
| 276 '../base/apply_tag.cc', | |
| 277 '../base/atlassert_unittest.cc', | |
| 278 '../base/atl_regexp_unittest.cc', | |
| 279 '../base/browser_utils_unittest.cc', | |
| 280 '../base/cgi_unittest.cc', | |
| 281 '../base/command_line_parser_unittest.cc', | |
| 282 '../base/command_line_validator_unittest.cc', | |
| 283 '../base/commands_unittest.cc', | |
| 284 '../base/disk_unittest.cc', | |
| 285 '../base/dynamic_link_kernel32_unittest.cc', | |
| 286 '../base/encrypt_test.cc', | |
| 287 '../base/error_unittest.cc', | |
| 288 '../base/etw_log_writer_unittest.cc', | |
| 289 '../base/event_trace_consumer_unittest.cc', | |
| 290 '../base/event_trace_controller_unittest.cc', | |
| 291 '../base/event_trace_provider_unittest.cc', | |
| 292 '../base/extractor_unittest.cc', | |
| 293 '../base/file_reader_unittest.cc', | |
| 294 '../base/file_store_unittest.cc', | |
| 295 '../base/file_unittest.cc', | |
| 296 '../base/firewall_product_detection_unittest.cc', | |
| 297 '../base/highres_timer_unittest.cc', | |
| 298 '../base/localization_unittest.cc', | |
| 299 '../base/lock_ptr_unittest.cc', | |
| 300 '../base/logging_unittest.cc', | |
| 301 '../base/md5_unittest.cc', | |
| 302 '../base/module_utils_unittest.cc', | |
| 303 '../base/omaha_version_unittest.cc', | |
| 304 '../base/path_unittest.cc', | |
| 305 '../base/pe_utils_unittest.cc', | |
| 306 '../base/proc_utils_unittest.cc', | |
| 307 '../base/process_unittest.cc', | |
| 308 '../base/queue_timer_unittest.cc', | |
| 309 '../base/reactor_unittest.cc', | |
| 310 '../base/reg_key_unittest.cc', | |
| 311 '../base/registry_monitor_manager_unittest.cc', | |
| 312 '../base/registry_store_unittest.cc', | |
| 313 '../base/safe_format_unittest.cc', | |
| 314 '../base/scoped_impersonation_unittest.cc', | |
| 315 '../base/scoped_ptr_cotask_unittest.cc', | |
| 316 '../base/serializable_object_unittest.cc', | |
| 317 '../base/service_utils_unittest.cc', | |
| 318 '../base/shell_unittest.cc', | |
| 319 '../base/signatures_unittest.cc', | |
| 320 '../base/signaturevalidator_unittest.cc', | |
| 321 '../base/sta_unittest.cc', | |
| 322 '../base/string_unittest.cc', | |
| 323 '../base/synchronized_unittest.cc', | |
| 324 '../base/system_unittest.cc', | |
| 325 '../base/system_info_unittest.cc', | |
| 326 '../base/thread_pool_unittest.cc', | |
| 327 '../base/time_unittest.cc', | |
| 328 '../base/timer_unittest.cc', | |
| 329 '../base/tr_rand_unittest.cc', | |
| 330 '../base/user_info_unittest.cc', | |
| 331 '../base/user_rights_unittest.cc', | |
| 332 '../base/utils_unittest.cc', | |
| 333 '../base/vistautil_unittest.cc', | |
| 334 '../base/vista_utils_unittest.cc', | |
| 335 '../base/wmi_query_unittest.cc', | |
| 336 '../base/xml_utils_unittest.cc', | |
| 337 | |
| 338 # Client unit tests | |
| 339 '../client/bundle_creator_test.cc', | |
| 340 '../client/bundle_installer_unittest.cc', | |
| 341 '../client/install_apps_unittest.cc', | |
| 342 '../client/install_self_unittest.cc', | |
| 343 '../client/install_unittest.cc', | |
| 344 | |
| 345 # Common unit tests | |
| 346 '../common/app_registry_utils_unittest.cc', | |
| 347 '../common/command_line_unittest.cc', | |
| 348 '../common/command_line_builder_unittest.cc', | |
| 349 '../common/config_manager_unittest.cc', | |
| 350 '../common/event_logger_unittest.cc', | |
| 351 '../common/experiment_labels_unittest.cc', | |
| 352 '../common/extra_args_parser_unittest.cc', | |
| 353 '../common/goopdate_utils_unittest.cc', | |
| 354 '../common/lang_unittest.cc', | |
| 355 '../common/oem_install_utils_test.cc', | |
| 356 '../common/ping_test.cc', | |
| 357 '../common/protocol_definition_test.cc', | |
| 358 '../common/scheduled_task_utils_unittest.cc', | |
| 359 '../common/stats_uploader_unittest.cc', | |
| 360 '../common/update_request_unittest.cc', | |
| 361 '../common/webplugin_utils_unittest.cc', | |
| 362 '../common/web_services_client_unittest.cc', | |
| 363 '../common/xml_parser_unittest.cc', | |
| 364 | |
| 365 # Core unit tests | |
| 366 '../core/core_unittest.cc', | |
| 367 '../core/system_monitor_unittest.cc', | |
| 368 '../core/google_update_core_unittest.cc', | |
| 369 | |
| 370 # Google Update unit tests. | |
| 371 '../google_update/google_update_unittest.cc', | |
| 372 | |
| 373 # Goopdate unit tests | |
| 374 '../goopdate/application_usage_data_unittest.cc', | |
| 375 '../goopdate/app_unittest.cc', | |
| 376 '../goopdate/app_command_unittest.cc', | |
| 377 '../goopdate/app_bundle_unittest.cc', | |
| 378 '../goopdate/app_manager_unittest.cc', | |
| 379 '../goopdate/app_version_unittest.cc', | |
| 380 '../goopdate/crash_unittest.cc', | |
| 381 '../goopdate/cred_dialog_unittest.cc', | |
| 382 '../goopdate/download_manager_unittest.cc', | |
| 383 '../goopdate/download_complete_ping_event_test.cc', | |
| 384 '../goopdate/goopdate_unittest.cc', | |
| 385 '../goopdate/install_manager_unittest.cc', | |
| 386 '../goopdate/installer_wrapper_unittest.cc', | |
| 387 '../goopdate/main_unittest.cc', | |
| 388 '../goopdate/model_unittest.cc', | |
| 389 '../goopdate/offline_utils_unittest.cc', | |
| 390 '../goopdate/string_formatter_unittest.cc', | |
| 391 '../goopdate/package_cache_unittest.cc', | |
| 392 '../goopdate/resource_manager_unittest.cc', | |
| 393 '../goopdate/update_request_utils_unittest.cc', | |
| 394 '../goopdate/update_response_utils_unittest.cc', | |
| 395 '../goopdate/worker_unittest.cc', | |
| 396 '../goopdate/worker_utils_unittest.cc', | |
| 397 | |
| 398 # Net unit tests. | |
| 399 '../net/bits_request_unittest.cc', | |
| 400 '../net/bits_utils_unittest.cc', | |
| 401 '../net/cup_request_unittest.cc', | |
| 402 '../net/cup_utils_unittest.cc', | |
| 403 '../net/detector_unittest.cc', | |
| 404 '../net/http_client_unittest.cc', | |
| 405 '../net/net_utils_unittest.cc', | |
| 406 '../net/network_config_unittest.cc', | |
| 407 '../net/network_request_unittest.cc', | |
| 408 '../net/simple_request_unittest.cc', | |
| 409 '../net/winhttp_adapter_unittest.cc', | |
| 410 '../net/winhttp_vtable_unittest.cc', | |
| 411 | |
| 412 # Plugin unit tests are specified in the individual build.scons files. | |
| 413 | |
| 414 # Code Red-related unit tests. | |
| 415 # Others are specified in the individual build.scons files. | |
| 416 '../recovery/client/google_update_recovery_unittest.cc', | |
| 417 | |
| 418 # Setup unit tests. | |
| 419 '../setup/msi_test_utils.cc', | |
| 420 '../setup/setup_unittest.cc', | |
| 421 '../setup/setup_files_unittest.cc', | |
| 422 '../setup/setup_google_update_unittest.cc', | |
| 423 '../setup/setup_service_unittest.cc', | |
| 424 | |
| 425 # Statsreport unit tests. | |
| 426 '../statsreport/aggregator_unittest.cc', | |
| 427 '../statsreport/aggregator-win32_unittest.cc', | |
| 428 '../statsreport/formatter_unittest.cc', | |
| 429 '../statsreport/metrics_unittest.cc', | |
| 430 '../statsreport/persistent_iterator-win32_unittest.cc', | |
| 431 | |
| 432 # Resource files. | |
| 433 omaha_unittest_env.RES('omaha_unittest.rc'), | |
| 434 omaha_unittest_env.RES('omaha_unittest_version.rc'), | |
| 435 run_as_invoker, | |
| 436 | |
| 437 # Testing unit tests. | |
| 438 'unit_test_unittest.cc', | |
| 439 'unittest_debug_helper_unittest.cc', | |
| 440 ] | |
| 441 omaha_unittest_inputs += omaha_unittest_env.GetAllInOneUnittestSources() | |
| 442 | |
| 443 # Force a rebuild when the version changes and when the header changes since | |
| 444 # the .rc file scanner does not. | |
| 445 omaha_unittest_env.Depends( | |
| 446 '$OBJ_ROOT/testing/omaha_unittest.res', | |
| 447 [ '$MAIN_DIR/VERSION', 'resource.h' ] | |
| 448 ) | |
| 449 | |
| 450 # Ensure that obj files don't collide with ones from non-test build | |
| 451 # TODO(omaha): We should try to avoid rebuilding production code files. Doing so | |
| 452 # should make this unnecessary. | |
| 453 omaha_unittest_env['OBJPREFIX'] = omaha_unittest_env['OBJPREFIX'] + 'testing/' | |
| 454 | |
| 455 target_name = 'omaha_unittest' | |
| 456 | |
| 457 if env.Bit('use_precompiled_headers'): | |
| 458 omaha_unittest_inputs += omaha_unittest_env.EnablePrecompile(target_name) | |
| 459 | |
| 460 # omaha_unittest can be built as a test program in 'tests\' or a normal program | |
| 461 # in 'staging\'. | |
| 462 # TODO(omaha3): Switch entirely to the former. | |
| 463 if 'HAMMER_RUNS_TESTS' in os.environ.keys(): | |
| 464 print 'If build fails, you may need to delete test executables from staging\.' | |
| 465 # Copy all the files from staging to the tests directory so that the unit | |
| 466 # tests can use them. | |
| 467 # TODO(omaha3): Consider using the files from staging, though that may cause | |
| 468 # staging to be polluted. | |
| 469 omaha_unittest_env.Publish(target_name, 'test_input', '$STAGING_DIR/*') | |
| 470 # UnitTestHelpersTest.GetLocalAppDataPath requires 'USERNAME'. | |
| 471 omaha_unittest_env['ENV']['USERNAME'] = os.environ['USERNAME'] | |
| 472 # ConfigManagerTest.GetDir requires 'USERPROFILE'. | |
| 473 omaha_unittest_env['ENV']['USERPROFILE'] = os.environ['USERPROFILE'] | |
| 474 # UtilsTest.GetEnvironmentVariableAsString requires 'OS'. | |
| 475 omaha_unittest_env['ENV']['OS'] = os.environ['OS'] | |
| 476 # Tests that use psexec require 'OMAHA_PSEXEC_DIR' | |
| 477 omaha_unittest_env['ENV']['OMAHA_PSEXEC_DIR'] = os.environ['OMAHA_PSEXEC_DIR'] | |
| 478 | |
| 479 # Set environment variables specific to the tests. | |
| 480 for env_var in os.environ: | |
| 481 if (not env_var in omaha_unittest_env['ENV'] and | |
| 482 (env_var.startswith('GTEST_') or env_var.startswith('OMAHA_TEST_'))): | |
| 483 omaha_unittest_env['ENV'][env_var] = os.environ[env_var] | |
| 484 | |
| 485 test = omaha_unittest_env.ComponentTestProgram(target_name, | |
| 486 omaha_unittest_inputs, | |
| 487 COMPONENT_TEST_SIZE='large') | |
| 488 | |
| 489 # The tests depend on the unittest_support directory. | |
| 490 omaha_unittest_env.Depends(test, unittest_support) | |
| 491 | |
| 492 # resource_manager_unittest.cc uses the Russian resources. | |
| 493 omaha_unittest_env.Depends(test, '$TESTS_DIR/goopdateres_ru.dll') | |
| 494 | |
| 495 else: | |
| 496 test = omaha_unittest_env.ComponentProgram(target_name, omaha_unittest_inputs) | |
| 497 | |
| 498 # The tests depend on the unittest_support directory. | |
| 499 omaha_unittest_env.Depends(test, unittest_support) | |
| 500 | |
| 501 # resource_manager_unittest.cc uses the Russian resources. | |
| 502 omaha_unittest_env.Depends(test, '$STAGING_DIR/goopdateres_ru.dll') | |
| 503 | |
| 504 if env.Bit('all'): | |
| 505 save_args_env = env.Clone() | |
| 506 save_args_env.Append( | |
| 507 CPPPATH = [ | |
| 508 '$OBJ_ROOT', # Needed for the generated files | |
| 509 ], | |
| 510 LIBS = [ | |
| 511 ('atls.lib', 'atlsd.lib')[save_args_env.Bit('debug')], | |
| 512 ('libcmt.lib', 'libcmtd.lib')[save_args_env.Bit('debug')], | |
| 513 ('libcpmt.lib', 'libcpmtd.lib')[save_args_env.Bit('debug')], | |
| 514 '$LIB_DIR/base.lib', | |
| 515 | |
| 516 # These are required by common_lib | |
| 517 'netapi32.lib', | |
| 518 'psapi.lib', | |
| 519 'rasapi32.lib', | |
| 520 'shlwapi.lib', | |
| 521 'userenv.lib', | |
| 522 'version.lib', | |
| 523 'wtsapi32.lib', | |
| 524 ], | |
| 525 RCFLAGS = [ | |
| 526 '/DVERSION_MAJOR=%d' % omaha_version_info.version_major, | |
| 527 '/DVERSION_MINOR=%d' % omaha_version_info.version_minor, | |
| 528 '/DVERSION_BUILD=%d' % omaha_version_info.version_build, | |
| 529 '/DVERSION_PATCH=%d' % omaha_version_info.version_patch, | |
| 530 '/DVERSION_NUMBER_STRING=\\"%s\\"' % version_string, | |
| 531 '/DLANGUAGE_STRING=\\"en\\"' | |
| 532 ], | |
| 533 ) | |
| 534 | |
| 535 save_args_env.FilterOut(LINKFLAGS = ['/SUBSYSTEM:WINDOWS']) | |
| 536 save_args_env['LINKFLAGS'] += ['/SUBSYSTEM:CONSOLE'] | |
| 537 | |
| 538 target_name = 'SaveArguments_unsigned' | |
| 539 | |
| 540 unsigned_inputs = [ | |
| 541 'save_arguments.cc', | |
| 542 save_args_env.RES('save_arguments_version.rc'), | |
| 543 run_as_invoker, | |
| 544 save_args_env.RES('recovery_markup.res', | |
| 545 '$MAIN_DIR/recovery/recovery_markup.rc'), | |
| 546 ] | |
| 547 | |
| 548 # Force a rebuild when the version changes. | |
| 549 save_args_env.Depends('$OBJ_ROOT/testing/save_arguments_version.res', | |
| 550 '$MAIN_DIR/VERSION' | |
| 551 ) | |
| 552 | |
| 553 if env.Bit('use_precompiled_headers'): | |
| 554 unsigned_inputs += save_args_env.EnablePrecompile(target_name) | |
| 555 | |
| 556 # Build the *unsigned* executeable | |
| 557 unsigned_output = save_args_env.ComponentTestProgram( | |
| 558 prog_name=target_name, | |
| 559 source=unsigned_inputs, | |
| 560 COMPONENT_TEST_RUNNABLE=False | |
| 561 ) | |
| 562 | |
| 563 signed_output = save_args_env.SignedBinary( | |
| 564 target='SaveArguments.exe', | |
| 565 source=unsigned_output, | |
| 566 ) | |
| 567 | |
| 568 save_args_env.Replicate('$TESTS_DIR', signed_output) | |
| OLD | NEW |