OLD | NEW |
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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 if (shard_index_ < 0 || | 609 if (shard_index_ < 0 || |
610 total_shards_ < 0 || | 610 total_shards_ < 0 || |
611 shard_index_ >= total_shards_) { | 611 shard_index_ >= total_shards_) { |
612 LOG(ERROR) << "Invalid sharding settings: we require 0 <= " | 612 LOG(ERROR) << "Invalid sharding settings: we require 0 <= " |
613 << kTestShardIndex << " < " << kTestTotalShards | 613 << kTestShardIndex << " < " << kTestTotalShards |
614 << ", but you have " << kTestShardIndex << "=" << shard_index_ | 614 << ", but you have " << kTestShardIndex << "=" << shard_index_ |
615 << ", " << kTestTotalShards << "=" << total_shards_ << ".\n"; | 615 << ", " << kTestTotalShards << "=" << total_shards_ << ".\n"; |
616 return false; | 616 return false; |
617 } | 617 } |
618 | 618 |
| 619 // Make sure we don't pass any sharding-related environment to the child |
| 620 // processes. This test launcher implements the sharding completely. |
| 621 scoped_ptr<Environment> env(Environment::Create()); |
| 622 CHECK(env->UnSetVar("GTEST_TOTAL_SHARDS")); |
| 623 CHECK(env->UnSetVar("GTEST_SHARD_INDEX")); |
| 624 |
619 if (command_line->HasSwitch(kGTestRepeatFlag) && | 625 if (command_line->HasSwitch(kGTestRepeatFlag) && |
620 !StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag), | 626 !StringToInt(command_line->GetSwitchValueASCII(kGTestRepeatFlag), |
621 &cycles_)) { | 627 &cycles_)) { |
622 LOG(ERROR) << "Invalid value for " << kGTestRepeatFlag; | 628 LOG(ERROR) << "Invalid value for " << kGTestRepeatFlag; |
623 return false; | 629 return false; |
624 } | 630 } |
625 | 631 |
626 // Split --gtest_filter at '-', if there is one, to separate into | 632 // Split --gtest_filter at '-', if there is one, to separate into |
627 // positive filter and negative filter portions. | 633 // positive filter and negative filter portions. |
628 std::string filter = command_line->GetSwitchValueASCII(kGTestFilterFlag); | 634 std::string filter = command_line->GetSwitchValueASCII(kGTestFilterFlag); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 | 927 |
922 g_live_processes.Get().erase(process_handle); | 928 g_live_processes.Get().erase(process_handle); |
923 } | 929 } |
924 | 930 |
925 base::CloseProcessHandle(process_handle); | 931 base::CloseProcessHandle(process_handle); |
926 | 932 |
927 return exit_code; | 933 return exit_code; |
928 } | 934 } |
929 | 935 |
930 } // namespace base | 936 } // namespace base |
OLD | NEW |