mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Fix fuzzer when only explicit faults are used
This commit is contained in:
parent
3af24dacf8
commit
33885b27bf
@ -51,16 +51,17 @@ namespace ErrorCodes
|
||||
ThreadFuzzer::ThreadFuzzer()
|
||||
{
|
||||
initConfiguration();
|
||||
if (needsSetup())
|
||||
setup();
|
||||
|
||||
if (!isEffective())
|
||||
{
|
||||
/// It has no effect - disable it
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
setup();
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
static void initFromEnv(T & what, const char * name)
|
||||
{
|
||||
@ -133,10 +134,16 @@ void ThreadFuzzer::initConfiguration()
|
||||
}
|
||||
|
||||
|
||||
bool ThreadFuzzer::needsSetup() const
|
||||
{
|
||||
return cpu_time_period_us != 0
|
||||
&& (yield_probability > 0 || migrate_probability > 0 || (sleep_probability > 0 && sleep_time_us_max > 0));
|
||||
}
|
||||
|
||||
bool ThreadFuzzer::isEffective() const
|
||||
{
|
||||
if (!isStarted())
|
||||
return false;
|
||||
if (needsSetup())
|
||||
return true;
|
||||
|
||||
#if THREAD_FUZZER_WRAP_PTHREAD
|
||||
# define CHECK_WRAPPER_PARAMS(RET, NAME, ...) \
|
||||
@ -163,10 +170,13 @@ bool ThreadFuzzer::isEffective() const
|
||||
# undef INIT_WRAPPER_PARAMS
|
||||
#endif
|
||||
|
||||
return cpu_time_period_us != 0
|
||||
&& (yield_probability > 0
|
||||
|| migrate_probability > 0
|
||||
|| (sleep_probability > 0 && sleep_time_us_max > 0));
|
||||
if (explicit_sleep_probability > 0 && sleep_time_us_max > 0)
|
||||
return true;
|
||||
|
||||
if (explicit_memory_exception_probability > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ThreadFuzzer::stop()
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
}
|
||||
|
||||
bool isEffective() const;
|
||||
bool needsSetup() const;
|
||||
|
||||
static void stop();
|
||||
static void start();
|
||||
|
Loading…
Reference in New Issue
Block a user