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