mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
scratch: don't leave in use after hs_clone_scratch
Also updated unit tests to always check hs_alloc_scratch()'s return value.
This commit is contained in:
parent
6c1143a264
commit
73610c0b64
@ -129,7 +129,7 @@ hs_error_t alloc_scratch(const hs_scratch_t *proto, hs_scratch_t **scratch) {
|
||||
*s = *proto;
|
||||
|
||||
s->magic = SCRATCH_MAGIC;
|
||||
s->in_use = 1;
|
||||
s->in_use = 0;
|
||||
s->scratchSize = alloc_size;
|
||||
s->scratch_alloc = (char *)s_tmp;
|
||||
|
||||
@ -357,9 +357,10 @@ hs_error_t hs_alloc_scratch(const hs_database_t *db, hs_scratch_t **scratch) {
|
||||
}
|
||||
} else {
|
||||
hs_scratch_free(proto_tmp); /* kill off temp used for sizing */
|
||||
unmarkScratchInUse(*scratch);
|
||||
}
|
||||
|
||||
unmarkScratchInUse(*scratch);
|
||||
assert(!(*scratch)->in_use);
|
||||
return HS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -376,6 +377,7 @@ hs_error_t hs_clone_scratch(const hs_scratch_t *src, hs_scratch_t **dest) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
assert(!(*dest)->in_use);
|
||||
return HS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
@ -404,7 +404,8 @@ TEST(HyperscanArgChecks, ScanStreamNoStreamID) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -430,8 +431,10 @@ TEST(HyperscanArgChecks, ScanStreamNoData) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_close_stream(stream, scratch, dummy_cb, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_close_stream(stream, scratch, dummy_cb, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -457,8 +460,10 @@ TEST(HyperscanArgChecks, ScanStreamNoScratch) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_close_stream(stream, scratch, dummy_cb, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_close_stream(stream, scratch, dummy_cb, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -479,7 +484,8 @@ TEST(HyperscanArgChecks, CloseStreamNoStream) {
|
||||
ASSERT_NE(HS_SUCCESS, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -544,7 +550,8 @@ TEST(HyperscanArgChecks, CloseStreamNoMatchNoStream) {
|
||||
ASSERT_NE(HS_SUCCESS, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -588,7 +595,8 @@ TEST(HyperscanArgChecks, ChangeStreamContext) {
|
||||
|
||||
// teardown
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
// hs_reset_stream: Call with no stream id
|
||||
@ -606,7 +614,8 @@ TEST(HyperscanArgChecks, ResetStreamNoId) {
|
||||
|
||||
err = hs_reset_stream(nullptr, 0, scratch, dummy_cb, nullptr);
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -632,7 +641,8 @@ TEST(HyperscanArgChecks, ResetStreamNoScratch) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -664,7 +674,8 @@ TEST(HyperscanArgChecks, CopyStreamNoToId) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -687,8 +698,10 @@ TEST(HyperscanArgChecks, ResetAndCopyStreamNoToId) {
|
||||
err = hs_reset_and_copy_stream(nullptr, stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -711,8 +724,10 @@ TEST(HyperscanArgChecks, ResetAndCopyStreamNoFromId) {
|
||||
err = hs_reset_and_copy_stream(stream, nullptr, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -735,8 +750,10 @@ TEST(HyperscanArgChecks, ResetAndCopyStreamSameToId) {
|
||||
err = hs_reset_and_copy_stream(stream, stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -764,9 +781,12 @@ TEST(HyperscanArgChecks, ResetAndCopyStreamNoCallbackOrScratch) {
|
||||
err = hs_reset_and_copy_stream(stream_to, stream, nullptr, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
hs_close_stream(stream_to, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_close_stream(stream_to, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -795,9 +815,12 @@ TEST(HyperscanArgChecks, ResetAndCopyStreamNoScratch) {
|
||||
nullptr);
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
hs_close_stream(stream_to, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_close_stream(stream_to, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -830,9 +853,12 @@ TEST(HyperscanArgChecks, ResetAndCopyStreamDiffDb) {
|
||||
nullptr);
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
hs_close_stream(stream_to, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_close_stream(stream_to, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
hs_free_database(db2);
|
||||
}
|
||||
@ -854,7 +880,8 @@ TEST(HyperscanArgChecks, ScanBlockNoDatabase) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -878,7 +905,8 @@ TEST(HyperscanArgChecks, ScanBlockBrokenDatabaseMagic) {
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
free(db);
|
||||
}
|
||||
|
||||
@ -902,7 +930,8 @@ TEST(HyperscanArgChecks, ScanBlockBrokenDatabaseVersion) {
|
||||
ASSERT_EQ(HS_DB_VERSION_ERROR, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -926,7 +955,8 @@ TEST(HyperscanArgChecks, ScanBlockBrokenDatabaseBytecode) {
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -947,7 +977,8 @@ TEST(HyperscanArgChecks, ScanBlockStreamingDatabase) {
|
||||
ASSERT_EQ(HS_DB_MODE_ERROR, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -967,7 +998,8 @@ TEST(HyperscanArgChecks, ScanBlockVectoredDatabase) {
|
||||
ASSERT_EQ(HS_DB_MODE_ERROR, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -989,7 +1021,8 @@ TEST(HyperscanArgChecks, ScanBlockNoData) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1026,7 +1059,8 @@ TEST(HyperscanArgChecks, ScanBlockNoHandler) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1049,7 +1083,8 @@ TEST(HyperscanArgChecks, ScanVectorNoDatabase) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1075,7 +1110,8 @@ TEST(HyperscanArgChecks, ScanVectorBrokenDatabaseMagic) {
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
free(db);
|
||||
}
|
||||
|
||||
@ -1101,7 +1137,8 @@ TEST(HyperscanArgChecks, ScanVectorBrokenDatabaseVersion) {
|
||||
ASSERT_EQ(HS_DB_VERSION_ERROR, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1127,7 +1164,8 @@ TEST(HyperscanArgChecks, ScanVectorBrokenDatabaseBytecode) {
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1150,7 +1188,8 @@ TEST(HyperscanArgChecks, ScanVectorStreamingDatabase) {
|
||||
ASSERT_EQ(HS_DB_MODE_ERROR, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1172,7 +1211,8 @@ TEST(HyperscanArgChecks, ScanVectorBlockDatabase) {
|
||||
ASSERT_EQ(HS_DB_MODE_ERROR, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1195,7 +1235,8 @@ TEST(HyperscanArgChecks, ScanVectorNoDataArray) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1218,7 +1259,8 @@ TEST(HyperscanArgChecks, ScanVectorNoDataBlock) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1240,7 +1282,8 @@ TEST(HyperscanArgChecks, ScanVectorNoLenArray) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1281,7 +1324,8 @@ TEST(HyperscanArgChecks, ScanVectorNoHandler) {
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1421,7 +1465,8 @@ TEST(HyperscanArgChecks, AllocScratchBadDatabaseCRC) {
|
||||
hs_scratch_t *scratch = nullptr;
|
||||
err = hs_alloc_scratch(db, &scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
// for want of a better case, corrupt the "middle byte" of the database.
|
||||
char *mid = (char *)db + len/2;
|
||||
@ -1959,7 +2004,8 @@ TEST(HyperscanArgChecks, ScratchSizeNoSize) {
|
||||
err = hs_scratch_size(scratch, nullptr);
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -2039,7 +2085,8 @@ TEST(HyperscanArgChecks, ScanStreamBadScratch) {
|
||||
ASSERT_TRUE(scratch != nullptr);
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
free(local_garbage);
|
||||
}
|
||||
|
||||
@ -2073,7 +2120,8 @@ TEST(HyperscanArgChecks, ResetStreamBadScratch) {
|
||||
ASSERT_TRUE(scratch != nullptr);
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
free(local_garbage);
|
||||
}
|
||||
|
||||
@ -2116,7 +2164,8 @@ TEST(HyperscanArgChecks, ScanFreedScratch) {
|
||||
err = hs_alloc_scratch(db, &scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_TRUE(scratch != NULL);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
err = hs_scan(db, "data", 4, 0, scratch, dummy_cb, 0);
|
||||
ASSERT_EQ(HS_INVALID, err);
|
||||
EXPECT_NE(HS_SCAN_TERMINATED, err);
|
||||
|
@ -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:
|
||||
@ -118,7 +118,8 @@ TEST(HyperscanTestBehaviour, ScanSeveralGigabytesNoMatch) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -197,7 +198,8 @@ TEST_P(HyperscanScanGigabytesMatch, StreamingMatch) {
|
||||
}
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -287,7 +289,8 @@ TEST_P(HyperscanScanGigabytesMatch, BlockMatch) {
|
||||
}
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -349,7 +352,8 @@ TEST(HyperscanTestBehaviour, StreamingThereCanBeOnlyOne) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -379,7 +383,8 @@ TEST(HyperscanTestBehaviour, BlockThereCanBeOnlyOne) {
|
||||
EXPECT_EQ(1U, matchCount); // only one match
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -425,7 +430,8 @@ TEST_P(HyperscanLiteralLengthTest, FloatingBlock) {
|
||||
EXPECT_EQ(0U, matchCount); // no matches
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -463,7 +469,8 @@ TEST_P(HyperscanLiteralLengthTest, AnchoredBlock) {
|
||||
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -505,7 +512,8 @@ TEST_P(CallbackReturnStop, Block) {
|
||||
ASSERT_EQ(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -543,7 +551,8 @@ TEST_P(CallbackReturnStop, Streaming) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -575,7 +584,8 @@ TEST_P(CallbackReturnStop, Vectored) {
|
||||
ASSERT_EQ(HS_SCAN_TERMINATED, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -642,7 +652,8 @@ TEST(HyperscanTestBehaviour, SerializedDogfood1) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(len, lastMatchTo);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db2);
|
||||
}
|
||||
|
||||
@ -734,7 +745,8 @@ TEST(HyperscanTestBehaviour, SerializedDogfood2) {
|
||||
ASSERT_EQ(len2, lastMatchTo);
|
||||
ASSERT_EQ(ids[3], lastMatchId);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db2);
|
||||
}
|
||||
|
||||
@ -805,7 +817,8 @@ TEST(HyperscanTestBehaviour, SerializedDogfood3) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(len, lastMatchTo);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
free(mem);
|
||||
}
|
||||
|
||||
@ -840,7 +853,8 @@ TEST(HyperscanTestBehaviour, CloseStreamMatch) {
|
||||
EXPECT_EQ(1U, matchCount); // our match was returned
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -876,7 +890,8 @@ TEST(HyperscanTestBehaviour, NoMainCB) {
|
||||
EXPECT_EQ(1U, matchCount); // our match was returned
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -913,7 +928,8 @@ TEST(HyperscanTestBehaviour, CloseStreamNoMatch) {
|
||||
EXPECT_EQ(0U, matchCount); // no match was returned
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -948,7 +964,8 @@ TEST(HyperscanTestBehaviour, CloseStreamAfterTermination) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -976,7 +993,8 @@ TEST(HyperscanTestBehaviour, Vectored1) {
|
||||
EXPECT_EQ(1U, matchCount);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1004,7 +1022,8 @@ TEST(HyperscanTestBehaviour, Vectored2) {
|
||||
EXPECT_EQ(1U, matchCount);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1032,7 +1051,8 @@ TEST(HyperscanTestBehaviour, Vectored3) {
|
||||
EXPECT_EQ(1U, matchCount);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1060,7 +1080,8 @@ TEST(HyperscanTestBehaviour, Vectored4) {
|
||||
EXPECT_EQ(1U, matchCount);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1088,7 +1109,8 @@ TEST(HyperscanTestBehaviour, Vectored5) {
|
||||
EXPECT_EQ(0U, matchCount);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1116,7 +1138,8 @@ TEST(HyperscanTestBehaviour, Vectored6) {
|
||||
EXPECT_EQ(1U, matchCount);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1144,7 +1167,8 @@ TEST(HyperscanTestBehaviour, Vectored7) {
|
||||
EXPECT_EQ(1U, matchCount);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1189,7 +1213,8 @@ TEST(regression, UE_1005) {
|
||||
!= c.matches.end());
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1293,7 +1318,8 @@ TEST(regression, UE_2762) {
|
||||
c.matches.end());
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1333,7 +1359,8 @@ TEST(regression, UE_2763) {
|
||||
c.matches.end());
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1378,7 +1405,8 @@ TEST(regression, UE_2798) {
|
||||
c.matches.end());
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1403,7 +1431,8 @@ TEST(PcreSpace, NewPcre) {
|
||||
EXPECT_EQ(data.size(), matchCount); // all are spaces
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1428,7 +1457,8 @@ TEST(PcreSpace, NewPcreClass) {
|
||||
EXPECT_EQ(data.size(), matchCount); // all are spaces
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1453,7 +1483,8 @@ TEST(PcreSpace, NewPcreNeg) {
|
||||
EXPECT_EQ(0, matchCount); // no matches, all are spaces
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1478,7 +1509,8 @@ TEST(PcreSpace, NewPcreClassNeg) {
|
||||
EXPECT_EQ(0, matchCount); // no matches, all are spaces
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -1502,7 +1534,8 @@ TEST(Parser, NewlineTerminatedComment) {
|
||||
EXPECT_EQ(1, matchCount);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
@ -70,7 +70,8 @@ TEST(ExtParam, LargeMinOffset) {
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(100000, 0), c.matches[0]);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -116,7 +117,8 @@ TEST(ExtParam, LargeExactOffset) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(0U, c.matches.size());
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -153,6 +155,7 @@ TEST(ExtParam, LargeMinLength) {
|
||||
ASSERT_EQ(1U, c.matches.size());
|
||||
ASSERT_EQ(MatchRecord(110000, 0), c.matches[0]);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
@ -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:
|
||||
@ -64,7 +64,8 @@ TEST_P(IdenticalTest, Block) {
|
||||
record_cb, &cb);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
|
||||
ASSERT_EQ(patterns.size(), cb.matches.size());
|
||||
@ -111,7 +112,8 @@ TEST_P(IdenticalTest, Stream) {
|
||||
err = hs_close_stream(stream, scratch, record_cb, &cb);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
|
||||
ASSERT_EQ(patterns.size(), cb.matches.size());
|
||||
@ -151,7 +153,8 @@ TEST_P(IdenticalTest, Vectored) {
|
||||
err = hs_scan_vector(db, data, datalen, 1, 0, scratch, record_cb, &cb);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
|
||||
ASSERT_EQ(patterns.size(), cb.matches.size());
|
||||
|
@ -67,7 +67,8 @@ TEST(MMAdaptor, norm_cont1) { // UE-901
|
||||
ASSERT_EQ(MatchRecord(12, 31), c.matches[2]);
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(MMAdaptor, norm_cont2) {
|
||||
@ -99,7 +100,8 @@ TEST(MMAdaptor, norm_cont2) {
|
||||
ASSERT_TRUE(c.matches.end() != find(c.matches.begin(), c.matches.end(), MatchRecord(28, 31)));
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(MMAdaptor, norm_halt1) {
|
||||
@ -129,7 +131,8 @@ TEST(MMAdaptor, norm_halt1) {
|
||||
ASSERT_EQ(MatchRecord(4, 30), c.matches[0]);
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(MMAdaptor, norm_halt2) { // UE-901
|
||||
@ -159,7 +162,8 @@ TEST(MMAdaptor, norm_halt2) { // UE-901
|
||||
ASSERT_EQ(MatchRecord(20, 30), c.matches[0]);
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(MMAdaptor, high_cont1) { // UE-901
|
||||
@ -190,7 +194,8 @@ TEST(MMAdaptor, high_cont1) { // UE-901
|
||||
ASSERT_TRUE(c.matches.end() != find(c.matches.begin(), c.matches.end(), MatchRecord(12, 31)));
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(MMAdaptor, high_cont2) {
|
||||
@ -221,7 +226,8 @@ TEST(MMAdaptor, high_cont2) {
|
||||
ASSERT_TRUE(c.matches.end() != find(c.matches.begin(), c.matches.end(), MatchRecord(28, 31)));
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(MMAdaptor, high_halt1) {
|
||||
@ -251,7 +257,8 @@ TEST(MMAdaptor, high_halt1) {
|
||||
ASSERT_EQ(MatchRecord(4, 30), c.matches[0]);
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(MMAdaptor, high_halt2) {
|
||||
@ -282,7 +289,8 @@ TEST(MMAdaptor, high_halt2) {
|
||||
|| MatchRecord(28, 31) == c.matches[0]);
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
TEST(MPV, UE_2395) {
|
||||
@ -322,5 +330,6 @@ TEST(MPV, UE_2395) {
|
||||
ASSERT_EQ(300, seen);
|
||||
|
||||
hs_free_database(db);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
@ -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:
|
||||
@ -91,7 +91,8 @@ TEST(order, ordering1) {
|
||||
EXPECT_EQ(5U, countMatchesById(c.matches, 4));
|
||||
EXPECT_EQ(5U, countMatchesById(c.matches, 5));
|
||||
ASSERT_TRUE(matchesOrdered(c.matches));
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -122,7 +123,8 @@ TEST(order, ordering2) {
|
||||
EXPECT_EQ(5U, countMatchesById(c.matches, 4));
|
||||
EXPECT_EQ(5U, countMatchesById(c.matches, 5));
|
||||
ASSERT_TRUE(matchesOrdered(c.matches));
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -152,7 +154,8 @@ TEST(order, ordering3) {
|
||||
EXPECT_EQ(5U, countMatchesById(c.matches, 4));
|
||||
EXPECT_EQ(0U, countMatchesById(c.matches, 5));
|
||||
ASSERT_TRUE(matchesOrdered(c.matches));
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -182,7 +185,8 @@ TEST(order, ordering4) {
|
||||
EXPECT_EQ(0U, countMatchesById(c.matches, 4));
|
||||
EXPECT_EQ(0U, countMatchesById(c.matches, 5));
|
||||
ASSERT_TRUE(matchesOrdered(c.matches));
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -225,7 +229,8 @@ TEST(order, ordering5) {
|
||||
c.matches.clear();
|
||||
hs_close_stream(stream, scratch, record_cb, (void *)&c);
|
||||
}
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -267,7 +272,8 @@ TEST(order, ordering6) {
|
||||
c.matches.clear();
|
||||
hs_close_stream(stream, scratch, record_cb, (void *)&c);
|
||||
}
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -308,7 +314,8 @@ TEST(order, ordering7) {
|
||||
c.matches.clear();
|
||||
hs_close_stream(stream, scratch, record_cb, (void *)&c);
|
||||
}
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -349,7 +356,8 @@ TEST(order, ordering8) {
|
||||
c.matches.clear();
|
||||
hs_close_stream(stream, scratch, record_cb, (void *)&c);
|
||||
}
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,8 @@ void runBlockTest(match_event_handler cb_func) {
|
||||
ASSERT_EQ(1, rc.matches);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
// Generic streaming mode test that uses the given scan callback.
|
||||
@ -112,7 +113,8 @@ void runStreamingTest(match_event_handler cb_func) {
|
||||
|
||||
// teardown
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
// Generic vectored mode test that uses the given scan callback.
|
||||
@ -139,7 +141,8 @@ void runVectoredTest(match_event_handler cb_func) {
|
||||
ASSERT_EQ(1, rc.matches);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -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:
|
||||
@ -75,7 +75,8 @@ TEST(scratch, testAlloc) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(last_alloc_size, curr_size);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
hs_set_allocator(nullptr, nullptr);
|
||||
}
|
||||
@ -114,7 +115,8 @@ TEST(scratch, testScratchAlloc) {
|
||||
ASSERT_EQ(allocated_count, curr_size);
|
||||
ASSERT_EQ(allocated_count_b, old_b);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
hs_set_allocator(nullptr, nullptr);
|
||||
|
||||
@ -185,7 +187,8 @@ TEST(scratch, testScratchRealloc) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(last_alloc_size, curr_size);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
hs_free_database(db2);
|
||||
hs_set_scratch_allocator(nullptr, nullptr);
|
||||
@ -217,7 +220,8 @@ TEST(scratch, tooSmallForDatabase) {
|
||||
err = hs_scan(db2, "somedata", 8, 0, scratch, dummy_cb, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db2);
|
||||
}
|
||||
|
||||
@ -252,7 +256,8 @@ TEST(scratch, tooSmallForDatabase2) {
|
||||
err = hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db2);
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
@ -157,7 +157,8 @@ protected:
|
||||
}
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
virtual void zeroLengthScan() {
|
||||
@ -195,7 +196,8 @@ protected:
|
||||
}
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
// Can we allocate and clone scratch
|
||||
@ -212,8 +214,10 @@ protected:
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
EXPECT_TRUE(cloned != nullptr);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
hs_free_scratch(cloned);
|
||||
err = hs_free_scratch(scratch);
|
||||
EXPECT_EQ(HS_SUCCESS, err);
|
||||
err = hs_free_scratch(cloned);
|
||||
EXPECT_EQ(HS_SUCCESS, err);
|
||||
}
|
||||
|
||||
// Can we scan with the database (ignoring the matches, and using
|
||||
@ -412,7 +416,8 @@ protected:
|
||||
// that platform produces HS_SUCCESS.
|
||||
if (err == HS_SUCCESS) {
|
||||
// host platform.
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
} else {
|
||||
ASSERT_EQ(HS_DB_PLATFORM_ERROR, err);
|
||||
ASSERT_TRUE(!scratch);
|
||||
@ -519,7 +524,8 @@ TEST_P(HyperscanTestMatchTerminate, MoreThanOne) {
|
||||
ASSERT_EQ(HS_SUCCESS, err) << "hs_scan didn't return HS_SCAN_TERMINATED";
|
||||
ASSERT_LT(1, count) << "Number of matches returned was not greater than 1.";
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -538,7 +544,8 @@ TEST_P(HyperscanTestMatchTerminate, Block) {
|
||||
<< "hs_scan didn't return HS_SCAN_TERMINATED";
|
||||
ASSERT_EQ(1, count) << "Number of matches returned was not 1.";
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -563,7 +570,8 @@ TEST_P(HyperscanTestMatchTerminate, StreamWhole) {
|
||||
err = hs_close_stream(stream, scratch, terminateHandler, &count);
|
||||
ASSERT_EQ(1, count) << "Number of matches returned was not 1.";
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -591,7 +599,8 @@ TEST_P(HyperscanTestMatchTerminate, StreamByteByByte) {
|
||||
err = hs_close_stream(stream, scratch, terminateHandler, &count);
|
||||
ASSERT_EQ(1, count) << "Number of matches returned was not 1.";
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
@ -132,7 +132,8 @@ TEST_P(SomTest, PastHorizon) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -190,7 +191,8 @@ TEST_P(SomTest, NearHorizon) {
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
|
||||
// teardown
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
@ -82,7 +82,8 @@ TEST(StreamUtil, reset1) {
|
||||
ASSERT_EQ(MatchRecord(1009, 0), c2.matches[0]);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -122,7 +123,8 @@ TEST(StreamUtil, reset2) {
|
||||
ASSERT_EQ(MatchRecord(9, 0), c2.matches[0]);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -150,7 +152,8 @@ TEST(StreamUtil, reset_matches) {
|
||||
ASSERT_EQ(MatchRecord(9, 0), c.matches[0]);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -198,7 +201,8 @@ TEST(StreamUtil, copy1) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -241,7 +245,8 @@ TEST(StreamUtil, copy2) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -284,7 +289,8 @@ TEST(StreamUtil, copy_reset1) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -328,7 +334,8 @@ TEST(StreamUtil, copy_reset2) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -380,7 +387,8 @@ TEST(StreamUtil, copy_reset3) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -427,7 +435,8 @@ TEST(StreamUtil, copy_reset4) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -483,7 +492,8 @@ TEST(StreamUtil, copy_reset5) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -519,7 +529,8 @@ TEST(StreamUtil, copy_reset_matches) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -554,7 +565,8 @@ TEST(StreamUtil, size) {
|
||||
hs_set_allocator(nullptr, nullptr);
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
}
|
||||
|
||||
@ -629,7 +641,8 @@ TEST(StreamUtil, Alloc) {
|
||||
|
||||
hs_close_stream(stream, scratch, record_cb, (void *)&c);
|
||||
ASSERT_EQ(alloc_called, 0);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
hs_free_compile_error(compile_err);
|
||||
hs_set_allocator(nullptr, nullptr);
|
||||
@ -670,7 +683,8 @@ TEST(StreamUtil, MoreAlloc) {
|
||||
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
ASSERT_EQ(alloc_called, 2);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
ASSERT_EQ(alloc_called, 1);
|
||||
hs_free_database(db);
|
||||
ASSERT_EQ(alloc_called, 0);
|
||||
@ -702,7 +716,8 @@ TEST(StreamUtil, BadStreamAlloc) {
|
||||
err = hs_open_stream(db, 0, &stream);
|
||||
ASSERT_NE(HS_SUCCESS, err);
|
||||
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
hs_free_compile_error(compile_err);
|
||||
hs_set_stream_allocator(nullptr, nullptr);
|
||||
@ -758,7 +773,8 @@ TEST(StreamUtil, StreamAllocUsage) {
|
||||
hs_close_stream(stream, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream2, scratch, nullptr, nullptr);
|
||||
hs_close_stream(stream3, scratch, nullptr, nullptr);
|
||||
hs_free_scratch(scratch);
|
||||
err = hs_free_scratch(scratch);
|
||||
ASSERT_EQ(HS_SUCCESS, err);
|
||||
hs_free_database(db);
|
||||
hs_free_compile_error(compile_err);
|
||||
hs_set_allocator(nullptr, nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user