From d125c7deb88aa6c8a8ae97f9ea611575aba050ec Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Tue, 20 Dec 2016 12:44:44 -0500 Subject: [PATCH] Update test programs. All now succeed. --- Makefile.am | 83 +++++++++++++++++++++------------------------- common/tests/cfg_test.c | 21 +++++------- common/tests/commtest.c | 5 +-- common/tests/idp.cfg | 26 ++++++++++----- common/tests/mq_test.c | 19 ++++++----- common/tests/thread_test.c | 13 ++++---- 6 files changed, 85 insertions(+), 82 deletions(-) diff --git a/Makefile.am b/Makefile.am index aa266a0..402cb02 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,17 +36,6 @@ common/tr_mq.c check_PROGRAMS = common/t_constraint TESTS = common/t_constraint -#lib_LTLIBRARIES = libtr_tid.la - -# libtr_tid_la_SOURCES = $(tid_srcs) \ -# $(common_srcs) \ -# trp/trp_req.c \ -# trp/trp_upd.c -# -# libtr_tid_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden -# libtr_tid_la_LIBADD = gsscon/libgsscon.la $(GLIB_LIBS) -# libtr_tid_la_LDFLAGS = $(AM_LDFLAGS) -version-info 2 -no-undefined - common_t_constraint_SOURCES = common/t_constraint.c \ common/tr_debug.c \ common/tr_name.c \ @@ -67,31 +56,24 @@ $(tid_srcs) \ $(trp_srcs) \ $(common_srcs) -tr_trust_router_CFLAGS = $(AM_CFLAGS) -pthread tr_trust_router_LDFLAGS = $(AM_LDFLAGS) -levent_pthreads -pthread -#tr_trust_router_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS) tr_trust_router_LDADD = gsscon/libgsscon.la $(GLIB_LIBS) - tr_trpc_SOURCES =tr/trpc_main.c \ tr/tr_trp.c \ -$(trp_srcs) -tr_trpc_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS) +$(trp_srcs) \ +$(tid_srcs) \ +$(common_srcs) + +tr_trpc_LDADD = gsscon/libgsscon.la $(GLIB_LIBS) tr_trpc_LDFLAGS = $(AM_LDFLAGS) -pthread -tr_trpc_CFLAGS = $(AM_CFLAGS) -pthread trp_msgtst_SOURCES = trp/msgtst.c \ -common/tr_msg.c \ -common/tr_comm.c \ -common/tr_apc.c \ -common/tr_rp.c \ -common/tr_idp.c \ -common/tr_gss.c \ -common/tr_filter.c \ +$(common_srcs) \ trp/trp_req.c \ trp/trp_upd.c \ tid/tid_resp.c \ tid/tid_req.c -trp_msgtst_LDADD = libtr_tid.la $(GLIB_LIBS) +trp_msgtst_LDADD = $(GLIB_LIBS) trp_test_rtbl_test_SOURCES = trp/test/rtbl_test.c \ common/tr_name.c \ @@ -101,44 +83,55 @@ trp/trp_rtable.c trp_test_rtbl_test_LDADD = $(GLIB_LIBS) trp_test_ptbl_test_SOURCES = trp/test/ptbl_test.c \ -$(trp_srcs) -trp_test_ptbl_test_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS) +$(tid_srcs) \ +$(trp_srcs) \ +$(common_srcs) +trp_test_ptbl_test_LDADD = gsscon/libgsscon.la $(GLIB_LIBS) +trp_test_ptbl_test_LDFLAGS = $(AM_LDFLAGS) -pthread -tid_example_tidc_SOURCES = tid/example/tidc_main.c -tid_example_tidc_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS) +tid_example_tidc_SOURCES = tid/example/tidc_main.c \ +$(tid_srcs) \ +$(trp_srcs) \ +$(common_srcs) +tid_example_tidc_LDADD = gsscon/libgsscon.la $(GLIB_LIBS) +tid_example_tidc_LDFLAGS = $(AM_LDFLAGS) -pthread -tid_example_tids_SOURCES = tid/example/tids_main.c -tid_example_tids_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS) +tid_example_tids_SOURCES = tid/example/tids_main.c \ +$(tid_srcs) \ +$(trp_srcs) \ +$(common_srcs) +tid_example_tids_LDADD = gsscon/libgsscon.la $(GLIB_LIBS) +tid_example_tids_LDFLAGS = $(AM_LDFLAGS) -pthread common_tests_tr_dh_test_SOURCES = common/tr_dh.c \ common/tr_debug.c \ common/tests/dh_test.c common_tests_mq_test_SOURCES = common/tr_mq.c \ -common/tests/mq_test.c +common/tests/mq_test.c \ +common/tr_debug.c -common_tests_mq_test_CFLAGS = -pthread -common_tests_mq_test_LDFLAGS = $(AM_LDFLAGS) -ltalloc +common_tests_mq_test_LDFLAGS = $(AM_LDFLAGS) -ltalloc -pthread common_tests_cfg_test_SOURCES = common/tests/cfg_test.c \ +$(common_srcs) \ +$(tid_srcs) \ $(trp_srcs) - -common_tests_cfg_test_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS) -common_tests_cfg_test_CFLAGS = -pthread -common_tests_cfg_test_LDFLAGS = $(AM_LDFLAGS) -ltalloc +common_tests_cfg_test_LDADD = gsscon/libgsscon.la $(GLIB_LIBS) +common_tests_cfg_test_LDFLAGS = $(AM_LDFLAGS) -ltalloc -pthread common_tests_thread_test_SOURCES = common/tr_mq.c \ common/tr_debug.c \ common/tests/thread_test.c -common_tests_thread_test_CFLAGS = -pthread -common_tests_thread_test_LDFLAGS = $(AM_LDFLAGS) -ltalloc +common_tests_commtest_SOURCES = common/tests/commtest.c \ +$(common_srcs) \ +$(tid_srcs) \ +$(trp_srcs) +common_tests_commtest_LDADD = gsscon/libgsscon.la $(GLIB_LIBS) +common_tests_commtest_LDFLAGS = $(AM_LDFLAGS) -ltalloc -pthread -# common_tests_commtest_SOURCES = common/tests/commtest.c \ -# $(trp_srcs) -# common_tests_commtest_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS) -# common_tests_commtest_CFLAGS = -pthread -# common_test_commtest_LDFLAGS = $(AM_LDFLAGS) -ltalloc +common_tests_thread_test_LDFLAGS = $(AM_LDFLAGS) -ltalloc -pthread pkginclude_HEADERS = include/trust_router/tid.h include/trust_router/tr_name.h \ include/tr_debug.h \ diff --git a/common/tests/cfg_test.c b/common/tests/cfg_test.c index d8a0117..f487c53 100644 --- a/common/tests/cfg_test.c +++ b/common/tests/cfg_test.c @@ -51,16 +51,15 @@ static int verify_idp_cfg(TR_CFG *cfg) { TR_COMM *comm=NULL; TR_NAME *name=NULL; - TR_APC *apc=NULL; TR_IDP_REALM *idp_realm=NULL; TR_AAA_SERVER *aaa=NULL; assert(cfg!=NULL); /* test the comms attribute */ - assert(cfg->comms!=NULL); + assert(cfg->ctable!=NULL); name=tr_new_name("apc.example.com"); - comm=tr_comm_lookup(cfg->comms, name); + comm=tr_comm_table_find_comm(cfg->ctable, name); tr_free_name(name); assert(comm!=NULL); @@ -69,9 +68,8 @@ static int verify_idp_cfg(TR_CFG *cfg) assert(comm->apcs==NULL); name=tr_new_name("A.idp.cfg"); - for (idp_realm=comm->idp_realms; - (idp_realm!=NULL) && (tr_name_cmp(name, idp_realm->realm_id)!=0); - idp_realm=idp_realm->comm_next) { } + assert(name!=NULL); + idp_realm=tr_comm_find_idp(cfg->ctable, comm, name); assert(idp_realm!=NULL); assert(idp_realm->shared_config==0); assert(idp_realm->origin==TR_REALM_LOCAL); @@ -107,14 +105,13 @@ static int verify_rp_cfg(TR_CFG *cfg) assert(cfg->rp_clients!=NULL); assert(cfg->rp_clients->next==NULL); assert(cfg->rp_clients->comm_next==NULL); - /* need to update next test to use TR_GSS_NAMES structure */ -#if 0 + + assert(cfg->rp_clients->gss_names!=NULL); for (ii=1; iirp_clients->gss_names[ii]==NULL); - assert(cfg->rp_clients->gss_names[0]!=NULL); + assert(cfg->rp_clients->gss_names->names[ii]==NULL); + assert(cfg->rp_clients->gss_names->names[0]!=NULL); name=tr_new_name("gss@example.com"); - assert(tr_name_cmp(name, cfg->rp_clients->gss_names[0])==0); -#endif + assert(tr_name_cmp(name, cfg->rp_clients->gss_names->names[0])==0); return 0; } diff --git a/common/tests/commtest.c b/common/tests/commtest.c index 9c9c008..34153cb 100644 --- a/common/tests/commtest.c +++ b/common/tests/commtest.c @@ -70,7 +70,7 @@ static int add_comm_set(TR_COMM_TABLE *ctab, struct comm_entry *entries) for (this=entries,ii=0; this->id!=NULL; this++, ii++) { new=comm_entry_to_comm(tmp_ctx, this); if (new==NULL) { - printf("Error creating community %d.\n", ii+1); + printf("Error creating community %u.\n", (unsigned int)ii+1); rc=1; goto cleanup; } @@ -273,7 +273,7 @@ static TR_IDP_REALM *idp_realm_entry_to_idp_realm(TALLOC_CTX *mem_ctx, struct id realm=NULL; /* still in tmp_ctx so will be freed */ else { tr_idp_realm_set_apcs(realm, apc_entry_to_apc(tmp_ctx, re->apcs)); - if (tr_idp_realm_get_apcs==NULL) + if (tr_idp_realm_get_apcs(realm)==NULL) realm=NULL; } } @@ -818,6 +818,7 @@ static int membership_test(void) assert(0==tr_comm_table_size(ctab)); talloc_free(mem_ctx); + return 0; } diff --git a/common/tests/idp.cfg b/common/tests/idp.cfg index 0bfc87f..cfb1729 100644 --- a/common/tests/idp.cfg +++ b/common/tests/idp.cfg @@ -1,15 +1,25 @@ { + "communities": [ + { + "apcs": [], + "community_id": "apc.example.com", + "idp_realms": ["A.idp.cfg"], + "rp_realms": ["A.idp.cfg"], + "type": "apc" + } + ], "local_organizations": [ {"organization_name": "idp.cfg test org", "realms": [ - {"realm": "A.idp.cfg", - "identity_provider": { - "aaa_servers": ["rad1.A.idp.cfg", - "rad2.A.idp.cfg"], - "apc": "apc.example.com", - "shared_config": "no" - }, - "gss_names": ["gss@example.com"] + { + "realm": "A.idp.cfg", + "identity_provider": { + "aaa_servers": ["rad1.A.idp.cfg", + "rad2.A.idp.cfg"], + "apcs": ["apc.example.com"], + "shared_config": "no" + }, + "gss_names": ["gss@example.com"] } ] } diff --git a/common/tests/mq_test.c b/common/tests/mq_test.c index b1c4be7..5c04b37 100644 --- a/common/tests/mq_test.c +++ b/common/tests/mq_test.c @@ -60,7 +60,7 @@ int main(void) mq->notify_cb_arg=mq_name; msg1=tr_mq_msg_new(NULL,"Message 1", TR_MQ_PRIO_NORMAL); - assert(asprintf((char **)&(msg2->p), "First message.\n")!=-1); + assert(asprintf((char **)&(msg1->p), "First message.\n")!=-1); msg1->p_free=free; tr_mq_add(mq, msg1); assert(mq->head==msg1); @@ -76,7 +76,7 @@ int main(void) assert(mq->tail==msg2); assert(msg2->next==NULL); - msg=tr_mq_pop(mq); + msg=tr_mq_pop(mq, NULL); assert(msg==msg1); assert(mq->head==msg2); assert(mq->tail==msg2); @@ -88,7 +88,7 @@ int main(void) printf("no message to pop\n"); msg3=tr_mq_msg_new(NULL, "Message 3", TR_MQ_PRIO_NORMAL); - assert(asprintf("%s",(char **)&(msg3->p), "Third message.\n")!=-1); + assert(asprintf((char **)&(msg3->p), "%s", "Third message.\n")!=-1); msg3->p_free=free; tr_mq_add(mq, msg3); assert(mq->head==msg2); @@ -96,7 +96,7 @@ int main(void) assert(msg2->next==msg3); assert(msg3->next==NULL); - msg=tr_mq_pop(mq); + msg=tr_mq_pop(mq, NULL); assert(msg==msg2); assert(mq->head==msg3); assert(mq->tail==msg3); @@ -107,7 +107,7 @@ int main(void) } else printf("no message to pop\n"); - msg=tr_mq_pop(mq); + msg=tr_mq_pop(mq, NULL); assert(msg==msg3); assert(mq->head==NULL); assert(mq->tail==NULL); @@ -117,7 +117,7 @@ int main(void) } else printf("no message to pop\n"); - msg=tr_mq_pop(mq); + msg=tr_mq_pop(mq, NULL); assert(msg==NULL); assert(mq->head==NULL); assert(mq->tail==NULL); @@ -128,14 +128,14 @@ int main(void) printf("no message to pop\n"); msg4=tr_mq_msg_new(NULL, "Message 4", TR_MQ_PRIO_NORMAL); - assert(asprintf("%s",(char **)&(msg4->p), "Fourth message.\n")!=-1); + assert(asprintf((char **)&(msg4->p), "%s", "Fourth message.\n")!=-1); msg4->p_free=free; tr_mq_add(mq, msg4); assert(mq->head==msg4); assert(mq->tail==msg4); assert(msg4->next==NULL); - msg=tr_mq_pop(mq); + msg=tr_mq_pop(mq, NULL); assert(msg==msg4); assert(mq->head==NULL); assert(mq->tail==NULL); @@ -145,7 +145,7 @@ int main(void) } else printf("no message to pop\n"); - msg=tr_mq_pop(mq); + msg=tr_mq_pop(mq, NULL); assert(msg==NULL); assert(mq->head==NULL); assert(mq->tail==NULL); @@ -157,5 +157,6 @@ int main(void) tr_mq_free(mq); + printf("success\n"); return 0; } diff --git a/common/tests/thread_test.c b/common/tests/thread_test.c index 0e5aeb4..2cf1438 100644 --- a/common/tests/thread_test.c +++ b/common/tests/thread_test.c @@ -49,7 +49,7 @@ struct thread_data { char *label; }; -TR_MQ_MSG *make_msg(label, n) +static TR_MQ_MSG *make_msg(char *label, int n) { TR_MQ_MSG *msg=NULL; msg=tr_mq_msg_new(NULL, "Message", TR_MQ_PRIO_NORMAL); @@ -58,12 +58,12 @@ TR_MQ_MSG *make_msg(label, n) return msg; } -void *thread_start(void *arg) +static void *thread_start(void *arg) { TR_MQ *mq=((struct thread_data *)arg)->mq; int n_msgs=((struct thread_data *)arg)->n_msgs; useconds_t msg_dly=((struct thread_data *)arg)->msg_dly; - const char *label=((struct thread_data *)arg)->label; + char *label=((struct thread_data *)arg)->label; while (n_msgs>=0) { usleep(msg_dly); @@ -80,7 +80,7 @@ struct message_data { int ready; }; -void handle_messages(TR_MQ *mq, void *arg) +static void handle_messages(TR_MQ *mq, void *arg) { struct message_data *status=(struct message_data *)arg; pthread_mutex_lock(&(status->lock)); @@ -89,12 +89,12 @@ void handle_messages(TR_MQ *mq, void *arg) pthread_mutex_unlock(&(status->lock)); } -void output_messages(TR_MQ *mq) +static void output_messages(TR_MQ *mq) { TR_MQ_MSG *msg=NULL; printf("\n* handle_messages notified of new messages in queue.\n"); - for (msg=tr_mq_pop(mq); msg!=NULL; msg=tr_mq_pop(mq)) { + for (msg=tr_mq_pop(mq, NULL); msg!=NULL; msg=tr_mq_pop(mq, NULL)) { printf(" > %s\n", (char *)msg->p); tr_mq_msg_free(msg); } @@ -153,5 +153,6 @@ int main(void) for (ii=0; ii