aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-25 03:40:08 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-25 03:40:08 +0100
commit2f5a56e69f618000c16c0aceaaa46aeeb56ba8c2 (patch)
tree31cf3706cfdfd46db0138e062a89059102c348f0
parent50c57e0ffa957a9d3773844de9851ab2aadbbc82 (diff)
downloadgnunet-ext-2f5a56e69f618000c16c0aceaaa46aeeb56ba8c2.tar.gz
gnunet-ext-2f5a56e69f618000c16c0aceaaa46aeeb56ba8c2.zip
update test as well
-rw-r--r--src/ext/test_ext_api.c74
1 files changed, 49 insertions, 25 deletions
diff --git a/src/ext/test_ext_api.c b/src/ext/test_ext_api.c
index c987108..75a7cc4 100644
--- a/src/ext/test_ext_api.c
+++ b/src/ext/test_ext_api.c
@@ -26,9 +26,15 @@
26#include "gnunet_ext_service.h" 26#include "gnunet_ext_service.h"
27 27
28 28
29/**
30 * Return value from #main(). Set to 0 to mark test as passing.
31 */
29static int ok = 1; 32static int ok = 1;
30 33
31 34
35/**
36 * Main function of the test.
37 */
32static void 38static void
33run (void *cls, 39run (void *cls,
34 char *const *args, 40 char *const *args,
@@ -39,58 +45,76 @@ run (void *cls,
39} 45}
40 46
41 47
42static void 48/**
43check () 49 * Launches the gnunet-service-ext and then the #run() function
50 * with some specified arguments, allowing it to then interact
51 * with the 'ext' service.
52 *
53 * Note that you may want to use libgnunettesting or
54 * libgnunettestbed to launch a "full" peer instead of just
55 * a single service.
56 *
57 * @param argc ignored
58 * @param argv ignored
59 * @return 77 if we failed to find gnunet-service-ext
60 */
61int
62main (int argc,
63 char *argv[])
44{ 64{
45 char *const argv[] = { "test-ext-api", NULL }; 65 char *const ext_argv[] = {
66 "test-ext-api",
67 NULL
68 };
46 struct GNUNET_GETOPT_CommandLineOption options[] = { 69 struct GNUNET_GETOPT_CommandLineOption options[] = {
47 GNUNET_GETOPT_OPTION_END 70 GNUNET_GETOPT_OPTION_END
48 }; 71 };
49 struct GNUNET_OS_Process *proc; 72 struct GNUNET_OS_Process *proc;
50 char *path = GNUNET_OS_get_libexec_binary_path ("gnunet-service-ext"); 73 char *path;
51 74
75 GNUNET_log_setup ("test_ext_api",
76 "WARNING",
77 NULL);
78 path = GNUNET_OS_get_libexec_binary_path ("gnunet-service-ext");
52 if (NULL == path) 79 if (NULL == path)
53 { 80 {
54 fprintf (stderr, 81 fprintf (stderr,
55 "Failed to determine path for `%s'\n", 82 "Failed to determine path for `%s'\n",
56 "gnunet-service-ext"); 83 "gnunet-service-ext");
57 ok = 77; 84 return 77;
58 return;
59 } 85 }
60
61 proc = GNUNET_OS_start_process (GNUNET_NO, 86 proc = GNUNET_OS_start_process (GNUNET_NO,
62 GNUNET_OS_INHERIT_STD_ALL, 87 GNUNET_OS_INHERIT_STD_ALL,
63 NULL, 88 NULL,
64 NULL, NULL, path, 89 NULL,
65 "gnunet-service-ext", NULL); 90 NULL,
91 path,
92 "gnunet-service-ext",
93 NULL);
66 GNUNET_free (path); 94 GNUNET_free (path);
67 if (NULL == proc) 95 if (NULL == proc)
68 { 96 {
69 fprintf (stderr, 97 fprintf (stderr,
70 "Service executable not found `%s'\n", 98 "Service executable not found `%s'\n",
71 "gnunet-service-ext"); 99 "gnunet-service-ext");
72 ok = 77; 100 return 77;
73 return;
74 } 101 }
75 GNUNET_PROGRAM_run (1, argv, "test-ext-api", "nohelp", 102 GNUNET_PROGRAM_run (1,
76 options, &run, &ok); 103 ext_argv,
77 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 104 "test-ext-api",
105 "nohelp",
106 options,
107 &run,
108 &ok);
109 if (0 != GNUNET_OS_process_kill (proc,
110 SIGTERM))
78 { 111 {
79 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 112 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
113 "kill");
80 ok = 1; 114 ok = 1;
81 } 115 }
82 GNUNET_OS_process_wait (proc); 116 GNUNET_OS_process_wait (proc);
83 GNUNET_OS_process_destroy (proc); 117 GNUNET_OS_process_destroy (proc);
84}
85
86
87int
88main (int argc, char *argv[])
89{
90 GNUNET_log_setup ("test_statistics_api",
91 "WARNING",
92 NULL);
93 check ();
94 return ok; 118 return ok;
95} 119}
96 120