@ -211,6 +211,8 @@ default_params = {
}
}
_TEST_DIR_ENV_VAR = " TEST_TMPDIR "
_TEST_DIR_ENV_VAR = " TEST_TMPDIR "
# If TEST_TMPDIR_EXPECTED is not specified, default value will be TEST_TMPDIR
_TEST_EXPECTED_DIR_ENV_VAR = " TEST_TMPDIR_EXPECTED "
_DEBUG_LEVEL_ENV_VAR = " DEBUG_LEVEL "
_DEBUG_LEVEL_ENV_VAR = " DEBUG_LEVEL "
stress_cmd = " ./db_stress "
stress_cmd = " ./db_stress "
@ -233,7 +235,10 @@ def get_dbname(test_name):
print ( " Running DB cleanup command - %s \n " % cleanup_cmd )
print ( " Running DB cleanup command - %s \n " % cleanup_cmd )
# Ignore failure
# Ignore failure
os . system ( cleanup_cmd )
os . system ( cleanup_cmd )
os . mkdir ( dbname )
try :
os . mkdir ( dbname )
except OSError :
pass
return dbname
return dbname
@ -245,12 +250,18 @@ def setup_expected_values_dir():
if expected_values_dir is not None :
if expected_values_dir is not None :
return expected_values_dir
return expected_values_dir
expected_dir_prefix = " rocksdb_crashtest_expected_ "
expected_dir_prefix = " rocksdb_crashtest_expected_ "
test_tmpdir = os . environ . get ( _TEST_DIR_ENV_VAR )
test_exp_tmpdir = os . environ . get ( _TEST_EXPECTED_DIR_ENV_VAR )
if test_tmpdir is None or test_tmpdir == " " :
# set the value to _TEST_DIR_ENV_VAR if _TEST_EXPECTED_DIR_ENV_VAR is not
# specified.
if test_exp_tmpdir is None or test_exp_tmpdir == " " :
test_exp_tmpdir = os . environ . get ( _TEST_DIR_ENV_VAR )
if test_exp_tmpdir is None or test_exp_tmpdir == " " :
expected_values_dir = tempfile . mkdtemp ( prefix = expected_dir_prefix )
expected_values_dir = tempfile . mkdtemp ( prefix = expected_dir_prefix )
else :
else :
# if tmpdir is specified, store the expected_values_dir under that dir
# if tmpdir is specified, store the expected_values_dir under that dir
expected_values_dir = test_tmpdir + " /rocksdb_crashtest_expected "
expected_values_dir = test_exp_ tmpdir + " /rocksdb_crashtest_expected "
if os . path . exists ( expected_values_dir ) :
if os . path . exists ( expected_values_dir ) :
shutil . rmtree ( expected_values_dir )
shutil . rmtree ( expected_values_dir )
os . mkdir ( expected_values_dir )
os . mkdir ( expected_values_dir )
@ -265,16 +276,22 @@ def setup_multiops_txn_key_spaces_file():
if multiops_txn_key_spaces_file is not None :
if multiops_txn_key_spaces_file is not None :
return multiops_txn_key_spaces_file
return multiops_txn_key_spaces_file
key_spaces_file_prefix = " rocksdb_crashtest_multiops_txn_key_spaces "
key_spaces_file_prefix = " rocksdb_crashtest_multiops_txn_key_spaces "
test_tmpdir = os . environ . get ( _TEST_DIR_ENV_VAR )
test_exp_tmpdir = os . environ . get ( _TEST_EXPECTED_DIR_ENV_VAR )
if test_tmpdir is None or test_tmpdir == " " :
# set the value to _TEST_DIR_ENV_VAR if _TEST_EXPECTED_DIR_ENV_VAR is not
# specified.
if test_exp_tmpdir is None or test_exp_tmpdir == " " :
test_exp_tmpdir = os . environ . get ( _TEST_DIR_ENV_VAR )
if test_exp_tmpdir is None or test_exp_tmpdir == " " :
multiops_txn_key_spaces_file = tempfile . mkstemp ( prefix = key_spaces_file_prefix ) [
multiops_txn_key_spaces_file = tempfile . mkstemp ( prefix = key_spaces_file_prefix ) [
1
1
]
]
else :
else :
if not os . path . exists ( test_tmpdir ) :
if not os . path . exists ( test_exp_ tmpdir ) :
os . mkdir ( test_tmpdir )
os . mkdir ( test_exp_ tmpdir )
multiops_txn_key_spaces_file = tempfile . mkstemp (
multiops_txn_key_spaces_file = tempfile . mkstemp (
prefix = key_spaces_file_prefix , dir = test_tmpdir
prefix = key_spaces_file_prefix , dir = test_exp_ tmpdir
) [ 1 ]
) [ 1 ]
return multiops_txn_key_spaces_file
return multiops_txn_key_spaces_file
@ -938,7 +955,10 @@ def whitebox_crash_main(args, unknown_args):
if ret != 0 :
if ret != 0 :
print ( " TEST FAILED. DB cleanup returned error %d \n " % ret )
print ( " TEST FAILED. DB cleanup returned error %d \n " % ret )
sys . exit ( 1 )
sys . exit ( 1 )
os . mkdir ( dbname )
try :
os . mkdir ( dbname )
except OSError :
pass
if ( expected_values_dir is not None ) :
if ( expected_values_dir is not None ) :
shutil . rmtree ( expected_values_dir , True )
shutil . rmtree ( expected_values_dir , True )
os . mkdir ( expected_values_dir )
os . mkdir ( expected_values_dir )
@ -992,12 +1012,18 @@ def main():
args , unknown_args = parser . parse_known_args ( )
args , unknown_args = parser . parse_known_args ( )
test_tmpdir = os . environ . get ( _TEST_DIR_ENV_VAR )
test_tmpdir = os . environ . get ( _TEST_DIR_ENV_VAR )
if test_tmpdir is not None and not os . path . isdir ( test_tmpdir ) :
if test_tmpdir is not None :
print (
isdir = False
" %s env var is set to a non-existent directory: %s "
try :
% ( _TEST_DIR_ENV_VAR , test_tmpdir )
isdir = os . path . isdir ( test_tmpdir )
)
if not isdir :
sys . exit ( 1 )
print (
" %s env var is set to a non-existent directory: %s "
% ( _TEST_DIR_ENV_VAR , test_tmpdir )
)
sys . exit ( 1 )
except OSError :
pass
if args . stress_cmd :
if args . stress_cmd :
stress_cmd = args . stress_cmd
stress_cmd = args . stress_cmd