| 2452 | { |
| 2453 | protected: |
| 2454 | void SetUp() override |
| 2455 | { |
| 2456 | ZooKeeperTest::SetUp(); |
| 2457 | |
| 2458 | // Save the current working directory. |
| 2459 | cwd = os::getcwd(); |
| 2460 | |
| 2461 | // Create a temporary directory for the test. |
| 2462 | Try<string> directory = environment->mkdtemp(); |
| 2463 | |
| 2464 | ASSERT_SOME(directory) << "Failed to mkdtemp"; |
| 2465 | |
| 2466 | sandbox = directory.get(); |
| 2467 | |
| 2468 | LOG(INFO) << "Using temporary directory '" << sandbox.get() << "'"; |
| 2469 | |
| 2470 | // Run the test out of the temporary directory we created. |
| 2471 | ASSERT_SOME(os::chdir(sandbox.get())) |
| 2472 | << "Failed to chdir into '" << sandbox.get() << "'"; |
| 2473 | } |
| 2474 | |
| 2475 | void TearDown() override |
| 2476 | { |