Skip to content

Commit 0cfae4c

Browse files
committed
Fixed #167, debug build crashed on exit.
Also added rlp testing to CI pipeline
1 parent c627dd6 commit 0cfae4c

File tree

11 files changed

+54
-34
lines changed

11 files changed

+54
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
/test/test_*/report.txt
5959
/test/test_*/Conf
6060
/test/data
61+
/test/localsettings.inc
6162

6263
# /test/ql/
6364
/test/ql/data/*.log

CMakeLists.txt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ else ( WIN32 )
309309
message ( STATUS "Option WITH_RLP ${WITH_RLP}" )
310310
option ( WITH_RLP "compile with RLP library support" OFF )
311311
if ( WITH_RLP )
312-
SET ( RLP_ROOT "${MANTICORE_SOURCE_DIR}/rlp" CACHE PATH "RLP root folder." )
312+
SET ( RLP_ROOT "${MANTICORE_SOURCE_DIR}" CACHE PATH "RLP root folder." )
313313
if ( RLP_PATH )
314314
if ( NOT RLP_ROOT )
315315
set ( RLP_ROOT "${RLP_PATH}" )
@@ -320,7 +320,15 @@ else ( WIN32 )
320320
endif ()
321321

322322
if ( RLP_ROOT )
323-
if ( EXISTS "${RLP_ROOT}/rlp/include/bt_rlp_c.h" )
323+
if ( EXISTS "${RLP_ROOT}/rlp/rlp/include/bt_rlp_c.h" )
324+
set ( USE_RLP 1 )
325+
elseif ( EXISTS "${RLP_ROOT}/rlp/include/bt_rlp_c.h" )
326+
message ( WARNING "RLP_ROOT must point not to RLP sources folder, but to it's parent" )
327+
GET_FILENAME_COMPONENT ( RLP_ROOT_NAME ${RLP_ROOT} NAME )
328+
GET_FILENAME_COMPONENT ( RLP_ROOT ${RLP_ROOT} PATH )
329+
if ( NOT ${RLP_ROOT_NAME} STREQUAL rlp )
330+
message ( SEND_ERROR "RLP sources must be located in folder '${RLP_ROOT}/rlp', not '${RLP_ROOT}/${RLP_ROOT_NAME}'" )
331+
endif ()
324332
set ( USE_RLP 1 )
325333
else ()
326334
message ( SEND_ERROR "missing RLP sources from ${RLP_ROOT}" )
@@ -329,10 +337,10 @@ else ( WIN32 )
329337

330338
if ( USE_RLP )
331339
if ( NOT RLP_LIBPATH )
332-
file ( GLOB RLPLIBS "${RLP_ROOT}/lib/*gcc*" )
340+
file ( GLOB RLPLIBS "${RLP_ROOT}/rlp/lib/*gcc*" )
333341
endif ()
334342

335-
include_directories ( "${RLP_ROOT}/rlp/include" "${RLP_ROOT}/utilities/include" )
343+
include_directories ( "${RLP_ROOT}/rlp/rlp/include" "${RLP_ROOT}/rlp/utilities/include" )
336344
add_definitions ( "-D_REENTRANT" )
337345
find_library ( LIBRLPC btrlpc HINT "${RLPLIBS}" )
338346
find_library ( LIBRLPCORE btrlpcore HINT "${RLPLIBS}" )

config/config_cmake.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132

133133
/* RLP library support */
134134
#cmakedefine USE_RLP ${USE_RLP}
135+
#cmakedefine RLP_ROOT "${RLP_ROOT}"
135136

136137
/* define to use POSIX Syslog for logging */
137138
#cmakedefine USE_SYSLOG ${USE_SYSLOG}

src/sphinxrlp.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,20 @@
3535
#define SHAREDIR "."
3636
#endif
3737

38+
#ifndef RLP_ROOT
39+
#define RLP_ROOT SHAREDIR
40+
#define RLP_ENV SHAREDIR"/rlp-environment.xml"
41+
#else
42+
#define RLP_ENV RLP_ROOT"/rlp/etc/rlp-environment.xml"
43+
#endif
44+
3845

39-
CSphString g_sRLPRoot = SHAREDIR;
40-
CSphString g_sRLPEnv = SHAREDIR"/rlp-environment.xml";
46+
CSphString g_sRLPRoot { RLP_ROOT };
47+
CSphString g_sRLPEnv { RLP_ENV };
4148
int g_iRLPMaxBatchSize = 51200;
4249
int g_iRLPMaxBatchDocs = 50;
4350

44-
BT_RLP_EnvironmentC * g_pRLPEnv = NULL;
51+
BT_RLP_EnvironmentC * g_pRLPEnv = nullptr;
4552

4653

4754
static void RLPLog ( void *, int iChannel, const char * szMessage )
@@ -74,7 +81,7 @@ static bool sphRLPInit ( const char * szRootPath, const char * szEnvPath, CSphSt
7481
}
7582

