|
|
@ -23,13 +23,14 @@ protected: |
|
|
|
/// Verify that whether basic ranges data is correct.
|
|
|
|
static void Verify() { |
|
|
|
const auto &basic_ranges = BasicRanges::instance().fetch(); |
|
|
|
EXPECT_EQ(basic_ranges.size(), BASIC_RANGES_NUM); // verify basic ranges size
|
|
|
|
EXPECT_EQ(basic_ranges.size(), BASIC_RANGES_NUM_); // verify basic ranges size
|
|
|
|
EXPECT_EQ(hash::xxh3(basic_ranges), BASIC_RANGES_XXH3); // verify basic ranges checksum
|
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
TEST_FF(BasicRanges, constant) { |
|
|
|
EXPECT_EQ(BASIC_RANGES_NUM, 7311885); |
|
|
|
// TODO: check BASIC_RANGES_NUM array
|
|
|
|
EXPECT_EQ(BASIC_RANGES_NUM_, 7311885); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_FF(BasicRanges, basic_ranges) { |
|
|
@ -43,7 +44,7 @@ TEST_FF(BasicRanges, basic_ranges) { |
|
|
|
} |
|
|
|
|
|
|
|
TEST_FF(BasicRanges, basic_ranges_race) { |
|
|
|
racer_.Begin([] { |
|
|
|
racer_.Start([] { |
|
|
|
BasicRanges::instance().build(); |
|
|
|
}); |
|
|
|
EXPECT_FALSE(Available()); |
|
|
@ -51,3 +52,53 @@ TEST_FF(BasicRanges, basic_ranges_race) { |
|
|
|
EXPECT_TRUE(Available()); |
|
|
|
Verify(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_FF(BasicRanges, basic_ranges_async) { |
|
|
|
condition_.clear(); |
|
|
|
BasicRanges::instance().build_async(executor_.Entry(), [this] { |
|
|
|
EXPECT_FALSE(condition_.test_and_set()); |
|
|
|
condition_.notify_all(); |
|
|
|
}); |
|
|
|
EXPECT_FALSE(Available()); |
|
|
|
condition_.wait(false); |
|
|
|
EXPECT_TRUE(Available()); |
|
|
|
Verify(); |
|
|
|
|
|
|
|
condition_.clear(); |
|
|
|
BasicRanges::instance().build_async(executor_.Entry(), [this] { |
|
|
|
EXPECT_FALSE(condition_.test_and_set()); |
|
|
|
condition_.notify_all(); |
|
|
|
}); |
|
|
|
EXPECT_TRUE(Available()); |
|
|
|
condition_.wait(false); |
|
|
|
EXPECT_TRUE(Available()); |
|
|
|
Verify(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_FF(BasicRanges, basic_ranges_async_race) { |
|
|
|
counter_.store(0); |
|
|
|
racer_.Start([this] { |
|
|
|
BasicRanges::instance().build_async(executor_.Entry(), [this] { |
|
|
|
counter_.fetch_add(1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
EXPECT_FALSE(Available()); |
|
|
|
racer_.Join(); |
|
|
|
EXPECT_TRUE(Available()); |
|
|
|
EXPECT_EQ(counter_.load(), racer_.RaceNum()); |
|
|
|
Verify(); |
|
|
|
} |
|
|
|
|
|
|
|
TEST_FF(BasicRanges, basic_ranges_async_block) { |
|
|
|
condition_.clear(); |
|
|
|
serial_.Entry()([this] { |
|
|
|
BasicRanges::instance().build_async(serial_.Entry(), [this] { |
|
|
|
EXPECT_FALSE(condition_.test_and_set()); |
|
|
|
condition_.notify_all(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
EXPECT_FALSE(Available()); |
|
|
|
condition_.wait(false); |
|
|
|
EXPECT_TRUE(Available()); |
|
|
|
Verify(); |
|
|
|
} |
|
|
|