greenplumn faultinjector_warnings_test 源码

  • 2022-08-18
  • 浏览 (253)

greenplumn faultinjector_warnings_test 代码

文件路径:/src/backend/utils/misc/test/faultinjector_warnings_test.c

#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include "cmockery.h"


#include "postgres.h"
#include "nodes/pg_list.h"
#include "utils/memutils.h"

#include "utils/faultinjector.h"
#include "../faultinjector_warnings.h"


static bool warning_was_called = false;


static void
some_warning(FaultInjectorEntry_s faultEntry)
{
	warning_was_called = true;
}

static void
setup()
{
	warning_was_called = false;

	warnings_init();
}

static void
test_fault_injection_warnings_can_be_added_and_emitted(void **state)
{
	setup();

	FaultInjectorEntry_s faultEntry;
	faultEntry.startOccurrence = 0;

	register_fault_injection_warning(some_warning);
	emit_warnings(faultEntry);

	assert_true(warning_was_called);
}

static void
test_fault_injection_warnings_not_called_when_empty(void **state)
{
	setup();

	FaultInjectorEntry_s faultEntry;
	faultEntry.startOccurrence = 0;

	emit_warnings(faultEntry);

	assert_false(warning_was_called);
}

int main(int argc, char* argv[]) {
	cmockery_parse_arguments(argc, argv);

	const UnitTest tests[] = {
		unit_test(test_fault_injection_warnings_can_be_added_and_emitted),
		unit_test(test_fault_injection_warnings_not_called_when_empty)
	};

	MemoryContextInit();

	return run_tests(tests);
}

相关信息

greenplumn 源码目录

相关文章

greenplumn bitmap_compression_test 源码

greenplumn bitstream_test 源码

greenplumn guc_gp_test 源码

greenplumn guc_test 源码

greenplumn pg_mkdir_p_test 源码

greenplumn ps_status_test 源码

0  赞