7683
BT_RLP_Environment_SetBTRootDirectory ( szRootPath );
77-
BT_RLP_Environment_SetLogCallbackFunction ( NULL, RLPLog );
84+
BT_RLP_Environment_SetLogCallbackFunction ( nullptr, RLPLog );
7885
BT_RLP_Environment_SetLogLevel ( "error" );
7986

8087
g_pRLPEnv = BT_RLP_Environment_Create();
@@ -89,7 +96,7 @@ static bool sphRLPInit ( const char * szRootPath, const char * szEnvPath, CSphSt
8996
{
9097
sError = "Unable to initialize the RLP environment";
9198
BT_RLP_Environment_Destroy ( g_pRLPEnv );
92-
g_pRLPEnv = NULL;
99+
g_pRLPEnv = nullptr;
93100
return false;
94101
}
95102
}
@@ -100,9 +107,9 @@ static bool sphRLPInit ( const char * szRootPath, const char * szEnvPath, CSphSt
100107

101108
void sphRLPDone ()
102109
{
103-
assert ( g_pRLPEnv );
104-
BT_RLP_Environment_Destroy ( g_pRLPEnv );
105-
g_pRLPEnv = NULL;
110+
if ( g_pRLPEnv )
111+
BT_RLP_Environment_Destroy ( g_pRLPEnv );
112+
g_pRLPEnv = nullptr;
106113
}
107114

108115

@@ -113,11 +120,6 @@ class CSphRLPPreprocessor
113120
: m_sRootPath ( szRootPath )
114121
, m_sEnvPath ( szEnvPath )
115122
, m_sCtxPath ( szCtxPath )
116-
, m_pContext ( NULL )
117-
, m_pFactory ( NULL )
118-
, m_pTokenIterator ( NULL )
119-
, m_iNextCompoundComponent ( -1 )
120-
, m_bInitialized ( false )
121123
{
122124
sphUTF8Encode ( m_pMarkerChunkSeparator, PROXY_CHUNK_SEPARATOR );
123125
}
@@ -218,11 +220,11 @@ class CSphRLPPreprocessor
218220
static const int MAX_TOKEN_LEN = 1024;
219221
static const int MAX_CHUNK_SIZE = 10485760;
220222

221-
BT_RLP_ContextC * m_pContext;
222-
BT_RLP_TokenIteratorFactoryC * m_pFactory;
223-
BT_RLP_TokenIteratorC * m_pTokenIterator;
224-
int m_iNextCompoundComponent;
225-
bool m_bInitialized;
223+
BT_RLP_ContextC * m_pContext = nullptr;
224+
BT_RLP_TokenIteratorFactoryC * m_pFactory = nullptr;
225+
BT_RLP_TokenIteratorC * m_pTokenIterator = nullptr;
226+
int m_iNextCompoundComponent = -1;
227+
bool m_bInitialized = false;
226228
CSphTightVector<BYTE> m_dCJKBuffer;
227229
CSphTightVector<BYTE> m_dNonCJKBuffer;
228230
CSphTightVector<TextChunk_t> m_dNonCJKChunks;

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ if ( NOT DISABLE_TESTING )
5454
COMMAND php ubertest.php
5555
-b "${MANTICORE_BINARY_DIR}/src/"
5656
-t "${MANTICORE_BINARY_DIR}/test/"
57+
-r "${RLP_ROOT}"
5758
--ctest -u test --strict-verbose --no-demo
5859
t ${onetest} )
5960
add_test ( NAME "\"rt_${tst_name}\""
@@ -62,6 +63,7 @@ if ( NOT DISABLE_TESTING )
6263
COMMAND php ubertest.php
6364
-b "${MANTICORE_BINARY_DIR}/src/"
6465
-t "${MANTICORE_BINARY_DIR}/test/"
66+
-r "${RLP_ROOT}"
6567
--ctest -u test --strict-verbose --no-demo
6668
--rt --ignore-weights
6769
t ${onetest} )

test/helpers.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ function StartSearchd ( $config_file, $error_file, $pidfile, &$error, $use_watch
495495
function StopSearchd ( $config, $pidfile )
496496
{
497497
global $g_locals, $action_retries, $action_wait_timeout;
498-
498+
$ret = 0;
499499
$abs_config = testdir($config);
500500
$abs_pidfile = testdir($pidfile);
501501

@@ -512,10 +512,12 @@ function StopSearchd ( $config, $pidfile )
512512
$i++;
513513
}
514514
}
515+
return $ret;
515516
}
516517

