greenplumn postinit_test 源码

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

greenplumn postinit_test 代码

文件路径:/src/backend/utils/init/test/postinit_test.c

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

/* Fetch definition of PG_exception_stack */
#include "postgres.h"

#undef PG_RE_THROW
#define PG_RE_THROW() siglongjmp(*PG_exception_stack, 1)

static void
_errfinish_impl()
{
	PG_RE_THROW();
}

static void expect_ereport(int expect_elevel)
{
	expect_value(errstart, elevel, expect_elevel);
	expect_any(errstart, domain);
	if (expect_elevel < ERROR)
	{
		will_return(errstart, false);
	}
    else
    {
		will_return_with_sideeffect(errstart, false, &_errfinish_impl, NULL);
    }
}

#include "../postinit.c"

static void
test_check_superuser_connection_limit_error(void **state)
{
	am_ftshandler = false;

	expect_value(HaveNFreeProcs, n, RESERVED_FTS_CONNECTIONS);
	will_return(HaveNFreeProcs, false);

	expect_ereport(FATAL);

	/*
	 * Expect ERROR
	 */
	PG_TRY();
	{
		check_superuser_connection_limit();
		fail();
	}
	PG_CATCH();
	{
	}
	PG_END_TRY();
}

static void
test_check_superuser_connection_limit_ok_with_free_procs(void **state)
{
	am_ftshandler = false;

	expect_value(HaveNFreeProcs, n, RESERVED_FTS_CONNECTIONS);
	will_return(HaveNFreeProcs, true);

	/*
	 * Expect OK
	 */
	check_superuser_connection_limit();
}

static void
test_check_superuser_connection_limit_ok_for_ftshandler(void **state)
{
	am_ftshandler = true;

	/*
	 * Expect OK
	 */
	check_superuser_connection_limit();
}

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

	const UnitTest tests[] = {
		unit_test(test_check_superuser_connection_limit_ok_with_free_procs),
		unit_test(test_check_superuser_connection_limit_ok_for_ftshandler),
		unit_test(test_check_superuser_connection_limit_error),
	};

	return run_tests(tests);
}

相关信息

greenplumn 源码目录

相关文章

greenplumn adminpack 源码

greenplumn verify_nbtree 源码

greenplumn auth_delay 源码

greenplumn auto_explain 源码

greenplumn blcost 源码

greenplumn blinsert 源码

greenplumn bloom 源码

greenplumn blscan 源码

greenplumn blutils 源码

greenplumn blvacuum 源码

0  赞