From 88f2161f9f1c36a4c65b3ad892afcb9dd07b9baf Mon Sep 17 00:00:00 2001 From: brarcher Date: Wed, 30 Jan 2013 05:04:11 +0000 Subject: [PATCH] renaming list API to start with check_ Based on patch #3448601, this renames the internal list structure API used by check to start with check_ to avoid name conflicts. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@685 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- AUTHORS | 1 + NEWS | 2 + src/check.c | 66 ++++++++++++------------- src/check_list.c | 22 ++++----- src/check_list.h | 16 +++--- src/check_log.c | 12 ++--- src/check_print.c | 4 +- src/check_run.c | 26 +++++----- tests/check_check_log_internal.c | 10 ++-- tests/check_list.c | 84 ++++++++++++++++---------------- 10 files changed, 123 insertions(+), 120 deletions(-) diff --git a/AUTHORS b/AUTHORS index 7b7ac6a..bbc991e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -37,6 +37,7 @@ Patches: Diego Elio Petteno (autoconf patch for 64-bit safe code) Jon Kowal (deadlock on thread cancellation fix) Jerry James (cleanup compiler warnings) + Martin Willers (rename check's internal list API to start with check_) Anybody who has contributed code to Check or Check's build system is considered an author. Send patches to this file to diff --git a/NEWS b/NEWS index 1c286e8..87ac3c7 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,8 @@ In development: * Cleanup compile warnings, patch #3579199 on SF. +* Renamed Check's internal list functions to start with check_, patch #3448601 on SF. + Mon, Oct 22, 2012: Released Check 0.9.9 based on r637 (2012-10-22 13:54:14 +0200) diff --git a/src/check.c b/src/check.c index 40fab63..c6e88da 100644 --- a/src/check.c +++ b/src/check.c @@ -71,8 +71,8 @@ int suite_tcase (Suite *s, const char *tcname) return 0; l = s->tclst; - for (list_front (l); !list_at_end (l); list_advance (l)) { - tc = list_val (l); + for (check_list_front (l); !check_list_at_end (l); check_list_advance (l)) { + tc = check_list_val (l); if (strcmp (tcname, tc->name) == 0) return 1; } @@ -86,10 +86,10 @@ static void suite_free (Suite *s) if (s == NULL) return; l = s->tclst; - for (list_front(l); !list_at_end(l); list_advance (l)) { - tcase_free (list_val(l)); + for (check_list_front(l); !check_list_at_end(l); check_list_advance (l)) { + tcase_free (check_list_val(l)); } - list_free (s->tclst); + check_list_free (s->tclst); free(s); } @@ -137,16 +137,16 @@ TCase *tcase_create (const char *name) static void tcase_free (TCase *tc) { - list_apply (tc->tflst, free); - list_apply (tc->unch_sflst, free); - list_apply (tc->ch_sflst, free); - list_apply (tc->unch_tflst, free); - list_apply (tc->ch_tflst, free); - list_free(tc->tflst); - list_free(tc->unch_sflst); - list_free(tc->ch_sflst); - list_free(tc->unch_tflst); - list_free(tc->ch_tflst); + check_list_apply (tc->tflst, free); + check_list_apply (tc->unch_sflst, free); + check_list_apply (tc->ch_sflst, free); + check_list_apply (tc->unch_tflst, free); + check_list_apply (tc->ch_tflst, free); + check_list_free(tc->tflst); + check_list_free(tc->unch_sflst); + check_list_free(tc->ch_sflst); + check_list_free(tc->unch_tflst); + check_list_free(tc->ch_tflst); free(tc); } @@ -155,7 +155,7 @@ void suite_add_tcase (Suite *s, TCase *tc) { if (s == NULL || tc == NULL) return; - list_add_end (s->tclst, tc); + check_list_add_end (s->tclst, tc); } void _tcase_add_test (TCase *tc, TFun fn, const char *name, int _signal, int allowed_exit_value, int start, int end) @@ -170,7 +170,7 @@ void _tcase_add_test (TCase *tc, TFun fn, const char *name, int _signal, int all tf->signal = _signal; /* 0 means no signal expected */ tf->allowed_exit_value = allowed_exit_value; /* 0 is default successful exit */ tf->name = name; - list_add_end (tc->tflst, tf); + check_list_add_end (tc->tflst, tf); } static Fixture *fixture_create (SFun fun, int ischecked) @@ -198,17 +198,17 @@ static void tcase_add_fixture (TCase *tc, SFun setup, SFun teardown, { if (setup) { if (ischecked) - list_add_end (tc->ch_sflst, fixture_create(setup, ischecked)); + check_list_add_end (tc->ch_sflst, fixture_create(setup, ischecked)); else - list_add_end (tc->unch_sflst, fixture_create(setup, ischecked)); + check_list_add_end (tc->unch_sflst, fixture_create(setup, ischecked)); } /* Add teardowns at front so they are run in reverse order. */ if (teardown) { if (ischecked) - list_add_front (tc->ch_tflst, fixture_create(teardown, ischecked)); + check_list_add_front (tc->ch_tflst, fixture_create(teardown, ischecked)); else - list_add_front (tc->unch_tflst, fixture_create(teardown, ischecked)); + check_list_add_front (tc->unch_tflst, fixture_create(teardown, ischecked)); } } @@ -272,7 +272,7 @@ SRunner *srunner_create (Suite *s) SRunner *sr = emalloc (sizeof(SRunner)); /* freed in srunner_free */ sr->slst = check_list_create(); if (s != NULL) - list_add_end(sr->slst, s); + check_list_add_end(sr->slst, s); sr->stats = emalloc (sizeof(TestStats)); /* freed in srunner_free */ sr->stats->n_checked = sr->stats->n_failed = sr->stats->n_errors = 0; sr->resultlst = check_list_create(); @@ -288,7 +288,7 @@ void srunner_add_suite (SRunner *sr, Suite *s) if (s == NULL) return; - list_add_end(sr->slst, s); + check_list_add_end(sr->slst, s); } void srunner_free (SRunner *sr) @@ -300,19 +300,19 @@ void srunner_free (SRunner *sr) free (sr->stats); l = sr->slst; - for (list_front(l); !list_at_end(l); list_advance(l)) { - suite_free(list_val(l)); + for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { + suite_free(check_list_val(l)); } - list_free(sr->slst); + check_list_free(sr->slst); l = sr->resultlst; - for (list_front(l); !list_at_end(l); list_advance(l)) { - tr = list_val(l); + for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { + tr = check_list_val(l); free(tr->file); free(tr->msg); free(tr); } - list_free (sr->resultlst); + check_list_free (sr->resultlst); free (sr); } @@ -335,8 +335,8 @@ TestResult **srunner_failures (SRunner *sr) trarray = malloc (sizeof(trarray[0]) * srunner_ntests_failed (sr)); rlst = sr->resultlst; - for (list_front(rlst); !list_at_end(rlst); list_advance(rlst)) { - TestResult *tr = list_val(rlst); + for (check_list_front(rlst); !check_list_at_end(rlst); check_list_advance(rlst)) { + TestResult *tr = check_list_val(rlst); if (non_pass(tr->rtype)) trarray[i++] = tr; @@ -353,8 +353,8 @@ TestResult **srunner_results (SRunner *sr) trarray = malloc (sizeof(trarray[0]) * srunner_ntests_run (sr)); rlst = sr->resultlst; - for (list_front(rlst); !list_at_end(rlst); list_advance(rlst)) { - trarray[i++] = list_val(rlst); + for (check_list_front(rlst); !check_list_at_end(rlst); check_list_advance(rlst)) { + trarray[i++] = check_list_val(rlst); } return trarray; } diff --git a/src/check_list.c b/src/check_list.c index e4a4385..fceb03a 100644 --- a/src/check_list.c +++ b/src/check_list.c @@ -59,7 +59,7 @@ List *check_list_create (void) return lp; } -void list_add_front (List *lp, const void *val) +void check_list_add_front (List *lp, const void *val) { if (lp == NULL) return; @@ -71,7 +71,7 @@ void list_add_front (List *lp, const void *val) lp->data[lp->current] = val; } -void list_add_end (List *lp, const void *val) +void check_list_add_end (List *lp, const void *val) { if (lp == NULL) return; @@ -82,7 +82,7 @@ void list_add_end (List *lp, const void *val) lp->data[lp->current] = val; } -int list_at_end (List *lp) +int check_list_at_end (List *lp) { if (lp->current == -1) return 1; @@ -90,7 +90,7 @@ int list_at_end (List *lp) return (lp->current > lp->last); } -void list_front (List *lp) +void check_list_front (List *lp) { if (lp->current == -1) return; @@ -98,7 +98,7 @@ void list_front (List *lp) } -void list_free (List *lp) +void check_list_free (List *lp) { if (lp == NULL) return; @@ -107,7 +107,7 @@ void list_free (List *lp) free (lp); } -void *list_val (List *lp) +void *check_list_val (List *lp) { if (lp == NULL) return NULL; @@ -117,23 +117,23 @@ void *list_val (List *lp) return (void*) lp->data[lp->current]; } -void list_advance (List *lp) +void check_list_advance (List *lp) { if (lp == NULL) return; - if (list_at_end(lp)) + if (check_list_at_end(lp)) return; lp->current++; } -void list_apply (List *lp, void (*fp) (void *)) +void check_list_apply (List *lp, void (*fp) (void *)) { if (lp == NULL || fp == NULL) return; - for (list_front(lp); !list_at_end(lp); list_advance(lp)) - fp (list_val(lp)); + for (check_list_front(lp); !check_list_at_end(lp); check_list_advance(lp)) + fp (check_list_val(lp)); } diff --git a/src/check_list.h b/src/check_list.h index e40f4f8..01501b7 100644 --- a/src/check_list.h +++ b/src/check_list.h @@ -27,30 +27,30 @@ typedef struct List List; List * check_list_create (void); /* Is list at end? */ -int list_at_end (List * lp); +int check_list_at_end (List * lp); /* Position list at front */ -void list_front(List *lp); +void check_list_front(List *lp); /* Add a value to the front of the list, positioning newly added value as current value. More expensive than list_add_end, as it uses memmove. */ -void list_add_front (List *lp, const void *val); +void check_list_add_front (List *lp, const void *val); /* Add a value to the end of the list, positioning newly added value as current value */ -void list_add_end (List *lp, const void *val); +void check_list_add_end (List *lp, const void *val); /* Give the value of the current node */ -void *list_val (List * lp); +void *check_list_val (List * lp); /* Position the list at the next node */ -void list_advance (List * lp); +void check_list_advance (List * lp); /* Free a list, but don't free values */ -void list_free (List * lp); +void check_list_free (List * lp); -void list_apply (List *lp, void (*fp) (void *)); +void check_list_apply (List *lp, void (*fp) (void *)); #endif /* CHECK_LIST_H */ diff --git a/src/check_log.c b/src/check_log.c index f1e2b4b..070986a 100644 --- a/src/check_log.c +++ b/src/check_log.c @@ -94,7 +94,7 @@ void srunner_register_lfun (SRunner *sr, FILE *lfile, int close, l->lfun = lfun; l->close = close; l->mode = printmode; - list_add_end (sr->loglst, l); + check_list_add_end (sr->loglst, l); return; } @@ -135,8 +135,8 @@ static void srunner_send_evt (SRunner *sr, void *obj, enum cl_event evt) List *l; Log *lg; l = sr->loglst; - for (list_front(l); !list_at_end(l); list_advance(l)) { - lg = list_val(l); + for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { + lg = check_list_val(l); fflush(lg->lfile); lg->lfun (sr, lg->lfile, lg->mode, obj, evt); fflush(lg->lfile); @@ -403,8 +403,8 @@ void srunner_end_logging (SRunner *sr) srunner_send_evt (sr, NULL, CLENDLOG_SR); l = sr->loglst; - for (list_front(l); !list_at_end(l); list_advance(l)) { - Log *lg = list_val(l); + for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { + Log *lg = check_list_val(l); if (lg->close) { rval = fclose (lg->lfile); if (rval != 0) @@ -412,6 +412,6 @@ void srunner_end_logging (SRunner *sr) } free (lg); } - list_free(l); + check_list_free(l); sr->loglst = NULL; } diff --git a/src/check_print.c b/src/check_print.c index d67fef6..94e84dc 100644 --- a/src/check_print.c +++ b/src/check_print.c @@ -81,8 +81,8 @@ static void srunner_fprint_results (FILE *file, SRunner *sr, resultlst = sr->resultlst; - for (list_front(resultlst); !list_at_end(resultlst); list_advance(resultlst)) { - TestResult *tr = list_val(resultlst); + for (check_list_front(resultlst); !check_list_at_end(resultlst); check_list_advance(resultlst)) { + TestResult *tr = check_list_val(resultlst); tr_fprint (file, tr, print_mode); } return; diff --git a/src/check_run.c b/src/check_run.c index 8b3f16c..def7344 100644 --- a/src/check_run.c +++ b/src/check_run.c @@ -135,8 +135,8 @@ static void srunner_iterate_suites (SRunner *sr, slst = sr->slst; - for (list_front(slst); !list_at_end(slst); list_advance(slst)) { - Suite *s = list_val(slst); + for (check_list_front(slst); !check_list_at_end(slst); check_list_advance(slst)) { + Suite *s = check_list_val(slst); if (((sname != NULL) && (strcmp (sname, s->name) != 0)) || ((tcname != NULL) && (!suite_tcase (s, tcname)))) @@ -146,8 +146,8 @@ static void srunner_iterate_suites (SRunner *sr, tcl = s->tclst; - for (list_front(tcl);!list_at_end (tcl); list_advance (tcl)) { - tc = list_val (tcl); + for (check_list_front(tcl);!check_list_at_end (tcl); check_list_advance (tcl)) { + tc = check_list_val (tcl); if ((tcname != NULL) && (strcmp (tcname, tc->name) != 0)) { continue; @@ -168,9 +168,9 @@ static void srunner_iterate_tcase_tfuns (SRunner *sr, TCase *tc) tfl = tc->tflst; - for (list_front(tfl); !list_at_end (tfl); list_advance (tfl)) { + for (check_list_front(tfl); !check_list_at_end (tfl); check_list_advance (tfl)) { int i; - tfun = list_val (tfl); + tfun = check_list_val (tfl); for (i = tfun->loop_start; i < tfun->loop_end; i++) { @@ -200,7 +200,7 @@ static void srunner_iterate_tcase_tfuns (SRunner *sr, TCase *tc) static void srunner_add_failure (SRunner *sr, TestResult *tr) { - list_add_end (sr->resultlst, tr); + check_list_add_end (sr->resultlst, tr); sr->stats->n_checked++; /* count checks during setup, test, and teardown */ if (tr->rtype == CK_FAILURE) sr->stats->n_failed++; @@ -220,9 +220,9 @@ static int srunner_run_unchecked_setup (SRunner *sr, TCase *tc) l = tc->unch_sflst; - for (list_front(l); !list_at_end(l); list_advance(l)) { + for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { send_ctx_info(CK_CTX_SETUP); - f = list_val(l); + f = check_list_val(l); if ( 0 == setjmp(error_jmp_buffer) ) { f->fun(); @@ -256,8 +256,8 @@ static TestResult * tcase_run_checked_setup (SRunner *sr, TCase *tc) send_ctx_info(CK_CTX_SETUP); } - for (list_front(l); !list_at_end(l); list_advance(l)) { - f = list_val(l); + for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { + f = check_list_val(l); if (fstat == CK_NOFORK) { send_ctx_info(CK_CTX_SETUP); @@ -290,8 +290,8 @@ static void srunner_run_teardown (List *l) { Fixture *f; - for (list_front(l); !list_at_end(l); list_advance(l)) { - f = list_val(l); + for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { + f = check_list_val(l); send_ctx_info(CK_CTX_TEARDOWN); f->fun (); } diff --git a/tests/check_check_log_internal.c b/tests/check_check_log_internal.c index 9b24be2..96556df 100644 --- a/tests/check_check_log_internal.c +++ b/tests/check_check_log_internal.c @@ -22,12 +22,12 @@ START_TEST(test_init_logging_subunit) Suite *s = suite_create("Suite"); SRunner *sr = srunner_create(s); srunner_init_logging(sr, CK_SUBUNIT); - list_front (sr->loglst); - ck_assert_msg (!list_at_end(sr->loglst), "No entries in log list"); - first_log = list_val(sr->loglst); + check_list_front (sr->loglst); + ck_assert_msg (!check_list_at_end(sr->loglst), "No entries in log list"); + first_log = check_list_val(sr->loglst); ck_assert_msg (first_log != NULL, "log is NULL"); - list_advance(sr->loglst); - ck_assert_msg(list_at_end(sr->loglst), "More than one entry in log list"); + check_list_advance(sr->loglst); + ck_assert_msg(check_list_at_end(sr->loglst), "More than one entry in log list"); ck_assert_msg(first_log->lfun == subunit_lfun, "Log function is not the subunit lfun."); srunner_end_logging(sr); diff --git a/tests/check_list.c b/tests/check_list.c index 821e09c..058ceef 100644 --- a/tests/check_list.c +++ b/tests/check_list.c @@ -11,30 +11,30 @@ START_TEST(test_create) { List *lp = NULL; - ck_assert_msg (list_val(lp) == NULL, + ck_assert_msg (check_list_val(lp) == NULL, "Current list value should be NULL for NULL list"); lp = check_list_create(); - ck_assert_msg (list_val(lp) == NULL, + ck_assert_msg (check_list_val(lp) == NULL, "Current list value should be NULL for newly created list"); - ck_assert_msg (list_at_end(lp), + ck_assert_msg (check_list_at_end(lp), "Newly created list should be at end"); - list_advance(lp); - ck_assert_msg (list_at_end(lp), + check_list_advance(lp); + ck_assert_msg (check_list_at_end(lp), "Advancing a list at end should produce a list at end"); - list_free (lp); + check_list_free (lp); } END_TEST START_TEST(test_free) { List *lp = check_list_create(); - list_add_end (lp, "abc"); - list_add_end (lp, "123"); - list_add_end (lp, NULL); - list_free (lp); + check_list_add_end (lp, "abc"); + check_list_add_end (lp, "123"); + check_list_add_end (lp, NULL); + check_list_free (lp); } END_TEST @@ -43,15 +43,15 @@ START_TEST(test_add_end) List * lp = check_list_create(); const char * tval = "abc"; - list_add_end (lp, tval); + check_list_add_end (lp, tval); - ck_assert_msg (list_val (lp) != NULL, + ck_assert_msg (check_list_val (lp) != NULL, "List current val should not be null after new insertion"); - ck_assert_msg (!list_at_end (lp), + ck_assert_msg (!check_list_at_end (lp), "List should be at end after new insertion"); - ck_assert_msg (strcmp(tval, (char *) list_val (lp)) == 0, + ck_assert_msg (strcmp(tval, (char *) check_list_val (lp)) == 0, "List current val should equal newly inserted val"); - list_free (lp); + check_list_free (lp); } END_TEST @@ -60,13 +60,13 @@ START_TEST(test_add_front) List * lp = check_list_create(); const char * tval = "abc"; - list_add_front (lp, tval); + check_list_add_front (lp, tval); - ck_assert_msg (list_val (lp) != NULL, + ck_assert_msg (check_list_val (lp) != NULL, "List current val should not be null after new insertion"); - ck_assert_msg (strcmp(tval, (char *) list_val (lp)) == 0, + ck_assert_msg (strcmp(tval, (char *) check_list_val (lp)) == 0, "List current val should equal newly inserted val"); - list_free (lp); + check_list_free (lp); } END_TEST @@ -76,20 +76,20 @@ START_TEST(test_add_end_and_next) const char *tval1 = "abc"; const char *tval2 = "123"; - list_add_end (lp, tval1); - list_add_end (lp, tval2); - list_front(lp); - ck_assert_msg (strcmp (tval1, list_val (lp)) == 0, + check_list_add_end (lp, tval1); + check_list_add_end (lp, tval2); + check_list_front(lp); + ck_assert_msg (strcmp (tval1, check_list_val (lp)) == 0, "List head val should equal first inserted val"); - list_advance (lp); - ck_assert_msg (!list_at_end (lp), + check_list_advance (lp); + ck_assert_msg (!check_list_at_end (lp), "List should not be at end after two adds and one next"); - ck_assert_msg (strcmp (tval2, list_val (lp)) == 0, + ck_assert_msg (strcmp (tval2, check_list_val (lp)) == 0, "List val should equal second inserted val"); - list_advance(lp); - ck_assert_msg (list_at_end (lp), + check_list_advance(lp); + ck_assert_msg (check_list_at_end (lp), "List should be at and after two adds and two nexts"); - list_free (lp); + check_list_free (lp); } END_TEST @@ -100,20 +100,20 @@ START_TEST(test_add_front_and_next) const char *tval1 = "abc"; const char *tval2 = "123"; - list_add_front (lp, tval1); - list_add_front (lp, tval2); - list_front(lp); - ck_assert_msg (strcmp (tval2, list_val (lp)) == 0, + check_list_add_front (lp, tval1); + check_list_add_front (lp, tval2); + check_list_front(lp); + ck_assert_msg (strcmp (tval2, check_list_val (lp)) == 0, "List head val should equal last inserted val"); - list_advance (lp); - ck_assert_msg (!list_at_end (lp), + check_list_advance (lp); + ck_assert_msg (!check_list_at_end (lp), "List should not be at end after two adds and one next"); - ck_assert_msg (strcmp (tval1, list_val (lp)) == 0, + ck_assert_msg (strcmp (tval1, check_list_val (lp)) == 0, "List val should equal first inserted val"); - list_advance(lp); - ck_assert_msg (list_at_end (lp), + check_list_advance(lp); + ck_assert_msg (check_list_at_end (lp), "List should be at and after two adds and two nexts"); - list_free (lp); + check_list_free (lp); } END_TEST @@ -124,10 +124,10 @@ START_TEST(test_add_a_bunch) for (i = 0; i < 3; i++) { lp = check_list_create(); for (j = 0; j < 1000; j++) { - list_add_end (lp, "abc"); - list_add_front (lp, "123"); + check_list_add_end (lp, "abc"); + check_list_add_front (lp, "123"); } - list_free(lp); + check_list_free(lp); } } END_TEST -- 2.40.0