517518
function StopWaitSearchd ( $config, $pidfile )
518519
{
520+
return StopSearchd ( $config, $pidfile );
519521
global $g_locals;
520522
$ret = 0;
521523

@@ -3113,6 +3115,7 @@ class SphinxConfig
31133115

31143116
case "local": fwrite ( $fp, $this->GetLocal ( $node->nodeValue ) ); return;
31153117
case "test_root": fwrite ( $fp, dirname(__FILE__) ); return;
3118+
case "rlp_root": fwrite ( $fp, $g_locals['rlproot'] ); return;
31163119
case "this_test": fwrite ( $fp, $this->_testdir ); return;
31173120
case "testdir": {
31183121
if ( $g_locals['testdir'] == '' ) {

test/test_218/model.bin

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

test/test_218/test.xml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ indexer
1616
searchd
1717
{
1818
<searchd_settings/>
19-
workers = threads
2019
}
2120

2221
source test
@@ -49,7 +48,7 @@ index base
4948
</dynamic>
5049

5150
blend_chars = -, U+23
52-
rlp_context = ../rlp/samples/etc/rlp-chinese-context.xml
51+
rlp_context = <rlp_root/>/rlp/samples/etc/rlp-chinese-context.xml
5352
}
5453

5554
index test : base
@@ -102,13 +101,13 @@ index test_spec
102101
U+F900..U+FAD9, U+20000..U+2FA1D
103102

104103
morphology = rlp_chinese_batched
105-
rlp_context = ../rlp/samples/etc/rlp-chinese-context.xml
104+
rlp_context = <rlp_root/>/rlp/samples/etc/rlp-chinese-context.xml
106105
}
107106

108107
common
109108
{
110-
rlp_root = ..
111-
rlp_environment = ../rlp/etc/rlp-environment.xml
109+
rlp_root = <rlp_root/>
110+
rlp_environment = <rlp_root/>/rlp/etc/rlp-environment.xml
112111
}
113112
</config>
114113

test/test_326/test.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ index test
3636
U+F900..U+FAD9, U+20000..U+2FA1D
3737

3838
morphology = rlp_chinese_batched, stem_enru
39-
rlp_context = ../rlp/samples/etc/rlp-chinese-context.xml
39+
rlp_context = <rlp_root/>/rlp/samples/etc/rlp-chinese-context.xml
4040
index_field_lengths = 1
4141
}
4242

@@ -50,7 +50,7 @@ index rt
5050
U+F900..U+FAD9, U+20000..U+2FA1D
5151

5252
morphology = rlp_chinese_batched, stem_enru
53-
rlp_context = ../rlp/samples/etc/rlp-chinese-context.xml
53+
rlp_context = <rlp_root/>/rlp/samples/etc/rlp-chinese-context.xml
5454

5555
rt_field = content
5656
rt_field = text
@@ -59,8 +59,8 @@ index rt
5959

6060
common
6161
{
62-
rlp_root = ..
63-
rlp_environment = ../rlp/etc/rlp-environment.xml
62+
rlp_root = <rlp_root/>
63+
rlp_environment = <rlp_root/>/rlp/etc/rlp-environment.xml
6464
}
6565
</config>
6666

test/ubertest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
print ( "-i, --indexer <PATH>\tpath to indexer\n" );
4141
print ( "-s, --searchd <PATH>\tpath to searchd\n" );
4242
print ( "-b, --bindir <PATH>\tpath to all binaries\n" );
43+
print ( "-r, --rlproot <PATH>\tpath to RLP root (if rlp tested)\n" );
4344
print ( "-t, --testdir <PATH>\tpath where to work and create artefacts\n" );
4445
print ( "--ctest\t\tPrint test report to console (for automatic grabbing)\n" );
4546
print ( "--strict\t\tterminate on the first failure (for automatic runs)\n" );
@@ -70,6 +71,7 @@
7071
$locals['rt_mode'] = false;
7172
$locals['testdir'] = '';
7273
$locals['ctest'] = false;
74+
$locals['rlproot'] = '..';
7375

7476
if ( array_key_exists ( "DBUSER", $_ENV ) && $_ENV["DBUSER"] )
7577
$locals['db-user'] = $_ENV["DBUSER"];
@@ -99,6 +101,7 @@
99101
else if ( $arg=="-s" || $arg=="--searchd" ) $locals['searchd'] = $args[++$i];
100102
else if ( $arg=="-b" || $arg=="--bindir" ) $locals['bin'] = $args[++$i];
101103
else if ( $arg=="-t" || $arg=="--testdir" ) $locals['testdir'] = $args[++$i];
104+
else if ( $arg=="-r" || $arg=="--rlproot" ) $locals['rlproot'] = $args[++$i];
102105
else if ( $arg=="--ctest" ) { $locals['ctest'] = true; $force_guess = false; }
103106
else if ( $arg=="--rt" ) $locals['rt_mode'] = true;
104107
else if ( $arg=="--test-thd-pool" ) $locals['use_pool'] = true;

0 commit comments

Comments
 (0)