| 24 | namespace { |
| 25 | |
| 26 | TEST(TuneTest, TuneTest) { |
| 27 | TuningResolver tuning_resolver; |
| 28 | ASSERT_FALSE(tuning_resolver.Resolve() == Tuning::kAuto); |
| 29 | // 1 second is likely higher than TuningResolver's internal cache expiry, |
| 30 | // exercising the logic invalidating earlier tuning resolutions. |
| 31 | std::this_thread::sleep_for(std::chrono::seconds(1)); |
| 32 | ASSERT_FALSE(tuning_resolver.Resolve() == Tuning::kAuto); |
| 33 | |
| 34 | tuning_resolver.SetTuning(Tuning::kAuto); |
| 35 | |
| 36 | #ifdef RUY_IMPLEMENT_TUNING |
| 37 | for (auto tuning : {Tuning::kOutOfOrder, Tuning::kInOrder}) { |
| 38 | tuning_resolver.SetTuning(tuning); |
| 39 | ASSERT_TRUE(tuning_resolver.Resolve() == tuning); |
| 40 | // See above comment about 1 second. |
| 41 | std::this_thread::sleep_for(std::chrono::seconds(1)); |
| 42 | ASSERT_TRUE(tuning_resolver.Resolve() == tuning); |
| 43 | } |
| 44 | #endif |
| 45 | } |
| 46 | |
| 47 | } // namespace |
| 48 | } // namespace ruy |