1
0
Fork 0

Fixed several ASan errors in the catch tests (#8624)

This commit is contained in:
Tobias Gödderz 2019-03-29 16:00:53 +01:00 committed by Jan
parent 9ab9cc7857
commit 1ac2c314de
4 changed files with 10 additions and 4 deletions

View File

@ -48,7 +48,7 @@ class AqlItemBlockManager {
TEST_VIRTUAL AqlItemBlock* requestBlock(size_t nrItems, RegisterId nrRegs);
/// @brief return a block to the manager
void returnBlock(AqlItemBlock*& block) noexcept;
TEST_VIRTUAL void returnBlock(AqlItemBlock*& block) noexcept;
/// @brief return a block to the manager
void returnBlock(std::unique_ptr<AqlItemBlock> block) noexcept {

View File

@ -85,6 +85,8 @@ SCENARIO("ExecutionBlockImpl", "[AQL][EXECUTOR][EXECBLOCKIMPL]") {
fakeit::When(Method(mockEngine, itemBlockManager)).AlwaysReturn(blockManager);
fakeit::When(Method(mockEngine, getQuery)).AlwaysReturn(&query);
fakeit::When(OverloadedMethod(mockBlockManager, returnBlock, void(AqlItemBlock*&)))
.AlwaysDo([&](AqlItemBlock*& block) -> void { delete block; block = nullptr; });
fakeit::When(ConstOverloadedMethod(mockQuery, queryOptions, QueryOptions const&()))
.AlwaysDo([&]() -> QueryOptions const& { return lqueryOptions; });
fakeit::When(OverloadedMethod(mockQuery, queryOptions, QueryOptions & ()))

View File

@ -56,7 +56,6 @@ namespace aql {
SCENARIO("SingleRowFetcher", "[AQL][EXECUTOR][FETCHER]") {
ResourceMonitor monitor;
ExecutionState state;
InputAqlItemRow row{CreateInvalidInputRowHint{}};
/*
* A hopefully temporary hack. Use TEMPLATE_TEST_CASE instead when it's
@ -82,6 +81,7 @@ SCENARIO("SingleRowFetcher", "[AQL][EXECUTOR][FETCHER]") {
GIVEN(std::string{"there are no blocks upstream, passBlocksThrough="} + std::string{passBlocksThrough}) {
VPackBuilder input;
BlockFetcherMock<passBlocksThrough> blockFetcherMock{monitor, 0};
InputAqlItemRow row{CreateInvalidInputRowHint{}};
WHEN("the producer does not wait") {
blockFetcherMock.shouldReturn(ExecutionState::DONE, nullptr);
@ -132,6 +132,7 @@ GIVEN(std::string{
std::string{passBlocksThrough}) {
VPackBuilder input;
BlockFetcherMock<passBlocksThrough> blockFetcherMock{monitor, 1};
InputAqlItemRow row{CreateInvalidInputRowHint{}};
std::unique_ptr<AqlItemBlock> block = buildBlock<1>(&monitor, {{42}});
@ -251,6 +252,7 @@ GIVEN(std::string{
GIVEN(std::string{"there are multiple blocks upstream, passBlocksThrough="} +
std::string{passBlocksThrough}) {
BlockFetcherMock<passBlocksThrough> blockFetcherMock{monitor, 1};
InputAqlItemRow row{CreateInvalidInputRowHint{}};
// three 1-column matrices with 3, 2 and 1 rows, respectively
std::unique_ptr<AqlItemBlock> block1 = buildBlock<1>(&monitor, {{{1}}, {{2}}, {{3}}}),

View File

@ -317,7 +317,8 @@ TEST_CASE("ConstantWeightShortestPathFinder", "[graph]") {
if (result.length() != vertices.size()) return false;
for (size_t i = 0; i < result.length(); i++) {
auto vert = result.vertexToAqlValue(spo->cache(), i);
AqlValue vert = result.vertexToAqlValue(spo->cache(), i);
AqlValueGuard guard{vert, true};
if (!vert.slice().get(StaticStrings::KeyString).isEqualString(vertices.at(i))) {
LOG_DEVEL << "expected vertex " << vertices.at(i) << " but found "
<< vert.slice().get(StaticStrings::KeyString).toString();
@ -328,7 +329,8 @@ TEST_CASE("ConstantWeightShortestPathFinder", "[graph]") {
// First edge is by convention null
CHECK((result.edgeToAqlValue(spo->cache(), 0).isNull(true)));
for (size_t i = 1; i < result.length(); i++) {
auto edge = result.edgeToAqlValue(spo->cache(), i);
AqlValue edge = result.edgeToAqlValue(spo->cache(), i);
AqlValueGuard guard{edge, true};
if (!edge.slice().get(StaticStrings::FromString).isEqualString(edges.at(i).first) ||
!edge.slice().get(StaticStrings::ToString).isEqualString(edges.at(i).second)) {
LOG_DEVEL << "expected edge " << edges.at(i).first << " -> "