Exemplo n.º 1
0
static void
init_ssl(void)
{
	SSL_library_init();
	ERR_load_crypto_strings();
	SSL_load_error_strings();
	OpenSSL_add_all_algorithms();
	if (SSLeay() != OPENSSL_VERSION_NUMBER) {
		TT_DECLARE("WARN", ("Version mismatch for openssl: compiled with %lx but running with %lx", (unsigned long)OPENSSL_VERSION_NUMBER, (unsigned long)SSLeay()));
	}
}
Exemplo n.º 2
0
void
init_ssl(void)
{
#if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
	(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
	SSL_library_init();
	ERR_load_crypto_strings();
	SSL_load_error_strings();
	OpenSSL_add_all_algorithms();
	if (SSLeay() != OPENSSL_VERSION_NUMBER) {
		TT_DECLARE("WARN", ("Version mismatch for openssl: compiled with %lx but running with %lx", (unsigned long)OPENSSL_VERSION_NUMBER, (unsigned long) SSLeay()));
	}
#endif
}
Exemplo n.º 3
0
/// TEST FUNCTIONS
void test_trap_lib(void *data) {
	(void)data;
	void * SOHandle;
	void * bartlby_address;


	struct trap modified_object;
	struct trap returned_object;


	struct trap * srvmap;
	
	srvmap=NULL;
	long (*AddTrap)(struct trap *, char *);
	int (*UpdateTrap)(struct trap *, char *);
	int (*DeleteTrap)(long trap_id, char *);
	int (*GetTrapById)(long, struct trap *, char * );
	long (*TrapChangeId)(long, long, char*);
	int (*GetTrapMap)(struct trap*, char*, int);
	


	int rtc=-1;
	long object_id=-1;
	long lrtc=-1;
	long NN=-1;
	int x;
	struct shm_header * shm_hdr;

	
	bartlby_address=NULL;
	SOHandle=NULL;
	SKIP_IF_NOT_RUNNING(CONFIG);

	SOHandle = bartlby_get_sohandle(CONFIG);
	bartlby_address=bartlby_get_shm(CONFIG);

	
	tt_ptr_op(bartlby_address, !=, NULL);
	tt_ptr_op(SOHandle, !=, NULL);
	
	shm_hdr = bartlby_SHM_GetHDR(bartlby_address);

	
	LOAD_SYMBOL_TEST(AddTrap,SOHandle, "AddTrap");
	LOAD_SYMBOL_TEST(DeleteTrap,SOHandle, "DeleteTrap");
	LOAD_SYMBOL_TEST(UpdateTrap,SOHandle, "UpdateTrap");	
	LOAD_SYMBOL_TEST(GetTrapById,SOHandle, "GetTrapById");	
	LOAD_SYMBOL_TEST(TrapChangeId,SOHandle, "TrapChangeId");	
	LOAD_SYMBOL_TEST(GetTrapMap,SOHandle, "GetTrapMap");	
	
	


	/******* ADD TRAP ****/
	lrtc=AddTrap(&dummy_trap, CONFIG);
	object_id=lrtc;
	tt_int_op(lrtc, >, 0);
	TT_DECLARE("INFO",("... Added Trap id: %ld", object_id));
	/******* ADD TRAP ****/


	/******* MODIFY TRAP ****/
	dummy_trap.trap_id=object_id;
	memcpy(&modified_object,&dummy_trap, sizeof(struct trap));
	memcpy(&returned_object,&dummy_trap, sizeof(struct trap));
	snprintf(modified_object.trap_catcher,2048, "modified-unit-test");
	rtc=UpdateTrap(&modified_object, CONFIG);
	tt_int_op(rtc, ==, 1);
	TT_DECLARE("INFO",("... Modified Trap, changed name"));
	/******* MODIFY TRAP ****/

	/******* GETTRAPBYID ****/
	rtc=GetTrapById(object_id, &returned_object, CONFIG);
	tt_int_op(rtc, ==, 0);
	tt_str_op(returned_object.trap_catcher, ==, modified_object.trap_catcher);
	TT_DECLARE("INFO",("... get trap by id  %ld", object_id));
	/******* GETTRAPBYID ****/

	/******* TRAPCHANGEID ****/
	NN=lrtc+999;
	object_id=TrapChangeId(lrtc, NN, CONFIG);
	tt_int_op(object_id, ==, NN);
	TT_DECLARE("INFO",("... Changed trap id from %ld to %ld ",lrtc, object_id));
	/******* TRAPCHANGEID ****/


	


	/*** TRAPMAP **/
	srvmap = malloc(sizeof(struct trap)*(shm_hdr->trapcount+2));
	rtc=GetTrapMap(srvmap, CONFIG, TEST_ORCH_ID);
	tt_int_op(rtc, >, 0);
	lrtc=-1;
	for(x=0; x<rtc; x++) {
		if(srvmap[x].trap_id==object_id) {
			lrtc = 1;
		}
	}
	tt_int_op(lrtc, ==, 1);
	TT_DECLARE("INFO",("... Created TrapMap and found  %ld ", object_id));
	/*** TRAPMAP **/






	/*** DELETETRAP **/
	rtc=DeleteTrap(object_id, CONFIG);
	tt_int_op(rtc, ==, 1);
	TT_DECLARE("INFO",("... Delete Trap  %ld ", object_id));
	/*** DELETETRAP **/
	




	end:
		if(srvmap != NULL) free(srvmap);
		if(SOHandle != NULL) dlclose(SOHandle);
		if(bartlby_address != NULL) shmdt(bartlby_address);
	
	;


}
Exemplo n.º 4
0
void test_trap_running(void *data) {
	(void)data;
	void * SOHandle;
	void * bartlby_address;
	struct shm_header * shm_hdr;
	struct trap * map;
	int x;
	int res;
	
	int (*AddTrap)(struct trap *, char *);
	int (*DeleteTrap)(long trap_id, char *);
		

	int rtc=-1;
	long lrtc=-1;
	long object_id=-1;

	bartlby_address=NULL;
	SOHandle=NULL;
	SKIP_IF_NOT_RUNNING(CONFIG);

	SOHandle = bartlby_get_sohandle(CONFIG);
	bartlby_address=bartlby_get_shm(CONFIG);

	
	tt_ptr_op(bartlby_address, !=, NULL);
	tt_ptr_op(SOHandle, !=, NULL);
	
	
	/// ADD trap

	LOAD_SYMBOL_TEST(AddTrap,SOHandle, "AddTrap");
	LOAD_SYMBOL_TEST(DeleteTrap,SOHandle, "DeleteTrap");


	lrtc=AddTrap(&dummy_trap, CONFIG);
	object_id=lrtc;
	tt_int_op(lrtc, >, 0);
	
	TT_DECLARE("INFO",("... Added Trap id: %ld", object_id));

	dummy_trap.trap_id=object_id;
	
	//Reload - and detach/reattach to shm
	shm_hdr=bartlby_SHM_GetHDR(bartlby_address);
	shm_hdr->do_reload=1;
	shmdt(bartlby_address);
	sleep(2);
	

	bartlby_address=bartlby_get_shm(CONFIG);

	shm_hdr=bartlby_SHM_GetHDR(bartlby_address);

	TT_DECLARE("INFO", ("Reloaded SHM"));
	tt_int_op(shm_hdr->do_reload, ==, 0);

	map = bartlby_SHM_TrapMap(bartlby_address);

	res = -1;
	for(x=0; x<shm_hdr->trapcount; x++) {
		
		if(map[x].trap_id == object_id) {
			res = 1;
			break;
		}
	}


	rtc=DeleteTrap(object_id, CONFIG);
	tt_int_op(rtc, ==, 1);

	TT_DECLARE("INFO",("... Delete Trap  ", object_id));



	tt_int_op(res, ==, 1);
	TT_DECLARE("INFO",("... SHM Trap found  ", object_id));



	end:
		if(SOHandle != NULL) dlclose(SOHandle);
		if(bartlby_address != NULL) shmdt(bartlby_address);
	;


}