test_sensor_api.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. This file is part of GNUnet.
  3. (C)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16. */
  17. /**
  18. * @file sensor/test_sensor_api.c
  19. * @brief testcase for sensor_api.c
  20. */
  21. #include "platform.h"
  22. #include "gnunet_util_lib.h"
  23. #include "gnunet_sensor_service.h"
  24. //FIXME:
  25. static int ok = 1;
  26. static void
  27. run (void *cls, char *const *args, const char *cfgfile,
  28. const struct GNUNET_CONFIGURATION_Handle *cfg)
  29. {
  30. ok = 0;
  31. }
  32. static int
  33. check ()
  34. {
  35. char *const argv[] = { "test-sensor-api", NULL };
  36. struct GNUNET_GETOPT_CommandLineOption options[] = {
  37. GNUNET_GETOPT_OPTION_END
  38. };
  39. struct GNUNET_OS_Process *proc;
  40. char *path = GNUNET_OS_get_libexec_binary_path ("gnunet-service-sensor");
  41. if (NULL == path)
  42. {
  43. fprintf (stderr, "Service executable not found `%s'\n",
  44. "gnunet-service-sensor");
  45. return -1;
  46. }
  47. proc =
  48. GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, NULL,
  49. NULL, path, "gnunet-service-sensor", NULL);
  50. GNUNET_free (path);
  51. GNUNET_assert (NULL != proc);
  52. GNUNET_PROGRAM_run (1, argv, "test-sensor-api", "nohelp", options, &run, &ok);
  53. if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
  54. {
  55. GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
  56. ok = 1;
  57. }
  58. GNUNET_OS_process_wait (proc);
  59. GNUNET_OS_process_destroy (proc);
  60. return ok;
  61. }
  62. int
  63. main (int argc, char *argv[])
  64. {
  65. GNUNET_log_setup ("test_statistics_api", "WARNING", NULL);
  66. return check ();
  67. }
  68. /* end of test_sensor_api.c */