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.
| 6888 | // returns default_val. If it is not an Int32, prints an error |
| 6889 | // and aborts. |
| 6890 | Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) { |
| 6891 | const char* str_val = posix::GetEnv(var); |
| 6892 | if (str_val == nullptr) { |
| 6893 | return default_val; |
| 6894 | } |
| 6895 | |
| 6896 | Int32 result; |
| 6897 | if (!ParseInt32(Message() << "The value of environment variable " << var, |
| 6898 | str_val, &result)) { |
| 6899 | exit(EXIT_FAILURE); |
| 6900 | } |
| 6901 | return result; |
| 6902 | } |
| 6903 | |
| 6904 | // Given the total number of shards, the shard index, and the test id, |
| 6905 | // returns true iff the test should be run on this shard. The test id is |
no test coverage detected