#include "thread.h"
#include <cstdint>
#include <cstdlib>
#define TEST_NAME "Event Group"
#include "tests.hh"
#include <atomic>
#include <event.h>
#include <thread_pool.h>

using thread_pool::async;

namespace
{
	std::atomic<uint32_t> counter{2};
	void                  barrier()
	{
		int c = --counter;
		debug_log("Thread {} waiting for barrier {}", thread_id_get(), c);
		while (counter > 0)
		{
			counter.wait(c);
			c = counter.load();
		}
		counter.notify_all();
	}
} // namespace

void test_eventgroup()
{
	EventGroup *group;

	Timeout t{1};
	int     ret = eventgroup_create(&t, MALLOC_CAPABILITY, &group);
	TEST(ret == 0, "Failed to create event group: {}", ret);

	t = 0;
	uint32_t bits;
	ret = eventgroup_set(&t, group, &bits, 1);
	TEST(ret == 0, "Failed to set event group bits: {}", ret);
	TEST(bits == 1, "Bits should be 1, but is {}", bits);
	eventgroup_get(group, &bits);
	TEST(bits == 1, "Fetched bits ({}) not the same as set bits (1)", bits);

	async([=]() {
		Timeout  t{2};
		uint32_t bits;
		int      ret = eventgroup_set(&t, group, &bits, 0b10);
		debug_log("eventgroup_set returned {}", ret);
		barrier();
		TEST(ret == 0, "Failed to set event group bits: {}", ret);
		TEST(bits == 0,
		     "Bits should be 0 (all cleared by clearOnExit), but is {}",
		     bits);
	});

	t   = 4;
	ret = eventgroup_wait(&t, group, &bits, 0b11, true, true);
	debug_log("eventgroup_wait returned {}", ret);
	TEST(ret == 0, "Failed to wait for event group: {}", ret);
	barrier();
	TEST(bits == 0b11, "Bits should be 0b11, but is {}", bits);
	eventgroup_get(group, &bits);
	TEST(bits == 0,
	     "Fetched bits {} after clearOnExit should have set them to 0",
	     bits);

	ret = eventgroup_set(&t, group, &bits, 0b1100);
	TEST(ret == 0, "Failed to set bits for event group: {}", ret);
	TEST(bits == 0b1100, "Bits should be 0b1100, but is {}", bits);
	ret = eventgroup_clear(&t, group, &bits, 0b100);
	TEST(ret == 0, "Failed to clear event group bits: {}", ret);
	TEST(bits == 0b1000, "Bits should be 0b1000, but is {}", bits);
}
