/fbus/service_manager_test.c

http://ftk.googlecode.com/ · C · 65 lines · 29 code · 7 blank · 29 comment · 8 complexity · 180ca3d6ce0355edea3de2674b00250e MD5 · raw file

  1. /*
  2. * File:
  3. * Author: Li XianJing <xianjimli@hotmail.com>
  4. * Brief:
  5. *
  6. * Copyright (c) 2009 - 2010 Li XianJing <xianjimli@hotmail.com>
  7. *
  8. * Licensed under the Academic Free License version 2.1
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. /*
  25. * History:
  26. * ================================================================
  27. * 2010-07-25 Li XianJing <xianjimli@hotmail.com> created
  28. *
  29. */
  30. #include "ftk_globals.h"
  31. #include "ftk_allocator_default.h"
  32. #include "fbus_service_manager.h"
  33. int main(int argc, char* argv[])
  34. {
  35. int j = 0;
  36. int i = 0;
  37. int nr = 0;
  38. FBusServiceInfo info = {0};
  39. FBusServiceManager* thiz = NULL;
  40. #ifndef USE_STD_MALLOC
  41. ftk_set_allocator((ftk_allocator_default_create()));
  42. #endif
  43. for(j = 0; j < 1000; j++)
  44. {
  45. thiz = fbus_service_manager_create();
  46. assert(fbus_service_manager_get_nr(thiz, &nr) == RET_OK);
  47. for(i = 0; i < nr; i++)
  48. {
  49. assert(fbus_service_manager_get(thiz, i, &info) == RET_OK);
  50. assert(fbus_service_manager_start(thiz, info.name) == RET_OK);
  51. assert(fbus_service_manager_query(thiz, info.name, &info) == RET_OK);
  52. assert(fbus_service_manager_start(thiz, info.name) == RET_OK);
  53. assert(fbus_service_manager_stop(thiz, info.name) == RET_OK);
  54. }
  55. fbus_service_manager_destroy(thiz);
  56. }
  57. return 0;
  58. }