Parses the environment variable var as an Int32. If it is unset, returns default_val. If it is not an Int32, prints an error and aborts.
| 5649 | // returns default_val. If it is not an Int32, prints an error |
| 5650 | // and aborts. |
| 5651 | Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) { |
| 5652 | const char* str_val = posix::GetEnv(var); |
| 5653 | if (str_val == NULL) { |
| 5654 | return default_val; |
| 5655 | } |
| 5656 | |
| 5657 | Int32 result; |
| 5658 | if (!ParseInt32(Message() << "The value of environment variable " << var, |
| 5659 | str_val, &result)) { |
| 5660 | exit(EXIT_FAILURE); |
| 5661 | } |
| 5662 | return result; |
| 5663 | } |
| 5664 | |
| 5665 | // Given the total number of shards, the shard index, and the test id, |
| 5666 | // returns true iff the test should be run on this shard. The test id is |
no test coverage detected