]> granicus.if.org Git - check/commitdiff
Run indent on source
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Mon, 27 Jan 2014 03:18:40 +0000 (03:18 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Mon, 27 Jan 2014 03:18:40 +0000 (03:18 +0000)
The indent program was run against the source, to enforce a consistent
layout and spacing. The following arguments were used:

--blank-lines-after-declarations --blank-lines-after-procedures
--brace-indent0 --case-indentation4 --case-brace-indentation0
--no-space-after-function-call-names --no-space-after-casts
--declaration-indentation1 --no-blank-lines-after-commas
--braces-after-struct-decl-line --braces-after-func-def-line
--continue-at-parentheses --preprocessor-indentation0  --indent-level4
--no-tabs --dont-break-procedure-type --no-space-after-parentheses
--no-space-after-for --no-space-after-if --no-space-after-while

Note that this was not run againt the test files for two reasons:
1) some of the tests depend on the failures occuring on specific lines,
and I did not want to go through and fix that for each test.
2) indent does not know what to do with END_TEST, and thinks it is a
type modifier for the function that follows.

git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@1081 64e312b2-a51f-0410-8e61-82d0ca0eb02a

46 files changed:
doc/example/src/main.c
doc/example/src/money.2.h
doc/example/src/money.3.c
doc/example/src/money.4.c
doc/example/src/money.5.c
doc/example/src/money.6.c
doc/example/src/money.c
doc/example/src/money.h
doc/example/tests/check_money.1.c
doc/example/tests/check_money.2.c
doc/example/tests/check_money.3.c
doc/example/tests/check_money.6.c
doc/example/tests/check_money.7.c
doc/example/tests/check_money.c
lib/alarm.c
lib/clock_gettime.c
lib/gettimeofday.c
lib/libcompat.c
lib/libcompat.h
lib/localtime_r.c
lib/malloc.c
lib/realloc.c
lib/strdup.c
lib/strsignal.c
lib/timer_create.c
lib/timer_delete.c
lib/timer_settime.c
src/check.c
src/check.h.in
src/check_error.c
src/check_error.h
src/check_impl.h
src/check_list.c
src/check_list.h
src/check_log.c
src/check_log.h
src/check_msg.c
src/check_msg.h
src/check_pack.c
src/check_pack.h
src/check_print.c
src/check_print.h
src/check_run.c
src/check_str.c
src/check_str.h
tests/ex_output.c

index caeae4a09c0c8c801d97a0b869be69406f2dc1fb..75e52cb0c6b066e717d53ce94b646d355dc410fb 100644 (file)
@@ -5,8 +5,7 @@
    whole program testing framework like Autotest.
 */
 
-int
-main (void)
+int main(void)
 {
-  return 0;
+    return 0;
 }
index 1897415977b5552f1f63b4c6428d37b92710978b..3d4ce00fdc7257ef7712bef7f90e0ddaa54fa133 100644 (file)
@@ -3,9 +3,9 @@
 
 typedef struct Money Money;
 
-Money *money_create (int amount, char *currency);
-int money_amount (Money * m);
-char *money_currency (Money * m);
-void money_free (Money * m);
+Money *money_create(int amount, char *currency);
+int money_amount(Money * m);
+char *money_currency(Money * m);
+void money_free(Money * m);
 
 #endif /* MONEY_H */
index 52ac9eafa93ea50769aae64acee7873e998eb5b5..dd9108346897b8dc6dde5f43c265d6af27a0bec5 100644 (file)
@@ -1,26 +1,22 @@
 #include <stdlib.h>
 #include "money.h"
 
-Money *
-money_create (int amount, char *currency)
+Money *money_create(int amount, char *currency)
 {
-  return NULL;
+    return NULL;
 }
 
-int
-money_amount (Money * m)
+int money_amount(Money * m)
 {
-  return 0;
+    return 0;
 }
 
-char *
-money_currency (Money * m)
+char *money_currency(Money * m)
 {
-  return NULL;
+    return NULL;
 }
 
-void
-money_free (Money * m)
+void money_free(Money * m)
 {
-  return;
+    return;
 }
index e925672692cc8b381a54dbbd5247be54d8f6813d..9570c10c7a8f630f6210f96f8a85bd18d1a5630c 100644 (file)
@@ -3,29 +3,25 @@
 
 struct Money
 {
-  int amount;
+    int amount;
 };
 
-Money *
-money_create (int amount, char *currency)
+Money *money_create(int amount, char *currency)
 {
-  return NULL;
+    return NULL;
 }
 
-int
-money_amount (Money * m)
+int money_amount(Money * m)
 {
-  return m->amount;
+    return m->amount;
 }
 
-char *
-money_currency (Money * m)
+char *money_currency(Money * m)
 {
-  return NULL;
+    return NULL;
 }
 
-void
-money_free (Money * m)
+void money_free(Money * m)
 {
-  return;
+    return;
 }
index 64267a9223857f6a3a8b73116aa35be4488c60fa..92e5860ade41574f4d2be8f48617cf686ac0393b 100644 (file)
@@ -3,39 +3,36 @@
 
 struct Money
 {
-  int amount;
-  char *currency;
+    int amount;
+    char *currency;
 };
 
-Money *
-money_create (int amount, char *currency)
+Money *money_create(int amount, char *currency)
 {
-  Money *m = malloc (sizeof (Money));
-  if (m == NULL)
+    Money *m = malloc(sizeof(Money));
+
+    if (m == NULL)
     {
-      return NULL;
+        return NULL;
     }
 
-  m->amount = amount;
-  m->currency = currency;
-  return m;
+    m->amount = amount;
+    m->currency = currency;
+    return m;
 }
 
-int
-money_amount (Money * m)
+int money_amount(Money * m)
 {
-  return m->amount;
+    return m->amount;
 }
 
-char *
-money_currency (Money * m)
+char *money_currency(Money * m)
 {
-  return m->currency;
+    return m->currency;
 }
 
-void
-money_free (Money * m)
+void money_free(Money * m)
 {
-  free (m);
-  return;
+    free(m);
+    return;
 }
index 47f09bb68827553e34a9c035b91e9ae47a198161..111e611c3b025b976a1e1f3b578d597e441bf36a 100644 (file)
@@ -3,44 +3,41 @@
 
 struct Money
 {
-  int amount;
-  char *currency;
+    int amount;
+    char *currency;
 };
 
-Money *
-money_create (int amount, char *currency)
+Money *money_create(int amount, char *currency)
 {
-  if (amount < 0)
+    if (amount < 0)
     {
-      return NULL;
+        return NULL;
     }
 
-  Money *m = malloc (sizeof (Money));
-  if (m == NULL)
+    Money *m = malloc(sizeof(Money));
+
+    if (m == NULL)
     {
-      return NULL;
+        return NULL;
     }
 
-  m->amount = amount;
-  m->currency = currency;
-  return m;
+    m->amount = amount;
+    m->currency = currency;
+    return m;
 }
 
-int
-money_amount (Money * m)
+int money_amount(Money * m)
 {
-  return m->amount;
+    return m->amount;
 }
 
-char *
-money_currency (Money * m)
+char *money_currency(Money * m)
 {
-  return m->currency;
+    return m->currency;
 }
 
-void
-money_free (Money * m)
+void money_free(Money * m)
 {
-  free (m);
-  return;
+    free(m);
+    return;
 }
index 47f09bb68827553e34a9c035b91e9ae47a198161..111e611c3b025b976a1e1f3b578d597e441bf36a 100644 (file)
@@ -3,44 +3,41 @@
 
 struct Money
 {
-  int amount;
-  char *currency;
+    int amount;
+    char *currency;
 };
 
-Money *
-money_create (int amount, char *currency)
+Money *money_create(int amount, char *currency)
 {
-  if (amount < 0)
+    if (amount < 0)
     {
-      return NULL;
+        return NULL;
     }
 
-  Money *m = malloc (sizeof (Money));
-  if (m == NULL)
+    Money *m = malloc(sizeof(Money));
+
+    if (m == NULL)
     {
-      return NULL;
+        return NULL;
     }
 
-  m->amount = amount;
-  m->currency = currency;
-  return m;
+    m->amount = amount;
+    m->currency = currency;
+    return m;
 }
 
-int
-money_amount (Money * m)
+int money_amount(Money * m)
 {
-  return m->amount;
+    return m->amount;
 }
 
-char *
-money_currency (Money * m)
+char *money_currency(Money * m)
 {
-  return m->currency;
+    return m->currency;
 }
 
-void
-money_free (Money * m)
+void money_free(Money * m)
 {
-  free (m);
-  return;
+    free(m);
+    return;
 }
index 1897415977b5552f1f63b4c6428d37b92710978b..3d4ce00fdc7257ef7712bef7f90e0ddaa54fa133 100644 (file)
@@ -3,9 +3,9 @@
 
 typedef struct Money Money;
 
-Money *money_create (int amount, char *currency);
-int money_amount (Money * m);
-char *money_currency (Money * m);
-void money_free (Money * m);
+Money *money_create(int amount, char *currency);
+int money_amount(Money * m);
+char *money_currency(Money * m);
+void money_free(Money * m);
 
 #endif /* MONEY_H */
index 398ec675a07c73e572e07e11d4c3bd1d6500dae0..58fe69254d012146d9d2032c8845e6d65c8aff52 100644 (file)
@@ -1,5 +1,4 @@
-int
-main (void)
+int main(void)
 {
-  return 0;
+    return 0;
 }
index ecfde5d093246ceda1bbb4aca69f39d8b1853ede..3eb18382447154ab47fc705c15942f22df17982b 100644 (file)
@@ -1,18 +1,18 @@
 #include <check.h>
 #include "../src/money.h"
 
-START_TEST (test_money_create)
+START_TEST(test_money_create)
 {
-  Money *m;
-  m = money_create (5, "USD");
-  ck_assert_int_eq (money_amount (m), 5);
-  ck_assert_str_eq (money_currency (m), "USD");
-  money_free (m);
+    Money *m;
+
+    m = money_create(5, "USD");
+    ck_assert_int_eq(money_amount(m), 5);
+    ck_assert_str_eq(money_currency(m), "USD");
+    money_free(m);
 }
 END_TEST
 
-int
-main (void)
+int main(void)
 {
-  return 0;
+    return 0;
 }
index eb339bf613bf6dd269eec8d32070645731d1a651..3404114ebd98308e9a64fd02ee94bb2a6fcfd747 100644 (file)
@@ -2,37 +2,38 @@
 #include <check.h>
 #include "../src/money.h"
 
-START_TEST (test_money_create)
+START_TEST(test_money_create)
 {
-  Money *m;
-  m = money_create (5, "USD");
-  ck_assert_int_eq (money_amount (m), 5);
-  ck_assert_str_eq (money_currency (m), "USD");
-  money_free (m);
+    Money *m;
+
+    m = money_create(5, "USD");
+    ck_assert_int_eq(money_amount(m), 5);
+    ck_assert_str_eq(money_currency(m), "USD");
+    money_free(m);
 }
 END_TEST
 
-Suite *
-money_suite (void)
+Suite * money_suite(void)
 {
-  Suite *s = suite_create ("Money");
+    Suite *s = suite_create("Money");
+
+    /* Core test case */
+    TCase *tc_core = tcase_create("Core");
 
-  /* Core test case */
-  TCase *tc_core = tcase_create ("Core");
-  tcase_add_test (tc_core, test_money_create);
-  suite_add_tcase (s, tc_core);
+    tcase_add_test(tc_core, test_money_create);
+    suite_add_tcase(s, tc_core);
 
-  return s;
+    return s;
 }
 
