mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
ng: ensure that only match states have reports
Ensure (and assert) that vertices without an edge to {accept, acceptEod} do not have reports set.
This commit is contained in:
committed by
Matthew Barr
parent
3d9a60d023
commit
4ce268af47
@@ -36,6 +36,7 @@
|
||||
#include "nfa/nfa_internal.h"
|
||||
#include "nfa/nfa_api_util.h"
|
||||
#include "nfagraph/ng_lbr.h"
|
||||
#include "nfagraph/ng_util.h"
|
||||
#include "util/alloc.h"
|
||||
#include "util/compile_context.h"
|
||||
#include "grey.h"
|
||||
@@ -97,6 +98,7 @@ protected:
|
||||
ParsedExpression parsed(0, pattern.c_str(), flags, 0);
|
||||
unique_ptr<NGWrapper> g = buildWrapper(rm, cc, parsed);
|
||||
ASSERT_TRUE(g != nullptr);
|
||||
clearReports(*g);
|
||||
|
||||
ASSERT_TRUE(isLBR(*g, grey));
|
||||
|
||||
|
@@ -31,14 +31,15 @@
|
||||
|
||||
#include "grey.h"
|
||||
#include "compiler/compiler.h"
|
||||
#include "nfagraph/ng.h"
|
||||
#include "nfagraph/ng_limex.h"
|
||||
#include "nfagraph/ng_restructuring.h"
|
||||
#include "nfa/limex_context.h"
|
||||
#include "nfa/limex_internal.h"
|
||||
#include "nfa/nfa_api.h"
|
||||
#include "nfa/nfa_api_util.h"
|
||||
#include "nfa/nfa_internal.h"
|
||||
#include "nfagraph/ng.h"
|
||||
#include "nfagraph/ng_limex.h"
|
||||
#include "nfagraph/ng_restructuring.h"
|
||||
#include "nfagraph/ng_util.h"
|
||||
#include "util/alloc.h"
|
||||
#include "util/target_info.h"
|
||||
|
||||
@@ -76,6 +77,7 @@ protected:
|
||||
ParsedExpression parsed(0, expr.c_str(), flags, 0);
|
||||
unique_ptr<NGWrapper> g = buildWrapper(rm, cc, parsed);
|
||||
ASSERT_TRUE(g != nullptr);
|
||||
clearReports(*g);
|
||||
|
||||
rm.setProgramOffset(0, MATCH_REPORT);
|
||||
|
||||
@@ -310,10 +312,12 @@ protected:
|
||||
ParsedExpression parsed(0, expr.c_str(), flags, 0);
|
||||
unique_ptr<NGWrapper> g = buildWrapper(rm, cc, parsed);
|
||||
ASSERT_TRUE(g != nullptr);
|
||||
clearReports(*g);
|
||||
|
||||
// Reverse the graph and add some reports on the accept vertices.
|
||||
NGHolder g_rev(NFA_REV_PREFIX);
|
||||
reverseHolder(*g, g_rev);
|
||||
clearReports(g_rev);
|
||||
for (NFAVertex v : inv_adjacent_vertices_range(g_rev.accept, g_rev)) {
|
||||
g_rev[v].reports.insert(0);
|
||||
}
|
||||
@@ -367,6 +371,7 @@ protected:
|
||||
ReportManager rm(cc.grey);
|
||||
unique_ptr<NGWrapper> g = buildWrapper(rm, cc, parsed);
|
||||
ASSERT_TRUE(g != nullptr);
|
||||
clearReports(*g);
|
||||
|
||||
rm.setProgramOffset(0, MATCH_REPORT);
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Intel Corporation
|
||||
* Copyright (c) 2015-2016, Intel Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "nfagraph/ng_repeat.h"
|
||||
#include "nfagraph/ng_util.h"
|
||||
#include "util/depth.h"
|
||||
#include "hs_compile.h"
|
||||
|
||||
@@ -89,12 +90,15 @@ static const PureRepeatTest pureRepeatTests[] = {
|
||||
{ "^..?..?..?..?..?", 5, 10 }
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(PureRepeat, NFAPureRepeatTest, ValuesIn(pureRepeatTests));
|
||||
INSTANTIATE_TEST_CASE_P(PureRepeat, NFAPureRepeatTest,
|
||||
ValuesIn(pureRepeatTests));
|
||||
|
||||
TEST_P(NFAPureRepeatTest, Check) {
|
||||
const PureRepeatTest &t = GetParam();
|
||||
SCOPED_TRACE(testing::Message() << "Pattern: " << t.pattern);
|
||||
unique_ptr<NGWrapper> w(constructGraph(t.pattern, HS_FLAG_ALLOWEMPTY));
|
||||
auto w = constructGraph(t.pattern, HS_FLAG_ALLOWEMPTY);
|
||||
ASSERT_TRUE(w != nullptr);
|
||||
clearReports(*w);
|
||||
|
||||
PureRepeat repeat;
|
||||
bool result = isPureRepeat(*w, repeat);
|
||||
|
Reference in New Issue
Block a user