test_rps_api.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C)
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your 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. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. /**
  17. * @file rps/test_rps_api.c
  18. * @brief testcase for rps_api.c
  19. */
  20. #include "platform.h"
  21. #include "gnunet_util_lib.h"
  22. #include "gnunet_rps_service.h"
  23. static int ok = 1;
  24. static void
  25. run (void *cls,
  26. char *const *args,
  27. 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-rps-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-rps");
  41. if (NULL == path)
  42. {
  43. fprintf (stderr, "Service executable not found `%s'\n",
  44. "gnunet-service-rps");
  45. return;
  46. }
  47. proc = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
  48. NULL, NULL, path, "gnunet-service-rps", NULL);
  49. GNUNET_free (path);
  50. GNUNET_assert (NULL != proc);
  51. GNUNET_PROGRAM_run (1, argv, "test-rps-api", "nohelp",
  52. 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",
  66. "WARNING",
  67. NULL);
  68. return check ();
  69. }
  70. /* end of test_rps_api.c */