-int
-main (void)
+int main(void)
 {
-  int number_failed;
-  Suite *s = money_suite ();
-  SRunner *sr = srunner_create (s);
-  srunner_run_all (sr, CK_NORMAL);
-  number_failed = srunner_ntests_failed (sr);
-  srunner_free (sr);
-  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+    int number_failed;
+    Suite *s = money_suite();
+    SRunner *sr = srunner_create(s);
+
+    srunner_run_all(sr, CK_NORMAL);
+    number_failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index acb00f416c52b74e3223f9889cde5efe36713927..4c25348e637e72ab25d4a29bb002dd197f10c75e 100644 (file)
@@ -2,62 +2,66 @@
 #include <check.h>
 #include "../src/money.h"
 
-START_TEST (test_money_create)
+START_TEST(test_money_create)
 {
-  Money *m;
-  m = money_create (5, "USD");
-  ck_assert_int_eq (money_amount (m), 5);
-  ck_assert_str_eq (money_currency (m), "USD");
-  money_free (m);
+    Money *m;
+
+    m = money_create(5, "USD");
+    ck_assert_int_eq(money_amount(m), 5);
+    ck_assert_str_eq(money_currency(m), "USD");
+    money_free(m);
 }
 END_TEST
 
-START_TEST (test_money_create_neg)
+START_TEST(test_money_create_neg)
 {
-  Money *m = money_create (-1, "USD");
-  ck_assert_msg (m == NULL,
-              "NULL should be returned on attempt to create with "
-              "a negative amount");
+    Money *m = money_create(-1, "USD");
+
+    ck_assert_msg(m == NULL,
+                  "NULL should be returned on attempt to create with "
+                  "a negative amount");
 }
 END_TEST
 
-START_TEST (test_money_create_zero)
+START_TEST(test_money_create_zero)
 {
-  Money *m = money_create (0, "USD");
-  if(money_amount (m) != 0)
-  {
-    ck_abort_msg("Zero is a valid amount of money");
-  }
+    Money *m = money_create(0, "USD");
+
+    if (money_amount(m) != 0)
+    {
+        ck_abort_msg("Zero is a valid amount of money");
+    }
 }
-END_TEST
+END_TEST 
 
-Suite *
-money_suite (void)
+Suite * money_suite(void)
 {
-  Suite *s = suite_create ("Money");
+    Suite *s = suite_create("Money");
 
-  /* Core test case */
-  TCase *tc_core = tcase_create ("Core");
-  tcase_add_test (tc_core, test_money_create);
-  suite_add_tcase (s, tc_core);
+    /* Core test case */
+    TCase *tc_core = tcase_create("Core");
 
-  /* Limits test case */
-  TCase *tc_limits = tcase_create ("Limits");
-  tcase_add_test (tc_limits, test_money_create_neg);
-  tcase_add_test (tc_limits, test_money_create_zero);
-  suite_add_tcase (s, tc_limits);
+    tcase_add_test(tc_core, test_money_create);
+    suite_add_tcase(s, tc_core);
 
-  return s;
+    /* Limits test case */
+    TCase *tc_limits = tcase_create("Limits");
+
+    tcase_add_test(tc_limits, test_money_create_neg);
+    tcase_add_test(tc_limits, test_money_create_zero);
+    suite_add_tcase(s, tc_limits);
+
+    return s;
 }
 
-int
-main (void)
+int main(void)
 {
-  int number_failed;
-  Suite *s = money_suite ();
-  SRunner *sr = srunner_create (s);
-  srunner_run_all (sr, CK_NORMAL);
-  number_failed = srunner_ntests_failed (sr);
-  srunner_free (sr);
-  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+    int number_failed;
+    Suite *s = money_suite();
+    SRunner *sr = srunner_create(s);
+
+    srunner_run_all(sr, CK_NORMAL);
+    number_failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index bbc03eb6b9663772259dfb92814989515c958a00..4c4c0a6b13a9a46910b3a497cfc6ed3bb794feee 100644 (file)
@@ -4,72 +4,73 @@
 
 Money *five_dollars;
 
-void
-setup (void)
+void setup(void)
 {
-  five_dollars = money_create (5, "USD");
+    five_dollars = money_create(5, "USD");
 }
 
-void
-teardown (void)
+void teardown(void)
 {
-  money_free (five_dollars);
+    money_free(five_dollars);
 }
 
-START_TEST (test_money_create)
+START_TEST(test_money_create)
 {
-  ck_assert_int_eq (money_amount (five_dollars), 5);
-  ck_assert_str_eq (money_currency (five_dollars), "USD");
+    ck_assert_int_eq(money_amount(five_dollars), 5);
+    ck_assert_str_eq(money_currency(five_dollars), "USD");
 }
 END_TEST
 
-START_TEST (test_money_create_neg)
+START_TEST(test_money_create_neg)
 {
-  Money *m = money_create (-1, "USD");
-  ck_assert_msg (m == NULL,
-              "NULL should be returned on attempt to create with "
-              "a negative amount");
+    Money *m = money_create(-1, "USD");
+
+    ck_assert_msg(m == NULL,
+                  "NULL should be returned on attempt to create with "
+                  "a negative amount");
 }
 END_TEST
 
-START_TEST (test_money_create_zero)
+START_TEST(test_money_create_zero)
 {
-  Money *m = money_create (0, "USD");
-  if(money_amount (m) != 0)
-  {
-    ck_abort_msg("Zero is a valid amount of money");
-  }
+    Money *m = money_create(0, "USD");
+
+    if (money_amount(m) != 0)
+    {
+        ck_abort_msg("Zero is a valid amount of money");
+    }
 }
 END_TEST
 
-Suite *
-money_suite (void)
+Suite * money_suite(void)
 {
-  Suite *s = suite_create ("Money");
+    Suite *s = suite_create("Money");
+
+    /* Core test case */
+    TCase *tc_core = tcase_create("Core");
 
-  /* Core test case */
-  TCase *tc_core = tcase_create ("Core");
-  tcase_add_checked_fixture (tc_core, setup, teardown);
-  tcase_add_test (tc_core, test_money_create);
-  suite_add_tcase (s, tc_core);
+    tcase_add_checked_fixture(tc_core, setup, teardown);
+    tcase_add_test(tc_core, test_money_create);
+    suite_add_tcase(s, tc_core);
 
-  /* Limits test case */
-  TCase *tc_limits = tcase_create ("Limits");
-  tcase_add_test (tc_limits, test_money_create_neg);
-  tcase_add_test (tc_limits, test_money_create_zero);
-  suite_add_tcase (s, tc_limits);
+    /* Limits test case */
+    TCase *tc_limits = tcase_create("Limits");
 
-  return s;
+    tcase_add_test(tc_limits, test_money_create_neg);
+    tcase_add_test(tc_limits, test_money_create_zero);
+    suite_add_tcase(s, tc_limits);
+
+    return s;
 }
 
-int
-main (void)
+int main(void)
 {
-  int number_failed;
-  Suite *s = money_suite ();
-  SRunner *sr = srunner_create (s);
-  srunner_run_all (sr, CK_NORMAL);
-  number_failed = srunner_ntests_failed (sr);
-  srunner_free (sr);
-  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+    int number_failed;
+    Suite *s = money_suite();
+    SRunner *sr = srunner_create(s);
+
+    srunner_run_all(sr, CK_NORMAL);
+    number_failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index bbc03eb6b9663772259dfb92814989515c958a00..4c4c0a6b13a9a46910b3a497cfc6ed3bb794feee 100644 (file)
@@ -4,72 +4,73 @@
 
 Money *five_dollars;
 
-void
-setup (void)
+void setup(void)
 {
-  five_dollars = money_create (5, "USD");
+    five_dollars = money_create(5, "USD");
 }
 
-void
-teardown (void)
+void teardown(void)
 {
-  money_free (five_dollars);
+    money_free(five_dollars);
 }
 
-START_TEST (test_money_create)
+START_TEST(test_money_create)
 {
-  ck_assert_int_eq (money_amount (five_dollars), 5);
-  ck_assert_str_eq (money_currency (five_dollars), "USD");
+    ck_assert_int_eq(money_amount(five_dollars), 5);
+    ck_assert_str_eq(money_currency(five_dollars), "USD");
 }
 END_TEST
 
-START_TEST (test_money_create_neg)
+START_TEST(test_money_create_neg)
 {
-  Money *m = money_create (-1, "USD");
-  ck_assert_msg (m == NULL,
-              "NULL should be returned on attempt to create with "
-              "a negative amount");
+    Money *m = money_create(-1, "USD");
+
+    ck_assert_msg(m == NULL,
+                  "NULL should be returned on attempt to create with "
+                  "a negative amount");
 }
 END_TEST
 
-START_TEST (test_money_create_zero)
+START_TEST(test_money_create_zero)
 {
-  Money *m = money_create (0, "USD");
-  if(money_amount (m) != 0)
-  {
-    ck_abort_msg("Zero is a valid amount of money");
-  }
+    Money *m = money_create(0, "USD");
+
+    if (money_amount(m) != 0)
+    {
+        ck_abort_msg("Zero is a valid amount of money");
+    }
 }
 END_TEST
 
-Suite *
-money_suite (void)
+Suite * money_suite(void)
 {
-  Suite *s = suite_create ("Money");
+    Suite *s = suite_create("Money");
+
+    /* Core test case */
+    TCase *tc_core = tcase_create("Core");
 
-  /* Core test case */
-  TCase *tc_core = tcase_create ("Core");
-  tcase_add_checked_fixture (tc_core, setup, teardown);
-  tcase_add_test (tc_core, test_money_create);
-  suite_add_tcase (s, tc_core);
+    tcase_add_checked_fixture(tc_core, setup, teardown);
+    tcase_add_test(tc_core, test_money_create);
+    suite_add_tcase(s, tc_core);
 
-  /* Limits test case */
-  TCase *tc_limits = tcase_create ("Limits");
-  tcase_add_test (tc_limits, test_money_create_neg);
-  tcase_add_test (tc_limits, test_money_create_zero);
-  suite_add_tcase (s, tc_limits);
+    /* Limits test case */
+    TCase *tc_limits = tcase_create("Limits");
 
-  return s;
+    tcase_add_test(tc_limits, test_money_create_neg);
+    tcase_add_test(tc_limits, test_money_create_zero);
+    suite_add_tcase(s, tc_limits);
+
+    return s;
 }
 
-int
-main (void)
+int main(void)
 {
-  int number_failed;
-  Suite *s = money_suite ();
-  SRunner *sr = srunner_create (s);
-  srunner_run_all (sr, CK_NORMAL);
-  number_failed = srunner_ntests_failed (sr);
-  srunner_free (sr);
-  return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+    int number_failed;
+    Suite *s = money_suite();
+    SRunner *sr = srunner_create(s);
+
+    srunner_run_all(sr, CK_NORMAL);
+    number_failed = srunner_ntests_failed(sr);
+    srunner_free(sr);
+    return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index e503c08ea454664356322822a5fb26bdbe2a0b09..1dd0df5255a65c77a753c2537b65a53c6ef0ffc4 100644 (file)
@@ -1,8 +1,7 @@
 #include "libcompat.h"
 
-unsigned int alarm (unsigned int seconds CK_ATTRIBUTE_UNUSED)
+unsigned int alarm(unsigned int seconds CK_ATTRIBUTE_UNUSED)
 {
     assert(0);
     return 0;
 }
-
index 4031db2a9b3141648dae5dc114e1b235d47a15ff..b71e5971b15f42f4a6608a19d5add219055800d5 100644 (file)
 
 int clock_gettime(clockid_t clk_id CK_ATTRIBUTE_UNUSED, struct timespec *ts)
 {
-  
-#ifdef __MACH__ 
-  /* OS X does not have clock_gettime, use mach_absolute_time */
-  
-  static mach_timebase_info_data_t  sTimebaseInfo;
-  uint64_t rawTime;
-  uint64_t nanos;
-  
-  rawTime = mach_absolute_time();
-  
-  /*
-   * OS X has a function to convert abs time to nano seconds: AbsoluteToNanoseconds
-   * However, the function may not be available as we may not have
-   * access to CoreServices. Because of this, we convert the abs time
-   * to nano seconds manually.
-   */
-   
-  /*
-   * First grab the time base used on the system, if this is the first
-   * time we are being called. We can check if the value is uninitialized,
-   * as the denominator will be zero. 
-   */
-  if ( sTimebaseInfo.denom == 0 ) 
-  {
-      (void) mach_timebase_info(&sTimebaseInfo);
-  }
-  
-  /* 
-   * Do the conversion. We hope that the multiplication doesn't 
-   * overflow; the price you pay for working in fixed point.
-   */
-  nanos = rawTime * sTimebaseInfo.numer / sTimebaseInfo.denom;
-  
-  /* 
-   * Fill in the timespec container 
-   */
-  ts->tv_sec  = nanos / NANOSECONDS_PER_SECOND;
-  ts->tv_nsec = nanos - (ts->tv_sec * NANOSECONDS_PER_SECOND);
+
+#ifdef __MACH__
+    /* OS X does not have clock_gettime, use mach_absolute_time */
+
+    static mach_timebase_info_data_t sTimebaseInfo;
+    uint64_t rawTime;
+    uint64_t nanos;
+
+    rawTime = mach_absolute_time();
+
+    /*
+     * OS X has a function to convert abs time to nano seconds: AbsoluteToNanoseconds
+     * However, the function may not be available as we may not have
+     * access to CoreServices. Because of this, we convert the abs time
+     * to nano seconds manually.
+     */
+
+    /*
+     * First grab the time base used on the system, if this is the first
+     * time we are being called. We can check if the value is uninitialized,
+     * as the denominator will be zero. 
+     */
+    if(sTimebaseInfo.denom == 0)
+    {
+        (void)mach_timebase_info(&sTimebaseInfo);
+    }
+
+    /* 
+     * Do the conversion. We hope that the multiplication doesn't 
+     * overflow; the price you pay for working in fixed point.
+     */
+    nanos = rawTime * sTimebaseInfo.numer / sTimebaseInfo.denom;
+
+    /* 
+     * Fill in the timespec container 
+     */
+    ts->tv_sec = nanos / NANOSECONDS_PER_SECOND;
+    ts->tv_nsec = nanos - (ts->tv_sec * NANOSECONDS_PER_SECOND);
 #else
-  /* 
-   * As there is no function to fall back onto to get the current
-   * time, zero out the time so the caller will have a sane value. 
-   */
-  ts->tv_sec  = 0;
-  ts->tv_nsec = 0;
+    /* 
+     * As there is no function to fall back onto to get the current
+     * time, zero out the time so the caller will have a sane value. 
+     */
+    ts->tv_sec = 0;
+    ts->tv_nsec = 0;
 #endif
 
-  return 0;
+    return 0;
 }
index 8b3be8c07d89641860b2d355c88efdc8aab4dbb4..ad579726576893f9e1d897b93d5517229c24de48 100644 (file)
@@ -7,23 +7,22 @@
 #define EPOCHFILETIME (116444736000000000LL)
 #endif
 
-int gettimeofday (struct timeval *tv, void* tz)
+int gettimeofday(struct timeval *tv, void *tz)
 {
 #if _MSC_VER
-    union {
-        __int64 ns100; /*time since 1 Jan 1601 in 100ns units */
+    union
+    {
+        __int64 ns100;          /*time since 1 Jan 1601 in 100ns units */
         FILETIME ft;
     } now;
 
-    GetSystemTimeAsFileTime (&now.ft);
-    tv->tv_usec = (long) ((now.ns100 / 10LL) % 1000000LL);
-    tv->tv_sec = (long) ((now.ns100 - EPOCHFILETIME) / 10000000LL);
+    GetSystemTimeAsFileTime(&now.ft);
+    tv->tv_usec = (long)((now.ns100 / 10LL) % 1000000LL);
+    tv->tv_sec = (long)((now.ns100 - EPOCHFILETIME) / 10000000LL);
     return (0);
 #else
     // Return that there is no implementation of this on the system
-    errno=ENOSYS;
+    errno = ENOSYS;
     return -1;
 #endif /* _MSC_VER */
 }
-
-
index 77b8849c4629e6581a6b2742ee73b5c26b50fba7..750d66148ae18ffd8cf0535f64e579c5e8afbc58 100644 (file)
@@ -1,15 +1,14 @@
 #include "libcompat.h"
 
 /* silence warnings about an empty library */
-void
-ck_do_nothing (void)
+void ck_do_nothing(void)
 {
-    assert (0);
+    assert(0);
 
     /*
-    * to silence warning about this function actually
-    * returning, but being marked as noreturn. assert()
-    * must be marked as a function that returns.
-    */
+     * to silence warning about this function actually
+     * returning, but being marked as noreturn. assert()
+     * must be marked as a function that returns.
+     */
     exit(1);
 }
index 674ea95252bb24d24cd224750cd2ffc51baf1d66..cc4bb521915a8b5a2abf34e2e9447d9fb226aa44 100644 (file)
@@ -16,7 +16,7 @@
 #if GCC_VERSION_AT_LEAST(2,95)
 #define CK_ATTRIBUTE_UNUSED __attribute__ ((unused))
 #else
-#define CK_ATTRIBUTE_UNUSED              
+#define CK_ATTRIBUTE_UNUSED
 #endif /* GCC 2.95 */
 
 #if GCC_VERSION_AT_LEAST(2,5)
@@ -35,9 +35,9 @@
 #endif
 
 #if _MSC_VER
-#include <WinSock2.h> /* struct timeval, API used in gettimeofday implementation */
-#include <io.h> /* read, write */
-#include <process.h> /* getpid */
+#include <WinSock2.h>           /* struct timeval, API used in gettimeofday implementation */
+#include <io.h>                 /* read, write */
+#include <process.h>            /* getpid */
 #endif /* _MSC_VER */
 
 /* defines size_t */
 
 /* replacement functions for broken originals */
 #if !HAVE_DECL_ALARM
-CK_DLL_EXP unsigned int alarm (unsigned int seconds);
+CK_DLL_EXP unsigned int alarm(unsigned int seconds);
 #endif /* !HAVE_DECL_ALARM */
 
 #if !HAVE_MALLOC
-CK_DLL_EXP void *rpl_malloc (size_t n);
+CK_DLL_EXP void *rpl_malloc(size_t n);
 #endif /* !HAVE_MALLOC */
 
 #if !HAVE_REALLOC
-CK_DLL_EXP void *rpl_realloc (void *p, size_t n);
+CK_DLL_EXP void *rpl_realloc(void *p, size_t n);
 #endif /* !HAVE_REALLOC */
 
 #if !HAVE_GETPID && HAVE__GETPID
@@ -97,23 +97,23 @@ CK_DLL_EXP void *rpl_realloc (void *p, size_t n);
 #endif /* !HAVE_GETPID && HAVE__GETPID */
 
 #if !HAVE_GETTIMEOFDAY
-CK_DLL_EXP int gettimeofday (struct timeval *tv, void* tz);
+CK_DLL_EXP int gettimeofday(struct timeval *tv, void *tz);
 #endif /* !HAVE_GETTIMEOFDAY */
 
 #if !HAVE_DECL_LOCALTIME_R
 #if !defined(localtime_r)
-CK_DLL_EXP struct tm *localtime_r (const time_t *clock, struct tm *result);
+CK_DLL_EXP struct tm *localtime_r(const time_t * clock, struct tm *result);
 #endif
 #endif /* !HAVE_DECL_LOCALTIME_R */
 
 #if !HAVE_DECL_STRDUP && !HAVE__STRDUP
-CK_DLL_EXP char *strdup (const char *str);
+CK_DLL_EXP char *strdup(const char *str);
 #elif !HAVE_DECL_STRDUP && HAVE__STRDUP
 #define strdup _strdup
 #endif /* !HAVE_DECL_STRDUP && HAVE__STRDUP */
 
 #if !HAVE_DECL_STRSIGNAL
-CK_DLL_EXP const char *strsignal (int sig);
+CK_DLL_EXP const char *strsignal(int sig);
 #endif /* !HAVE_DECL_STRSIGNAL */
 
 /* 
@@ -144,9 +144,10 @@ CK_DLL_EXP const char *strsignal (int sig);
  * specified in seconds and nanoseconds. If it is not defined in
  * time.g, then we need to define it here
  */
-struct timespec {
-   time_t   tv_sec;
-   long     tv_nsec;
+struct timespec
+{
+    time_t tv_sec;
+    long tv_nsec;
 };
 #endif /* STRUCT_TIMESPEC_DEFINITION_MISSING */
 
@@ -170,8 +171,11 @@ struct itimerspec
 struct sigevent;
 
 CK_DLL_EXP int clock_gettime(clockid_t clk_id, struct timespec *ts);
-CK_DLL_EXP int timer_create(int clockid, struct sigevent *sevp, timer_t *timerid);
-CK_DLL_EXP int timer_settime(timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec * old_value);
+CK_DLL_EXP int timer_create(int clockid, struct sigevent *sevp,
+                            timer_t * timerid);
+CK_DLL_EXP int timer_settime(timer_t timerid, int flags,
+                             const struct itimerspec *new_value,
+                             struct itimerspec *old_value);
 CK_DLL_EXP int timer_delete(timer_t timerid);
 #endif /* HAVE_LIBRT */
 
@@ -188,15 +192,17 @@ CK_DLL_EXP int timer_delete(timer_t timerid);
 
 #if !HAVE_VSNPRINTF
 CK_DLL_EXP int rpl_vsnprintf(char *, size_t, const char *, va_list);
+
 #define vsnprintf rpl_vsnprintf
 #endif
 #if !HAVE_SNPRINTF
 CK_DLL_EXP int rpl_snprintf(char *, size_t, const char *, ...);
+
 #define snprintf rpl_snprintf
 #endif
 #endif /* HAVE_STDARG_H */
 
 /* silence warnings about an empty library */
-CK_DLL_EXP void ck_do_nothing (void) CK_ATTRIBUTE_NORETURN;
+CK_DLL_EXP void ck_do_nothing(void) CK_ATTRIBUTE_NORETURN;
 
 #endif /* !LIBCOMPAT_H */
index 081b01fdea90be097398931c2a23eb7adc520774..ec7056edf5e07592abb05382f5b3a2ac709b8fae 100644 (file)
@@ -2,10 +2,11 @@
 
 #if !defined(localtime_r)
 
-struct tm * localtime_r (const time_t *clock, struct tm *result)
+struct tm *localtime_r(const time_t * clock, struct tm *result)
 {
-    struct tm *now = localtime (clock);
-    if (now == NULL)
+    struct tm *now = localtime(clock);
+
+    if(now == NULL)
     {
         return NULL;
     }
index e375459a6b69758b6ccbda63e9936de75298f241..7a99122ec50decaaa722fae34a707a5a634ae375 100644 (file)
@@ -9,13 +9,12 @@
 #undef malloc
 
 /* this gives us the real malloc to use below */
-void *malloc (size_t n);
+void *malloc(size_t n);
 
 /* force malloc(0) to return a valid pointer */
-void *
-rpl_malloc (size_t n)
+void *rpl_malloc(size_t n)
 {
-    if (n == 0)
+    if(n == 0)
         n = 1;
-    return malloc (n);
+    return malloc(n);
 }
index bad57e231209191df56d6d686a63b051cf5107e6..2fa26543607d7a92daf2a444dcfd08c18e4c7786 100644 (file)
 #undef realloc
 
 /* this gives us the real realloc to use below */
-void *realloc (void *p, size_t n);
+void *realloc(void *p, size_t n);
 
 /* force realloc(p, 0) and realloc (NULL, n) to return a valid pointer */
-void *
-rpl_realloc (void *p, size_t n)
+void *rpl_realloc(void *p, size_t n)
 {
-    if (n == 0)
+    if(n == 0)
         n = 1;
-    if (p == 0)
-        return malloc (n);
-    return realloc (p, n);
+    if(p == 0)
+        return malloc(n);
+    return realloc(p, n);
 }
index a9212c388c96f4ce18fc6dcdca89cb9559042863..7a8d36addd8697c9a62afe71639da1d698b0d4e9 100644 (file)
@@ -1,7 +1,7 @@
 #include "libcompat.h"
 
-char * strdup (const char *str CK_ATTRIBUTE_UNUSED)
+char *strdup(const char *str CK_ATTRIBUTE_UNUSED)
 {
-    assert (0);
+    assert(0);
     return NULL;
 }
index 4eb61f044e28d489a1380dcf15c9e389c6b57192..ed069c805ed3796d5a2cabdaf7a16bdd42bc00c7 100644 (file)
@@ -1,8 +1,9 @@
 #include "libcompat.h"
 
-const char * strsignal (int sig)
+const char *strsignal(int sig)
 {
     static char signame[40];
+
     sprintf(signame, "SIG #%d", sig);
     return signame;
 }
index 4d01b61c82262671cfa911dcd565c0c28a38a94c..ba956d98b5cf43ff4ed767c2f0cb03e965323eaf 100644 (file)
@@ -1,14 +1,14 @@
 #include "libcompat.h"
 
-int timer_create(int clockid           CK_ATTRIBUTE_UNUSED, 
-                 struct sigevent *sevp CK_ATTRIBUTE_UNUSED, 
-                 timer_t *timerid      CK_ATTRIBUTE_UNUSED)
+int timer_create(int clockid CK_ATTRIBUTE_UNUSED,
+                 struct sigevent *sevp CK_ATTRIBUTE_UNUSED,
+                 timer_t * timerid CK_ATTRIBUTE_UNUSED)
 {
     /* 
      * The create function does nothing. timer_settime will use
      * alarm to set the timer, and timer_delete will stop the
      * alarm
      */
-    
+
     return 0;
 }
index 02cf16b6d4f97148abe3e7d7bf4290c8fed34e3d..189fe4cf4c360a74d54f193577cdfaab0d5ed29c 100644 (file)
@@ -12,9 +12,9 @@ int timer_delete(timer_t timerid CK_ATTRIBUTE_UNUSED)
     /*
      * Setting values to '0' results in disabling the running timer.
      */
-    new.it_value.tv_sec     = 0;
-    new.it_value.tv_usec    = 0;
-    new.it_interval.tv_sec  = 0;
+    new.it_value.tv_sec = 0;
+    new.it_value.tv_usec = 0;
+    new.it_interval.tv_sec = 0;
     new.it_interval.tv_usec = 0;
 
     return setitimer(ITIMER_REAL, &new, NULL);
@@ -24,9 +24,9 @@ int timer_delete(timer_t timerid CK_ATTRIBUTE_UNUSED)
      * Setting alarm(0) will not set a new alarm, and
      * will kill the previous timer.
      */
-    
+
     alarm(0);
-    
+
     return 0;
 #endif
 }
index 963830a32af610934b53fdee54b6ac72388edf99..479838b9152d0da98437841a2fae7b4c5f8593d7 100644 (file)
@@ -1,9 +1,9 @@
 #include "libcompat.h"
 
-int timer_settime(timer_t timerid               CK_ATTRIBUTE_UNUSED, 
-                  int flags                     CK_ATTRIBUTE_UNUSED, 
-                  const struct itimerspec *new_value, 
-                  struct itimerspec * old_value CK_ATTRIBUTE_UNUSED)
+int timer_settime(timer_t timerid CK_ATTRIBUTE_UNUSED,
+                  int flags CK_ATTRIBUTE_UNUSED,
+                  const struct itimerspec *new_value,
+                  struct itimerspec *old_value CK_ATTRIBUTE_UNUSED)
 {
 #ifdef HAVE_SETITIMER
     /*
@@ -12,15 +12,15 @@ int timer_settime(timer_t timerid               CK_ATTRIBUTE_UNUSED,
      */
     struct itimerval new;
 
-    new.it_value.tv_sec     = new_value->it_value.tv_sec;
-    new.it_value.tv_usec    = new_value->it_value.tv_nsec / 1000;
-    new.it_interval.tv_sec  = new_value->it_interval.tv_sec;
+    new.it_value.tv_sec = new_value->it_value.tv_sec;
+    new.it_value.tv_usec = new_value->it_value.tv_nsec / 1000;
+    new.it_interval.tv_sec = new_value->it_interval.tv_sec;
     new.it_interval.tv_usec = new_value->it_interval.tv_nsec / 1000;
 
     return setitimer(ITIMER_REAL, &new, NULL);
 #else
     int seconds = new_value->it_value.tv_sec;
-    
+
     /* 
      * As the alarm() call has only second precision, if the caller
      * specifies partial seconds, we round up to the nearest second.
@@ -29,9 +29,9 @@ int timer_settime(timer_t timerid               CK_ATTRIBUTE_UNUSED,
     {
         seconds += 1;
     }
-    
+
     alarm(seconds);
-    
+
     return 0;
 #endif
 }
index 4da6c37a0ee1365cd29b7989523930e07bdbdea9..1afcfcd17feb571f5d21ea9e0fb4732f05864f82 100644 (file)
@@ -48,420 +48,466 @@ int check_major_version = CHECK_MAJOR_VERSION;
 int check_minor_version = CHECK_MINOR_VERSION;
 int check_micro_version = CHECK_MICRO_VERSION;
 
-static int non_pass (int val);
-static Fixture *fixture_create (SFun fun, int ischecked);
-static void tcase_add_fixture (TCase *tc, SFun setup, SFun teardown,
-                              int ischecked);
-static void tr_init (TestResult *tr);
-static void suite_free (Suite *s);
-static void tcase_free (TCase *tc);
+static int non_pass(int val);
+static Fixture *fixture_create(SFun fun, int ischecked);
+static void tcase_add_fixture(TCase * tc, SFun setup, SFun teardown,
+                              int ischecked);
+static void tr_init(TestResult * tr);
+static void suite_free(Suite * s);
+static void tcase_free(TCase * tc);
 
-Suite *suite_create (const char *name)
+Suite *suite_create(const char *name)
 {
-  Suite *s;
-  s = emalloc (sizeof(Suite)); /* freed in suite_free */
-  if (name == NULL)
-    s->name = "";
-  else
-    s->name = name;
-  s->tclst = check_list_create();
-  return s;
+    Suite *s;
+
+    s = emalloc(sizeof(Suite)); /* freed in suite_free */
+    if(name == NULL)
+        s->name = "";
+    else
+        s->name = name;
+    s->tclst = check_list_create();
+    return s;
 }
 
-int suite_tcase (Suite *s, const char *tcname)
+int suite_tcase(Suite * s, const char *tcname)
 {
-  List *l;
-  TCase *tc;
+    List *l;
+    TCase *tc;
+
+    if(s == NULL)
+        return 0;
+
+    l = s->tclst;
+    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;
+    }
 
-  if (s == NULL)
     return 0;
+}
+
+static void suite_free(Suite * s)
+{
+    List *l;
+
+    if(s == NULL)
+        return;
+    l = s->tclst;
+    for(check_list_front(l); !check_list_at_end(l); check_list_advance(l))
+    {
+        tcase_free(check_list_val(l));
+    }
+    check_list_free(s->tclst);
+    free(s);
+}
 
-  l = s->tclst;
-  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;
-  }
-
-  return 0;
-}
-
-static void suite_free (Suite *s)
-{
-  List *l;
-  if (s == NULL)
-    return;
-  l = s->tclst;
-  for (check_list_front(l); !check_list_at_end(l); check_list_advance (l)) {
-    tcase_free (check_list_val(l));
-  }
-  check_list_free (s->tclst);
-  free(s);
-}
-
-TCase *tcase_create (const char *name)
-{
-  char *env;
-  double timeout_sec = DEFAULT_TIMEOUT;
-  
-  TCase *tc = emalloc (sizeof(TCase)); /*freed in tcase_free */
-  if (name == NULL)
-    tc->name = "";
-  else
-    tc->name = name;
-
-  env = getenv("CK_DEFAULT_TIMEOUT");
-  if (env != NULL) {
-    char * endptr = NULL;
-    double tmp = strtod(env, &endptr);
-    if (tmp >= 0 && endptr != env && (*endptr) == '\0') {
-      timeout_sec = tmp;
+TCase *tcase_create(const char *name)
+{
+    char *env;
+    double timeout_sec = DEFAULT_TIMEOUT;
+
+    TCase *tc = emalloc(sizeof(TCase)); /*freed in tcase_free */
+
+    if(name == NULL)
+        tc->name = "";
+    else
+        tc->name = name;
+
+    env = getenv("CK_DEFAULT_TIMEOUT");
+    if(env != NULL)
+    {
+        char *endptr = NULL;
+        double tmp = strtod(env, &endptr);
+
+        if(tmp >= 0 && endptr != env && (*endptr) == '\0')
+        {
+            timeout_sec = tmp;
+        }
     }
-  }
-
-  env = getenv("CK_TIMEOUT_MULTIPLIER");
-  if (env != NULL) {
-    char * endptr = NULL;
-    double tmp = strtod(env, &endptr);
-    if (tmp >= 0 && endptr != env && (*endptr) == '\0') {
-      timeout_sec = timeout_sec * tmp;
+
+    env = getenv("CK_TIMEOUT_MULTIPLIER");
+    if(env != NULL)
+    {
+        char *endptr = NULL;
+        double tmp = strtod(env, &endptr);
+
+        if(tmp >= 0 && endptr != env && (*endptr) == '\0')
+        {
+            timeout_sec = timeout_sec * tmp;
+        }
     }
-  }  
 
-  tc->timeout.tv_sec   = (time_t)floor(timeout_sec);
-  tc->timeout.tv_nsec  = (long)((timeout_sec-floor(timeout_sec)) * (double)NANOS_PER_SECONDS);
-  
-  tc->tflst = check_list_create();
-  tc->unch_sflst = check_list_create();
-  tc->ch_sflst = check_list_create();
-  tc->unch_tflst = check_list_create();
-  tc->ch_tflst = check_list_create();
+    tc->timeout.tv_sec = (time_t) floor(timeout_sec);
+    tc->timeout.tv_nsec =
+        (long)((timeout_sec -
+                floor(timeout_sec)) * (double)NANOS_PER_SECONDS);
 
-  return tc;
+    tc->tflst = check_list_create();
+    tc->unch_sflst = check_list_create();
+    tc->ch_sflst = check_list_create();
+    tc->unch_tflst = check_list_create();
+    tc->ch_tflst = check_list_create();
+
+    return tc;
 }
 
 
-static void tcase_free (TCase *tc)
+static void tcase_free(TCase * tc)
 {
-  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);
+    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);
 }
 
-void suite_add_tcase (Suite *s, TCase *tc)
+void suite_add_tcase(Suite * s, TCase * tc)
 {
-  if (s == NULL || tc == NULL)
-    return;
-  check_list_add_end (s->tclst, tc);
+    if(s == NULL || tc == NULL)
+        return;
+    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)
+void _tcase_add_test(TCase * tc, TFun fn, const char *name, int _signal,
+                     int allowed_exit_value, int start, int end)
 {
-  TF * tf;
-  if (tc == NULL || fn == NULL || name == NULL)
-    return;
-  tf = emalloc (sizeof(TF)); /* freed in tcase_free */
-  tf->fn = fn;
-  tf->loop_start = start;
-  tf->loop_end = end;
-  tf->signal = _signal; /* 0 means no signal expected */
-  tf->allowed_exit_value = (WEXITSTATUS_MASK & allowed_exit_value); /* 0 is default successful exit */
-  tf->name = name;
-  check_list_add_end (tc->tflst, tf);
+    TF *tf;
+
+    if(tc == NULL || fn == NULL || name == NULL)
+        return;
+    tf = emalloc(sizeof(TF));   /* freed in tcase_free */
+    tf->fn = fn;
+    tf->loop_start = start;
+    tf->loop_end = end;
+    tf->signal = _signal;       /* 0 means no signal expected */
+    tf->allowed_exit_value = (WEXITSTATUS_MASK & allowed_exit_value);   /* 0 is default successful exit */
+    tf->name = name;
+    check_list_add_end(tc->tflst, tf);
 }
 
-static Fixture *fixture_create (SFun fun, int ischecked)
+static Fixture *fixture_create(SFun fun, int ischecked)
 {
-  Fixture *f;
-  f = emalloc (sizeof(Fixture));
-  f->fun = fun;
-  f->ischecked = ischecked;
+    Fixture *f;
 
-  return f;
+    f = emalloc(sizeof(Fixture));
+    f->fun = fun;
+    f->ischecked = ischecked;
+
+    return f;
 }
 
-void tcase_add_unchecked_fixture (TCase *tc, SFun setup, SFun teardown)
+void tcase_add_unchecked_fixture(TCase * tc, SFun setup, SFun teardown)
 {
-  tcase_add_fixture(tc,setup,teardown,0);
+    tcase_add_fixture(tc, setup, teardown, 0);
 }
 
-void tcase_add_checked_fixture (TCase *tc, SFun setup, SFun teardown)
+void tcase_add_checked_fixture(TCase * tc, SFun setup, SFun teardown)
 {
 #if defined(HAVE_FORK)
-  tcase_add_fixture (tc,setup,teardown,1);
+    tcase_add_fixture(tc, setup, teardown, 1);
 #else
-  (void)tc;
-  (void)setup;
-  (void)teardown;
-  eprintf("This version does not support checked fixtures, as fork is not supported", __FILE__, __LINE__);
+    (void)tc;
+    (void)setup;
+    (void)teardown;
+    eprintf
+        ("This version does not support checked fixtures, as fork is not supported",
+         __FILE__, __LINE__);
 #endif
 }
 
-static void tcase_add_fixture (TCase *tc, SFun setup, SFun teardown,
-                              int ischecked)
+static void tcase_add_fixture(TCase * tc, SFun setup, SFun teardown,
+                              int ischecked)
 {
-  if (setup) {
-    if (ischecked)
-      check_list_add_end (tc->ch_sflst, fixture_create(setup, ischecked));
-    else
-      check_list_add_end (tc->unch_sflst, fixture_create(setup, ischecked));
-  }
+    if(setup)
+    {
+        if(ischecked)
+            check_list_add_end(tc->ch_sflst,
+                               fixture_create(setup, ischecked));
+        else
+            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)
-      check_list_add_front (tc->ch_tflst, fixture_create(teardown, ischecked));
-    else
-      check_list_add_front (tc->unch_tflst, fixture_create(teardown, ischecked));  
-  }
+    /* Add teardowns at front so they are run in reverse order. */
+    if(teardown)
+    {
+        if(ischecked)
+            check_list_add_front(tc->ch_tflst,
+                                 fixture_create(teardown, ischecked));
+        else
+            check_list_add_front(tc->unch_tflst,
+                                 fixture_create(teardown, ischecked));
+    }
 }
 
-void tcase_set_timeout (TCase *tc, double timeout)
+void tcase_set_timeout(TCase * tc, double timeout)
 {
 #if defined(HAVE_FORK)
-  if (timeout >= 0) {
-    char *env = getenv("CK_TIMEOUT_MULTIPLIER");
-    if (env != NULL) {
-      char * endptr = NULL;
-      double tmp = strtod(env, &endptr);
-      if (tmp >= 0 && endptr != env && (*endptr) == '\0') {
-        timeout = timeout * tmp;
-      }
+    if(timeout >= 0)
+    {
+        char *env = getenv("CK_TIMEOUT_MULTIPLIER");
+
+        if(env != NULL)
+        {
+            char *endptr = NULL;
+            double tmp = strtod(env, &endptr);
+
+            if(tmp >= 0 && endptr != env && (*endptr) == '\0')
+            {
+                timeout = timeout * tmp;
+            }
+        }
+
+        tc->timeout.tv_sec = (time_t) floor(timeout);
+        tc->timeout.tv_nsec =
+            (long)((timeout - floor(timeout)) * (double)NANOS_PER_SECONDS);
     }
-    
-  tc->timeout.tv_sec   = (time_t)floor(timeout);
-  tc->timeout.tv_nsec  = (long)((timeout-floor(timeout)) * (double)NANOS_PER_SECONDS);
-  }
 #else
-  (void)tc;
-  (void)timeout;
-  eprintf("This version does not support timeouts, as fork is not supported", __FILE__, __LINE__);
+    (void)tc;
+    (void)timeout;
+    eprintf
+        ("This version does not support timeouts, as fork is not supported",
+         __FILE__, __LINE__);
 #endif /* HAVE_FORK */
 }
 
-void tcase_fn_start (const char *fname CK_ATTRIBUTE_UNUSED, const char *file, int line)
+void tcase_fn_start(const char *fname CK_ATTRIBUTE_UNUSED, const char *file,
+                    int line)
 {
-  send_ctx_info (CK_CTX_TEST);
-  send_loc_info (file, line);
+    send_ctx_info(CK_CTX_TEST);
+    send_loc_info(file, line);
 }
 
-void _mark_point (const char *file, int line)
+void _mark_point(const char *file, int line)
 {
-  send_loc_info (file, line);
+    send_loc_info(file, line);
 }
 
-void _ck_assert_failed (const char *file,
-                   int line, const char *expr, ...)
+void _ck_assert_failed(const char *file, int line, const char *expr, ...)
 {
-  const char *msg;
-  va_list ap;
-  char buf[BUFSIZ];
+    const char *msg;
+    va_list ap;
+    char buf[BUFSIZ];
 
-  send_loc_info (file, line);
+    send_loc_info(file, line);
 
-  va_start(ap,expr);
-  msg = (const char*)va_arg(ap, char *);
-  if (msg == NULL)
-    msg = expr;
-  vsnprintf(buf, BUFSIZ, msg, ap);
-  va_end(ap);
-  send_failure_info (buf);
-  if (cur_fork_status() == CK_FORK) {
-  #if defined(HAVE_FORK) && HAVE_FORK==1
-    exit(1);
-  #endif /* HAVE_FORK */
-  } else {
-    longjmp(error_jmp_buffer, 1);
-  }
+    va_start(ap, expr);
+    msg = (const char *)va_arg(ap, char *);
+
+    if(msg == NULL)
+        msg = expr;
+    vsnprintf(buf, BUFSIZ, msg, ap);
+    va_end(ap);
+    send_failure_info(buf);
+    if(cur_fork_status() == CK_FORK)
+    {
+#if defined(HAVE_FORK) && HAVE_FORK==1
+        exit(1);
+#endif /* HAVE_FORK */
+    }
+    else
+    {
+        longjmp(error_jmp_buffer, 1);
+    }
 }
 
-SRunner *srunner_create (Suite *s)
+SRunner *srunner_create(Suite * s)
 {
-  SRunner *sr = emalloc (sizeof(SRunner)); /* freed in srunner_free */
-  sr->slst = check_list_create();
-  if (s != NULL)
-    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();
-  sr->log_fname = NULL;
-  sr->xml_fname = NULL;
-  sr->tap_fname = NULL;
-  sr->loglst = NULL;
+    SRunner *sr = emalloc(sizeof(SRunner));     /* freed in srunner_free */
+
+    sr->slst = check_list_create();
+    if(s != NULL)
+        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();
+    sr->log_fname = NULL;
+    sr->xml_fname = NULL;
+    sr->tap_fname = NULL;
+    sr->loglst = NULL;
 
 #if defined(HAVE_FORK)
-  sr->fstat = CK_FORK_GETENV;
+    sr->fstat = CK_FORK_GETENV;
 #else
-  /*
-   * Overriding the default of running tests in fork mode,
-   * as this system does not have fork()
-   */
-  sr->fstat = CK_NOFORK;
+    /*
+     * Overriding the default of running tests in fork mode,
+     * as this system does not have fork()
+     */
+    sr->fstat = CK_NOFORK;
 #endif /* HAVE_FORK */
 
-  return sr;
+    return sr;
 }
 
-void srunner_add_suite (SRunner *sr, Suite *s)
+void srunner_add_suite(SRunner * sr, Suite * s)
 {
-  if (s == NULL)
-    return;
+    if(s == NULL)
+        return;
 
-  check_list_add_end(sr->slst, s);
+    check_list_add_end(sr->slst, s);
 }
 
-void srunner_free (SRunner *sr)
+void srunner_free(SRunner * sr)
 {
-  List *l;
-  TestResult *tr;
-  if (sr == NULL)
-    return;
-  
-  free (sr->stats);
-  l = sr->slst;
-  for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) {
-    suite_free(check_list_val(l));
-  }
-  check_list_free(sr->slst);
+    List *l;
+    TestResult *tr;
 
-  l = sr->resultlst;
-  for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) {
-    tr = check_list_val(l);
-    tr_free(tr);
-  }
-  check_list_free (sr->resultlst);
+    if(sr == NULL)
+        return;
 
-  free (sr);
+    free(sr->stats);
+    l = sr->slst;
+    for(check_list_front(l); !check_list_at_end(l); check_list_advance(l))
+    {
+        suite_free(check_list_val(l));
+    }
+    check_list_free(sr->slst);
+
+    l = sr->resultlst;
+    for(check_list_front(l); !check_list_at_end(l); check_list_advance(l))
+    {
+        tr = check_list_val(l);
+        tr_free(tr);
+    }
+    check_list_free(sr->resultlst);
+
+    free(sr);
 }
 
-int srunner_ntests_failed (SRunner *sr)
+int srunner_ntests_failed(SRunner * sr)
 {
-  return sr->stats->n_failed + sr->stats->n_errors;
+    return sr->stats->n_failed + sr->stats->n_errors;
 }
 
-int srunner_ntests_run (SRunner *sr)
+int srunner_ntests_run(SRunner * sr)
 {
-  return sr->stats->n_checked;
+    return sr->stats->n_checked;
 }
 
-TestResult **srunner_failures (SRunner *sr)
+TestResult **srunner_failures(SRunner * sr)
 {
-  int i = 0;
-  TestResult **trarray;
-  List *rlst;
-  trarray = malloc (sizeof(trarray[0]) * srunner_ntests_failed (sr));
+    int i = 0;
+    TestResult **trarray;
+    List *rlst;
+
+    trarray = malloc(sizeof(trarray[0]) * srunner_ntests_failed(sr));
+
+    rlst = sr->resultlst;
+    for(check_list_front(rlst); !check_list_at_end(rlst);
+        check_list_advance(rlst))
+    {
+        TestResult *tr = check_list_val(rlst);
 
-  rlst = sr->resultlst;
-  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;
-    
-  }
-  return trarray;
+        if(non_pass(tr->rtype))
+            trarray[i++] = tr;
+
+    }
+    return trarray;
 }
 
-TestResult **srunner_results (SRunner *sr)
+TestResult **srunner_results(SRunner * sr)
 {
-  int i = 0;
-  TestResult **trarray;
-  List *rlst;
+    int i = 0;
+    TestResult **trarray;
+    List *rlst;
 
-  trarray = malloc (sizeof(trarray[0]) * srunner_ntests_run (sr));
+    trarray = malloc(sizeof(trarray[0]) * srunner_ntests_run(sr));
 
-  rlst = sr->resultlst;
-  for (check_list_front(rlst); !check_list_at_end(rlst); check_list_advance(rlst)) {
-    trarray[i++] = check_list_val(rlst);
-  }
-  return trarray;
+    rlst = sr->resultlst;
+    for(check_list_front(rlst); !check_list_at_end(rlst);
+        check_list_advance(rlst))
+    {
+        trarray[i++] = check_list_val(rlst);
+    }
+    return trarray;
 }
 
-static int non_pass (int val)
+static int non_pass(int val)
 {
-  return val != CK_PASS;
+    return val != CK_PASS;
 }
 
 TestResult *tr_create(void)
 {
-  TestResult *tr;
+    TestResult *tr;
 
-  tr = emalloc (sizeof(TestResult));
-  tr_init (tr);
-  return tr;
+    tr = emalloc(sizeof(TestResult));
+    tr_init(tr);
+    return tr;
 }
 
-static void tr_init (TestResult *tr)
+static void tr_init(TestResult * tr)
 {
-  tr->ctx = CK_CTX_INVALID;
-  tr->line = -1;
-  tr->rtype = CK_TEST_RESULT_INVALID;
-  tr->msg = NULL;
-  tr->file = NULL;
-  tr->tcname = NULL;
-  tr->tname = NULL;
-  tr->duration = -1;
+    tr->ctx = CK_CTX_INVALID;
+    tr->line = -1;
+    tr->rtype = CK_TEST_RESULT_INVALID;
+    tr->msg = NULL;
+    tr->file = NULL;
+    tr->tcname = NULL;
+    tr->tname = NULL;
+    tr->duration = -1;
 }
 
-void tr_free(TestResult *tr)
+void tr_free(TestResult * tr)
 {
-  free(tr->file);
-  free(tr->msg);
-  free(tr);
+    free(tr->file);
+    free(tr->msg);
+    free(tr);
 }
 
 
-const char *tr_msg (TestResult *tr)
+const char *tr_msg(TestResult * tr)
 {
-  return tr->msg;
+    return tr->msg;
 }
 
-int tr_lno (TestResult *tr)
+int tr_lno(TestResult * tr)
 {
-  return tr->line;
+    return tr->line;
 }
 
-const char *tr_lfile (TestResult *tr)
+const char *tr_lfile(TestResult * tr)
 {
-  return tr->file;
+    return tr->file;
 }
 
-int tr_rtype (TestResult *tr)
+int tr_rtype(TestResult * tr)
 {
-  return tr->rtype;
+    return tr->rtype;
 }
 
-enum ck_result_ctx tr_ctx (TestResult *tr)
+enum ck_result_ctx tr_ctx(TestResult * tr)
 {
-  return tr->ctx;
+    return tr->ctx;
 }
 
-const char *tr_tcname (TestResult *tr)
+const char *tr_tcname(TestResult * tr)
 {
-  return tr->tcname;
+    return tr->tcname;
 }
 
 static int _fstat = CK_FORK;
 
-void set_fork_status (enum fork_status fstat)
+void set_fork_status(enum fork_status fstat)
 {
-  if (fstat == CK_FORK || fstat == CK_NOFORK || fstat == CK_FORK_GETENV)
-    _fstat = fstat;
-  else
-    eprintf ("Bad status in set_fork_status", __FILE__, __LINE__);
+    if(fstat == CK_FORK || fstat == CK_NOFORK || fstat == CK_FORK_GETENV)
+        _fstat = fstat;
+    else
+        eprintf("Bad status in set_fork_status", __FILE__, __LINE__);
 }
 
-enum fork_status cur_fork_status (void)
+enum fork_status cur_fork_status(void)
 {
-  return _fstat;
+    return _fstat;
 }
 
 /**
@@ -474,10 +520,10 @@ enum fork_status cur_fork_status (void)
  */
 clockid_t check_get_clockid()
 {
-       static clockid_t clockid = -1;
+    static clockid_t clockid = -1;
 
-       if(clockid == -1)
-       {
+    if(clockid == -1)
+    {
 /*
  * Only check if we have librt available. Otherwise, the clockid
  * will be ignored anyway, as the clock_gettime() and
@@ -486,20 +532,21 @@ clockid_t check_get_clockid()
  * will result in an assert(0).
  */
 #ifdef HAVE_LIBRT
-               timer_t timerid;
-               if(timer_create(CLOCK_MONOTONIC, NULL, &timerid) == 0)
-               {
-                       timer_delete(timerid);
-                       clockid = CLOCK_MONOTONIC;
-               }
-               else
-               {
-                       clockid = CLOCK_REALTIME;
-               }
+        timer_t timerid;
+
+        if(timer_create(CLOCK_MONOTONIC, NULL, &timerid) == 0)
+        {
+            timer_delete(timerid);
+            clockid = CLOCK_MONOTONIC;
+        }
+        else
+        {
+            clockid = CLOCK_REALTIME;
+        }
 #else
-       clockid = CLOCK_MONOTONIC;
+        clockid = CLOCK_MONOTONIC;
 #endif
-       }
+    }
 
-       return clockid;
+    return clockid;
 }
index 1a0e08d7c28b200db4c59870d308367d57a537ae..48130dfc7f8f86cd1c547ad9f5c527bf991ff84f 100644 (file)
@@ -102,7 +102,7 @@ CK_CPPSTART
 #if GCC_VERSION_AT_LEAST(2,95)
 #define CK_ATTRIBUTE_UNUSED __attribute__ ((unused))
 #else
-#define CK_ATTRIBUTE_UNUSED              
+#define CK_ATTRIBUTE_UNUSED
 #endif /* GCC 2.95 */
 
 #if GCC_VERSION_AT_LEAST(2,5)
@@ -146,29 +146,29 @@ CK_DLL_EXP extern int CK_EXPORT check_micro_version;
    with tcase_free.  For the moment, test cases can only be run
    through a suite
 */
-typedef struct TCase TCase; 
+typedef struct TCase TCase;
 
 /* type for a test function */
 typedef void (*TFun) (int);
 
 /* type for a setup/teardown function */
 typedef void (*SFun) (void);
+
 /* Opaque type for a test suite */
 typedef struct Suite Suite;
+
 /* Creates a test suite with the given name */
-CK_DLL_EXP Suite * CK_EXPORT suite_create (const char *name);
+CK_DLL_EXP Suite *CK_EXPORT suite_create(const char *name);
 
 /* Determines whether a given test suite contains a case named after a
    given string.  */
-CK_DLL_EXP int CK_EXPORT suite_tcase (Suite *s, const char *tcname);
+CK_DLL_EXP int CK_EXPORT suite_tcase(Suite * s, const char *tcname);
 
 /* Add a test case to a suite */
-CK_DLL_EXP void CK_EXPORT suite_add_tcase (Suite *s, TCase *tc);
+CK_DLL_EXP void CK_EXPORT suite_add_tcase(Suite * s, TCase * tc);
 
 /* Create a test case */
-CK_DLL_EXP TCase * CK_EXPORT tcase_create (const char *name);
+CK_DLL_EXP TCase *CK_EXPORT tcase_create(const char *name);
 
 /* Add a test function to a test case (macro version) */
 #define tcase_add_test(tc,tf) tcase_add_test_raise_signal(tc,tf,0)
@@ -189,7 +189,7 @@ CK_DLL_EXP TCase * CK_EXPORT tcase_create (const char *name);
  */
 #define tcase_add_loop_test(tc,tf,s,e) \
   _tcase_add_test((tc),(tf),"" # tf "",0,0,(s),(e))
+
 /* Signal version of loop test.  
    FIXME: add a test case; this is untested as part of Check's tests.
  */
@@ -203,7 +203,10 @@ CK_DLL_EXP TCase * CK_EXPORT tcase_create (const char *name);
 /* Add a test function to a test case
   (function version -- use this when the macro won't work
 */
-CK_DLL_EXP void CK_EXPORT _tcase_add_test (TCase *tc, TFun tf, const char *fname, int _signal, int allowed_exit_value, int start, int end);
+CK_DLL_EXP void CK_EXPORT _tcase_add_test(TCase * tc, TFun tf,
+                                          const char *fname, int _signal,
+                                          int allowed_exit_value, int start,
+                                          int end);
 
 /* Add unchecked fixture setup/teardown functions to a test case
 
@@ -217,7 +220,8 @@ CK_DLL_EXP void CK_EXPORT _tcase_add_test (TCase *tc, TFun tf, const char *fname
    lead to different unit test behavior IF unit tests change data
    setup by the fixture functions.
 */
-CK_DLL_EXP void CK_EXPORT tcase_add_unchecked_fixture (TCase *tc, SFun setup, SFun teardown);
+CK_DLL_EXP void CK_EXPORT tcase_add_unchecked_fixture(TCase * tc, SFun setup,
+                                                      SFun teardown);
 
 /* Add fixture setup/teardown functions to a test case
 
@@ -232,22 +236,24 @@ CK_DLL_EXP void CK_EXPORT tcase_add_unchecked_fixture (TCase *tc, SFun setup, SF
    However, since fixture functions are run before and after each unit
    test, they should not be expensive code.
 
-*/ 
-CK_DLL_EXP void CK_EXPORT tcase_add_checked_fixture (TCase *tc, SFun setup, SFun teardown);
+*/
+CK_DLL_EXP void CK_EXPORT tcase_add_checked_fixture(TCase * tc, SFun setup,
+                                                    SFun teardown);
 
 /* Set the timeout for all tests in a test case. A test that lasts longer
    than the timeout (in seconds) will be killed and thus fail with an error.
    The timeout can also be set globaly with the environment variable
    CK_DEFAULT_TIMEOUT, the specific setting always takes precedence.
 */
-CK_DLL_EXP void CK_EXPORT tcase_set_timeout (TCase *tc, double timeout);
+CK_DLL_EXP void CK_EXPORT tcase_set_timeout(TCase * tc, double timeout);
+
 /* Internal function to mark the start of a test function */
-CK_DLL_EXP void CK_EXPORT tcase_fn_start (const char *fname, const char *file, int line);
+CK_DLL_EXP void CK_EXPORT tcase_fn_start(const char *fname, const char *file,
+                                         int line);
 
 /* Start a unit test with START_TEST(unit_name), end with END_TEST
    One must use braces within a START_/END_ pair to declare new variables
-*/ 
+*/
 #define START_TEST(__testname)\
 static void __testname (int _i CK_ATTRIBUTE_UNUSED)\
 {\
@@ -283,9 +289,12 @@ static void __testname (int _i CK_ATTRIBUTE_UNUSED)\
  * which are not valid, as longjmp() is like a return.
  */
 #if @HAVE_FORK@
-CK_DLL_EXP void CK_EXPORT _ck_assert_failed (const char *file, int line, const char *expr, ...) CK_ATTRIBUTE_NORETURN;
+CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
+                                            const char *expr,
+                                            ...) CK_ATTRIBUTE_NORETURN;
 #else
-CK_DLL_EXP void CK_EXPORT _ck_assert_failed (const char *file, int line, const char *expr, ...);
+CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
+                                            const char *expr, ...);
 #endif
 
 /* New check fail API. */
@@ -362,28 +371,30 @@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed (const char *file, int line, const c
 #define mark_point() _mark_point(__FILE__,__LINE__)
 
 /* Non macro version of #mark_point */
-CK_DLL_EXP void CK_EXPORT _mark_point (const char *file, int line);
+CK_DLL_EXP void CK_EXPORT _mark_point(const char *file, int line);
 
 /* Result of a test */
-enum test_result {
-  CK_TEST_RESULT_INVALID, /* Default value; should not encounter this */
-  CK_PASS, /* Test passed*/
-  CK_FAILURE, /* Test completed but failed */
-  CK_ERROR /* Test failed to complete
-             (unexpected signal or non-zero early exit) */ 
+enum test_result
+{
+    CK_TEST_RESULT_INVALID,     /* Default value; should not encounter this */
+    CK_PASS,                    /* Test passed */
+    CK_FAILURE,                 /* Test completed but failed */
+    CK_ERROR                    /* Test failed to complete
+                                   (unexpected signal or non-zero early exit) */
 };
 
 /* Specifies the how much output an SRunner should produce */
-enum print_output {
-  CK_SILENT, /* No output */
-  CK_MINIMAL, /* Only summary output */
-  CK_NORMAL, /* All failed tests */
-  CK_VERBOSE, /* All tests */
-  CK_ENV, /* Look at environment var */
+enum print_output
+{
+    CK_SILENT,                  /* No output */
+    CK_MINIMAL,                 /* Only summary output */
+    CK_NORMAL,                  /* All failed tests */
+    CK_VERBOSE,                 /* All tests */
+    CK_ENV,                     /* Look at environment var */
 #if @ENABLE_SUBUNIT@
-  CK_SUBUNIT, /* Run as a subunit child process */
+    CK_SUBUNIT,                 /* Run as a subunit child process */
 #endif
-  CK_LAST
+    CK_LAST
 };
 
 /* Holds state for a running of a test suite */
@@ -393,55 +404,64 @@ typedef struct SRunner SRunner;
 typedef struct TestResult TestResult;
 
 /* accessors for tr fields */
-enum ck_result_ctx {
-  CK_CTX_INVALID, /* Default value; should not encounter this */
-  CK_CTX_SETUP,
-  CK_CTX_TEST,
-  CK_CTX_TEARDOWN
+enum ck_result_ctx
+{
+    CK_CTX_INVALID,             /* Default value; should not encounter this */
+    CK_CTX_SETUP,
+    CK_CTX_TEST,
+    CK_CTX_TEARDOWN
 };
 
 /* Type of result */
-CK_DLL_EXP int CK_EXPORT tr_rtype (TestResult *tr);
-/* Context in which the result occurred */ 
-CK_DLL_EXP enum ck_result_ctx CK_EXPORT tr_ctx (TestResult *tr); 
+CK_DLL_EXP int CK_EXPORT tr_rtype(TestResult * tr);
+
+/* Context in which the result occurred */
+CK_DLL_EXP enum ck_result_ctx CK_EXPORT tr_ctx(TestResult * tr);
+
 /* Failure message */
-CK_DLL_EXP const char * CK_EXPORT tr_msg (TestResult *tr);
+CK_DLL_EXP const char *CK_EXPORT tr_msg(TestResult * tr);
+
 /* Line number at which failure occured */
-CK_DLL_EXP int CK_EXPORT tr_lno (TestResult *tr);
+CK_DLL_EXP int CK_EXPORT tr_lno(TestResult * tr);
+
 /* File name at which failure occured */
-CK_DLL_EXP const char * CK_EXPORT tr_lfile (TestResult *tr);
+CK_DLL_EXP const char *CK_EXPORT tr_lfile(TestResult * tr);
+
 /* Test case in which unit test was run */
-CK_DLL_EXP const char * CK_EXPORT tr_tcname (TestResult *tr);
+CK_DLL_EXP const char *CK_EXPORT tr_tcname(TestResult * tr);
 
 /* Creates an SRunner for the given suite */
-CK_DLL_EXP SRunner * CK_EXPORT srunner_create (Suite *s);
+CK_DLL_EXP SRunner *CK_EXPORT srunner_create(Suite * s);
 
 /* Adds a Suite to an SRunner */
-CK_DLL_EXP void CK_EXPORT srunner_add_suite (SRunner *sr, Suite *s);
+CK_DLL_EXP void CK_EXPORT srunner_add_suite(SRunner * sr, Suite * s);
 
 /* Frees an SRunner, all suites added to it and all contained test cases */
-CK_DLL_EXP void CK_EXPORT srunner_free (SRunner *sr);
+CK_DLL_EXP void CK_EXPORT srunner_free(SRunner * sr);
+
 
 /* Test running */
 
 /* Runs an SRunner, printing results as specified (see enum print_output) */
-CK_DLL_EXP void CK_EXPORT srunner_run_all (SRunner *sr, enum print_output print_mode);
+CK_DLL_EXP void CK_EXPORT srunner_run_all(SRunner * sr,
+                                          enum print_output print_mode);
 
 /* Runs an SRunner specifying test suite and test case by name,
    printing results as specified (see enum print_output).  A NULL
    value means "any test suite" or "any test case".  */
-CK_DLL_EXP void CK_EXPORT srunner_run (SRunner *sr, const char *sname, const char *tcname, enum print_output print_mode);
+CK_DLL_EXP void CK_EXPORT srunner_run(SRunner * sr, const char *sname,
+                                      const char *tcname,
+                                      enum print_output print_mode);
+
 
 /* Next functions are valid only after the suite has been
    completely run, of course */
 
 /* Number of failed tests in a run suite. Includes failures + errors */
-CK_DLL_EXP int CK_EXPORT srunner_ntests_failed (SRunner *sr);
+CK_DLL_EXP int CK_EXPORT srunner_ntests_failed(SRunner * sr);
 
 /* Total number of tests run in a run suite */
-CK_DLL_EXP int CK_EXPORT srunner_ntests_run (SRunner *sr);
+CK_DLL_EXP int CK_EXPORT srunner_ntests_run(SRunner * sr);
 
 /* Return an array of results for all failures
   
@@ -449,7 +469,7 @@ CK_DLL_EXP int CK_EXPORT srunner_ntests_run (SRunner *sr);
    the array is malloc'ed and must be freed, but individual TestResults
    must not
 */
-CK_DLL_EXP TestResult ** CK_EXPORT srunner_failures (SRunner *sr);
+CK_DLL_EXP TestResult **CK_EXPORT srunner_failures(SRunner * sr);
 
 /* Return an array of results for all run tests
 
@@ -458,29 +478,30 @@ CK_DLL_EXP TestResult ** CK_EXPORT srunner_failures (SRunner *sr);
 
    Memory is malloc'ed and must be freed, but individual TestResults
    must not
-*/  
-CK_DLL_EXP TestResult ** CK_EXPORT srunner_results (SRunner *sr);
+*/
+CK_DLL_EXP TestResult **CK_EXPORT srunner_results(SRunner * sr);
+
 
 /* Printing */
 
 /* Print the results contained in an SRunner */
-CK_DLL_EXP void CK_EXPORT srunner_print (SRunner *sr, enum print_output print_mode);
-  
-  
+CK_DLL_EXP void CK_EXPORT srunner_print(SRunner * sr,
+                                        enum print_output print_mode);
+
+
 /* Set a log file to which to write during test running.
 
   Log file setting is an initialize only operation -- it should be
   done immediatly after SRunner creation, and the log file can't be
   changed after being set.
 */
-CK_DLL_EXP void CK_EXPORT srunner_set_log (SRunner *sr, const char *fname);
+CK_DLL_EXP void CK_EXPORT srunner_set_log(SRunner * sr, const char *fname);
 
 /* Does the SRunner have a log file? */
-CK_DLL_EXP int CK_EXPORT srunner_has_log (SRunner *sr);
+CK_DLL_EXP int CK_EXPORT srunner_has_log(SRunner * sr);
 
 /* Return the name of the log file, or NULL if none */
-CK_DLL_EXP const char * CK_EXPORT srunner_log_fname (SRunner *sr);
+CK_DLL_EXP const char *CK_EXPORT srunner_log_fname(SRunner * sr);
 
 /* Set a xml file to which to write during test running.
 
@@ -488,13 +509,13 @@ CK_DLL_EXP const char * CK_EXPORT srunner_log_fname (SRunner *sr);
   done immediatly after SRunner creation, and the XML file can't be
   changed after being set.
 */
-CK_DLL_EXP void CK_EXPORT srunner_set_xml (SRunner *sr, const char *fname);
+CK_DLL_EXP void CK_EXPORT srunner_set_xml(SRunner * sr, const char *fname);
 
 /* Does the SRunner have an XML log file? */
-CK_DLL_EXP int CK_EXPORT srunner_has_xml (SRunner *sr);
+CK_DLL_EXP int CK_EXPORT srunner_has_xml(SRunner * sr);
 
 /* Return the name of the XML file, or NULL if none */
-CK_DLL_EXP const char * CK_EXPORT srunner_xml_fname (SRunner *sr);
+CK_DLL_EXP const char *CK_EXPORT srunner_xml_fname(SRunner * sr);
 
 /* Set a tap file to which to write during test running.
 
@@ -502,28 +523,30 @@ CK_DLL_EXP const char * CK_EXPORT srunner_xml_fname (SRunner *sr);
   done immediatly after SRunner creation, and the log file can't be
   changed after being set.
 */
-CK_DLL_EXP void CK_EXPORT srunner_set_tap (SRunner *sr, const char *fname);
+CK_DLL_EXP void CK_EXPORT srunner_set_tap(SRunner * sr, const char *fname);
 
 /* Does the SRunner have a tap file? */
-CK_DLL_EXP int CK_EXPORT srunner_has_tap (SRunner *sr);
+CK_DLL_EXP int CK_EXPORT srunner_has_tap(SRunner * sr);
 
 /* Return the name of the tap file, or NULL if none */
-CK_DLL_EXP const char * CK_EXPORT srunner_tap_fname (SRunner *sr);
+CK_DLL_EXP const char *CK_EXPORT srunner_tap_fname(SRunner * sr);
 
 
 /* Control forking */
-enum fork_status {
-  CK_FORK_GETENV, /* look in the environment for CK_FORK */
-  CK_FORK,        /* call fork to run tests */
-  CK_NOFORK       /* don't call fork */
+enum fork_status
+{
+    CK_FORK_GETENV,             /* look in the environment for CK_FORK */
+    CK_FORK,                    /* call fork to run tests */
+    CK_NOFORK                   /* don't call fork */
 };
+
 /* Get the current fork status */
-CK_DLL_EXP enum fork_status CK_EXPORT srunner_fork_status (SRunner *sr);
+CK_DLL_EXP enum fork_status CK_EXPORT srunner_fork_status(SRunner * sr);
 
 /* Set the current fork status */
-CK_DLL_EXP void CK_EXPORT srunner_set_fork_status (SRunner *sr, enum fork_status fstat); 
-  
+CK_DLL_EXP void CK_EXPORT srunner_set_fork_status(SRunner * sr,
+                                                  enum fork_status fstat);
+
 /* Fork in a test and make sure messaging and tests work. */
 CK_DLL_EXP pid_t CK_EXPORT check_fork(void);
 
index 588f616ac0925fdf067b8572c45b13e4f7edec0f..2c186f88b610da2ed1ce9790777a291d6edb7cf5 100644 (file)
@@ -36,38 +36,41 @@ jmp_buf error_jmp_buffer;
 
 
 /* FIXME: including a colon at the end is a bad way to indicate an error */
-void eprintf (const char *fmt, const char *file, int line, ...)
+void eprintf(const char *fmt, const char *file, int line, ...)
 {
-  va_list args;
-  fflush(stderr);
+    va_list args;
 
-  fprintf(stderr,"%s:%d: ",file,line);
-  va_start(args, line);
-  vfprintf(stderr, fmt, args);
-  va_end(args);
+    fflush(stderr);
 
-  /*include system error information if format ends in colon */
-  if (fmt[0] != '\0' && fmt[strlen(fmt)-1] == ':')
-    fprintf(stderr, " %s", strerror(errno));
-  fprintf(stderr, "\n");
+    fprintf(stderr, "%s:%d: ", file, line);
+    va_start(args, line);
+    vfprintf(stderr, fmt, args);
+    va_end(args);
 
-  exit(2);
+    /*include system error information if format ends in colon */
+    if(fmt[0] != '\0' && fmt[strlen(fmt) - 1] == ':')
+        fprintf(stderr, " %s", strerror(errno));
+    fprintf(stderr, "\n");
+
+    exit(2);
 }
 
-void *emalloc (size_t n)
+void *emalloc(size_t n)
 {
-  void *p;
-  p = malloc(n);
-  if (p == NULL)
-    eprintf("malloc of %u bytes failed:", __FILE__, __LINE__ - 2, n);
-  return p;
+    void *p;
+
+    p = malloc(n);
+    if(p == NULL)
+        eprintf("malloc of %u bytes failed:", __FILE__, __LINE__ - 2, n);
+    return p;
 }
 
-void *erealloc (void * ptr, size_t n)
+void *erealloc(void *ptr, size_t n)
 {
-  void *p;
-  p = realloc (ptr, n);
-  if (p == NULL)
-    eprintf("realloc of %u bytes failed:", __FILE__, __LINE__ - 2, n);
-  return p;
+    void *p;
+
+    p = realloc(ptr, n);
+    if(p == NULL)
+        eprintf("realloc of %u bytes failed:", __FILE__, __LINE__ - 2, n);
+    return p;
 }
index 8d1f6a381771dcce7152a21e168e9a01766cf0d7..33271b62683f4f1aacf3d18c3b332b25366e8179 100644 (file)
@@ -30,9 +30,10 @@ extern jmp_buf error_jmp_buffer;
 
 /* Print error message and die
    If fmt ends in colon, include system error information */
-void eprintf (const char *fmt, const char *file, int line,...) CK_ATTRIBUTE_NORETURN;
+void eprintf(const char *fmt, const char *file, int line,
+             ...) CK_ATTRIBUTE_NORETURN;
 /* malloc or die */
 void *emalloc(size_t n);
 void *erealloc(void *, size_t n);
 
-#endif /*ERROR_H*/
+#endif /*ERROR_H */
index 2f7d987b88688b7e7cd379c2b9d2a913f59f212f..d668eb2f018a545b35da9ae87e24f03fa61782a3 100644 (file)
   ( (((end).tv_sec - (begin).tv_sec) * US_PER_SEC) + \
     ((end).tv_nsec/1000) - ((begin).tv_nsec/1000) )
 
-typedef struct TF {
-  TFun fn;
-  int loop_start;
-  int loop_end;
-  const char *name;
-  int signal;
-  signed char allowed_exit_value;
+typedef struct TF
+{
+    TFun fn;
+    int loop_start;
+    int loop_end;
+    const char *name;
+    int signal;
+    signed char allowed_exit_value;
 } TF;
 
-struct Suite {
-  const char *name;
-  List *tclst; /* List of test cases */
+struct Suite
+{
+    const char *name;
+    List *tclst;                /* List of test cases */
 };
 
-typedef struct Fixture 
+typedef struct Fixture
 {
-  int ischecked;
-  SFun fun;
+    int ischecked;
+    SFun fun;
 } Fixture;
 
-struct TCase {
-  const char *name;
-  struct timespec timeout;
-  List *tflst; /* list of test functions */
-  List *unch_sflst;
-  List *unch_tflst;
-  List *ch_sflst;
-  List *ch_tflst;
+struct TCase
+{
+    const char *name;
+    struct timespec timeout;
+    List *tflst;                /* list of test functions */
+    List *unch_sflst;
+    List *unch_tflst;
+    List *ch_sflst;
+    List *ch_tflst;
 };
 
-typedef struct TestStats {
-  int n_checked;
-  int n_failed;
-  int n_errors;
+typedef struct TestStats
+{
+    int n_checked;
+    int n_failed;
+    int n_errors;
 } TestStats;
 
-struct TestResult {
-  enum test_result rtype;     /* Type of result */
-  enum ck_result_ctx ctx;     /* When the result occurred */
-  char *file;    /* File where the test occured */
-  int line;      /* Line number where the test occurred */
-  int iter;      /* The iteration value for looping tests */
-  int duration;  /* duration of this test in microseconds */
-  const char *tcname;  /* Test case that generated the result */
-  const char *tname;  /* Test that generated the result */
-  char *msg;     /* Failure message */
+struct TestResult
+{
+    enum test_result rtype;     /* Type of result */
+    enum ck_result_ctx ctx;     /* When the result occurred */
+    char *file;                 /* File where the test occured */
+    int line;                   /* Line number where the test occurred */
+    int iter;                   /* The iteration value for looping tests */
+    int duration;               /* duration of this test in microseconds */
+    const char *tcname;         /* Test case that generated the result */
+    const char *tname;          /* Test that generated the result */
+    char *msg;                  /* Failure message */
 };
 
 TestResult *tr_create(void);
-void tr_reset(TestResult *tr);
-void tr_free(TestResult *tr);
-
-enum cl_event {
-  CLINITLOG_SR, /* Initialize log file */
-  CLENDLOG_SR,  /* Tests are complete */
-  CLSTART_SR,   /* Suite runner start */
-  CLSTART_S,    /* Suite start */
-  CLEND_SR,     /* Suite runner end */
-  CLEND_S,      /* Suite end */
-  CLSTART_T,    /* A test case is about to run */
-  CLEND_T       /* Test case end */
+void tr_reset(TestResult * tr);
+void tr_free(TestResult * tr);
+
+enum cl_event
+{
+    CLINITLOG_SR,               /* Initialize log file */
+    CLENDLOG_SR,                /* Tests are complete */
+    CLSTART_SR,                 /* Suite runner start */
+    CLSTART_S,                  /* Suite start */
+    CLEND_SR,                   /* Suite runner end */
+    CLEND_S,                    /* Suite end */
+    CLSTART_T,                  /* A test case is about to run */
+    CLEND_T                     /* Test case end */
 };
 
-typedef void (*LFun) (SRunner *, FILE*, enum print_output,
-                     void *, enum cl_event);
+typedef void (*LFun) (SRunner *, FILE *, enum print_output,
+                      void *, enum cl_event);
 
-typedef struct Log {
-  FILE *lfile;
-  LFun lfun;
-  int close;
-  enum print_output mode;
+typedef struct Log
+{
+    FILE *lfile;
+    LFun lfun;
+    int close;
+    enum print_output mode;
 } Log;
 
-struct SRunner {
-  List *slst; /* List of Suite objects */
-  TestStats *stats; /* Run statistics */
-  List *resultlst; /* List of unit test results */
-  const char *log_fname; /* name of log file */
-  const char *xml_fname; /* name of xml output file */
-  const char *tap_fname; /* name of tap output file */
-  List *loglst; /* list of Log objects */
-  enum fork_status fstat; /* controls if suites are forked or not
-                            NOTE: Don't use this value directly,
-                            instead use srunner_fork_status */
+struct SRunner
+{
+    List *slst;                 /* List of Suite objects */
+    TestStats *stats;           /* Run statistics */
+    List *resultlst;            /* List of unit test results */
+    const char *log_fname;      /* name of log file */
+    const char *xml_fname;      /* name of xml output file */
+    const char *tap_fname;      /* name of tap output file */
+    List *loglst;               /* list of Log objects */
+    enum fork_status fstat;     /* controls if suites are forked or not
+                                   NOTE: Don't use this value directly,
+                                   instead use srunner_fork_status */
 };
 
 
 void set_fork_status(enum fork_status fstat);
-enum fork_status cur_fork_status (void);
+enum fork_status cur_fork_status(void);
 
 clockid_t check_get_clockid(void);
 
index 7f58cb19632e9c8fe7ae52aec55eb9e1ae6d43d4..54836833903963f2cc92cbe44f9c1bd30c4abf6d 100644 (file)
 #include "check_error.h"
 
 
-enum {
-  LINIT = 1,
-  LGROW = 2
+enum
+{
+    LINIT = 1,
+    LGROW = 2
 };
 
-struct List {
-  unsigned int n_elts;
-  unsigned int max_elts;
-  int current; /* pointer to the current node */
-  int last; /* pointer to the node before END */
-  void **data;
+struct List
+{
+    unsigned int n_elts;
+    unsigned int max_elts;
+    int current;                /* pointer to the current node */
+    int last;                   /* pointer to the node before END */
+    void **data;
 };
 
-static void maybe_grow (List *lp)
+static void maybe_grow(List * lp)
 {
-  if (lp->n_elts >= lp->max_elts) {
-    lp->max_elts *= LGROW;
-    lp->data = erealloc (lp->data, lp->max_elts * sizeof(lp->data[0]));
-  }
+    if(lp->n_elts >= lp->max_elts)
+    {
+        lp->max_elts *= LGROW;
+        lp->data = erealloc(lp->data, lp->max_elts * sizeof(lp->data[0]));
+    }
 }
 
-List *check_list_create (void)
+List *check_list_create(void)
 {
-  List *lp;
-  lp = emalloc (sizeof(List));
-  lp->n_elts = 0;
-  lp->max_elts = LINIT;
-  lp->data = emalloc(sizeof(lp->data[0]) * LINIT);
-  lp->current = lp->last = -1;
-  return lp;
+    List *lp;
+
+    lp = emalloc(sizeof(List));
+    lp->n_elts = 0;
+    lp->max_elts = LINIT;
+    lp->data = emalloc(sizeof(lp->data[0]) * LINIT);
+    lp->current = lp->last = -1;
+    return lp;
 }
 
-void check_list_add_front (List *lp, void *val)
+void check_list_add_front(List * lp, void *val)
 {
-  if (lp == NULL)
-    return;
-  maybe_grow(lp);
-  memmove(lp->data + 1, lp->data, lp->n_elts * sizeof lp->data[0]);
-  lp->last++;
-  lp->n_elts++;
-  lp->current = 0;
-  lp->data[lp->current] = val;
+    if(lp == NULL)
+        return;
+    maybe_grow(lp);
+    memmove(lp->data + 1, lp->data, lp->n_elts * sizeof lp->data[0]);
+    lp->last++;
+    lp->n_elts++;
+    lp->current = 0;
+    lp->data[lp->current] = val;
 }
 
-void check_list_add_end (List *lp, void *val)
+void check_list_add_end(List * lp, void *val)
 {
-  if (lp == NULL)
-    return;
-  maybe_grow(lp);
-  lp->last++;
-  lp->n_elts++;
-  lp->current = lp->last;
-  lp->data[lp->current] = val;
+    if(lp == NULL)
+        return;
+    maybe_grow(lp);
+    lp->last++;
+    lp->n_elts++;
+    lp->current = lp->last;
+    lp->data[lp->current] = val;
 }
 
-int check_list_at_end (List *lp)
+int check_list_at_end(List * lp)
 {
-  if (lp->current == -1)
-    return 1;
-  else
-    return (lp->current > lp->last);
+    if(lp->current == -1)
+        return 1;
+    else
+        return (lp->current > lp->last);
 }
 
-void check_list_front (List *lp)
+void check_list_front(List * lp)
 {
-  if (lp->current == -1)
-    return;
-  lp->current = 0;
+    if(lp->current == -1)
+        return;
+    lp->current = 0;
 }
 
 
-void check_list_free (List *lp)
+void check_list_free(List * lp)
 {
-  if (lp == NULL)
-    return;
-  
-  free(lp->data);
-  free (lp);
+    if(lp == NULL)
+        return;
+
+    free(lp->data);
+    free(lp);
 }
 
-void *check_list_val (List *lp)
+void *check_list_val(List * lp)
 {
-  if (lp == NULL)
-    return NULL;
-  if (lp->current == -1 || lp->current > lp->last)
-    return NULL;
-  
-  return lp->data[lp->current];
+    if(lp == NULL)
+        return NULL;
+    if(lp->current == -1 || lp->current > lp->last)
+        return NULL;
+
+    return lp->data[lp->current];
 }
 
-void check_list_advance (List *lp)
+void check_list_advance(List * lp)
 {
-  if (lp == NULL)
-    return;
-  if (check_list_at_end(lp))
-    return;
-  lp->current++;
+    if(lp == NULL)
+        return;
+    if(check_list_at_end(lp))
+        return;
+    lp->current++;
 }
 
 
-void check_list_apply (List *lp, void (*fp) (void *))
+void check_list_apply(List * lp, void (*fp) (void *))
 {
-  if (lp == NULL || fp == NULL)
-    return;
-
-  for (check_list_front(lp); !check_list_at_end(lp); check_list_advance(lp))
-    fp (check_list_val(lp));
-  
-}
+    if(lp == NULL || fp == NULL)
+        return;
 
+    for(check_list_front(lp); !check_list_at_end(lp); check_list_advance(lp))
+        fp(check_list_val(lp));
 
-  
+}
index 05df73a2b229d69c735f09e86b73a52a9433a0b0..adefe5a4f45da46d49d50c139bcbd9fed8861206 100644 (file)
 typedef struct List List;
 
 /* Create an empty list */
-List * check_list_create (void);
+List *check_list_create(void);
 
 /* Is list at end? */
-int check_list_at_end (List * lp);
+int check_list_at_end(List * lp);
 
 /* Position list at front */
-void check_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 check_list_add_front (List *lp, void *val);
+void check_list_add_front(List * lp, void *val);
 
 /* Add a value to the end of the list,
    positioning newly added value as current value */
-void check_list_add_end (List *lp, void *val);
+void check_list_add_end(List * lp, void *val);
 
 /* Give the value of the current node */
-void *check_list_val (List * lp);
+void *check_list_val(List * lp);
 
 /* Position the list at the next node */
-void check_list_advance (List * lp);
+void check_list_advance(List * lp);
 
 /* Free a list, but don't free values */
-void check_list_free (List * lp);
+void check_list_free(List * lp);
 
-void check_list_apply (List *lp, void (*fp) (void *));
+void check_list_apply(List * lp, void (*fp) (void *));
 
 
 #endif /* CHECK_LIST_H */
index 692764da177865d4be35aafeef6e79456a6e3d5d..45c1f61267ddc283b952d6c1562048a4efe4fe12 100644 (file)
  */
 #define STDOUT_OVERRIDE_LOG_FILE_NAME "-"
 
-static void srunner_send_evt (SRunner *sr, void *obj, enum cl_event evt);
+static void srunner_send_evt(SRunner * sr, void *obj, enum cl_event evt);
 
-void srunner_set_log (SRunner *sr, const char *fname)
+void srunner_set_log(SRunner * sr, const char *fname)
 {
-  if (sr->log_fname)
-    return;
-  sr->log_fname = fname;
+    if(sr->log_fname)
+        return;
+    sr->log_fname = fname;
 }
 
-int srunner_has_log (SRunner *sr)
+int srunner_has_log(SRunner * sr)
 {
-  return srunner_log_fname(sr) != NULL;
+    return srunner_log_fname(sr) != NULL;
 }
 
-const char *srunner_log_fname (SRunner *sr)
+const char *srunner_log_fname(SRunner * sr)
 {
-  /* check if log filename have been set explicitly */
-  if (sr->log_fname != NULL)
-    return sr->log_fname;
+    /* check if log filename have been set explicitly */
+    if(sr->log_fname != NULL)
+        return sr->log_fname;
 
-  return getenv("CK_LOG_FILE_NAME");
+    return getenv("CK_LOG_FILE_NAME");
 }
 
 
-void srunner_set_xml (SRunner *sr, const char *fname)
+void srunner_set_xml(SRunner * sr, const char *fname)
 {
-  if (sr->xml_fname)
-    return;
-  sr->xml_fname = fname;
+    if(sr->xml_fname)
+        return;
+    sr->xml_fname = fname;
 }
 
-int srunner_has_xml (SRunner *sr)
+int srunner_has_xml(SRunner * sr)
 {
-  return srunner_xml_fname(sr) != NULL;
+    return srunner_xml_fname(sr) != NULL;
 }
 
-const char *srunner_xml_fname (SRunner *sr)
+const char *srunner_xml_fname(SRunner * sr)
 {
-  /* check if XML log filename have been set explicitly */
-  if (sr->xml_fname != NULL) {
-    return sr->xml_fname;
-  }
+    /* check if XML log filename have been set explicitly */
+    if(sr->xml_fname != NULL)
+    {
+        return sr->xml_fname;
+    }
 
-  return getenv("CK_XML_LOG_FILE_NAME");
+    return getenv("CK_XML_LOG_FILE_NAME");
 }
 
-void srunner_set_tap (SRunner *sr, const char *fname)
+void srunner_set_tap(SRunner * sr, const char *fname)
 {
-  if (sr->tap_fname)
-    return;
-  sr->tap_fname = fname;
+    if(sr->tap_fname)
+        return;
+    sr->tap_fname = fname;
 }
 
-int srunner_has_tap (SRunner *sr)
+int srunner_has_tap(SRunner * sr)
 {
-  return srunner_tap_fname(sr) != NULL;
+    return srunner_tap_fname(sr) != NULL;
 }
 
-const char *srunner_tap_fname (SRunner *sr)
+const char *srunner_tap_fname(SRunner * sr)
 {
-  /* check if tap log filename have been set explicitly */
-  if (sr->tap_fname != NULL) {
-    return sr->tap_fname;
-  }
+    /* check if tap log filename have been set explicitly */
+    if(sr->tap_fname != NULL)
+    {
+        return sr->tap_fname;
+    }
 
-  return getenv("CK_TAP_LOG_FILE_NAME");
+    return getenv("CK_TAP_LOG_FILE_NAME");
 }
 
-void srunner_register_lfun (SRunner *sr, FILE *lfile, int close,
-                           LFun lfun, enum print_output printmode)
+void srunner_register_lfun(SRunner * sr, FILE * lfile, int close,
+                           LFun lfun, enum print_output printmode)
 {
-  Log *l = emalloc (sizeof(Log));
-
-  if (printmode == CK_ENV) {
-    printmode = get_env_printmode();
-  }
-
-  l->lfile = lfile;
-  l->lfun = lfun;
-  l->close = close;
-  l->mode = printmode;
-  check_list_add_end (sr->loglst, l);
-  return;
+    Log *l = emalloc(sizeof(Log));
+
+    if(printmode == CK_ENV)
+    {
+        printmode = get_env_printmode();
+    }
+
+    l->lfile = lfile;
+    l->lfun = lfun;
+    l->close = close;
+    l->mode = printmode;
+    check_list_add_end(sr->loglst, l);
+    return;
 }
 
-void log_srunner_start (SRunner *sr)
+void log_srunner_start(SRunner * sr)
 {
-  srunner_send_evt (sr, NULL, CLSTART_SR);
+    srunner_send_evt(sr, NULL, CLSTART_SR);
 }
 
-void log_srunner_end (SRunner *sr)
+void log_srunner_end(SRunner * sr)
 {
-  srunner_send_evt (sr, NULL, CLEND_SR);
+    srunner_send_evt(sr, NULL, CLEND_SR);
 }
 
-void log_suite_start (SRunner *sr, Suite *s)
+void log_suite_start(SRunner * sr, Suite * s)
 {
-  srunner_send_evt (sr, s, CLSTART_S);
+    srunner_send_evt(sr, s, CLSTART_S);
 }
 
-void log_suite_end (SRunner *sr, Suite *s)
+void log_suite_end(SRunner * sr, Suite * s)
 {
-  srunner_send_evt (sr, s, CLEND_S);
+    srunner_send_evt(sr, s, CLEND_S);
 }
 
-void log_test_start (SRunner *sr, TCase * tc, TF * tfun)
+void log_test_start(SRunner * sr, TCase * tc, TF * tfun)
 {
-  char buffer[100];
-  snprintf(buffer, 99, "%s:%s", tc->name, tfun->name);
-  srunner_send_evt (sr, buffer, CLSTART_T);
+    char buffer[100];
+
+    snprintf(buffer, 99, "%s:%s", tc->name, tfun->name);
+    srunner_send_evt(sr, buffer, CLSTART_T);
 }
 
-void log_test_end (SRunner *sr, TestResult *tr)
+void log_test_end(SRunner * sr, TestResult * tr)
 {
-  srunner_send_evt (sr, tr, CLEND_T);
+    srunner_send_evt(sr, tr, CLEND_T);
 }
 
-static void srunner_send_evt (SRunner *sr, void *obj, enum cl_event evt)
+static void srunner_send_evt(SRunner * sr, void *obj, enum cl_event evt)
 {
-  List *l;
-  Log *lg;
-  l = sr->loglst;
-  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);
-  }
+    List *l;
+    Log *lg;
+
+    l = sr->loglst;
+    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);
+    }
 }
 
-void stdout_lfun (SRunner *sr, FILE *file, enum print_output printmode,
-                 void *obj, enum cl_event evt)
+void stdout_lfun(SRunner * sr, FILE * file, enum print_output printmode,
+                 void *obj, enum cl_event evt)
 {
-  Suite *s;
-
-  switch (evt) {
-  case CLINITLOG_SR:
-    break;
-  case CLENDLOG_SR:
-    break;
-  case CLSTART_SR:
-    if (printmode > CK_SILENT) {
-      fprintf(file, "Running suite(s):");
-    }
-    break;
-  case CLSTART_S:
-    s = obj;
-    if (printmode > CK_SILENT) {
-      fprintf(file, " %s\n", s->name);
-    }
-    break;
-  case CLEND_SR:
-    if (printmode > CK_SILENT) {
-      /* we don't want a newline before printing here, newlines should
-        come after printing a string, not before.  it's better to add
-        the newline above in CLSTART_S.
-      */
-      srunner_fprint (file, sr, printmode);
+    Suite *s;
+
+    switch (evt)
+    {
+        case CLINITLOG_SR:
+            break;
+        case CLENDLOG_SR:
+            break;
+        case CLSTART_SR:
+            if(printmode > CK_SILENT)
+            {
+                fprintf(file, "Running suite(s):");
+            }
+            break;
+        case CLSTART_S:
+            s = obj;
+            if(printmode > CK_SILENT)
+            {
+                fprintf(file, " %s\n", s->name);
+            }
+            break;
+        case CLEND_SR:
+            if(printmode > CK_SILENT)
+            {
+                /* we don't want a newline before printing here, newlines should
+                   come after printing a string, not before.  it's better to add
+                   the newline above in CLSTART_S.
+                 */
+                srunner_fprint(file, sr, printmode);
+            }
+            break;
+        case CLEND_S:
+            break;
+        case CLSTART_T:
+            break;
+        case CLEND_T:
+            break;
+        default:
+            eprintf("Bad event type received in stdout_lfun", __FILE__,
+                    __LINE__);
     }
-    break;
-  case CLEND_S:
-    break;
-  case CLSTART_T:
-    break;
-  case CLEND_T:
-    break;
-  default:
-    eprintf("Bad event type received in stdout_lfun", __FILE__, __LINE__);
-  }
-
-  
+
+
 }
 
-void lfile_lfun (SRunner *sr, FILE *file, enum print_output printmode CK_ATTRIBUTE_UNUSED,
-                void *obj, enum cl_event evt)
+void lfile_lfun(SRunner * sr, FILE * file,
+                enum print_output printmode CK_ATTRIBUTE_UNUSED, void *obj,
+                enum cl_event evt)
 {
-  TestResult *tr;
-  Suite *s;
-  
-  switch (evt) {
-  case CLINITLOG_SR:
-    break;
-  case CLENDLOG_SR:
-    break;
-  case CLSTART_SR:
-    break;
-  case CLSTART_S:
-    s = obj;
-    fprintf(file, "Running suite %s\n", s->name);
-    break;
-  case CLEND_SR:
-    fprintf (file, "Results for all suites run:\n");
-    srunner_fprint (file, sr, CK_MINIMAL);
-    break;
-  case CLEND_S:
-    break;
-  case CLSTART_T:
-    break;
-  case CLEND_T:
-    tr = obj;
-    tr_fprint(file, tr, CK_VERBOSE);
-    break;
-  default:
-    eprintf("Bad event type received in lfile_lfun", __FILE__, __LINE__);
-  }
-
-  
+    TestResult *tr;
+    Suite *s;
+
+    switch (evt)
+    {
+        case CLINITLOG_SR:
+            break;
+        case CLENDLOG_SR:
+            break;
+        case CLSTART_SR:
+            break;
+        case CLSTART_S:
+            s = obj;
+            fprintf(file, "Running suite %s\n", s->name);
+            break;
+        case CLEND_SR:
+            fprintf(file, "Results for all suites run:\n");
+            srunner_fprint(file, sr, CK_MINIMAL);
+            break;
+        case CLEND_S:
+            break;
+        case CLSTART_T:
+            break;
+        case CLEND_T:
+            tr = obj;
+            tr_fprint(file, tr, CK_VERBOSE);
+            break;
+        default:
+            eprintf("Bad event type received in lfile_lfun", __FILE__,
+                    __LINE__);
+    }
+
+
 }
 
-void xml_lfun (SRunner *sr CK_ATTRIBUTE_UNUSED, FILE *file, enum print_output printmode CK_ATTRIBUTE_UNUSED,
-                 void *obj, enum cl_event evt)
+void xml_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file,
+              enum print_output printmode CK_ATTRIBUTE_UNUSED, void *obj,
+              enum cl_event evt)
 {
-  TestResult *tr;
-  Suite *s;
-  static struct timespec ts_start = {0,0};
-  static char t[sizeof "yyyy-mm-dd hh:mm:ss"] = {0};
-
-  if (t[0] == 0)
-  {
-    struct timeval inittv;
-    struct tm now;
-    gettimeofday(&inittv, NULL);
-    clock_gettime(check_get_clockid(), &ts_start);
-    if(localtime_r((const time_t*)&(inittv.tv_sec), &now) != NULL)
+    TestResult *tr;
+    Suite *s;
+    static struct timespec ts_start = { 0, 0 };
+    static char t[sizeof "yyyy-mm-dd hh:mm:ss"] = { 0 };
+
+    if(t[0] == 0)
     {
-        strftime(t, sizeof("yyyy-mm-dd hh:mm:ss"), "%Y-%m-%d %H:%M:%S", &now);
+        struct timeval inittv;
+        struct tm now;
+
+        gettimeofday(&inittv, NULL);
+        clock_gettime(check_get_clockid(), &ts_start);
+        if(localtime_r((const time_t *)&(inittv.tv_sec), &now) != NULL)
+        {
+            strftime(t, sizeof("yyyy-mm-dd hh:mm:ss"), "%Y-%m-%d %H:%M:%S",
+                     &now);
+        }
     }
-  }
-
-  switch (evt) {
-  case CLINITLOG_SR:
-    fprintf(file, "<?xml version=\"1.0\"?>\n");
-    fprintf(file, "<?xml-stylesheet type=\"text/xsl\" href=\"http://check.sourceforge.net/xml/check_unittest.xslt\"?>\n");
-    fprintf(file, "<testsuites xmlns=\"http://check.sourceforge.net/ns\">\n");
-    fprintf(file, "  <datetime>%s</datetime>\n", t);
-    break;
-  case CLENDLOG_SR:
+
+    switch (evt)
     {
-      struct timespec ts_end = {0,0};
-      unsigned long duration;
-
-      /* calculate time the test were running */
-      clock_gettime(check_get_clockid(), &ts_end);
-      duration = (unsigned long)DIFF_IN_USEC(ts_start, ts_end);
-      fprintf(file, "  <duration>%lu.%06lu</duration>\n",
-          duration / US_PER_SEC, duration % US_PER_SEC);
-      fprintf(file, "</testsuites>\n");
+        case CLINITLOG_SR:
+            fprintf(file, "<?xml version=\"1.0\"?>\n");
+            fprintf(file,
+                    "<?xml-stylesheet type=\"text/xsl\" href=\"http://check.sourceforge.net/xml/check_unittest.xslt\"?>\n");
+            fprintf(file,
+                    "<testsuites xmlns=\"http://check.sourceforge.net/ns\">\n");
+            fprintf(file, "  <datetime>%s</datetime>\n", t);
+            break;
+        case CLENDLOG_SR:
+        {
+            struct timespec ts_end = { 0, 0 };
+            unsigned long duration;
+
+            /* calculate time the test were running */
+            clock_gettime(check_get_clockid(), &ts_end);
+            duration = (unsigned long)DIFF_IN_USEC(ts_start, ts_end);
+            fprintf(file, "  <duration>%lu.%06lu</duration>\n",
+                    duration / US_PER_SEC, duration % US_PER_SEC);
+            fprintf(file, "</testsuites>\n");
+        }
+            break;
+        case CLSTART_SR:
+            break;
+        case CLSTART_S:
+            s = obj;
+            fprintf(file, "  <suite>\n");
+            fprintf(file, "    <title>");
+            fprint_xml_esc(file, s->name);
+            fprintf(file, "</title>\n");
+            break;
+        case CLEND_SR:
+            break;
+        case CLEND_S:
+            fprintf(file, "  </suite>\n");
+            break;
+        case CLSTART_T:
+            break;
+        case CLEND_T:
+            tr = obj;
+            tr_xmlprint(file, tr, CK_VERBOSE);
+            break;
+        default:
+            eprintf("Bad event type received in xml_lfun", __FILE__,
+                    __LINE__);
     }
-    break;
-  case CLSTART_SR:
-    break;
-  case CLSTART_S:
-    s = obj;
-    fprintf(file, "  <suite>\n");
-    fprintf(file, "    <title>");
-    fprint_xml_esc(file, s->name);
-    fprintf(file,"</title>\n");
-    break;
-  case CLEND_SR:
-    break;
-  case CLEND_S:
-    fprintf(file, "  </suite>\n");
-    break;
-  case CLSTART_T:
-    break;
-  case CLEND_T:
-    tr = obj;
-    tr_xmlprint(file, tr, CK_VERBOSE);
-    break;
-  default:
-    eprintf("Bad event type received in xml_lfun", __FILE__, __LINE__);
-  }
 
 }
 
-void tap_lfun (SRunner *sr CK_ATTRIBUTE_UNUSED, FILE *file, enum print_output printmode CK_ATTRIBUTE_UNUSED,
-                void *obj, enum cl_event evt)
+void tap_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file,
+              enum print_output printmode CK_ATTRIBUTE_UNUSED, void *obj,
+              enum cl_event evt)
 {
-  TestResult *tr;
-  Suite *s;
-
-  static int num_tests_run = 0;
-
-  switch (evt) {
-  case CLINITLOG_SR:
-    /* As this is a new log file, reset the number of tests executed */
-    num_tests_run = 0;
-    break;
-  case CLENDLOG_SR:
-    /* Output the test plan as the last line */
-    fprintf(file, "1..%d\n", num_tests_run);
-    fflush(file);
-    break;
-  case CLSTART_SR:
-    break;
-  case CLSTART_S:
-    break;
-  case CLEND_SR:
-    break;
-  case CLEND_S:
-    break;
-  case CLSTART_T:
-    break;
-  case CLEND_T:
-    /* Print the test result to the tap file */
-    num_tests_run+=1;
-    tr = obj;
-    fprintf(file, "%s %d - %s:%s:%s: %s\n", tr->rtype == CK_PASS ? "ok" : "not ok", num_tests_run, tr->file, tr->tcname, tr->tname, tr->msg);
-    fflush(file);
-    break;
-  default:
-    eprintf("Bad event type received in tap_lfun", __FILE__, __LINE__);
-  }
+    TestResult *tr;
+    Suite *s;
+
+    static int num_tests_run = 0;
+
+    switch (evt)
+    {
+        case CLINITLOG_SR:
+            /* As this is a new log file, reset the number of tests executed */
+            num_tests_run = 0;
+            break;
+        case CLENDLOG_SR:
+            /* Output the test plan as the last line */
+            fprintf(file, "1..%d\n", num_tests_run);
+            fflush(file);
+            break;
+        case CLSTART_SR:
+            break;
+        case CLSTART_S:
+            break;
+        case CLEND_SR:
+            break;
+        case CLEND_S:
+            break;
+        case CLSTART_T:
+            break;
+        case CLEND_T:
+            /* Print the test result to the tap file */
+            num_tests_run += 1;
+            tr = obj;
+            fprintf(file, "%s %d - %s:%s:%s: %s\n",
+                    tr->rtype == CK_PASS ? "ok" : "not ok", num_tests_run,
+                    tr->file, tr->tcname, tr->tname, tr->msg);
+            fflush(file);
+            break;
+        default:
+            eprintf("Bad event type received in tap_lfun", __FILE__,
+                    __LINE__);
+    }
 }
 
 #if ENABLE_SUBUNIT
-void subunit_lfun (SRunner *sr, FILE *file, enum print_output printmode,
-                 void *obj, enum cl_event evt)
+void subunit_lfun(SRunner * sr, FILE * file, enum print_output printmode,
+                  void *obj, enum cl_event evt)
 {
-  TestResult *tr;
-  char const * name;
-  
-  /* assert(printmode == CK_SUBUNIT); */
-
-  switch (evt) {
-  case CLINITLOG_SR:
-    break;
-  case CLENDLOG_SR:
-    break;
-  case CLSTART_SR:
-    break;
-  case CLSTART_S:
-    break;
-  case CLEND_SR:
-    if (printmode > CK_SILENT) {
-      fprintf (file, "\n");
-      srunner_fprint (file, sr, printmode);
-    }
-    break;
-  case CLEND_S:
-    break;
-  case CLSTART_T:
-    name = obj;
-    subunit_test_start(name);
-    break;
-  case CLEND_T:
-    tr = obj;
+    TestResult *tr;
+    char const *name;
+
+    /* assert(printmode == CK_SUBUNIT); */
+
+    switch (evt)
     {
-      char *name = ck_strdup_printf ("%s:%s", tr->tcname, tr->tname);
-      char *msg = tr_short_str (tr);
-      switch (tr->rtype) {
-      case CK_PASS:
-        subunit_test_pass(name);
-        break;
-      case CK_FAILURE:
-        subunit_test_fail(name, msg);
-        break;
-      case CK_ERROR:
-        subunit_test_error(name, msg);
-        break;
-      case CK_TEST_RESULT_INVALID:
-      default:
-        eprintf("Bad result type in subunit_lfun", __FILE__, __LINE__);
-        free(name);
-        free(msg);
-      }
+        case CLINITLOG_SR:
+            break;
+        case CLENDLOG_SR:
+            break;
+        case CLSTART_SR:
+            break;
+        case CLSTART_S:
+            break;
+        case CLEND_SR:
+            if(printmode > CK_SILENT)
+            {
+                fprintf(file, "\n");
+                srunner_fprint(file, sr, printmode);
+            }
+            break;
+        case CLEND_S:
+            break;
+        case CLSTART_T:
+            name = obj;
+            subunit_test_start(name);
+            break;
+        case CLEND_T:
+            tr = obj;
+            {
+                char *name = ck_strdup_printf("%s:%s", tr->tcname, tr->tname);
+                char *msg = tr_short_str(tr);
+
+                switch (tr->rtype)
+                {
+                    case CK_PASS:
+                        subunit_test_pass(name);
+                        break;
+                    case CK_FAILURE:
+                        subunit_test_fail(name, msg);
+                        break;
+                    case CK_ERROR:
+                        subunit_test_error(name, msg);
+                        break;
+                    case CK_TEST_RESULT_INVALID:
+                    default:
+                        eprintf("Bad result type in subunit_lfun", __FILE__,
+                                __LINE__);
+                        free(name);
+                        free(msg);
+                }
+            }
+            break;
+        default:
+            eprintf("Bad event type received in subunit_lfun", __FILE__,
+                    __LINE__);
     }
-    break;
-  default:
-    eprintf("Bad event type received in subunit_lfun", __FILE__, __LINE__);
-  }
 }
 #endif
 
-static FILE * srunner_open_file(const char * filename)
+static FILE *srunner_open_file(const char *filename)
 {
-    FILE * f = NULL;
+    FILE *f = NULL;
+
     if(strcmp(filename, STDOUT_OVERRIDE_LOG_FILE_NAME) == 0)
     {
         f = stdout;
@@ -424,89 +457,100 @@ static FILE * srunner_open_file(const char * filename)
     else
     {
         f = fopen(filename, "w");
-        if (f == NULL)
+        if(f == NULL)
         {
-            eprintf ("Error in call to fopen while opening file %s:", __FILE__, __LINE__ - 2,
-                    filename);
+            eprintf("Error in call to fopen while opening file %s:", __FILE__,
+                    __LINE__ - 2, filename);
         }
     }
     return f;
 }
 
-FILE *srunner_open_lfile (SRunner *sr)
+FILE *srunner_open_lfile(SRunner * sr)
 {
     FILE *f = NULL;
-    if (srunner_has_log (sr))
+
+    if(srunner_has_log(sr))
     {
         f = srunner_open_file(srunner_log_fname(sr));
     }
     return f;
 }
 
-FILE *srunner_open_xmlfile (SRunner *sr)
+FILE *srunner_open_xmlfile(SRunner * sr)
 {
     FILE *f = NULL;
-    if (srunner_has_xml (sr))
+
+    if(srunner_has_xml(sr))
     {
         f = srunner_open_file(srunner_xml_fname(sr));
     }
     return f;
 }
 
-FILE *srunner_open_tapfile (SRunner *sr)
+FILE *srunner_open_tapfile(SRunner * sr)
 {
     FILE *f = NULL;
-    if (srunner_has_tap (sr))
+
+    if(srunner_has_tap(sr))
     {
         f = srunner_open_file(srunner_tap_fname(sr));
     }
     return f;
 }
 
-void srunner_init_logging (SRunner *sr, enum print_output print_mode)
+void srunner_init_logging(SRunner * sr, enum print_output print_mode)
 {
-  FILE *f;
-  sr->loglst = check_list_create();
+    FILE *f;
+
+    sr->loglst = check_list_create();
 #if ENABLE_SUBUNIT
-  if (print_mode != CK_SUBUNIT)
+    if(print_mode != CK_SUBUNIT)
 #endif
-      srunner_register_lfun (sr, stdout, 0, stdout_lfun, print_mode);
+        srunner_register_lfun(sr, stdout, 0, stdout_lfun, print_mode);
 #if ENABLE_SUBUNIT
-  else
-      srunner_register_lfun (sr, stdout, 0, subunit_lfun, print_mode);
+    else
+        srunner_register_lfun(sr, stdout, 0, subunit_lfun, print_mode);
 #endif
-  f = srunner_open_lfile (sr);
-  if (f) {
-    srunner_register_lfun (sr, f, f!=stdout, lfile_lfun, print_mode);
-  }
-  f = srunner_open_xmlfile (sr);
-  if (f) {
-    srunner_register_lfun (sr, f, f!=stdout, xml_lfun, print_mode);
-  }
-  f = srunner_open_tapfile (sr);
-  if (f) {
-    srunner_register_lfun (sr, f, f!=stdout, tap_lfun, print_mode);
-  }
-  srunner_send_evt (sr, NULL, CLINITLOG_SR);
+    f = srunner_open_lfile(sr);
+    if(f)
+    {
+        srunner_register_lfun(sr, f, f != stdout, lfile_lfun, print_mode);
+    }
+    f = srunner_open_xmlfile(sr);
+    if(f)
+    {
+        srunner_register_lfun(sr, f, f != stdout, xml_lfun, print_mode);
+    }
+    f = srunner_open_tapfile(sr);
+    if(f)
+    {
+        srunner_register_lfun(sr, f, f != stdout, tap_lfun, print_mode);
+    }
+    srunner_send_evt(sr, NULL, CLINITLOG_SR);
 }
 
-void srunner_end_logging (SRunner *sr)
+void srunner_end_logging(SRunner * sr)
 {
-  List *l;
-  int rval;
-
-  srunner_send_evt (sr, NULL, CLENDLOG_SR);
-
-  l = sr->loglst;
-  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)
-       eprintf ("Error in call to fclose while closing log file:", __FILE__, __LINE__ - 2);
+    List *l;
+    int rval;
+
+    srunner_send_evt(sr, NULL, CLENDLOG_SR);
+
+    l = sr->loglst;
+    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)
+                eprintf("Error in call to fclose while closing log file:",
+                        __FILE__, __LINE__ - 2);
+        }
+        free(lg);
     }
-    free (lg);
-  }
-  check_list_free(l);
-  sr->loglst = NULL;
+    check_list_free(l);
+    sr->loglst = NULL;
 }
index b4650fe3abafc37f15db824cc57cde49b64a5548..cdcb3bf9282ec63998be723bb8894053be6647e7 100644 (file)
 #ifndef CHECK_LOG_H
 #define CHECK_LOG_H
 
-void log_srunner_start (SRunner *sr);
-void log_srunner_end (SRunner *sr);
-void log_suite_start (SRunner *sr, Suite *s);
-void log_suite_end (SRunner *sr, Suite *s);
-void log_test_end (SRunner *sr, TestResult *tr);
-void log_test_start (SRunner *sr, TCase *tc, TF *tfun);
+void log_srunner_start(SRunner * sr);
+void log_srunner_end(SRunner * sr);
+void log_suite_start(SRunner * sr, Suite * s);
+void log_suite_end(SRunner * sr, Suite * s);
+void log_test_end(SRunner * sr, TestResult * tr);
+void log_test_start(SRunner * sr, TCase * tc, TF * tfun);
 
-void stdout_lfun (SRunner *sr, FILE *file, enum print_output,
-                 void *obj, enum cl_event evt);
+void stdout_lfun(SRunner * sr, FILE * file, enum print_output,
+                 void *obj, enum cl_event evt);
 
-void lfile_lfun (SRunner *sr, FILE *file, enum print_output,
-                 void *obj, enum cl_event evt);
+void lfile_lfun(SRunner * sr, FILE * file, enum print_output,
+                void *obj, enum cl_event evt);
 
-void xml_lfun (SRunner *sr, FILE *file, enum print_output,
-                 void *obj, enum cl_event evt);
+void xml_lfun(SRunner * sr, FILE * file, enum print_output,
+              void *obj, enum cl_event evt);
 
-void tap_lfun (SRunner *sr, FILE *file, enum print_output,
-                 void *obj, enum cl_event evt);
+void tap_lfun(SRunner * sr, FILE * file, enum print_output,
+              void *obj, enum cl_event evt);
 
-void subunit_lfun (SRunner *sr, FILE *file, enum print_output,
-                 void *obj, enum cl_event evt);
+void subunit_lfun(SRunner * sr, FILE * file, enum print_output,
+                  void *obj, enum cl_event evt);
 
-void srunner_register_lfun (SRunner *sr, FILE *lfile, int close,
-                           LFun lfun, enum print_output);
+void srunner_register_lfun(SRunner * sr, FILE * lfile, int close,
+                           LFun lfun, enum print_output);
 
-FILE *srunner_open_lfile (SRunner *sr);
-FILE *srunner_open_xmlfile (SRunner *sr);
-FILE *srunner_open_tapfile (SRunner *sr);
-void srunner_init_logging (SRunner *sr, enum print_output print_mode);
-void srunner_end_logging (SRunner *sr);
+FILE *srunner_open_lfile(SRunner * sr);
+FILE *srunner_open_xmlfile(SRunner * sr);
+FILE *srunner_open_tapfile(SRunner * sr);
+void srunner_init_logging(SRunner * sr, enum print_output print_mode);
+void srunner_end_logging(SRunner * sr);
 
 #endif /* CHECK_LOG_H */
index 2a7cb72533e164830d9daa3f831a2dff450bb195..eeacaa0f07ec1f3bdcec5f22e5c077121b1efd98 100644 (file)
@@ -59,138 +59,152 @@ static char *send_file1_name;
 static FILE *send_file2;
 static char *send_file2_name;
 
-static FILE * get_pipe(void);
-static void setup_pipe (void);
-static void teardown_pipe (void);
-static TestResult *construct_test_result (RcvMsg *rmsg, int waserror);
-static void tr_set_loc_by_ctx (TestResult *tr, enum ck_result_ctx ctx,
-                              RcvMsg *rmsg);
-static FILE * get_pipe(void)
+static FILE *get_pipe(void);
+static void setup_pipe(void);
+static void teardown_pipe(void);
+static TestResult *construct_test_result(RcvMsg * rmsg, int waserror);
+static void tr_set_loc_by_ctx(TestResult * tr, enum ck_result_ctx ctx,
+                              RcvMsg * rmsg);
+static FILE *get_pipe(void)
 {
-  if (send_file2 != 0) {
-    return send_file2;
-  }
-  
-  if (send_file1 != 0) {
-    return send_file1;
-  }
-  
-  eprintf("No messaging setup", __FILE__, __LINE__);
-
-  return NULL;
+    if(send_file2 != 0)
+    {
+        return send_file2;
+    }
+
+    if(send_file1 != 0)
+    {
+        return send_file1;
+    }
+
+    eprintf("No messaging setup", __FILE__, __LINE__);
+
+    return NULL;
 }
 
 void send_failure_info(const char *msg)
 {
-  FailMsg fmsg;
-  fmsg.msg = strdup(msg);
-  ppack(get_pipe(), CK_MSG_FAIL, (CheckMsg *) &fmsg);
-  free(fmsg.msg);
+    FailMsg fmsg;
+
+    fmsg.msg = strdup(msg);
+    ppack(get_pipe(), CK_MSG_FAIL, (CheckMsg *) & fmsg);
+    free(fmsg.msg);
 }
 
 void send_duration_info(int duration)
 {
-  DurationMsg dmsg;
-  dmsg.duration = duration;
-  ppack(get_pipe(), CK_MSG_DURATION, (CheckMsg *) &dmsg);
+    DurationMsg dmsg;
+
+    dmsg.duration = duration;
+    ppack(get_pipe(), CK_MSG_DURATION, (CheckMsg *) & dmsg);
 }
 
-void send_loc_info(const char * file, int line)
+void send_loc_info(const char *file, int line)
 {
-  LocMsg lmsg;
-  lmsg.file = strdup(file);
-  lmsg.line = line;
-  ppack(get_pipe(), CK_MSG_LOC, (CheckMsg *) &lmsg);
-  free(lmsg.file);
+    LocMsg lmsg;
+
+    lmsg.file = strdup(file);
+    lmsg.line = line;
+    ppack(get_pipe(), CK_MSG_LOC, (CheckMsg *) & lmsg);
+    free(lmsg.file);
 }
 
 void send_ctx_info(enum ck_result_ctx ctx)
 {
-  CtxMsg cmsg;
-  cmsg.ctx = ctx;
-  ppack(get_pipe(), CK_MSG_CTX, (CheckMsg *) &cmsg);
+    CtxMsg cmsg;
+
+    cmsg.ctx = ctx;
+    ppack(get_pipe(), CK_MSG_CTX, (CheckMsg *) & cmsg);
 }
 
-TestResult *receive_test_result (int waserror)
+TestResult *receive_test_result(int waserror)
 {
-  FILE *fp;
-  RcvMsg *rmsg;
-  TestResult *result;
-
-  fp = get_pipe();
-  if (fp == NULL)
-  {
-    eprintf ("Error in call to get_pipe",__FILE__, __LINE__ - 2);
-  }
-
-  rewind(fp);
-  rmsg = punpack (fp);
-
-  if(rmsg == NULL)
-  {
-         eprintf ("Error in call to punpack",__FILE__, __LINE__ - 4);
-  }
-
-  teardown_pipe();
-  setup_pipe();
-
-  result = construct_test_result (rmsg, waserror);
-  rcvmsg_free(rmsg);
-  return result;
+    FILE *fp;
+    RcvMsg *rmsg;
+    TestResult *result;
+
+    fp = get_pipe();
+    if(fp == NULL)
+    {
+        eprintf("Error in call to get_pipe", __FILE__, __LINE__ - 2);
+    }
+
+    rewind(fp);
+    rmsg = punpack(fp);
+
+    if(rmsg == NULL)
+    {
+        eprintf("Error in call to punpack", __FILE__, __LINE__ - 4);
+    }
+
+    teardown_pipe();
+    setup_pipe();
+
+    result = construct_test_result(rmsg, waserror);
+    rcvmsg_free(rmsg);
+    return result;
 }
 
-static void tr_set_loc_by_ctx (TestResult *tr, enum ck_result_ctx ctx,
-                              RcvMsg *rmsg)
+static void tr_set_loc_by_ctx(TestResult * tr, enum ck_result_ctx ctx,
+                              RcvMsg * rmsg)
 {
-  if (ctx == CK_CTX_TEST) {
-    tr->file = rmsg->test_file;
-    tr->line = rmsg->test_line;
-    rmsg->test_file = NULL;
-    rmsg->test_line = -1;
-  } else {
-    tr->file = rmsg->fixture_file;
-    tr->line = rmsg->fixture_line;
-    rmsg->fixture_file = NULL;
-    rmsg->fixture_line = -1;
-  }
+    if(ctx == CK_CTX_TEST)
+    {
+        tr->file = rmsg->test_file;
+        tr->line = rmsg->test_line;
+        rmsg->test_file = NULL;
+        rmsg->test_line = -1;
+    }
+    else
+    {
+        tr->file = rmsg->fixture_file;
+        tr->line = rmsg->fixture_line;
+        rmsg->fixture_file = NULL;
+        rmsg->fixture_line = -1;
+    }
 }
 
-static TestResult *construct_test_result (RcvMsg *rmsg, int waserror)
+static TestResult *construct_test_result(RcvMsg * rmsg, int waserror)
 {
-  TestResult *tr;
+    TestResult *tr;
 
-  if (rmsg == NULL)
-    return NULL;
+    if(rmsg == NULL)
+        return NULL;
+
+    tr = tr_create();
+
+    if(rmsg->msg != NULL || waserror)
+    {
+        tr->ctx = rmsg->lastctx;
+        tr->msg = rmsg->msg;
+        rmsg->msg = NULL;
+        tr_set_loc_by_ctx(tr, tr->ctx, rmsg);
+    }
+    else if(rmsg->lastctx == CK_CTX_SETUP)
+    {
+        tr->ctx = CK_CTX_SETUP;
+        tr->msg = NULL;
+        tr_set_loc_by_ctx(tr, CK_CTX_SETUP, rmsg);
+    }
+    else
+    {
+        tr->ctx = CK_CTX_TEST;
+        tr->msg = NULL;
+        tr->duration = rmsg->duration;
+        tr_set_loc_by_ctx(tr, CK_CTX_TEST, rmsg);
+    }
 
-  tr = tr_create();
-
-  if (rmsg->msg != NULL || waserror) {
-    tr->ctx = rmsg->lastctx;
-    tr->msg = rmsg->msg;
-    rmsg->msg = NULL;
-    tr_set_loc_by_ctx (tr, tr->ctx, rmsg);
-  } else if (rmsg->lastctx == CK_CTX_SETUP) {
-    tr->ctx = CK_CTX_SETUP;
-    tr->msg = NULL;
-    tr_set_loc_by_ctx (tr, CK_CTX_SETUP, rmsg);  
-  } else {
-    tr->ctx = CK_CTX_TEST;
-    tr->msg = NULL;
-    tr->duration = rmsg->duration;
-    tr_set_loc_by_ctx (tr, CK_CTX_TEST, rmsg);
-  }
-
-  return tr;
+    return tr;
 }
 
 void setup_messaging(void)
 {
-  setup_pipe();
+    setup_pipe();
 }
 
 void teardown_messaging(void)
 {
-  teardown_pipe();
+    teardown_pipe();
 }
 
 /**
@@ -202,79 +216,87 @@ void teardown_messaging(void)
  * expecting the caller to both delete the file and
  * free the 'name' field after the file is closed.
  */
-FILE * open_tmp_file (char ** name)
+FILE *open_tmp_file(char **name)
 {
-  FILE *file;
-  *name = NULL;
-
-  /* Windows does not like tmpfile(). This is likely because tmpfile()
-   * call unlink() on the file before returning it, to make sure the
-   * file is deleted when it is closed. The unlink() call also fails
-   * on Windows if the file is still open. */
-  /* also note that mkstemp is apparently a C90 replacement for tmpfile */
-  /* perhaps all we need to do on Windows is set TMPDIR to whatever is
-     stored in TEMP for tmpfile to work */
-  /* and finally, the "b" from "w+b" is ignored on OS X, not sure about WIN32 */
-
-  file = tmpfile ();
-  if (file == NULL)
+    FILE *file;
+
+    *name = NULL;
+
+    /* Windows does not like tmpfile(). This is likely because tmpfile()
+     * call unlink() on the file before returning it, to make sure the
+     * file is deleted when it is closed. The unlink() call also fails
+     * on Windows if the file is still open. */
+    /* also note that mkstemp is apparently a C90 replacement for tmpfile */
+    /* perhaps all we need to do on Windows is set TMPDIR to whatever is
+       stored in TEMP for tmpfile to work */
+    /* and finally, the "b" from "w+b" is ignored on OS X, not sure about WIN32 */
+
+    file = tmpfile();
+    if(file == NULL)
     {
-      char *tmp = getenv ("TEMP");
-      char *tmp_file = tempnam (tmp, "check_");
-      /*
-       * Note, tempnam is not enough to get a unique name. Between
-       * getting the name and opening the file, something else also
-       * calling tempnam() could get the same name. It has been observed
-       * on MinGW-w64 builds on Wine that this exact thing happens
-       * if multiple instances of a unit tests are running concurrently.
-       * To prevent two concurrent unit tests from getting the same file,
-       * we append the pid to the file. The pid should be unique on the
-       * system.
-       */
-      char *uniq_tmp_file = ck_strdup_printf("%s.%d",tmp_file, getpid());
-      file = fopen (uniq_tmp_file, "w+b");
-      *name = uniq_tmp_file;
-      free (tmp_file);
+        char *tmp = getenv("TEMP");
+        char *tmp_file = tempnam(tmp, "check_");
+
+        /*
+         * Note, tempnam is not enough to get a unique name. Between
+         * getting the name and opening the file, something else also
+         * calling tempnam() could get the same name. It has been observed
+         * on MinGW-w64 builds on Wine that this exact thing happens
+         * if multiple instances of a unit tests are running concurrently.
+         * To prevent two concurrent unit tests from getting the same file,
+         * we append the pid to the file. The pid should be unique on the
+         * system.
+         */
+        char *uniq_tmp_file = ck_strdup_printf("%s.%d", tmp_file, getpid());
+
+        file = fopen(uniq_tmp_file, "w+b");
+        *name = uniq_tmp_file;
+        free(tmp_file);
     }
-  return file;
+    return file;
 }
 
-static void
-setup_pipe (void)
+static void setup_pipe(void)
 {
-  if (send_file1 == NULL)
+    if(send_file1 == NULL)
     {
-      send_file1 = open_tmp_file (&send_file1_name);
-      return;
+        send_file1 = open_tmp_file(&send_file1_name);
+        return;
     }
-  if (send_file2 == NULL)
+    if(send_file2 == NULL)
     {
-      send_file2 = open_tmp_file (&send_file2_name);
-      return;
+        send_file2 = open_tmp_file(&send_file2_name);
+        return;
     }
-  eprintf ("Only one nesting of suite runs supported", __FILE__, __LINE__);
+    eprintf("Only one nesting of suite runs supported", __FILE__, __LINE__);
 }
 
 static void teardown_pipe(void)
 {
-  if (send_file2 != 0) {
-    fclose(send_file2);
-    send_file2 = 0;
-    if(send_file2_name != NULL) {
-               unlink(send_file2_name);
-               free(send_file2_name);
-               send_file2_name = NULL;
-       }
-  } else if (send_file1 != 0) {
-    fclose(send_file1);
-    send_file1 = 0;
-    if(send_file1_name != NULL) {
-               unlink(send_file1_name);
-               free(send_file1_name);
-               send_file1_name = NULL;
-       }
-  } else {
-    eprintf("No messaging setup", __FILE__, __LINE__);
-  }
+    if(send_file2 != 0)
+    {
+        fclose(send_file2);
+        send_file2 = 0;
+        if(send_file2_name != NULL)
+        {
+            unlink(send_file2_name);
+            free(send_file2_name);
+            send_file2_name = NULL;
+        }
+    }
+    else if(send_file1 != 0)
+    {
+        fclose(send_file1);
+        send_file1 = 0;
+        if(send_file1_name != NULL)
+        {
+            unlink(send_file1_name);
+            free(send_file1_name);
+            send_file1_name = NULL;
+        }
+    }
+    else
+    {
+        eprintf("No messaging setup", __FILE__, __LINE__);
+    }
 }
-
index aeae54808444e6ca0430f59805ef1bdc302f71b7..64eca2f53b301e06919575b7b400b67d0d359654 100644 (file)
@@ -34,6 +34,6 @@ TestResult *receive_test_result(int waserror);
 void setup_messaging(void);
 void teardown_messaging(void);
 
-FILE * open_tmp_file (char ** name);
+FILE *open_tmp_file(char **name);
 
 #endif /*CHECK_MSG_NEW_H */
index 12f75961cae46bbd4ef70148e5ac5ed03532d750..0547987dab02622ff763e52e5f279404ae26e136 100644 (file)
 typedef uint32_t ck_uint32;
 
 
-static void  pack_int   (char **buf, int val);
-static int   upack_int  (char **buf);
-static void  pack_str   (char **buf, const char *str);
-static char *upack_str  (char **buf);
-
-static int   pack_ctx   (char **buf, CtxMsg  *cmsg);
-static int   pack_loc   (char **buf, LocMsg  *lmsg);
-static int   pack_fail  (char **buf, FailMsg *fmsg);
-static int   pack_duration  (char **buf, DurationMsg *fmsg);
-static void  upack_ctx  (char **buf, CtxMsg  *cmsg);
-static void  upack_loc  (char **buf, LocMsg  *lmsg);
-static void  upack_fail (char **buf, FailMsg *fmsg);
-static void  upack_duration (char **buf, DurationMsg *fmsg);
-
-static void  check_type (int type, const char *file, int line);
-static enum ck_msg_type upack_type (char **buf);
-static void  pack_type  (char **buf, enum ck_msg_type type);
-
-static int   read_buf   (FILE* fdes, int size, char *buf);
-static int   get_result (char *buf, RcvMsg *rmsg);
-static void  rcvmsg_update_ctx (RcvMsg *rmsg, enum ck_result_ctx ctx);
-static void  rcvmsg_update_loc (RcvMsg *rmsg, const char *file, int line);
-static RcvMsg *rcvmsg_create (void);
-void rcvmsg_free (RcvMsg *rmsg);
-
-typedef int  (*pfun)  (char **, CheckMsg *);
+static void pack_int(char **buf, int val);
+static int upack_int(char **buf);
+static void pack_str(char **buf, const char *str);
+static char *upack_str(char **buf);
+
+static int pack_ctx(char **buf, CtxMsg * cmsg);
+static int pack_loc(char **buf, LocMsg * lmsg);
+static int pack_fail(char **buf, FailMsg * fmsg);
+static int pack_duration(char **buf, DurationMsg * fmsg);
+static void upack_ctx(char **buf, CtxMsg * cmsg);
+static void upack_loc(char **buf, LocMsg * lmsg);
+static void upack_fail(char **buf, FailMsg * fmsg);
+static void upack_duration(char **buf, DurationMsg * fmsg);
+
+static void check_type(int type, const char *file, int line);
+static enum ck_msg_type upack_type(char **buf);
+static void pack_type(char **buf, enum ck_msg_type type);
+
+static int read_buf(FILE * fdes, int size, char *buf);
+static int get_result(char *buf, RcvMsg * rmsg);
+static void rcvmsg_update_ctx(RcvMsg * rmsg, enum ck_result_ctx ctx);
+static void rcvmsg_update_loc(RcvMsg * rmsg, const char *file, int line);
+static RcvMsg *rcvmsg_create(void);
+void rcvmsg_free(RcvMsg * rmsg);
+
+typedef int (*pfun) (char **, CheckMsg *);
 typedef void (*upfun) (char **, CheckMsg *);
 
-static pfun pftab [] = {
-  (pfun) pack_ctx,
-  (pfun) pack_fail,
-  (pfun) pack_loc,
-  (pfun) pack_duration
+static pfun pftab[] = {
+    (pfun) pack_ctx,
+    (pfun) pack_fail,
+    (pfun) pack_loc,
+    (pfun) pack_duration
 };
 
-static upfun upftab [] = {
-  (upfun) upack_ctx,
-  (upfun) upack_fail,
-  (upfun) upack_loc,
-  (upfun) upack_duration
+static upfun upftab[] = {
+    (upfun) upack_ctx,
+    (upfun) upack_fail,
+    (upfun) upack_loc,
+    (upfun) upack_duration
 };
 
-int pack (enum ck_msg_type type, char **buf, CheckMsg *msg)
+int pack(enum ck_msg_type type, char **buf, CheckMsg * msg)
 {
-  if (buf == NULL)
-    return -1;
-  if (msg == NULL)
-    return 0;
+    if(buf == NULL)
+        return -1;
+    if(msg == NULL)
+        return 0;
 
-  check_type (type, __FILE__, __LINE__);
+    check_type(type, __FILE__, __LINE__);
 
-  return pftab[type] (buf, msg);
+    return pftab[type] (buf, msg);
 }
 
-int upack (char *buf, CheckMsg *msg, enum ck_msg_type *type)
+int upack(char *buf, CheckMsg * msg, enum ck_msg_type *type)
 {
-  char *obuf;
+    char *obuf;
 
-  if (buf == NULL)
-    return -1;
+    if(buf == NULL)
+        return -1;
 
-  obuf = buf;
+    obuf = buf;
 
-  *type = upack_type (&buf);
+    *type = upack_type(&buf);
 
-  check_type (*type, __FILE__, __LINE__);
-  
-  upftab[*type] (&buf, msg);
+    check_type(*type, __FILE__, __LINE__);
 
-  return buf - obuf;
+    upftab[*type] (&buf, msg);
+
+    return buf - obuf;
 }
 
-static void pack_int (char **buf, int val)
+static void pack_int(char **buf, int val)
 {
-  unsigned char *ubuf = (unsigned char *) *buf;
-  ck_uint32 uval = val;
+    unsigned char *ubuf = (unsigned char *)*buf;
+    ck_uint32 uval = val;
 
-  ubuf[0] = (unsigned char)((uval >> 24) & 0xFF);
-  ubuf[1] = (unsigned char)((uval >> 16) & 0xFF);
-  ubuf[2] = (unsigned char)((uval >> 8)  & 0xFF);
-  ubuf[3] = (unsigned char)(uval & 0xFF);
+    ubuf[0] = (unsigned char)((uval >> 24) & 0xFF);
+    ubuf[1] = (unsigned char)((uval >> 16) & 0xFF);
+    ubuf[2] = (unsigned char)((uval >> 8) & 0xFF);
+    ubuf[3] = (unsigned char)(uval & 0xFF);
 
-  *buf += 4;
+    *buf += 4;
 }
 
-static int upack_int (char **buf)
+static int upack_int(char **buf)
 {
-  unsigned char *ubuf = (unsigned char *) *buf;
-  ck_uint32 uval;
+    unsigned char *ubuf = (unsigned char *)*buf;
+    ck_uint32 uval;
 
-  uval = (ck_uint32)((ubuf[0] << 24) | (ubuf[1] << 16) | (ubuf[2] << 8) | ubuf[3]);
+    uval =
+        (ck_uint32) ((ubuf[0] << 24) | (ubuf[1] << 16) | (ubuf[2] << 8) |
+                     ubuf[3]);
 
-  *buf += 4;
+    *buf += 4;
 
-  return (int) uval;
+    return (int)uval;
 }
 
-static void pack_str (char **buf, const char *val)
+static void pack_str(char **buf, const char *val)
 {
-  int strsz;
+    int strsz;
 
-  if (val == NULL)
-    strsz = 0;
-  else
-    strsz = strlen (val);
+    if(val == NULL)
+        strsz = 0;
+    else
+        strsz = strlen(val);
 
-  pack_int (buf, strsz);  
+    pack_int(buf, strsz);
 
-  if (strsz > 0) {
-    memcpy (*buf, val, strsz);
-    *buf += strsz;
-  } 
+    if(strsz > 0)
+    {
+        memcpy(*buf, val, strsz);
+        *buf += strsz;
+    }
 }
 
-static char *upack_str (char **buf)
+static char *upack_str(char **buf)
 {
-  char *val;
-  int strsz;
-
-  strsz = upack_int (buf);
-
-  if (strsz > 0) {
-    val = emalloc (strsz + 1);
-    memcpy (val, *buf, strsz);
-    val[strsz] = 0;
-    *buf += strsz;
-  } else {
-    val = emalloc (1);
-    *val = 0;
-  }
-
-  return val;
+    char *val;
+    int strsz;
+
+    strsz = upack_int(buf);
+
+    if(strsz > 0)
+    {
+        val = emalloc(strsz + 1);
+        memcpy(val, *buf, strsz);
+        val[strsz] = 0;
+        *buf += strsz;
+    }
+    else
+    {
+        val = emalloc(1);
+        *val = 0;
+    }
+
+    return val;
 }
 
-static void pack_type (char **buf, enum ck_msg_type type)
+static void pack_type(char **buf, enum ck_msg_type type)
 {
-  pack_int (buf, (int) type);
+    pack_int(buf, (int)type);
 }
 
-static enum ck_msg_type upack_type (char **buf)
+static enum ck_msg_type upack_type(char **buf)
 {
-  return (enum ck_msg_type) upack_int (buf);
+    return (enum ck_msg_type)upack_int(buf);
 }
 
-  
-static int pack_ctx (char **buf, CtxMsg *cmsg)
+
+static int pack_ctx(char **buf, CtxMsg * cmsg)
 {
-  char *ptr;
-  int len;
+    char *ptr;
+    int len;
+
+    len = 4 + 4;
+    *buf = ptr = emalloc(len);
 
-  len = 4 + 4;
-  *buf = ptr = emalloc (len);
-  
-  pack_type (&ptr, CK_MSG_CTX);
-  pack_int (&ptr, (int) cmsg->ctx);
+    pack_type(&ptr, CK_MSG_CTX);
+    pack_int(&ptr, (int)cmsg->ctx);
 
-  return len;
+    return len;
 }
 
-static void upack_ctx (char **buf, CtxMsg *cmsg)
+static void upack_ctx(char **buf, CtxMsg * cmsg)
 {
-  cmsg->ctx = upack_int (buf);
+    cmsg->ctx = upack_int(buf);
 }
 
-static int pack_duration (char **buf, DurationMsg *cmsg)
+static int pack_duration(char **buf, DurationMsg * cmsg)
 {
-  char *ptr;
-  int len;
+    char *ptr;
+    int len;
 
-  len = 4 + 4;
-  *buf = ptr = emalloc (len);
+    len = 4 + 4;
+    *buf = ptr = emalloc(len);
 
-  pack_type (&ptr, CK_MSG_DURATION);
-  pack_int (&ptr, cmsg->duration);
+    pack_type(&ptr, CK_MSG_DURATION);
+    pack_int(&ptr, cmsg->duration);
 
-  return len;
+    return len;
 }
 
-static void upack_duration (char **buf, DurationMsg *cmsg)
+static void upack_duration(char **buf, DurationMsg * cmsg)
 {
-  cmsg->duration = upack_int (buf);
+    cmsg->duration = upack_int(buf);
 }
 
-static int pack_loc (char **buf, LocMsg *lmsg)
+static int pack_loc(char **buf, LocMsg * lmsg)
 {
-  char *ptr;
-  int len;
+    char *ptr;
+    int len;
 
-  len = 4 + 4 + (lmsg->file ? strlen (lmsg->file) : 0) + 4;
-  *buf = ptr = emalloc (len);
+    len = 4 + 4 + (lmsg->file ? strlen(lmsg->file) : 0) + 4;
+    *buf = ptr = emalloc(len);
 
-  pack_type (&ptr, CK_MSG_LOC);
-  pack_str (&ptr, lmsg->file);
-  pack_int (&ptr, lmsg->line);
+    pack_type(&ptr, CK_MSG_LOC);
+    pack_str(&ptr, lmsg->file);
+    pack_int(&ptr, lmsg->line);
 
-  return len;
+    return len;
 }
 
-static void upack_loc (char **buf, LocMsg *lmsg)
+static void upack_loc(char **buf, LocMsg * lmsg)
 {
-  lmsg->file = upack_str (buf);
-  lmsg->line = upack_int (buf);
+    lmsg->file = upack_str(buf);
+    lmsg->line = upack_int(buf);
 }
 
-static int pack_fail (char **buf, FailMsg *fmsg)
+static int pack_fail(char **buf, FailMsg * fmsg)
 {
-  char *ptr;
-  int len;
+    char *ptr;
+    int len;
 
-  len = 4 + 4 + (fmsg->msg ? strlen (fmsg->msg) : 0);
-  *buf = ptr = emalloc (len);
+    len = 4 + 4 + (fmsg->msg ? strlen(fmsg->msg) : 0);
+    *buf = ptr = emalloc(len);
 
-  pack_type (&ptr, CK_MSG_FAIL);
-  pack_str (&ptr, fmsg->msg);
+    pack_type(&ptr, CK_MSG_FAIL);
+    pack_str(&ptr, fmsg->msg);
 
-  return len;
+    return len;
 }
 
-static void upack_fail (char **buf, FailMsg *fmsg)
+static void upack_fail(char **buf, FailMsg * fmsg)
 {
-  fmsg->msg = upack_str (buf);
+    fmsg->msg = upack_str(buf);
 }
 
-static void check_type (int type, const char *file, int line)
+static void check_type(int type, const char *file, int line)
 {
-  if (type < 0 || type >= CK_MSG_LAST)
-    eprintf ("Bad message type arg %d", file, line, type);
+    if(type < 0 || type >= CK_MSG_LAST)
+        eprintf("Bad message type arg %d", file, line, type);
 }
 
 #ifdef HAVE_PTHREAD
 static pthread_mutex_t ck_mutex_lock = PTHREAD_MUTEX_INITIALIZER;
-static void ppack_cleanup( void *mutex )
+static void ppack_cleanup(void *mutex)
 {
-  pthread_mutex_unlock(mutex);
+    pthread_mutex_unlock(mutex);
 }
 #endif
 
-void ppack (FILE* fdes, enum ck_msg_type type, CheckMsg *msg)
+void ppack(FILE * fdes, enum ck_msg_type type, CheckMsg * msg)
 {
-  char *buf;
-  int n;
-  ssize_t r;
-
-  n = pack (type, &buf, msg);
-  /* Keep it on the safe side to not send too much data. */
-  if (n > (CK_MAX_MSG_SIZE / 2))
-    eprintf("Message string too long", __FILE__, __LINE__ - 2);
-
-  pthread_cleanup_push( ppack_cleanup, &ck_mutex_lock );
-  pthread_mutex_lock(&ck_mutex_lock);
-  r = fwrite(buf, 1, n, fdes);
-  fflush(fdes);
-  pthread_mutex_unlock(&ck_mutex_lock);
-  pthread_cleanup_pop(0);
-  if (r != n)
-    eprintf ("Error in call to fwrite:", __FILE__, __LINE__ - 2);
-
-  free (buf);
+    char *buf;
+    int n;
+    ssize_t r;
+
+    n = pack(type, &buf, msg);
+    /* Keep it on the safe side to not send too much data. */
+    if(n > (CK_MAX_MSG_SIZE / 2))
+        eprintf("Message string too long", __FILE__, __LINE__ - 2);
+
+    pthread_cleanup_push(ppack_cleanup, &ck_mutex_lock);
+    pthread_mutex_lock(&ck_mutex_lock);
+    r = fwrite(buf, 1, n, fdes);
+    fflush(fdes);
+    pthread_mutex_unlock(&ck_mutex_lock);
+    pthread_cleanup_pop(0);
+    if(r != n)
+        eprintf("Error in call to fwrite:", __FILE__, __LINE__ - 2);
+
+    free(buf);
 }
 
-static int read_buf (FILE* fdes, int size, char *buf)
+static int read_buf(FILE * fdes, int size, char *buf)
 {
-  int n;
-  n = fread(buf, 1, size, fdes);
+    int n;
 
-  if (ferror(fdes))
-  {
-    eprintf ("Error in call to fread:", __FILE__, __LINE__ - 4);
-  }
+    n = fread(buf, 1, size, fdes);
 
-  return n;
-}    
+    if(ferror(fdes))
+    {
+        eprintf("Error in call to fread:", __FILE__, __LINE__ - 4);
+    }
 
-static int get_result (char *buf, RcvMsg *rmsg)
+    return n;
+}
+
+static int get_result(char *buf, RcvMsg * rmsg)
 {
-  enum ck_msg_type type;
-  CheckMsg msg;
-  int n;
-
-  n = upack (buf, &msg, &type);
-  if (n == -1)
-    eprintf ("Error in call to upack", __FILE__, __LINE__ - 2);
-  
-  if (type == CK_MSG_CTX) {
-    CtxMsg *cmsg = (CtxMsg *) &msg;
-    rcvmsg_update_ctx (rmsg, cmsg->ctx);
-  } else if (type == CK_MSG_LOC) {
-    LocMsg *lmsg = (LocMsg *) &msg;
-    if (rmsg->failctx == CK_CTX_INVALID)
+    enum ck_msg_type type;
+    CheckMsg msg;
+    int n;
+
+    n = upack(buf, &msg, &type);
+    if(n == -1)
+        eprintf("Error in call to upack", __FILE__, __LINE__ - 2);
+
+    if(type == CK_MSG_CTX)
+    {
+        CtxMsg *cmsg = (CtxMsg *) & msg;
+
+        rcvmsg_update_ctx(rmsg, cmsg->ctx);
+    }
+    else if(type == CK_MSG_LOC)
     {
-      rcvmsg_update_loc (rmsg, lmsg->file, lmsg->line);
+        LocMsg *lmsg = (LocMsg *) & msg;
+
+        if(rmsg->failctx == CK_CTX_INVALID)
+        {
+            rcvmsg_update_loc(rmsg, lmsg->file, lmsg->line);
+        }
+        free(lmsg->file);
     }
-    free (lmsg->file);
-  } else if (type == CK_MSG_FAIL) {      
-    FailMsg *fmsg = (FailMsg *) &msg;
-    if (rmsg->msg == NULL)
+    else if(type == CK_MSG_FAIL)
     {
-      rmsg->msg = strdup(fmsg->msg);
-      rmsg->failctx = rmsg->lastctx;
+        FailMsg *fmsg = (FailMsg *) & msg;
+
+        if(rmsg->msg == NULL)
+        {
+            rmsg->msg = strdup(fmsg->msg);
+            rmsg->failctx = rmsg->lastctx;
+        }
+        else
+        {
+            /* Skip subsequent failure messages, only happens for CK_NOFORK */
+        }
+        free(fmsg->msg);
     }
-    else
+    else if(type == CK_MSG_DURATION)
     {
-      /* Skip subsequent failure messages, only happens for CK_NOFORK */
+        DurationMsg *cmsg = (DurationMsg *) & msg;
+
+        rmsg->duration = cmsg->duration;
     }
-    free (fmsg->msg);
-  } else if (type == CK_MSG_DURATION) {
-    DurationMsg *cmsg = (DurationMsg *) &msg;
-    rmsg->duration = cmsg->duration;
-  } else
-    check_type (type, __FILE__, __LINE__);
-
-  return n;
+    else
+        check_type(type, __FILE__, __LINE__);
+
+    return n;
 }
 
-static void reset_rcv_test (RcvMsg *rmsg)
+static void reset_rcv_test(RcvMsg * rmsg)
 {
-  rmsg->test_line = -1;
-  rmsg->test_file = NULL;
+    rmsg->test_line = -1;
+    rmsg->test_file = NULL;
 }
 
-static void reset_rcv_fixture (RcvMsg *rmsg)
+static void reset_rcv_fixture(RcvMsg * rmsg)
 {
-  rmsg->fixture_line = -1;
-  rmsg->fixture_file = NULL;
+    rmsg->fixture_line = -1;
+    rmsg->fixture_file = NULL;
 }
 
-static RcvMsg *rcvmsg_create (void)
+static RcvMsg *rcvmsg_create(void)
 {
-  RcvMsg *rmsg;
-
-  rmsg = emalloc (sizeof (RcvMsg));
-  rmsg->lastctx = CK_CTX_INVALID;
-  rmsg->failctx = CK_CTX_INVALID;
-  rmsg->msg = NULL;
-  rmsg->duration = -1;
-  reset_rcv_test (rmsg);
-  reset_rcv_fixture (rmsg);
-  return rmsg;
+    RcvMsg *rmsg;
+
+    rmsg = emalloc(sizeof(RcvMsg));
+    rmsg->lastctx = CK_CTX_INVALID;
+    rmsg->failctx = CK_CTX_INVALID;
+    rmsg->msg = NULL;
+    rmsg->duration = -1;
+    reset_rcv_test(rmsg);
+    reset_rcv_fixture(rmsg);
+    return rmsg;
 }
 
-void rcvmsg_free (RcvMsg *rmsg)
+void rcvmsg_free(RcvMsg * rmsg)
 {
-  free(rmsg->fixture_file);
-  free(rmsg->test_file);
-  free(rmsg->msg);
-  free(rmsg);
+    free(rmsg->fixture_file);
+    free(rmsg->test_file);
+    free(rmsg->msg);
+    free(rmsg);
 }
 
-static void rcvmsg_update_ctx (RcvMsg *rmsg, enum ck_result_ctx ctx)
+static void rcvmsg_update_ctx(RcvMsg * rmsg, enum ck_result_ctx ctx)
 {
-  if (rmsg->lastctx != CK_CTX_INVALID)
-  {
-    free(rmsg->fixture_file);
-    reset_rcv_fixture (rmsg);
-  }
-  rmsg->lastctx = ctx;
+    if(rmsg->lastctx != CK_CTX_INVALID)
+    {
+        free(rmsg->fixture_file);
+        reset_rcv_fixture(rmsg);
+    }
+    rmsg->lastctx = ctx;
 }
 
-static void rcvmsg_update_loc (RcvMsg *rmsg, const char *file, int line)
+static void rcvmsg_update_loc(RcvMsg * rmsg, const char *file, int line)
 {
-  if (rmsg->lastctx == CK_CTX_TEST) {
-    free(rmsg->test_file);
-    rmsg->test_line = line;
-    rmsg->test_file = strdup(file);
-  } else {
-    free(rmsg->fixture_file);
-    rmsg->fixture_line = line;
-    rmsg->fixture_file = strdup(file);
-  }
+    if(rmsg->lastctx == CK_CTX_TEST)
+    {
+        free(rmsg->test_file);
+        rmsg->test_line = line;
+        rmsg->test_file = strdup(file);
+    }
+    else
+    {
+        free(rmsg->fixture_file);
+        rmsg->fixture_line = line;
+        rmsg->fixture_file = strdup(file);
+    }
 }
-  
-RcvMsg *punpack (FILE* fdes)
+
+RcvMsg *punpack(FILE * fdes)
 {
-  int nread, nparse, n;
-  char *buf;
-  RcvMsg *rmsg;
-
-  rmsg = rcvmsg_create ();
-  
-  /* Allcate a buffer */
-  buf = emalloc(CK_MAX_MSG_SIZE);
-  /* Fill the buffer from the file */
-  nread = read_buf (fdes, CK_MAX_MSG_SIZE, buf);
-  nparse = nread;
-  /* While not all parsed */
-  while (nparse > 0) {
-    /* Parse one message */
-    n = get_result (buf, rmsg);
-    nparse -= n;
-    /* Move remaining data in buffer to the beginning */
-    memmove(buf, buf + n, nparse);
-    /* If EOF has not been seen */
-    if (nread > 0) {
-      /* Read more data into empty space at end of the buffer */
-      nread = read_buf (fdes, n, buf + nparse);
-      nparse += nread;
+    int nread, nparse, n;
+    char *buf;
+    RcvMsg *rmsg;
+
+    rmsg = rcvmsg_create();
+
+    /* Allcate a buffer */
+    buf = emalloc(CK_MAX_MSG_SIZE);
+    /* Fill the buffer from the file */
+    nread = read_buf(fdes, CK_MAX_MSG_SIZE, buf);
+    nparse = nread;
+    /* While not all parsed */
+    while(nparse > 0)
+    {
+        /* Parse one message */
+        n = get_result(buf, rmsg);
+        nparse -= n;
+        /* Move remaining data in buffer to the beginning */
+        memmove(buf, buf + n, nparse);
+        /* If EOF has not been seen */
+        if(nread > 0)
+        {
+            /* Read more data into empty space at end of the buffer */
+            nread = read_buf(fdes, n, buf + nparse);
+            nparse += nread;
+        }
     }
-  }
-  free (buf);
+    free(buf);
 
-  if (rmsg->lastctx == CK_CTX_INVALID) {
-    free (rmsg);
-    rmsg = NULL;
-  }
+    if(rmsg->lastctx == CK_CTX_INVALID)
+    {
+        free(rmsg);
+        rmsg = NULL;
+    }
 
-  return rmsg;
+    return rmsg;
 }
index a0eb294123e57a1fdbf887150c46675d59e093e2..372ef73223255965bc3ffbdd95fd3ecb48efea3a 100644 (file)
 #define CHECK_PACK_H
 
 
-enum ck_msg_type {
-  CK_MSG_CTX,
-  CK_MSG_FAIL,
-  CK_MSG_LOC,
-  CK_MSG_DURATION,
-  CK_MSG_LAST
+enum ck_msg_type
+{
+    CK_MSG_CTX,
+    CK_MSG_FAIL,
+    CK_MSG_LOC,
+    CK_MSG_DURATION,
+    CK_MSG_LAST
 };
 
 typedef struct CtxMsg
 {
-  enum ck_result_ctx ctx;
+    enum ck_result_ctx ctx;
 } CtxMsg;
 
-typedef struct LocMsg 
+typedef struct LocMsg
 {
-  int line;
-  char *file;
+    int line;
+    char *file;
 } LocMsg;
 
 typedef struct FailMsg
 {
-  char *msg;
+    char *msg;
 } FailMsg;
 
 typedef struct DurationMsg
 {
-  int duration;
+    int duration;
 } DurationMsg;
 
 typedef union
 {
-  CtxMsg  ctx_msg;
-  FailMsg fail_msg;
-  LocMsg  loc_msg;
+    CtxMsg ctx_msg;
+    FailMsg fail_msg;
+    LocMsg loc_msg;
 } CheckMsg;
 
 typedef struct RcvMsg
 {
-  enum ck_result_ctx lastctx;
-  enum ck_result_ctx failctx;
-  char *fixture_file;
-  int fixture_line;
-  char *test_file;
-  int test_line;
-  char *msg;
-  int duration;
+    enum ck_result_ctx lastctx;
+    enum ck_result_ctx failctx;
+    char *fixture_file;
+    int fixture_line;
+    char *test_file;
+    int test_line;
+    char *msg;
+    int duration;
 } RcvMsg;
 
-void rcvmsg_free (RcvMsg *rmsg);
+void rcvmsg_free(RcvMsg * rmsg);
+
 
-  
-int pack (enum ck_msg_type type, char **buf, CheckMsg *msg);
-int upack (char *buf, CheckMsg *msg, enum ck_msg_type *type);
+int pack(enum ck_msg_type type, char **buf, CheckMsg * msg);
+int upack(char *buf, CheckMsg * msg, enum ck_msg_type *type);
 
-void ppack (FILE* fdes, enum ck_msg_type type, CheckMsg *msg);
-RcvMsg *punpack (FILE* fdes);
+void ppack(FILE * fdes, enum ck_msg_type type, CheckMsg * msg);
+RcvMsg *punpack(FILE * fdes);
 
 #endif /*CHECK_PACK_H */
index 83f51e90ca9c34179bda33903d326e246c289d5d..1a403db3498d45656a006d3772338d42de75f752 100644 (file)
 #include "check_str.h"
 #include "check_print.h"
 
-static void srunner_fprint_summary (FILE *file, SRunner *sr,
-                                   enum print_output print_mode);
-static void srunner_fprint_results (FILE *file, SRunner *sr,
-                                   enum print_output print_mode);
+static void srunner_fprint_summary(FILE * file, SRunner * sr,
+                                   enum print_output print_mode);
+static void srunner_fprint_results(FILE * file, SRunner * sr,
+                                   enum print_output print_mode);
 
 
-void srunner_print (SRunner *sr, enum print_output print_mode)
+void srunner_print(SRunner * sr, enum print_output print_mode)
 {
-  srunner_fprint (stdout, sr, print_mode);
+    srunner_fprint(stdout, sr, print_mode);
 }
 
-void srunner_fprint (FILE *file, SRunner *sr, enum print_output print_mode)
+void srunner_fprint(FILE * file, SRunner * sr, enum print_output print_mode)
 {
-  if (print_mode == CK_ENV) {
-    print_mode = get_env_printmode();
-  }
+    if(print_mode == CK_ENV)
+    {
+        print_mode = get_env_printmode();
+    }
 
-  srunner_fprint_summary (file, sr, print_mode);
-  srunner_fprint_results (file, sr, print_mode);
+    srunner_fprint_summary(file, sr, print_mode);
+    srunner_fprint_results(file, sr, print_mode);
 }
 
-static void srunner_fprint_summary (FILE *file, SRunner *sr,
-                                   enum print_output print_mode)
+static void srunner_fprint_summary(FILE * file, SRunner * sr,
+                                   enum print_output print_mode)
 {
 #if ENABLE_SUBUNIT
-  if (print_mode == CK_SUBUNIT)
-      return;
+    if(print_mode == CK_SUBUNIT)
+        return;
 #endif
 
-  if (print_mode >= CK_MINIMAL) {
-    char *str;
+    if(print_mode >= CK_MINIMAL)
+    {
+        char *str;
 
-    str = sr_stat_str (sr);
-    fprintf (file, "%s\n", str);
-    free(str);
-  }
-  return;
+        str = sr_stat_str(sr);
+        fprintf(file, "%s\n", str);
+        free(str);
+    }
+    return;
 }
 
-static void srunner_fprint_results (FILE *file, SRunner *sr,
-                                   enum print_output print_mode)
+static void srunner_fprint_results(FILE * file, SRunner * sr,
+                                   enum print_output print_mode)
 {
-  List *resultlst;
+    List *resultlst;
 
 #if ENABLE_SUBUNIT
-  if (print_mode == CK_SUBUNIT)
-      return;
+    if(print_mode == CK_SUBUNIT)
+        return;
 #endif
-  
-  resultlst = sr->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;
+
+    resultlst = sr->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;
 }
 
-void fprint_xml_esc(FILE *file, const char *str)
+void fprint_xml_esc(FILE * file, const char *str)
 {
-  for (; *str != '\0'; str++) {
-
-    switch (*str) {
-
-    /* handle special characters that must be escaped */
-    case '"':
-      fputs("&quot;", file);
-      break;
-    case '\'':
-      fputs("&apos;", file);
-      break;
-    case '<':
-      fputs("&lt;", file);
-      break;
-    case '>':
-      fputs("&gt;", file);
-      break;
-    case '&':
-      fputs("&amp;", file);
-      break;
-
-    /* regular characters, print as is */
-    default:
-      fputc(*str, file);
-      break;
+    for(; *str != '\0'; str++)
+    {
+
+        switch (*str)
+        {
+
+                /* handle special characters that must be escaped */
+            case '"':
+                fputs("&quot;", file);
+                break;
+            case '\'':
+                fputs("&apos;", file);
+                break;
+            case '<':
+                fputs("&lt;", file);
+                break;
+            case '>':
+                fputs("&gt;", file);
+                break;
+            case '&':
+                fputs("&amp;", file);
+                break;
+
+                /* regular characters, print as is */
+            default:
+                fputc(*str, file);
+                break;
+        }
     }
-  }
 }
 
-void tr_fprint (FILE *file, TestResult *tr, enum print_output print_mode)
+void tr_fprint(FILE * file, TestResult * tr, enum print_output print_mode)
 {
-  if (print_mode == CK_ENV) {
-    print_mode = get_env_printmode();
-  }
-
-  if ((print_mode >= CK_VERBOSE && tr->rtype == CK_PASS) ||
-      (tr->rtype != CK_PASS && print_mode >= CK_NORMAL)) {
-    char *trstr = tr_str (tr);
-    fprintf (file,"%s\n", trstr);
-    free(trstr);
-  }
+    if(print_mode == CK_ENV)
+    {
+        print_mode = get_env_printmode();
+    }
+
+    if((print_mode >= CK_VERBOSE && tr->rtype == CK_PASS) ||
+       (tr->rtype != CK_PASS && print_mode >= CK_NORMAL))
+    {
+        char *trstr = tr_str(tr);
+
+        fprintf(file, "%s\n", trstr);
+        free(trstr);
+    }
 }
 
-void tr_xmlprint (FILE *file, TestResult *tr, enum print_output print_mode CK_ATTRIBUTE_UNUSED)
+void tr_xmlprint(FILE * file, TestResult * tr,
+                 enum print_output print_mode CK_ATTRIBUTE_UNUSED)
 {
-  char result[10];
-  char *path_name = NULL;
-  char *file_name = NULL;
-  char *slash = NULL;
-
-  switch (tr->rtype) {
-  case CK_PASS:
-    snprintf(result, sizeof(result), "%s", "success");
-    break;
-  case CK_FAILURE:
-    snprintf(result, sizeof(result), "%s", "failure");
-    break;
-  case CK_ERROR:
-    snprintf(result, sizeof(result), "%s", "error");
-    break;
-  case CK_TEST_RESULT_INVALID:
-  default:
-    abort ();
-    break;
-  }
-
-  if (tr->file) {
-    slash = strrchr(tr->file, '/');
-    if(slash == NULL)
+    char result[10];
+    char *path_name = NULL;
+    char *file_name = NULL;
+    char *slash = NULL;
+
+    switch (tr->rtype)
     {
-        slash = strrchr(tr->file, '\\');
+        case CK_PASS:
+            snprintf(result, sizeof(result), "%s", "success");
+            break;
+        case CK_FAILURE:
+            snprintf(result, sizeof(result), "%s", "failure");
+            break;
+        case CK_ERROR:
+            snprintf(result, sizeof(result), "%s", "error");
+            break;
+        case CK_TEST_RESULT_INVALID:
+        default:
+            abort();
+            break;
     }
 
-    if (slash == NULL) {
-      path_name = strdup(".");
-      file_name = tr->file;
-    } else {
-      path_name = strdup(tr->file);
-      path_name[slash - tr->file] = 0; /* Terminate the temporary string. */
-      file_name = slash + 1;
+    if(tr->file)
+    {
+        slash = strrchr(tr->file, '/');
+        if(slash == NULL)
+        {
+            slash = strrchr(tr->file, '\\');
+        }
+
+        if(slash == NULL)
+        {
+            path_name = strdup(".");
+            file_name = tr->file;
+        }
+        else
+        {
+            path_name = strdup(tr->file);
+            path_name[slash - tr->file] = 0;    /* Terminate the temporary string. */
+            file_name = slash + 1;
+        }
     }
-  } 
-    
-
-  fprintf(file, "    <test result=\"%s\">\n", result);
-  fprintf(file, "      <path>%s</path>\n", (path_name == NULL ? "" : path_name));
-  fprintf(file, "      <fn>%s:%d</fn>\n", (file_name == NULL ? "" : file_name), tr->line);
-  fprintf(file, "      <id>%s</id>\n", tr->tname);
-  fprintf(file, "      <iteration>%d</iteration>\n", tr->iter);
-  fprintf(file, "      <duration>%d.%06d</duration>\n",
-          tr->duration < 0 ? -1 : tr->duration / 1000000,
-          tr->duration < 0 ? 0 : tr->duration % 1000000);
-  fprintf(file, "      <description>");
-  fprint_xml_esc(file, tr->tcname);
-  fprintf(file,"</description>\n");
-  fprintf(file, "      <message>");
-  fprint_xml_esc(file, tr->msg);
-  fprintf(file,"</message>\n");
-  fprintf(file, "    </test>\n");
-  
-  free(path_name);
+
+
+    fprintf(file, "    <test result=\"%s\">\n", result);
+    fprintf(file, "      <path>%s</path>\n",
+            (path_name == NULL ? "" : path_name));
+    fprintf(file, "      <fn>%s:%d</fn>\n",
+            (file_name == NULL ? "" : file_name), tr->line);
+    fprintf(file, "      <id>%s</id>\n", tr->tname);
+    fprintf(file, "      <iteration>%d</iteration>\n", tr->iter);
+    fprintf(file, "      <duration>%d.%06d</duration>\n",
+            tr->duration < 0 ? -1 : tr->duration / 1000000,
+            tr->duration < 0 ? 0 : tr->duration % 1000000);
+    fprintf(file, "      <description>");
+    fprint_xml_esc(file, tr->tcname);
+    fprintf(file, "</description>\n");
+    fprintf(file, "      <message>");
+    fprint_xml_esc(file, tr->msg);
+    fprintf(file, "</message>\n");
+    fprintf(file, "    </test>\n");
+
+    free(path_name);
 }
 
-enum print_output get_env_printmode (void)
+enum print_output get_env_printmode(void)
 {
-  char *env = getenv ("CK_VERBOSITY");
-  if (env == NULL)
+    char *env = getenv("CK_VERBOSITY");
+
+    if(env == NULL)
+        return CK_NORMAL;
+    if(strcmp(env, "silent") == 0)
+        return CK_SILENT;
+    if(strcmp(env, "minimal") == 0)
+        return CK_MINIMAL;
+    if(strcmp(env, "verbose") == 0)
+        return CK_VERBOSE;
     return CK_NORMAL;
-  if (strcmp (env, "silent") == 0)
-    return CK_SILENT;
-  if (strcmp (env, "minimal") == 0)
-    return CK_MINIMAL;
-  if (strcmp (env, "verbose") == 0)
-    return CK_VERBOSE;
-  return CK_NORMAL;
 }
index f4ab08d7fad05fec6652f6d53bf4230910bd32ed..b7eebc85e8dd65d5d2aa7c8bae6ceae003a9a368 100644 (file)
 #define CHECK_PRINT_H
 
 /* escape XML special characters (" ' < > &) in str and print to file */
-void fprint_xml_esc(FILE *file, const char *str);
-void tr_fprint (FILE *file, TestResult *tr, enum print_output print_mode);
-void tr_xmlprint (FILE *file, TestResult *tr, enum print_output print_mode);
-void srunner_fprint (FILE *file, SRunner *sr, enum print_output print_mode);
-enum print_output get_env_printmode (void);
+void fprint_xml_esc(FILE * file, const char *str);
+void tr_fprint(FILE * file, TestResult * tr, enum print_output print_mode);
+void tr_xmlprint(FILE * file, TestResult * tr, enum print_output print_mode);
+void srunner_fprint(FILE * file, SRunner * sr, enum print_output print_mode);
+enum print_output get_env_printmode(void);
 
 
 #endif /* CHECK_PRINT_H */
index d6795c17c2e4c1365d7f9c1bd6b4b737993b9c94..39b692bf0655cd3750850673fa4cf008b2fbf5e6 100644 (file)
 #include "check_msg.h"
 #include "check_log.h"
 
-enum rinfo {
-  CK_R_SIG,
-  CK_R_PASS,
-  CK_R_EXIT,
-  CK_R_FAIL_TEST,
-  CK_R_FAIL_FIXTURE
+enum rinfo
+{
+    CK_R_SIG,
+    CK_R_PASS,
+    CK_R_EXIT,
+    CK_R_FAIL_TEST,
+    CK_R_FAIL_FIXTURE
 };
 
-enum tf_type {
-  CK_FORK_TEST,
-  CK_NOFORK_TEST,
-  CK_NOFORK_FIXTURE
+enum tf_type
+{
+    CK_FORK_TEST,
+    CK_NOFORK_TEST,
+    CK_NOFORK_FIXTURE
 };
 
 
 /* all functions are defined in the same order they are declared.
    functions that depend on forking are gathered all together.
    non-static functions are at the end of the file. */
-static void srunner_run_init (SRunner *sr, enum print_output print_mode);
-static void srunner_run_end (SRunner *sr, enum print_output print_mode);
-static void srunner_iterate_suites (SRunner *sr,
-                                    const char *sname, const char *tcname,
-                                   enum print_output print_mode);
-static void srunner_iterate_tcase_tfuns (SRunner *sr, TCase *tc);
-static void srunner_add_failure (SRunner *sr, TestResult *tf);
-static int srunner_run_unchecked_setup (SRunner *sr, TCase *tc);
-static TestResult * tcase_run_checked_setup (SRunner *sr, TCase *tc);
-static void srunner_run_teardown (List *l);
-static void srunner_run_unchecked_teardown (TCase *tc);
-static void tcase_run_checked_teardown (TCase *tc);
-static void srunner_run_tcase (SRunner *sr, TCase *tc);
-static TestResult *tcase_run_tfun_nofork (SRunner *sr, TCase *tc, TF *tf, int i);
-static TestResult *receive_result_info_nofork (const char *tcname,
-                                               const char *tname,
-                                               int iter,
-                                               int duration);
-static void set_nofork_info (TestResult *tr);
-static char *pass_msg (void);
+static void srunner_run_init(SRunner * sr, enum print_output print_mode);
+static void srunner_run_end(SRunner * sr, enum print_output print_mode);
+static void srunner_iterate_suites(SRunner * sr,
+                                   const char *sname, const char *tcname,
+                                   enum print_output print_mode);
+static void srunner_iterate_tcase_tfuns(SRunner * sr, TCase * tc);
+static void srunner_add_failure(SRunner * sr, TestResult * tf);
+static int srunner_run_unchecked_setup(SRunner * sr, TCase * tc);
+static TestResult *tcase_run_checked_setup(SRunner * sr, TCase * tc);
+static void srunner_run_teardown(List * l);
+static void srunner_run_unchecked_teardown(TCase * tc);
+static void tcase_run_checked_teardown(TCase * tc);
+static void srunner_run_tcase(SRunner * sr, TCase * tc);
+static TestResult *tcase_run_tfun_nofork(SRunner * sr, TCase * tc, TF * tf,
+                                         int i);
+static TestResult *receive_result_info_nofork(const char *tcname,
+                                              const char *tname, int iter,
+                                              int duration);
+static void set_nofork_info(TestResult * tr);
+static char *pass_msg(void);
 
 #if defined(HAVE_FORK) && HAVE_FORK==1
-static TestResult *tcase_run_tfun_fork (SRunner *sr, TCase *tc, TF *tf, int i);
-static TestResult *receive_result_info_fork (const char *tcname,
-                                             const char *tname,
-                                             int iter,
-                                            int status, int expected_signal,
-                                            signed char allowed_exit_value);
-static void set_fork_info (TestResult *tr, int status, int expected_signal,
-                          signed char allowed_exit_value);
-static char *signal_msg (int sig);
-static char *signal_error_msg (int signal_received, int signal_expected);
-static char *exit_msg (int exitstatus);
-static int waserror (int status, int expected_signal);
+static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tf,
+                                       int i);
+static TestResult *receive_result_info_fork(const char *tcname,
+                                            const char *tname, int iter,
+                                            int status, int expected_signal,
+                                            signed char allowed_exit_value);
+static void set_fork_info(TestResult * tr, int status, int expected_signal,
+                          signed char allowed_exit_value);
+static char *signal_msg(int sig);
+static char *signal_error_msg(int signal_received, int signal_expected);
+static char *exit_msg(int exitstatus);
+static int waserror(int status, int expected_signal);
 
 static int alarm_received;
 static pid_t group_pid;
 
 static void CK_ATTRIBUTE_UNUSED sig_handler(int sig_nr)
 {
-  switch (sig_nr) {
-   case SIGALRM:
-    alarm_received = 1;
-    killpg(group_pid, SIGKILL);
-    break;
-   default:
-    eprintf("Unhandled signal: %d", __FILE__, __LINE__, sig_nr);
-    break;
-  }
+    switch (sig_nr)
+    {
+        case SIGALRM:
+            alarm_received = 1;
+            killpg(group_pid, SIGKILL);
+            break;
+        default:
+            eprintf("Unhandled signal: %d", __FILE__, __LINE__, sig_nr);
+            break;
+    }
 }
 #endif /* HAVE_FORK */
 
 #define MSG_LEN 100
 
-static void srunner_run_init (SRunner *sr, enum print_output print_mode)
+static void srunner_run_init(SRunner * sr, enum print_output print_mode)
 {
-  set_fork_status(srunner_fork_status(sr));
-  setup_messaging();
-  srunner_init_logging (sr, print_mode);
-  log_srunner_start (sr);
+    set_fork_status(srunner_fork_status(sr));
+    setup_messaging();
+    srunner_init_logging(sr, print_mode);
+    log_srunner_start(sr);
 }
 
-static void srunner_run_end (SRunner *sr, enum print_output CK_ATTRIBUTE_UNUSED print_mode)
+static void srunner_run_end(SRunner * sr,
+                            enum print_output CK_ATTRIBUTE_UNUSED print_mode)
 {
-  log_srunner_end (sr);
-  srunner_end_logging (sr);
-  teardown_messaging();
-  set_fork_status(CK_FORK);  
+    log_srunner_end(sr);
+    srunner_end_logging(sr);
+    teardown_messaging();
+    set_fork_status(CK_FORK);
 }
 
-static void srunner_iterate_suites (SRunner *sr,
-                                    const char *sname, const char *tcname,
-                                   enum print_output CK_ATTRIBUTE_UNUSED print_mode)
-  
+static void srunner_iterate_suites(SRunner * sr,
+                                   const char *sname, const char *tcname,
+                                   enum print_output CK_ATTRIBUTE_UNUSED
+                                   print_mode)
 {
-  List *slst;
-  List *tcl;
-  TCase *tc;
+    List *slst;
+    List *tcl;
+    TCase *tc;
 
-  slst = sr->slst;
+    slst = sr->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))))
-      continue;
+    for(check_list_front(slst); !check_list_at_end(slst);
+        check_list_advance(slst))
+    {
+        Suite *s = check_list_val(slst);
 
-    log_suite_start (sr, s);
+        if(((sname != NULL) && (strcmp(sname, s->name) != 0))
+           || ((tcname != NULL) && (!suite_tcase(s, tcname))))
+            continue;
+
+        log_suite_start(sr, s);
+
+        tcl = s->tclst;
+
+        for(check_list_front(tcl); !check_list_at_end(tcl);
+            check_list_advance(tcl))
+        {
+            tc = check_list_val(tcl);
 
-    tcl = s->tclst;
-  
-    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;
+            }
 
-      if ((tcname != NULL) && (strcmp (tcname, tc->name) != 0)) {
-          continue;
+            srunner_run_tcase(sr, tc);
         }
 
-      srunner_run_tcase (sr, tc);
+        log_suite_end(sr, s);
     }
-    
-    log_suite_end (sr, s);
-  }
 }
 
-static void srunner_iterate_tcase_tfuns (SRunner *sr, TCase *tc)
+static void srunner_iterate_tcase_tfuns(SRunner * sr, TCase * tc)
 {
-  List *tfl;
-  TF *tfun;
-  TestResult *tr = NULL;
+    List *tfl;
+    TF *tfun;
+    TestResult *tr = NULL;
 
-  tfl = tc->tflst;
-  
-  for (check_list_front(tfl); !check_list_at_end (tfl); check_list_advance (tfl)) {
-    int i;
-    tfun = check_list_val (tfl);
+    tfl = tc->tflst;
 
-    for (i = tfun->loop_start; i < tfun->loop_end; i++)
+    for(check_list_front(tfl); !check_list_at_end(tfl);
+        check_list_advance(tfl))
     {
-      log_test_start (sr, tc, tfun);
-      switch (srunner_fork_status(sr)) {
-      case CK_FORK:
+        int i;
+
+        tfun = check_list_val(tfl);
+
+        for(i = tfun->loop_start; i < tfun->loop_end; i++)
+        {
+            log_test_start(sr, tc, tfun);
+            switch (srunner_fork_status(sr))
+            {
+                case CK_FORK:
 #if defined(HAVE_FORK) && HAVE_FORK==1
-        tr = tcase_run_tfun_fork (sr, tc, tfun, i);
+                    tr = tcase_run_tfun_fork(sr, tc, tfun, i);
 #else /* HAVE_FORK */
-        eprintf("This version does not support fork", __FILE__, __LINE__);
+                    eprintf("This version does not support fork", __FILE__,
+                            __LINE__);
 #endif /* HAVE_FORK */
-        break;
-      case CK_NOFORK:
-        tr = tcase_run_tfun_nofork (sr, tc, tfun, i);
-        break;
-      case CK_FORK_GETENV:
-      default:
-        eprintf("Bad fork status in SRunner", __FILE__, __LINE__);
-      }
-
-      if ( NULL != tr ) {
-        srunner_add_failure (sr, tr);
-        log_test_end(sr, tr);
-      }
+                    break;
+                case CK_NOFORK:
+                    tr = tcase_run_tfun_nofork(sr, tc, tfun, i);
+                    break;
+                case CK_FORK_GETENV:
+                default:
+                    eprintf("Bad fork status in SRunner", __FILE__, __LINE__);
+            }
+
+            if(NULL != tr)
+            {
+                srunner_add_failure(sr, tr);
+                log_test_end(sr, tr);
+            }
+        }
     }
-  }
-}  
-
-static void srunner_add_failure (SRunner *sr, TestResult *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++;
-  else if (tr->rtype == CK_ERROR)
-    sr->stats->n_errors++;
-  
 }
 
-static int srunner_run_unchecked_setup (SRunner *sr, TCase *tc)
+static void srunner_add_failure(SRunner * sr, TestResult * tr)
 {
-  TestResult *tr;
-  List *l;
-  Fixture *f;
-  int rval = 1;
+    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++;
+    else if(tr->rtype == CK_ERROR)
+        sr->stats->n_errors++;
 
-  set_fork_status(CK_NOFORK);
+}
+
+static int srunner_run_unchecked_setup(SRunner * sr, TCase * tc)
+{
+    TestResult *tr;
+    List *l;
+    Fixture *f;
+    int rval = 1;
 
-  l = tc->unch_sflst;
+    set_fork_status(CK_NOFORK);
 
-  for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) {
-    send_ctx_info(CK_CTX_SETUP);
-    f = check_list_val(l);
+    l = tc->unch_sflst;
 
-    if ( 0 == setjmp(error_jmp_buffer) ) {
-      f->fun();
-    }
+    for(check_list_front(l); !check_list_at_end(l); check_list_advance(l))
+    {
+        send_ctx_info(CK_CTX_SETUP);
+        f = check_list_val(l);
 
-    tr = receive_result_info_nofork (tc->name, "unchecked_setup", 0, -1);
+        if(0 == setjmp(error_jmp_buffer))
+        {
+            f->fun();
+        }
 
-    if (tr->rtype != CK_PASS) {
-      srunner_add_failure(sr, tr);
-      rval = 0;
-      break;
+        tr = receive_result_info_nofork(tc->name, "unchecked_setup", 0, -1);
+
+        if(tr->rtype != CK_PASS)
+        {
+            srunner_add_failure(sr, tr);
+            rval = 0;
+            break;
+        }
+        free(tr->file);
+        free(tr->msg);
+        free(tr);
     }
-    free(tr->file);
-    free(tr->msg);
-    free(tr);
-  } 
 
-  set_fork_status(srunner_fork_status(sr));
-  return rval;
+    set_fork_status(srunner_fork_status(sr));
+    return rval;
 }
 
-static TestResult * tcase_run_checked_setup (SRunner *sr, TCase *tc)
+static TestResult *tcase_run_checked_setup(SRunner * sr, TCase * tc)
 {
-  TestResult *tr = NULL;
-  List *l;
-  Fixture *f;
-  enum fork_status fstat = srunner_fork_status(sr);
+    TestResult *tr = NULL;
+    List *l;
+    Fixture *f;
+    enum fork_status fstat = srunner_fork_status(sr);
 
-  l = tc->ch_sflst;
-  if (fstat == CK_FORK) {
-    send_ctx_info(CK_CTX_SETUP);
-  }
+    l = tc->ch_sflst;
+    if(fstat == CK_FORK)
+    {
+        send_ctx_info(CK_CTX_SETUP);
+    }
 
-  for (check_list_front(l); !check_list_at_end(l); check_list_advance(l)) {
-    f = check_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);
+        if(fstat == CK_NOFORK)
+        {
+            send_ctx_info(CK_CTX_SETUP);
 
-      if ( 0 == setjmp(error_jmp_buffer) ) {
-        f->fun();
-      }
-    } else {
-      f->fun();
-    }
+            if(0 == setjmp(error_jmp_buffer))
+            {
+                f->fun();
+            }
+        }
+        else
+        {
+            f->fun();
+        }
 
-    /* Stop the setup and return the failure if nofork mode. */
-    if (fstat == CK_NOFORK) {
-      tr = receive_result_info_nofork (tc->name, "checked_setup", 0, -1);
-      if (tr->rtype != CK_PASS) {
-        break;
-      }
-
-      free(tr->file);
-      free(tr->msg);
-      free(tr);
-      tr = NULL;
+        /* Stop the setup and return the failure if nofork mode. */
+        if(fstat == CK_NOFORK)
+        {
+            tr = receive_result_info_nofork(tc->name, "checked_setup", 0, -1);
+            if(tr->rtype != CK_PASS)
+            {
+                break;
+            }
+
+            free(tr->file);
+            free(tr->msg);
+            free(tr);
+            tr = NULL;
+        }
     }
-  }
 
-  return tr;
+    return tr;
 }
 
-static void srunner_run_teardown (List *l)
+static void srunner_run_teardown(List * l)
 {
-  Fixture *f;
-  
-  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 ();
-  }
+    Fixture *f;
+
+    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();
+    }
 }
 
-static void srunner_run_unchecked_teardown (TCase *tc)
+static void srunner_run_unchecked_teardown(TCase * tc)
 {
-  srunner_run_teardown(tc->unch_tflst);
+    srunner_run_teardown(tc->unch_tflst);
 }
 
-static void tcase_run_checked_teardown (TCase *tc)
+static void tcase_run_checked_teardown(TCase * tc)
 {
-  srunner_run_teardown(tc->ch_tflst);
+    srunner_run_teardown(tc->ch_tflst);
 }
 
-static void srunner_run_tcase (SRunner *sr, TCase *tc)
+static void srunner_run_tcase(SRunner * sr, TCase * tc)
 {
-  if (srunner_run_unchecked_setup(sr,tc)) {
-    srunner_iterate_tcase_tfuns(sr,tc);
-    srunner_run_unchecked_teardown(tc);
-  }
+    if(srunner_run_unchecked_setup(sr, tc))
+    {
+        srunner_iterate_tcase_tfuns(sr, tc);
+        srunner_run_unchecked_teardown(tc);
+    }
 }
 
-static TestResult *tcase_run_tfun_nofork (SRunner *sr, TCase *tc, TF *tfun, int i)
+static TestResult *tcase_run_tfun_nofork(SRunner * sr, TCase * tc, TF * tfun,
+                                         int i)
 {
-  TestResult *tr;
-  struct timespec ts_start={0,0}, ts_end={0,0};
-  
-  tr = tcase_run_checked_setup(sr, tc);
-  if (tr == NULL) {
-    clock_gettime(check_get_clockid(), &ts_start);
-    if ( 0 == setjmp(error_jmp_buffer) ) {
-      tfun->fn(i);
+    TestResult *tr;
+    struct timespec ts_start = { 0, 0 }, ts_end =
+    {
+    0, 0};
+
+    tr = tcase_run_checked_setup(sr, tc);
+    if(tr == NULL)
+    {
+        clock_gettime(check_get_clockid(), &ts_start);
+        if(0 == setjmp(error_jmp_buffer))
+        {
+            tfun->fn(i);
+        }
+        clock_gettime(check_get_clockid(), &ts_end);
+        tcase_run_checked_teardown(tc);
+        return receive_result_info_nofork(tc->name, tfun->name, i,
+                                          DIFF_IN_USEC(ts_start, ts_end));
     }
-    clock_gettime(check_get_clockid(), &ts_end);
-    tcase_run_checked_teardown(tc);
-    return receive_result_info_nofork(tc->name, tfun->name, i,
-                                      DIFF_IN_USEC(ts_start, ts_end));
-  }
-  
-  return tr;
+
+    return tr;
 }
 
-static TestResult *receive_result_info_nofork (const char *tcname,
-                                               const char *tname,
-                                               int iter,
-                                               int duration)
+static TestResult *receive_result_info_nofork(const char *tcname,
+                                              const char *tname,
+                                              int iter, int duration)
 {
-  TestResult *tr;
-
-  tr = receive_test_result(0);
-  if (tr == NULL) {
-    eprintf("Failed to receive test result", __FILE__, __LINE__);
-  } else {
-    tr->tcname = tcname;
-    tr->tname = tname;
-    tr->iter = iter;
-    tr->duration = duration;
-    set_nofork_info(tr);
-  }
-
-  return tr;
+    TestResult *tr;
+
+    tr = receive_test_result(0);
+    if(tr == NULL)
+    {
+        eprintf("Failed to receive test result", __FILE__, __LINE__);
+    }
+    else
+    {
+        tr->tcname = tcname;
+        tr->tname = tname;
+        tr->iter = iter;
+        tr->duration = duration;
+        set_nofork_info(tr);
+    }
+
+    return tr;
 }
 
-static void set_nofork_info (TestResult *tr)
+static void set_nofork_info(TestResult * tr)
 {
-  if (tr->msg == NULL) {
-    tr->rtype = CK_PASS;
-    tr->msg = pass_msg();
-  } else {
-    tr->rtype = CK_FAILURE;
-  }
+    if(tr->msg == NULL)
+    {
+        tr->rtype = CK_PASS;
+        tr->msg = pass_msg();
+    }
+    else
+    {
+        tr->rtype = CK_FAILURE;
+    }
 }
 
-static char *pass_msg (void)
+static char *pass_msg(void)
 {
-  return strdup("Passed");
+    return strdup("Passed");
 }
 
 #if defined(HAVE_FORK) && HAVE_FORK==1
-static TestResult *tcase_run_tfun_fork (SRunner *sr, TCase *tc, TF *tfun, int i)
+static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tfun,
+                                       int i)
 {
-  pid_t pid_w;
-  pid_t pid;
-  int status = 0;
-  struct timespec ts_start = {0,0}, ts_end = {0,0};
-
-  timer_t timerid;
-  struct itimerspec timer_spec; 
-  TestResult * tr;
-
-
-  pid = fork();
-  if (pid == -1)
-    eprintf("Error in call to fork:", __FILE__, __LINE__ - 2);
-  if (pid == 0) {
-    setpgid(0, 0);
-    group_pid = getpgrp();
-    tr = tcase_run_checked_setup(sr, tc);
-    free(tr);
-    clock_gettime(check_get_clockid(), &ts_start);
-    tfun->fn(i);
-    clock_gettime(check_get_clockid(), &ts_end);
-    tcase_run_checked_teardown(tc);
-    send_duration_info(DIFF_IN_USEC(ts_start, ts_end));
-    exit(EXIT_SUCCESS);
-  } else {
-    group_pid = pid;
-  }
-
-  alarm_received = 0;
-
-  if(timer_create(check_get_clockid(),
-                  NULL /* fire SIGALRM if timer expires */,
-                  &timerid) == 0)
-  {
-    /* Set the timer to fire once */
-    timer_spec.it_value            = tc->timeout;
-    timer_spec.it_interval.tv_sec  = 0;
-    timer_spec.it_interval.tv_nsec = 0;
-    if(timer_settime (timerid, 0, &timer_spec, NULL) == 0)
-    {
-      do {
-        pid_w = waitpid(pid, &status, 0);
-      } while (pid_w == -1);
+    pid_t pid_w;
+    pid_t pid;
+    int status = 0;
+    struct timespec ts_start = { 0, 0 }, ts_end =
+    {
+    0, 0};
+
+    timer_t timerid;
+    struct itimerspec timer_spec;
+    TestResult *tr;
+
+
+    pid = fork();
+    if(pid == -1)
+        eprintf("Error in call to fork:", __FILE__, __LINE__ - 2);
+    if(pid == 0)
+    {
+        setpgid(0, 0);
+        group_pid = getpgrp();
+        tr = tcase_run_checked_setup(sr, tc);
+        free(tr);
+        clock_gettime(check_get_clockid(), &ts_start);
+        tfun->fn(i);
+        clock_gettime(check_get_clockid(), &ts_end);
+        tcase_run_checked_teardown(tc);
+        send_duration_info(DIFF_IN_USEC(ts_start, ts_end));
+        exit(EXIT_SUCCESS);
+    }
+    else
+    {
+        group_pid = pid;
+    }
+
+    alarm_received = 0;
+
+    if(timer_create(check_get_clockid(),
+                    NULL /* fire SIGALRM if timer expires */ ,
+                    &timerid) == 0)
+    {
+        /* Set the timer to fire once */
+        timer_spec.it_value = tc->timeout;
+        timer_spec.it_interval.tv_sec = 0;
+        timer_spec.it_interval.tv_nsec = 0;
+        if(timer_settime(timerid, 0, &timer_spec, NULL) == 0)
+        {
+            do
+            {
+                pid_w = waitpid(pid, &status, 0);
+            }
+            while(pid_w == -1);
+        }
+        else
+        {
+            eprintf("Error in call to timer_settime:", __FILE__, __LINE__);
+        }
+
+        /* If the timer has not fired, disable it */
+        timer_delete(timerid);
     }
     else
     {
-      eprintf("Error in call to timer_settime:", __FILE__, __LINE__);
+        eprintf("Error in call to timer_create:", __FILE__, __LINE__);
     }
-    
-      /* If the timer has not fired, disable it */
-      timer_delete(timerid);
-  }
-  else
-  {
-    eprintf("Error in call to timer_create:", __FILE__, __LINE__);
-  }
-  
-  killpg(pid, SIGKILL); /* Kill remaining processes. */
-
-  return receive_result_info_fork(tc->name, tfun->name, i, status, tfun->signal,  tfun->allowed_exit_value);
+
+    killpg(pid, SIGKILL);       /* Kill remaining processes. */
+
+    return receive_result_info_fork(tc->name, tfun->name, i, status,
+                                    tfun->signal, tfun->allowed_exit_value);
 }
 
-static TestResult *receive_result_info_fork (const char *tcname,
-                                             const char *tname,
-                                             int iter,
-                                            int status, int expected_signal, 
-                                             signed char allowed_exit_value)
+static TestResult *receive_result_info_fork(const char *tcname,
+                                            const char *tname,
+                                            int iter,
+                                            int status, int expected_signal,
+                                            signed char allowed_exit_value)
 {
-  TestResult *tr;
-
-  tr = receive_test_result(waserror(status, expected_signal));
-  if (tr == NULL) {
-    eprintf("Failed to receive test result", __FILE__, __LINE__);
-  } else {
-    tr->tcname = tcname;
-    tr->tname = tname;
-    tr->iter = iter;
-    set_fork_info(tr, status, expected_signal, allowed_exit_value);
-  }
-
-  return tr;
+    TestResult *tr;
+
+    tr = receive_test_result(waserror(status, expected_signal));
+    if(tr == NULL)
+    {
+        eprintf("Failed to receive test result", __FILE__, __LINE__);
+    }
+    else
+    {
+        tr->tcname = tcname;
+        tr->tname = tname;
+        tr->iter = iter;
+        set_fork_info(tr, status, expected_signal, allowed_exit_value);
+    }
+
+    return tr;
 }
 
-static void set_fork_info (TestResult *tr, int status, int signal_expected, signed char allowed_exit_value)
+static void set_fork_info(TestResult * tr, int status, int signal_expected,
+                          signed char allowed_exit_value)
 {
-  int was_sig = WIFSIGNALED(status);
-  int was_exit = WIFEXITED(status);
-  signed char exit_status = WEXITSTATUS(status);
-  int signal_received = WTERMSIG(status);
-
-  if (was_sig) {
-    if (signal_expected == signal_received) {
-      if (alarm_received) {
-        /* Got alarm instead of signal */
-        tr->rtype = CK_ERROR;
-        if(tr->msg != NULL)
+    int was_sig = WIFSIGNALED(status);
+    int was_exit = WIFEXITED(status);
+    signed char exit_status = WEXITSTATUS(status);
+    int signal_received = WTERMSIG(status);
+
+    if(was_sig)
+    {
+        if(signal_expected == signal_received)
         {
-          free(tr->msg);
+            if(alarm_received)
+            {
+                /* Got alarm instead of signal */
+                tr->rtype = CK_ERROR;
+                if(tr->msg != NULL)
+                {
+                    free(tr->msg);
+                }
+                tr->msg = signal_error_msg(signal_received, signal_expected);
+            }
+            else
+            {
+                tr->rtype = CK_PASS;
+                if(tr->msg != NULL)
+                {
+                    free(tr->msg);
+                }
+                tr->msg = pass_msg();
+            }
         }
-        tr->msg = signal_error_msg(signal_received, signal_expected);
-      } else {
-        tr->rtype = CK_PASS;
-        if(tr->msg != NULL)
+        else if(signal_expected != 0)
         {
-          free(tr->msg);
+            /* signal received, but not the expected one */
+            tr->rtype = CK_ERROR;
+            if(tr->msg != NULL)
+            {
+                free(tr->msg);
+            }
+            tr->msg = signal_error_msg(signal_received, signal_expected);
+        }
+        else
+        {
+            /* signal received and none expected */
+            tr->rtype = CK_ERROR;
+            if(tr->msg != NULL)
+            {
+                free(tr->msg);
+            }
+            tr->msg = signal_msg(signal_received);
         }
-        tr->msg = pass_msg();
-      }
-    } else if (signal_expected != 0) {
-      /* signal received, but not the expected one */
-      tr->rtype = CK_ERROR;
-      if(tr->msg != NULL)
-      {
-        free(tr->msg);
-      }
-      tr->msg = signal_error_msg(signal_received, signal_expected);
-    } else {
-      /* signal received and none expected */
-      tr->rtype = CK_ERROR;
-      if(tr->msg != NULL)
-      {
-        free(tr->msg);
-      }
-      tr->msg = signal_msg(signal_received);
     }
-  } else if (signal_expected == 0) {
-    if (was_exit && exit_status == allowed_exit_value) {
-      tr->rtype = CK_PASS;
-      if(tr->msg != NULL)
-      {
-        free(tr->msg);
-      }
-      tr->msg = pass_msg();
-    } else if (was_exit && exit_status != allowed_exit_value) {
-      if (tr->msg == NULL) { /* early exit */
-        tr->rtype = CK_ERROR;
-        tr->msg = exit_msg(exit_status);
-      } else {
-        tr->rtype = CK_FAILURE;
-      }
+    else if(signal_expected == 0)
+    {
+        if(was_exit && exit_status == allowed_exit_value)
+        {
+            tr->rtype = CK_PASS;
+            if(tr->msg != NULL)
+            {
+                free(tr->msg);
+            }
+            tr->msg = pass_msg();
+        }
+        else if(was_exit && exit_status != allowed_exit_value)
+        {
+            if(tr->msg == NULL)
+            {                   /* early exit */
+                tr->rtype = CK_ERROR;
+                tr->msg = exit_msg(exit_status);
+            }
+            else
+            {
+                tr->rtype = CK_FAILURE;
+            }
+        }
     }
-  } else { /* a signal was expected and none raised */
-    if (was_exit) {
-      if(tr->msg != NULL)
-      {
-        free(tr->msg);
-      }
-      tr->msg = exit_msg(exit_status);
-      if (exit_status == allowed_exit_value)
-      {
-        tr->rtype = CK_FAILURE; /* normal exit status */
-      }
-      else
-      {
-        tr->rtype = CK_FAILURE; /* early exit */
-      }
+    else
+    {                           /* a signal was expected and none raised */
+        if(was_exit)
+        {
+            if(tr->msg != NULL)
+            {
+                free(tr->msg);
+            }
+            tr->msg = exit_msg(exit_status);
+            if(exit_status == allowed_exit_value)
+            {
+                tr->rtype = CK_FAILURE; /* normal exit status */
+            }
+            else
+            {
+                tr->rtype = CK_FAILURE; /* early exit */
+            }
+        }
     }
-  }
 }
 
-static char *signal_msg (int signal)
+static char *signal_msg(int signal)
 {
-  char *msg = emalloc(MSG_LEN); /* free'd by caller */
-  if (alarm_received) {
-    snprintf(msg, MSG_LEN, "Test timeout expired");
-  } else {
-    snprintf(msg, MSG_LEN, "Received signal %d (%s)",
-             signal, strsignal(signal));
-  }
-  return msg;
+    char *msg = emalloc(MSG_LEN);       /* free'd by caller */
+
+    if(alarm_received)
+    {
+        snprintf(msg, MSG_LEN, "Test timeout expired");
+    }
+    else
+    {
+        snprintf(msg, MSG_LEN, "Received signal %d (%s)",
+                 signal, strsignal(signal));
+    }
+    return msg;
 }
 
-static char *signal_error_msg (int signal_received, int signal_expected)
+static char *signal_error_msg(int signal_received, int signal_expected)
 {
-  char *sig_r_str;
-  char *sig_e_str;
-  char *msg = emalloc (MSG_LEN); /* free'd by caller */
-  sig_r_str = strdup(strsignal(signal_received));
-  sig_e_str = strdup(strsignal(signal_expected));
-  if (alarm_received) {
-    snprintf (msg, MSG_LEN, "Test timeout expired, expected signal %d (%s)",
-              signal_expected, sig_e_str);
-  } else {
-    snprintf (msg, MSG_LEN, "Received signal %d (%s), expected %d (%s)",
-              signal_received, sig_r_str, signal_expected, sig_e_str);
-  }
-  free(sig_r_str);
-  free(sig_e_str);
-  return msg;
+    char *sig_r_str;
+    char *sig_e_str;
+    char *msg = emalloc(MSG_LEN);       /* free'd by caller */
+
+    sig_r_str = strdup(strsignal(signal_received));
+    sig_e_str = strdup(strsignal(signal_expected));
+    if(alarm_received)
+    {
+        snprintf(msg, MSG_LEN,
+                 "Test timeout expired, expected signal %d (%s)",
+                 signal_expected, sig_e_str);
+    }
+    else
+    {
+        snprintf(msg, MSG_LEN, "Received signal %d (%s), expected %d (%s)",
+                 signal_received, sig_r_str, signal_expected, sig_e_str);
+    }
+    free(sig_r_str);
+    free(sig_e_str);
+    return msg;
 }
 
-static char *exit_msg (int exitval)
+static char *exit_msg(int exitval)
 {
-  char *msg = emalloc(MSG_LEN); /* free'd by caller */
-  snprintf (msg, MSG_LEN,
-            "Early exit with return value %d", exitval);
-  return msg;
+    char *msg = emalloc(MSG_LEN);       /* free'd by caller */
+
+    snprintf(msg, MSG_LEN, "Early exit with return value %d", exitval);
+    return msg;
 }
 
-static int waserror (int status, int signal_expected)
+static int waserror(int status, int signal_expected)
 {
-  int was_sig = WIFSIGNALED (status);
-  int was_exit = WIFEXITED (status);
-  int exit_status = WEXITSTATUS (status);
-  int signal_received = WTERMSIG (status);
+    int was_sig = WIFSIGNALED(status);
+    int was_exit = WIFEXITED(status);
+    int exit_status = WEXITSTATUS(status);
+    int signal_received = WTERMSIG(status);
 
-  return ((was_sig && (signal_received != signal_expected)) ||
-          (was_exit && exit_status != 0));
+    return ((was_sig && (signal_received != signal_expected)) ||
+            (was_exit && exit_status != 0));
 }
 #endif /* HAVE_FORK */
 
-enum fork_status srunner_fork_status (SRunner *sr)
+enum fork_status srunner_fork_status(SRunner * sr)
 {
-  if (sr->fstat == CK_FORK_GETENV) {
-    char *env = getenv ("CK_FORK");
-    if (env == NULL)
+    if(sr->fstat == CK_FORK_GETENV)
+    {
+        char *env = getenv("CK_FORK");
+
+        if(env == NULL)
 #if defined(HAVE_FORK) && HAVE_FORK==1
-      return CK_FORK;
+            return CK_FORK;
 #else
-      return CK_NOFORK;
+            return CK_NOFORK;
 #endif
-    if (strcmp (env,"no") == 0)
-      return CK_NOFORK;
-    else {
+        if(strcmp(env, "no") == 0)
+            return CK_NOFORK;
+        else
+        {
 #if defined(HAVE_FORK) && HAVE_FORK==1
-      return CK_FORK;
+            return CK_FORK;
 #else /* HAVE_FORK */
-      eprintf("This version does not support fork", __FILE__, __LINE__);
-      return CK_NOFORK;
+            eprintf("This version does not support fork", __FILE__, __LINE__);
+            return CK_NOFORK;
 #endif /* HAVE_FORK */
+        }
     }
-  } else
-    return sr->fstat;
+    else
+        return sr->fstat;
 }
 
-void srunner_set_fork_status (SRunner *sr, enum fork_status fstat)
+void srunner_set_fork_status(SRunner * sr, enum fork_status fstat)
 {
 #if !defined(HAVE_FORK) || HAVE_FORK==0
-  /* If fork() is unavailable, do not allow a fork mode to be set */
-  if (fstat != CK_NOFORK)
-  {
-         eprintf("This version does not support fork", __FILE__, __LINE__);
-  }
+    /* If fork() is unavailable, do not allow a fork mode to be set */
+    if(fstat != CK_NOFORK)
+    {
+        eprintf("This version does not support fork", __FILE__, __LINE__);
+    }
 #endif /* ! HAVE_FORK */
-  sr->fstat = fstat;
+    sr->fstat = fstat;
 }
 
-void srunner_run_all (SRunner *sr, enum print_output print_mode)
+void srunner_run_all(SRunner * sr, enum print_output print_mode)
 {
-  srunner_run (sr,
-               NULL,  /* All test suites.  */
-               NULL,  /* All test cases.   */
-               print_mode);
+    srunner_run(sr, NULL,       /* All test suites.  */
+                NULL,           /* All test cases.   */
+                print_mode);
 }
 
-void srunner_run (SRunner *sr, const char *sname, const char *tcname, enum print_output print_mode)
+void srunner_run(SRunner * sr, const char *sname, const char *tcname,
+                 enum print_output print_mode)
 {
 #if defined(HAVE_SIGACTION) && defined(HAVE_FORK)
-  struct sigaction old_action;
-  struct sigaction new_action;
+    struct sigaction old_action;
+    struct sigaction new_action;
 #endif /* HAVE_SIGACTION && HAVE_FORK */
 
-  /*  Get the selected test suite and test case from the
-      environment.  */
-  if (!tcname) tcname = getenv ("CK_RUN_CASE");
-  if (!sname) sname = getenv ("CK_RUN_SUITE");
+    /*  Get the selected test suite and test case from the
+       environment.  */
+    if(!tcname)
+        tcname = getenv("CK_RUN_CASE");
+    if(!sname)
+        sname = getenv("CK_RUN_SUITE");
 
-  if (sr == NULL)
-    return;
-  if (print_mode >= CK_LAST)
+    if(sr == NULL)
+        return;
+    if(print_mode >= CK_LAST)
     {
-      eprintf ("Bad print_mode argument to srunner_run_all: %d",
-             __FILE__, __LINE__, print_mode);
+        eprintf("Bad print_mode argument to srunner_run_all: %d",
+                __FILE__, __LINE__, print_mode);
     }
 #if defined(HAVE_SIGACTION) && defined(HAVE_FORK)
-  memset(&new_action, 0, sizeof new_action);
-  new_action.sa_handler = sig_handler;
-  sigaction(SIGALRM, &new_action, &old_action);
-#endif /* HAVE_SIGACTION && HAVE_FORK*/
-  srunner_run_init (sr, print_mode);
-  srunner_iterate_suites (sr, sname, tcname, print_mode);
-  srunner_run_end (sr, print_mode);
+    memset(&new_action, 0, sizeof new_action);
+    new_action.sa_handler = sig_handler;
+    sigaction(SIGALRM, &new_action, &old_action);
+#endif /* HAVE_SIGACTION && HAVE_FORK */
+    srunner_run_init(sr, print_mode);
+    srunner_iterate_suites(sr, sname, tcname, print_mode);
+    srunner_run_end(sr, print_mode);
 #if defined(HAVE_SIGACTION) && defined(HAVE_FORK)
-  sigaction(SIGALRM, &old_action, NULL);
+    sigaction(SIGALRM, &old_action, NULL);
 #endif /* HAVE_SIGACTION && HAVE_FORK */
 }
 
-pid_t check_fork (void)
+pid_t check_fork(void)
 {
 #if defined(HAVE_FORK) && HAVE_FORK==1
-  pid_t pid = fork();
-  /* Set the process to a process group to be able to kill it easily. */
-  if(pid >= 0)
-  {
-    setpgid(pid, group_pid);
-  }
-  return pid;
+    pid_t pid = fork();
+
+    /* Set the process to a process group to be able to kill it easily. */
+    if(pid >= 0)
+    {
+        setpgid(pid, group_pid);
+    }
+    return pid;
 #else /* HAVE_FORK */
-  eprintf("This version does not support fork", __FILE__, __LINE__);
-  return 0;
+    eprintf("This version does not support fork", __FILE__, __LINE__);
+    return 0;
 #endif /* HAVE_FORK */
 }
 
-void check_waitpid_and_exit (pid_t pid CK_ATTRIBUTE_UNUSED)
+void check_waitpid_and_exit(pid_t pid CK_ATTRIBUTE_UNUSED)
 {
 #if defined(HAVE_FORK) && HAVE_FORK==1
-  pid_t pid_w;
-  int status;
-
-  if (pid > 0) {
-    do {
-      pid_w = waitpid(pid, &status, 0);
-    } while (pid_w == -1);
-    if (waserror(status, 0)) {
-      exit(EXIT_FAILURE);
+    pid_t pid_w;
+    int status;
+
+    if(pid > 0)
+    {
+        do
+        {
+            pid_w = waitpid(pid, &status, 0);
+        }
+        while(pid_w == -1);
+        if(waserror(status, 0))
+        {
+            exit(EXIT_FAILURE);
+        }
     }
-  }
-  exit(EXIT_SUCCESS);
+    exit(EXIT_SUCCESS);
 #else /* HAVE_FORK */
-  eprintf("This version does not support fork", __FILE__, __LINE__);
+    eprintf("This version does not support fork", __FILE__, __LINE__);
 #endif /* HAVE_FORK */
-}  
+}
index 6f4ee2428221c7cab8d405009cde7aafa756a5c9..ad9b380ece3c33fe14f59d1e91d41919f4e39061 100644 (file)
 #include "check_impl.h"
 #include "check_str.h"
 
-static const char *tr_type_str (TestResult *tr);
-static int percent_passed (TestStats *t);
+static const char *tr_type_str(TestResult * tr);
+static int percent_passed(TestStats * t);
 
-char *tr_str (TestResult *tr) 
+char *tr_str(TestResult * tr)
 {
-  const char *exact_msg;
-  char *rstr;
-  
-  exact_msg = (tr->rtype == CK_ERROR) ? "(after this point) ": "";
-  
-  rstr = ck_strdup_printf ("%s:%d:%s:%s:%s:%d: %s%s",
-                           tr->file, tr->line,
-                           tr_type_str(tr), tr->tcname, tr->tname, tr->iter,
-                           exact_msg, tr->msg);
-
-  return rstr;
+    const char *exact_msg;
+    char *rstr;
+
+    exact_msg = (tr->rtype == CK_ERROR) ? "(after this point) " : "";
+
+    rstr = ck_strdup_printf("%s:%d:%s:%s:%s:%d: %s%s",
+                            tr->file, tr->line,
+                            tr_type_str(tr), tr->tcname, tr->tname, tr->iter,
+                            exact_msg, tr->msg);
+
+    return rstr;
 }
 
-char *tr_short_str (TestResult *tr) 
+char *tr_short_str(TestResult * tr)
 {
-  const char *exact_msg;
-  char *rstr;
-  
-  exact_msg = (tr->rtype == CK_ERROR) ? "(after this point) ": "";
-  
-  rstr = ck_strdup_printf ("%s:%d: %s%s",
-                           tr->file, tr->line,
-                           exact_msg, tr->msg);
-
-  return rstr;
+    const char *exact_msg;
+    char *rstr;
+
+    exact_msg = (tr->rtype == CK_ERROR) ? "(after this point) " : "";
+
+    rstr = ck_strdup_printf("%s:%d: %s%s",
+                            tr->file, tr->line, exact_msg, tr->msg);
+
+    return rstr;
 }
 
-char *sr_stat_str (SRunner *sr)
+char *sr_stat_str(SRunner * sr)
 {
-  char *str;
-  TestStats *ts;
-  
-  ts = sr->stats;
-  
-  str = ck_strdup_printf ("%d%%: Checks: %d, Failures: %d, Errors: %d",
-                          percent_passed (ts), ts->n_checked, ts->n_failed,
-                          ts->n_errors);
-
-  return str;
+    char *str;
+    TestStats *ts;
+
+    ts = sr->stats;
+
+    str = ck_strdup_printf("%d%%: Checks: %d, Failures: %d, Errors: %d",
+                           percent_passed(ts), ts->n_checked, ts->n_failed,
+                           ts->n_errors);
+
+    return str;
 }
 
-char *ck_strdup_printf (const char *fmt, ...)
+char *ck_strdup_printf(const char *fmt, ...)
 {
-  /* Guess we need no more than 100 bytes. */
-  int n;
-  size_t size = 100;
-  char *p;
-  va_list ap;
+    /* Guess we need no more than 100 bytes. */
+    int n;
+    size_t size = 100;
+    char *p;
+    va_list ap;
 
-  p = emalloc (size);
+    p = emalloc(size);
 
-  while (1)
+    while(1)
     {
-      /* Try to print in the allocated space. */
-      va_start(ap, fmt);
-      n = vsnprintf (p, size, fmt, ap);
-      va_end(ap);
-      /* If that worked, return the string. */
-      if (n > -1 && n < (int)size)
-        return p;
-
-      /* Else try again with more space. */
-      if (n > -1)   /* C99 conform vsnprintf() */
-        size = (size_t)n+1; /* precisely what is needed */
-      else          /* glibc 2.0 */
-        size *= 2;  /* twice the old size */
-
-      p = erealloc (p, size);
+        /* Try to print in the allocated space. */
+        va_start(ap, fmt);
+        n = vsnprintf(p, size, fmt, ap);
+        va_end(ap);
+        /* If that worked, return the string. */
+        if(n > -1 && n < (int)size)
+            return p;
+
+        /* Else try again with more space. */
+        if(n > -1)              /* C99 conform vsnprintf() */
+            size = (size_t) n + 1;      /* precisely what is needed */
+        else                    /* glibc 2.0 */
+            size *= 2;          /* twice the old size */
+
+        p = erealloc(p, size);
     }
 }
 
-static const char *tr_type_str (TestResult *tr)
+static const char *tr_type_str(TestResult * tr)
 {
-  const char *str = NULL;
-  if (tr->ctx == CK_CTX_TEST) {
-    if (tr->rtype == CK_PASS)
-      str = "P";
-    else if (tr->rtype == CK_FAILURE)
-      str = "F";
-    else if (tr->rtype == CK_ERROR)
-      str = "E";
-  } else
-    str = "S";
-
-  return str;
+    const char *str = NULL;
+
+    if(tr->ctx == CK_CTX_TEST)
+    {
+        if(tr->rtype == CK_PASS)
+            str = "P";
+        else if(tr->rtype == CK_FAILURE)
+            str = "F";
+        else if(tr->rtype == CK_ERROR)
+            str = "E";
+    }
+    else
+        str = "S";
+
+    return str;
 }
 
-static int percent_passed (TestStats *t)
+static int percent_passed(TestStats * t)
 {
-  if (t->n_failed == 0 && t->n_errors == 0)
-    return 100;
-  else if (t->n_checked == 0)
-    return 0;
-  else
-    return (int) ( (float) (t->n_checked - (t->n_failed + t->n_errors)) /
-                  (float) t->n_checked * 100);
+    if(t->n_failed == 0 && t->n_errors == 0)
+        return 100;
+    else if(t->n_checked == 0)
+        return 0;
+    else
+        return (int)((float)(t->n_checked - (t->n_failed + t->n_errors)) /
+                     (float)t->n_checked * 100);
 }
index bd4105502673bf7cd9600cf35780772002c8d93a..5bf416246df27bd65c4482f2a3d9c8c246810210 100644 (file)
 
 /* Return a string representation of the given TestResult.  Return
    value has been malloc'd, and must be freed by the caller */
-char *tr_str (TestResult *tr);
+char *tr_str(TestResult * tr);
 
 /* Return a string representation of the given TestResult message
    without the test id or result type. This is suitable for separate
    formatting of the test and the message. Return value has been 
    malloc'd, and must be freed by the caller */
-char *tr_short_str (TestResult *tr);
+char *tr_short_str(TestResult * tr);
 
 /* Return a string representation of the given SRunner's run
    statistics (% passed, num run, passed, errors, failures). Return
    value has been malloc'd, and must be freed by the caller
-*/ 
-char *sr_stat_str (SRunner *sr);
+*/
+char *sr_stat_str(SRunner * sr);
 
-char *ck_strdup_printf (const char *fmt, ...);
+char *ck_strdup_printf(const char *fmt, ...);
 
 #endif /* CHECK_STR_H */
index e86ce93f465394bc1f62cb0b13d375cb9daab49f..9668303c3f60cd43933bca0b5da7b5c726899aa3 100644 (file)
@@ -8,13 +8,13 @@
 
 START_TEST(test_pass)
 {
-  ck_assert_msg (1==1, "Shouldn't see this");
+    ck_assert_msg(1 == 1, "Shouldn't see this");
 }
 END_TEST
 
 START_TEST(test_fail)
 {
-  ck_abort_msg("Failure");
+    ck_abort_msg("Failure");
 }
 END_TEST
 
@@ -25,7 +25,7 @@ END_TEST
 #if defined(HAVE_FORK) && HAVE_FORK==1
 START_TEST(test_exit)
 {
-  exit(1);
+    exit(1);
 }
 END_TEST
 #endif /* HAVE_FORK */
@@ -37,86 +37,85 @@ END_TEST
  */
 START_TEST(test_abort)
 {
-  exit(1);
+    exit(1);
 }
 END_TEST
 
 START_TEST(test_pass2)
 {
-  ck_assert_msg (1==1, "Shouldn't see this");
+    ck_assert_msg(1 == 1, "Shouldn't see this");
 }
 END_TEST
 
 START_TEST(test_loop)
 {
-  ck_assert_msg (_i==1, "Iteration %d failed", _i);
+    ck_assert_msg(_i == 1, "Iteration %d failed", _i);
 }
 END_TEST
 
 START_TEST(test_xml_esc_fail_msg)
 {
-  ck_abort_msg("fail \" ' < > & message");
+    ck_abort_msg("fail \" ' < > & message");
 }
 END_TEST
 
-static Suite *make_log1_suite (void)
+static Suite *make_log1_suite(void)
 {
-  Suite *s;
-  TCase *tc;
-
-  s = suite_create("S1");
-  tc = tcase_create ("Core");
-  suite_add_tcase(s, tc);
-  tcase_add_test (tc, test_pass);
-  tcase_add_test (tc, test_fail);
+    Suite *s;
+    TCase *tc;
+
+    s = suite_create("S1");
+    tc = tcase_create("Core");
+    suite_add_tcase(s, tc);
+    tcase_add_test(tc, test_pass);
+    tcase_add_test(tc, test_fail);
 #if defined(HAVE_FORK) && HAVE_FORK==1
-  tcase_add_test (tc, test_exit);
+    tcase_add_test(tc, test_exit);
 #endif /* HAVE_FORK */
 
-  return s;
+    return s;
 }
 
-static Suite *make_log2_suite (int include_exit_test)
+static Suite *make_log2_suite(int include_exit_test)
 {
-  Suite *s;
-  TCase *tc;
+    Suite *s;
+    TCase *tc;
 
-  s = suite_create("S2");
-  tc = tcase_create ("Core");
-  suite_add_tcase(s, tc);
-  if(include_exit_test == 1)
-  {
-     tcase_add_test (tc, test_abort);
-  }
-  tcase_add_test (tc, test_pass2);
-  tcase_add_loop_test(tc, test_loop, 0, 3);
+    s = suite_create("S2");
+    tc = tcase_create("Core");
+    suite_add_tcase(s, tc);
+    if(include_exit_test == 1)
+    {
+        tcase_add_test(tc, test_abort);
+    }
+    tcase_add_test(tc, test_pass2);
+    tcase_add_loop_test(tc, test_loop, 0, 3);
 
-  return s;
+    return s;
 }
 
 /* check that XML special characters are properly escaped in XML log file */
-static Suite *make_xml_esc_suite (void)
+static Suite *make_xml_esc_suite(void)
 {
-  Suite *s;
-  TCase *tc;
+    Suite *s;
+    TCase *tc;
 
-  s = suite_create("XML escape \" ' < > & tests");
-  tc = tcase_create ("description \" ' < > &");
-  suite_add_tcase(s, tc);
+    s = suite_create("XML escape \" ' < > & tests");
+    tc = tcase_create("description \" ' < > &");
+    suite_add_tcase(s, tc);
 
-  tcase_add_test (tc, test_xml_esc_fail_msg);
+    tcase_add_test(tc, test_xml_esc_fail_msg);
 
-  return s;
+    return s;
 }
 
-
 static void print_usage(void)
 {
-    printf ("Usage: ex_output (CK_SILENT | CK_MINIMAL | CK_NORMAL | CK_VERBOSE | CK_ENV");
+    printf("Usage: ex_output (CK_SILENT | CK_MINIMAL | CK_NORMAL | CK_VERBOSE | CK_ENV");
 #if ENABLE_SUBUNIT
-    printf (" | CK_SUBUNIT");
+    printf(" | CK_SUBUNIT");
 #endif
-    printf (")\n");
+    printf(")\n");
     printf("                 (STDOUT | STDOUT_DUMP | LOG | LOG_STDOUT | TAP | TAP_STDOUT | XML | XML_STDOUT)\n");
     printf("                 (NORMAL | EXIT_TEST)\n");
     printf("   If CK_ENV is used, the environment variable CK_VERBOSITY can be set to\n");
@@ -126,7 +125,7 @@ static void print_usage(void)
     printf("   then use the following mode: CK_SILENT STDOUT [NORMAL|EXIT_TEST].\n");
 }
 
-static void run_tests (int printmode, char * log_type, int include_exit_test)
+static void run_tests(int printmode, char *log_type, int include_exit_test)
 {
     SRunner *sr;
     int dump_everything_to_stdout = 0;
@@ -201,54 +200,54 @@ static void run_tests (int printmode, char * log_type, int include_exit_test)
 #define OUTPUT_TYPE_ARG       1
 #define LOG_TYPE_ARG          2
 #define INCLUDE_EXIT_TEST_ARG 3
-int main (int argc, char **argv)
+int main(int argc, char **argv)
 {
     int printmode;
     int include_exit_test;
 
-    if (argc != 4)
+    if(argc != 4)
     {
         print_usage();
         return EXIT_FAILURE;
     }
 
-    if (strcmp (argv[OUTPUT_TYPE_ARG], "CK_SILENT") == 0)
+    if(strcmp(argv[OUTPUT_TYPE_ARG], "CK_SILENT") == 0)
     {
         printmode = CK_SILENT;
     }
-    else if (strcmp (argv[OUTPUT_TYPE_ARG], "CK_MINIMAL") == 0)
+    else if(strcmp(argv[OUTPUT_TYPE_ARG], "CK_MINIMAL") == 0)
     {
         printmode = CK_MINIMAL;
     }
-    else if (strcmp (argv[OUTPUT_TYPE_ARG], "CK_NORMAL") == 0)
+    else if(strcmp(argv[OUTPUT_TYPE_ARG], "CK_NORMAL") == 0)
     {
         printmode = CK_NORMAL;
     }
-    else if (strcmp (argv[OUTPUT_TYPE_ARG], "CK_VERBOSE") == 0)
+    else if(strcmp(argv[OUTPUT_TYPE_ARG], "CK_VERBOSE") == 0)
     {
         printmode = CK_VERBOSE;
     }
-    else if (strcmp (argv[OUTPUT_TYPE_ARG], "CK_ENV") == 0)
+    else if(strcmp(argv[OUTPUT_TYPE_ARG], "CK_ENV") == 0)
     {
         printmode = CK_ENV;
     }
-    #if ENABLE_SUBUNIT
-    else if (strcmp (argv[OUTPUT_TYPE_ARG], "CK_SUBUNIT") == 0)
+#if ENABLE_SUBUNIT
+    else if(strcmp(argv[OUTPUT_TYPE_ARG], "CK_SUBUNIT") == 0)
     {
         printmode = CK_SUBUNIT;
     }
-    #endif
+#endif
     else
     {
         print_usage();
         return EXIT_FAILURE;
     }
 
-    if (strcmp (argv[INCLUDE_EXIT_TEST_ARG], "NORMAL") == 0)
+    if(strcmp(argv[INCLUDE_EXIT_TEST_ARG], "NORMAL") == 0)
     {
         include_exit_test = 0;
     }
-    else if (strcmp (argv[INCLUDE_EXIT_TEST_ARG], "EXIT_TEST") == 0)
+    else if(strcmp(argv[INCLUDE_EXIT_TEST_ARG], "EXIT_TEST") == 0)
     {
         include_exit_test = 1;
     }
@@ -262,4 +261,3 @@ int main (int argc, char **argv)
 
     return EXIT_SUCCESS;
 }
-