aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_os_start_process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_os_start_process.c')
-rw-r--r--src/util/test_os_start_process.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c
index df8520546..918ef1bc5 100644
--- a/src/util/test_os_start_process.c
+++ b/src/util/test_os_start_process.c
@@ -53,9 +53,9 @@ end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
53{ 53{
54 54
55 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 55 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
56 { 56 {
57 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 57 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
58 } 58 }
59 GNUNET_OS_process_wait (proc); 59 GNUNET_OS_process_wait (proc);
60 GNUNET_OS_process_close (proc); 60 GNUNET_OS_process_close (proc);
61 proc = NULL; 61 proc = NULL;
@@ -79,28 +79,28 @@ read_call (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
79#endif 79#endif
80 80
81 if (bytes < 1) 81 if (bytes < 1)
82 { 82 {
83 GNUNET_break (0); 83 GNUNET_break (0);
84 ok = 1; 84 ok = 1;
85 GNUNET_SCHEDULER_cancel (die_task); 85 GNUNET_SCHEDULER_cancel (die_task);
86 GNUNET_SCHEDULER_add_now (&end_task, NULL); 86 GNUNET_SCHEDULER_add_now (&end_task, NULL);
87 return; 87 return;
88 } 88 }
89 89
90 ok = strncmp (&buf[0], test_phrase, strlen (test_phrase)); 90 ok = strncmp (&buf[0], test_phrase, strlen (test_phrase));
91#if VERBOSE 91#if VERBOSE
92 fprintf (stderr, "read %s\n", &buf[0]); 92 fprintf (stderr, "read %s\n", &buf[0]);
93#endif 93#endif
94 if (ok == 0) 94 if (ok == 0)
95 { 95 {
96 GNUNET_SCHEDULER_cancel (die_task); 96 GNUNET_SCHEDULER_cancel (die_task);
97 GNUNET_SCHEDULER_add_now (&end_task, NULL); 97 GNUNET_SCHEDULER_add_now (&end_task, NULL);
98 return; 98 return;
99 } 99 }
100 100
101 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 101 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
102 stdout_read_handle, &read_call, 102 stdout_read_handle, &read_call,
103 stdout_read_handle); 103 stdout_read_handle);
104 104
105} 105}
106 106
@@ -118,16 +118,16 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
118 hello_pipe_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES); 118 hello_pipe_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
119 119
120 if ((hello_pipe_stdout == NULL) || (hello_pipe_stdin == NULL)) 120 if ((hello_pipe_stdout == NULL) || (hello_pipe_stdin == NULL))
121 { 121 {
122 GNUNET_break (0); 122 GNUNET_break (0);
123 ok = 1; 123 ok = 1;
124 GNUNET_free (fn); 124 GNUNET_free (fn);
125 return; 125 return;
126 } 126 }
127 127
128 proc = 128 proc =
129 GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn, 129 GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn,
130 "test_gnunet_echo_hello", "-", NULL); 130 "test_gnunet_echo_hello", "-", NULL);
131 GNUNET_free (fn); 131 GNUNET_free (fn);
132 132
133 /* Close the write end of the read pipe */ 133 /* Close the write end of the read pipe */
@@ -140,26 +140,26 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
140 /* Write the test_phrase to the cat process */ 140 /* Write the test_phrase to the cat process */
141 if (GNUNET_DISK_file_write (wh, test_phrase, strlen (test_phrase) + 1) != 141 if (GNUNET_DISK_file_write (wh, test_phrase, strlen (test_phrase) + 1) !=
142 strlen (test_phrase) + 1) 142 strlen (test_phrase) + 1)
143 { 143 {
144 GNUNET_break (0); 144 GNUNET_break (0);
145 ok = 1; 145 ok = 1;
146 return; 146 return;
147 } 147 }
148 148
149 /* Close the write end to end the cycle! */ 149 /* Close the write end to end the cycle! */
150 GNUNET_DISK_pipe_close_end (hello_pipe_stdin, GNUNET_DISK_PIPE_END_WRITE); 150 GNUNET_DISK_pipe_close_end (hello_pipe_stdin, GNUNET_DISK_PIPE_END_WRITE);
151 151
152 stdout_read_handle = 152 stdout_read_handle =
153 GNUNET_DISK_pipe_handle (hello_pipe_stdout, GNUNET_DISK_PIPE_END_READ); 153 GNUNET_DISK_pipe_handle (hello_pipe_stdout, GNUNET_DISK_PIPE_END_READ);
154 154
155 die_task = 155 die_task =
156 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 156 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
157 (GNUNET_TIME_UNIT_MINUTES, 1), &end_task, 157 (GNUNET_TIME_UNIT_MINUTES, 1), &end_task,
158 NULL); 158 NULL);
159 159
160 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, 160 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
161 stdout_read_handle, &read_call, 161 stdout_read_handle, &read_call,
162 (void *) stdout_read_handle); 162 (void *) stdout_read_handle);
163 163
164} 164}
165 165
@@ -183,11 +183,11 @@ main (int argc, char *argv[])
183 183
184 GNUNET_log_setup ("test-os-start-process", 184 GNUNET_log_setup ("test-os-start-process",
185#if VERBOSE 185#if VERBOSE
186 "DEBUG", 186 "DEBUG",
187#else 187#else
188 "WARNING", 188 "WARNING",
189#endif 189#endif
190 NULL); 190 NULL);
191 ret = check (); 191 ret = check ();
192 192
193 return ret; 193 return ret;