greenplumn lock_test 源码

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

greenplumn lock_test 代码

文件路径:/src/backend/storage/lmgr/test/lock_test.c

#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include "cmockery.h"
#include "postgres.h"
#include "common/hashfn.h"

/* For RemoveLocalLock, we need to check if NULL is not passed to pfree */
#undef pfree
#define pfree(x) do { \
	assert_true(x != NULL); \
	free(x); \
} while(0)
#include "../lock.c"


/*
 * MPP-18576: RemoveLocalLock should be aware lockOwners can be NULL
 * in case of OOM after populating the hash entry.
 */
static void
test__RemoveLocalLock_Null(void **state)
{
	HASHCTL		info;
	int			hash_flags;

	LOCALLOCKTAG localtag;
	LOCALLOCK  *locallock;
	bool		found;

	info.keysize = sizeof(LOCALLOCKTAG);
	info.entrysize = sizeof(LOCALLOCK);
	info.hash = tag_hash;
	hash_flags = (HASH_ELEM | HASH_FUNCTION);

	LockMethodLocalHash = hash_create("LOCALLOCK hash",
									  128,
									  &info,
									  hash_flags);

	/* Create a dummy local lock */
	MemSet(&localtag, 0, sizeof(localtag));
	localtag.lock.locktag_field1 = 1;
	localtag.lock.locktag_field2 = 2;
	localtag.lock.locktag_field3 = 3;
	localtag.lock.locktag_field4 = 4;
	localtag.mode = AccessShareLock;

	locallock = (LOCALLOCK *) hash_search(LockMethodLocalHash,
										  (void *) &localtag,
										  HASH_ENTER, &found);

	assert_false(found);

	/* Assume lockOwners is NULL and we go into cleanup */
	locallock->lockOwners = NULL;
	RemoveLocalLock(locallock);
}

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

	const UnitTest tests[] = {
		unit_test(test__RemoveLocalLock_Null)
	};

	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  赞