<commit_before>#include "simlib/sandbox.hh"
#include "simlib/concurrent/job_processor.hh"
#include "simlib/file_manip.hh"
#include "simlib/path.hh"
#include "simlib/process.hh"
#include "simlib/temporary_file.hh"
#include "test/compilation_cache.hh"

#include <chrono>
#include <gtest/gtest.h>
#include <iomanip>
#include <linux/version.h>
#include <sys/syscall.h>
#include <thread>
#include <unistd.h>

using namespace std::chrono_literals;

using std::string;

class SandboxTests {
    static constexpr size_t MEM_LIMIT = 16 << 20; // 16 MiB (in bytes)
    // Big RT limit is needed for tests where memory dump is created - it is
    // really slow)
    static constexpr std::chrono::nanoseconds REAL_TIME_LIMIT = 3s;
    static constexpr std::chrono::nanoseconds CPU_TIME_LIMIT = 200ms;
    static constexpr Sandbox::Options SANDBOX_OPTIONS{
        -1, -1, -1, REAL_TIME_LIMIT, MEM_LIMIT, CPU_TIME_LIMIT};

    const string& test_cases_dir_;
    TemporaryFile executable_{"/tmp/simlib.test.sandbox.XXXXXX"};

public:
    explicit SandboxTests(const string& test_cases_dir)
    : test_cases_dir_(test_cases_dir) {}<commit_msg>test: Sandbox: fixed sometimes appearing time limit exceeded<commit_after>#include "simlib/sandbox.hh"
#include "simlib/concurrent/job_processor.hh"
#include "simlib/file_manip.hh"
#include "simlib/path.hh"
#include "simlib/process.hh"
#include "simlib/temporary_file.hh"
#include "test/compilation_cache.hh"

#include <chrono>
#include <gtest/gtest.h>
#include <iomanip>
#include <linux/version.h>
#include <sys/syscall.h>
#include <thread>
#include <unistd.h>

using namespace std::chrono_literals;

using std::string;

class SandboxTests {
    static constexpr size_t MEM_LIMIT = 16 << 20; // 16 MiB (in bytes)
    // Big RT limit is needed for tests where memory dump is created - it is
    // really slow)
    static constexpr std::chrono::nanoseconds REAL_TIME_LIMIT = 16s;
    static constexpr std::chrono::nanoseconds CPU_TIME_LIMIT = 200ms;
    static constexpr Sandbox::Options SANDBOX_OPTIONS{
        -1, -1, -1, REAL_TIME_LIMIT, MEM_LIMIT, CPU_TIME_LIMIT};

    const string& test_cases_dir_;
    TemporaryFile executable_{"/tmp/simlib.test.sandbox.XXXXXX"};

public:
    explicit SandboxTests(const string& test_cases_dir)
    : test_cases_dir_(test_cases_dir) {}
{'fraction_non_alphanumeric': 0.1170858629661752, 'fraction_numerical': 0.011708586296617519, 'mean_word_length': 4.855329949238579, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1496457', 'n_tokens_mistral': 845, 'n_tokens_neox': 796, 'n_words': 191}