test_rc.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. static const char version[] = "$Id: test_rc.c,v 1.7 2013/09/29 17:48:26 valtri Exp $";
  2. /*
  3. * test_rc.c
  4. *
  5. * Copyright 2001-2003, Meiosys (www.meiosys.com). All rights reserved.
  6. *
  7. * See the COPYING file for the terms of usage and distribution.
  8. */
  9. #ifdef HAVE_CONFIG_H
  10. #include "config.h"
  11. #endif
  12. #include <log4c/init.h>
  13. #include <log4c/rc.h>
  14. #include <log4c/category.h>
  15. #include <sd/test.h>
  16. #include <log4c/layout.h>
  17. #include <log4c/appender.h>
  18. #include <sd/factory.h>
  19. #include <stdio.h>
  20. /******************************************************************************/
  21. static void log4c_print(FILE* a_fp)
  22. {
  23. extern sd_factory_t* log4c_category_factory;
  24. extern sd_factory_t* log4c_appender_factory;
  25. extern sd_factory_t* log4c_layout_factory;
  26. sd_factory_print(log4c_category_factory, a_fp); fprintf(a_fp, "\n");
  27. sd_factory_print(log4c_appender_factory, a_fp); fprintf(a_fp, "\n");
  28. sd_factory_print(log4c_layout_factory, a_fp); fprintf(a_fp, "\n");
  29. }
  30. /******************************************************************************/
  31. static int test0(sd_test_t* a_test, int argc, char* argv[])
  32. {
  33. log4c_print(sd_test_out(a_test));
  34. return 1;
  35. }
  36. /******************************************************************************/
  37. static int test1(sd_test_t* a_test, int argc, char* argv[])
  38. {
  39. log4c_rc_t rc;
  40. if (log4c_rc_load(&rc, SRCDIR "/test_rc.in") == -1)
  41. return 0;
  42. log4c_print(sd_test_out(a_test));
  43. return 1;
  44. }
  45. /******************************************************************************/
  46. static int test2(sd_test_t* a_test, int argc, char* argv[])
  47. {
  48. log4c_rc_t rc;
  49. if (log4c_rc_load(&rc, SRCDIR "/test_rc.in") == -1)
  50. return 0;
  51. if (log4c_rc_load(&rc, SRCDIR "/test_rc.in") == -1)
  52. return 0;
  53. log4c_print(sd_test_out(a_test));
  54. return 1;
  55. }
  56. /******************************************************************************/
  57. int main(int argc, char* argv[])
  58. {
  59. int ret;
  60. sd_test_t* t;
  61. /*
  62. * initialize log4c to prevent memleaks
  63. * (there is no "unload")
  64. */
  65. log4c_init();
  66. t = sd_test_new(argc, argv);
  67. sd_test_add(t, test0);
  68. sd_test_add(t, test1);
  69. sd_test_add(t, test2);
  70. ret = sd_test_run(t, argc, argv);
  71. sd_test_delete(t);
  72. log4c_fini();
  73. return !ret;
  74. }