mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-23 11:38:38 +00:00
[lib/Fuzzer] when running multiple fuzzing processes, print something every 10 minutes to avoid buildbot timeouts
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237054 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4e5be5af59
commit
1d4481df82
@ -13,6 +13,7 @@
|
|||||||
#include "FuzzerInternal.h"
|
#include "FuzzerInternal.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <chrono>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -122,9 +123,18 @@ static void ParseFlags(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::mutex Mu;
|
||||||
|
|
||||||
|
static void PulseThread() {
|
||||||
|
while (true) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(600));
|
||||||
|
std::lock_guard<std::mutex> Lock(Mu);
|
||||||
|
std::cerr << "pulse...\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void WorkerThread(const std::string &Cmd, std::atomic<int> *Counter,
|
static void WorkerThread(const std::string &Cmd, std::atomic<int> *Counter,
|
||||||
int NumJobs, std::atomic<bool> *HasErrors) {
|
int NumJobs, std::atomic<bool> *HasErrors) {
|
||||||
static std::mutex CerrMutex;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int C = (*Counter)++;
|
int C = (*Counter)++;
|
||||||
if (C >= NumJobs) break;
|
if (C >= NumJobs) break;
|
||||||
@ -135,7 +145,7 @@ static void WorkerThread(const std::string &Cmd, std::atomic<int> *Counter,
|
|||||||
int ExitCode = system(ToRun.c_str());
|
int ExitCode = system(ToRun.c_str());
|
||||||
if (ExitCode != 0)
|
if (ExitCode != 0)
|
||||||
*HasErrors = true;
|
*HasErrors = true;
|
||||||
std::lock_guard<std::mutex> Lock(CerrMutex);
|
std::lock_guard<std::mutex> Lock(Mu);
|
||||||
std::cerr << "================== Job " << C
|
std::cerr << "================== Job " << C
|
||||||
<< " exited with exit code " << ExitCode
|
<< " exited with exit code " << ExitCode
|
||||||
<< " =================\n";
|
<< " =================\n";
|
||||||
@ -154,10 +164,12 @@ static int RunInMultipleProcesses(int argc, char **argv, int NumWorkers,
|
|||||||
Cmd += " ";
|
Cmd += " ";
|
||||||
}
|
}
|
||||||
std::vector<std::thread> V;
|
std::vector<std::thread> V;
|
||||||
|
std::thread Pulse(PulseThread);
|
||||||
for (int i = 0; i < NumWorkers; i++)
|
for (int i = 0; i < NumWorkers; i++)
|
||||||
V.push_back(std::thread(WorkerThread, Cmd, &Counter, NumJobs, &HasErrors));
|
V.push_back(std::thread(WorkerThread, Cmd, &Counter, NumJobs, &HasErrors));
|
||||||
for (auto &T : V)
|
for (auto &T : V)
|
||||||
T.join();
|
T.join();
|
||||||
|
Pulse.join();
|
||||||
return HasErrors ? 1 : 0;
|
return HasErrors ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user