Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: base/test/launcher/test_launcher.cc

Issue 58413003: GTTF: Make it possible to pass sharding settings from command line. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/test/test_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/test/launcher/test_launcher.h" 5 #include "base/test/launcher/test_launcher.h"
6 6
7 #if defined(OS_POSIX) 7 #if defined(OS_POSIX)
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #endif 9 #endif
10 10
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 bool TestLauncher::Init() { 545 bool TestLauncher::Init() {
546 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 546 const CommandLine* command_line = CommandLine::ForCurrentProcess();
547 547
548 if (command_line->HasSwitch(kGTestListTestsFlag)) { 548 if (command_line->HasSwitch(kGTestListTestsFlag)) {
549 // Child gtest processes would list tests instead of running tests. 549 // Child gtest processes would list tests instead of running tests.
550 // TODO(phajdan.jr): Restore support for the flag. 550 // TODO(phajdan.jr): Restore support for the flag.
551 LOG(ERROR) << kGTestListTestsFlag << " is not supported."; 551 LOG(ERROR) << kGTestListTestsFlag << " is not supported.";
552 return false; 552 return false;
553 } 553 }
554 554
555 if (!TakeInt32FromEnvironment(kTestTotalShards, &total_shards_)) 555 // Initialize sharding. Command line takes precedence over legacy environment
556 return false; 556 // variables.
557 if (!TakeInt32FromEnvironment(kTestShardIndex, &shard_index_)) 557 if (command_line->HasSwitch(switches::kTestLauncherTotalShards) &&
558 return false; 558 command_line->HasSwitch(switches::kTestLauncherShardIndex)) {
559 if (!StringToInt(
560 command_line->GetSwitchValueASCII(
561 switches::kTestLauncherTotalShards),
562 &total_shards_)) {
563 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherTotalShards;
564 return false;
565 }
566 if (!StringToInt(
567 command_line->GetSwitchValueASCII(
568 switches::kTestLauncherShardIndex),
569 &shard_index_)) {
570 LOG(ERROR) << "Invalid value for " << switches::kTestLauncherShardIndex;
571 return false;
572 }
573 fprintf(stdout,
574 "Using sharding settings from command line. This is shard %d/%d\n",
575 shard_index_, total_shards_);
576 fflush(stdout);
577 } else {
578 if (!TakeInt32FromEnvironment(kTestTotalShards, &total_shards_))
579 return false;
580 if (!TakeInt32FromEnvironment(kTestShardIndex, &shard_index_))
581 return false;
582 fprintf(stdout,
583 "Using sharding settings from environment. This is shard %d/%d\n",
584 shard_index_, total_shards_);
585 fflush(stdout);
586 }
559 if (shard_index_ < 0 || 587 if (shard_index_ < 0 ||
560 total_shards_ < 0 || 588 total_shards_ < 0 ||
561 shard_index_ >= total_shards_) { 589 shard_index_ >= total_shards_) {
562 LOG(ERROR) << "Invalid environment variables: we require 0 <= " 590 LOG(ERROR) << "Invalid sharding settings: we require 0 <= "
563 << kTestShardIndex << " < " << kTestTotalShards 591 << kTestShardIndex << " < " << kTestTotalShards
564 << ", but you have " << kTestShardIndex << "=" << shard_index_ 592 << ", but you have " << kTestShardIndex << "=" << shard_index_
565 << ", " << kTestTotalShards << "=" << total_shards_ << ".\n"; 593 << ", " << kTestTotalShards << "=" << total_shards_ << ".\n";
566 return false; 594 return false;
567 } 595 }
568 596
569 if (command_line->HasSwitch(kGTestRepeatFlag) && 597 if (command_line->HasSwitch(kGTestRepeatFlag) &&
570 !StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag), 598 !StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag),
571 &cycles_)) { 599 &cycles_)) {
572 LOG(ERROR) << "Invalid value for " << kGTestRepeatFlag; 600 LOG(ERROR) << "Invalid value for " << kGTestRepeatFlag;
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 896
869 g_live_processes.Get().erase(process_handle); 897 g_live_processes.Get().erase(process_handle);
870 } 898 }
871 899
872 base::CloseProcessHandle(process_handle); 900 base::CloseProcessHandle(process_handle);
873 901
874 return exit_code; 902 return exit_code;
875 } 903 }
876 904
877 } // namespace base 905 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/test/test_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698