<commit_before>#include "test.hh"

#include <controller.hh>
#include "mock-ptrace.hh"

static int test_thread(void *priv)
{
	return 0;
}

TEST(controllerForkError)
{
	IController &controller = IController::getInstance();
	MockPtrace &ptrace = (MockPtrace &)IPtrace::getInstance();

	EXPECT_CALL(ptrace, forkAndAttach())
		.Times(AtLeast(1))
		.WillRepeatedly(Return(-1));

	controller.run();
}

TEST(controllerAddProcessForkError)
{
	IController &controller = IController::getInstance();
	MockPtrace &ptrace = (MockPtrace &)IPtrace::getInstance();

	EXPECT_CALL(ptrace, forkAndAttach())
		.Times(AtLeast(1))
		.WillRepeatedly(Return(-1));

	controller.addThread(test_thread, NULL);
	controller.run();
}


TEST(controllerRunChild)
{
	IController &controller = IController::getInstance();
	MockPtrace &ptrace = (MockPtrace &)IPtrace::getInstance();

	EXPECT_CALL(ptrace, forkAndAttach())
		.Times(AtLeast(1))
		.WillRepeatedly(Return(100));

	IPtrace::PtraceEvent ev;

	ev.type = ptrace_breakpoint;
	ev.eventId = 100;
	ev.addr = NULL;
	EXPECT_CALL(ptrace, continueExecution(_))
		.Times(AtLeast(1))
		.WillRepeatedly(Return(ev));

	controller.addThread(test_thread, NULL);
	controller.run();
}<commit_msg>unit test: Use two threads...<commit_after>#include "test.hh"

#include <controller.hh>
#include "mock-ptrace.hh"

static int test_thread(void *priv)
{
	return 0;
}

TEST(controllerForkError)
{
	IController &controller = IController::getInstance();
	MockPtrace &ptrace = (MockPtrace &)IPtrace::getInstance();

	EXPECT_CALL(ptrace, forkAndAttach())
		.Times(AtLeast(1))
		.WillRepeatedly(Return(-1));

	controller.run();
}

TEST(controllerAddProcessForkError)
{
	IController &controller = IController::getInstance();
	MockPtrace &ptrace = (MockPtrace &)IPtrace::getInstance();

	EXPECT_CALL(ptrace, forkAndAttach())
		.Times(AtLeast(1))
		.WillRepeatedly(Return(-1));

	controller.addThread(test_thread, NULL);
	controller.run();
}


TEST(controllerRunChild)
{
	IController &controller = IController::getInstance();
	MockPtrace &ptrace = (MockPtrace &)IPtrace::getInstance();

	EXPECT_CALL(ptrace, forkAndAttach())
		.Times(AtLeast(1))
		.WillRepeatedly(Return(100));

	IPtrace::PtraceEvent ev;

	ev.type = ptrace_breakpoint;
	ev.eventId = 100;
	ev.addr = NULL;
	EXPECT_CALL(ptrace, continueExecution(_))
		.Times(AtLeast(1))
		.WillRepeatedly(Return(ev));

	// Add two threads
	controller.addThread(test_thread, NULL);
	controller.addThread(test_thread, NULL);

	controller.run();
}
{'fraction_non_alphanumeric': 0.1533199195171026, 'fraction_numerical': 0.010462776659959759, 'mean_word_length': 6.533333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '780520', 'n_tokens_mistral': 917, 'n_tokens_neox': 882, 'n_words': 143}