Skip to content

Commit

Permalink
Fix #427, add valgrind support to to ubertests
Browse files Browse the repository at this point in the history
Either add --valgrind-searchd for one-time run,
either add 'valgrindsearchd'=>true to .sphinx config file.
Suppression file test/valgrind.supp will be in game.
  • Loading branch information
klirichek committed Sep 6, 2018
1 parent 1d17669 commit 6da0df4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
25 changes: 21 additions & 4 deletions test/helpers.inc
Expand Up @@ -371,11 +371,25 @@ function StartSearchd ( $config_file, $error_file, $pidfile, &$error, $use_watch
$abs_error_file = testdir($error_file);
$abs_pidfile = testdir($pidfile);

$path = $g_locals['searchd'];
if ( !is_executable($path) )
if ( isset ( $g_locals['valgrindsearchd'] ) )
$use_valgrind = $g_locals['valgrindsearchd'];
else
$use_valgrind = false;

if ( $use_valgrind ) {
$path = "valgrind --leak-check=full ";
if ( file_exists("valgrind.supp" ) )
$path .= "--suppressions=" . getcwd() . "/valgrind.supp ";
$path .= $g_locals['searchd'];
}
else
{
$error = "$path: searchd not found";
return 1;
$path = $g_locals['searchd'];
if ( !is_executable($path) )
{
$error = "$path: searchd not found";
return 1;
}
}

if ( !@touch($abs_error_file) )
Expand Down Expand Up @@ -417,6 +431,9 @@ function StartSearchd ( $config_file, $error_file, $pidfile, &$error, $use_watch
if ($cd)
chdir($backdir);

if ( $use_valgrind )
usleep ( 2000000 );

// wait until pid appears
for ( $i=0; $i<$action_retries && !file_exists($abs_pidfile); $i++ )
usleep ( $action_wait_timeout );
Expand Down
2 changes: 2 additions & 0 deletions test/ubertest.php
Expand Up @@ -48,6 +48,7 @@
print ( "--keep-all\t\tKeep test db and all test data (like generated configs, etc.) after the test (for debugging)\n");
print ( "--no-demo\t\tJust skip all tests without models. Else - run them, but never fail (for debugging)\n");
print ( "--no-marks\t\tDon't mark the output of every test in the logs.\n");
print ( "--valgrind-searchd\t\tRun searchd under valgrind during test.\n");
print ( "--ignore-weights\tIgnore differences in weights. (Useful for testing that reference database changes are ok.)\n" );
print ( "--cwd\t\t\tchange directory to ubertest.php location (for git bisect)\n" );
print ( "\nEnvironment variables are:\n" );
Expand Down Expand Up @@ -103,6 +104,7 @@
else if ( $arg=="--test-thd-pool" ) $locals['use_pool'] = true;
else if ( $arg=="--strict" ) $g_strict = true;
else if ( $arg=="--strict-verbose" ) { $g_strict = true; $g_strictverbose = true; }
else if ( $arg=="--valgrind-searchd" ) $locals['valgrindsearchd'] = true;
else if ( $arg=="--ignore-weights" ) $g_ignore_weights = true;
else if ( $arg=="--no-drop-db" ) $locals['no_drop_db'] = true;
else if ( $arg=="--keep-all" ) $locals['keep_all'] = true;
Expand Down

0 comments on commit 6da0df4

Please sign in to comment.