File: cut-multi-process.h

package info (click to toggle)
cutter-testing-framework 1.1.7-1.2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 18,556 kB
  • sloc: ansic: 79,864; xml: 38,680; sh: 10,266; makefile: 2,324; ruby: 845; cpp: 697
file content (541 lines) | stat: -rw-r--r-- 15,057 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 *  Copyright (C) 2008  Kouhei Sutou <kou@cozmixng.org>
 *
 *  This library is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef __CUT_MULTI_PROCESS_H__
#define __CUT_MULTI_PROCESS_H__

#include <cutter/cut-types.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 * SECTION: cut-multi-process
 * @title: Multi Process
 * @short_description: Utilities to run your tests on multi
 * processes.
 *
 * If your test target supports multi-process and/or
 * multi-thread, you need to test them. You can use
 * #CutSubProcess and #CutSubProcessGroup to do it.
 *
 * #CutSubProcess runs your test on another process and
 * forwards results of it to a test on your main
 * process. You will get results of test on another process
 * as results of test on your main process.
 *
 * #CutSubProcessGroup is a convenience object to run some
 * #CutSubProcess.
 *
 * Since: 1.0.4
 */

/**
 * CutSubProcess:
 *
 * An object to represent sub cutter process. It contains
 * sub cutter process's parameters and results of sub cutter
 * process.
 *
 * e.g.:
 * |[
 * CutSubProcess *sub_process;
 *
 * sub_process = cut_take_new_sub_process("test-dir");
 * cut_sub_process_set_multi_thread(sub_process, TRUE);
 * cut_assert_true(cut_sub_process_run(sub_process));
 * ]|
 *
 * Since: 1.0.4
 */
typedef struct _CutSubProcess      CutSubProcess;

/**
 * CutSubProcessGroup:
 *
 * An object to run sub cutter processes. This is just for
 * convenience.
 *
 * e.g.:
 * |[
 * CutSubProcess *sub_process1, *sub_process2, *sub_process3;
 * CutSubProcessGroup *group;
 *
 * sub_process1 = cut_take_new_sub_process("test-dir1");
 * sub_process2 = cut_take_new_sub_process("test-dir2");
 * sub_process3 = cut_take_new_sub_process("test-dir3");
 *
 * group = cut_take_new_sub_process_group();
 * cut_sub_process_group_add(group, sub_process1);
 * cut_sub_process_group_add(group, sub_process2);
 * cut_sub_process_group_add(group, sub_process3);
 * cut_assert_true(cut_sub_process_group_run(group));
 * ]|
 *
 * Since: 1.0.4
 */
typedef struct _CutSubProcessGroup CutSubProcessGroup;

/**
 * cut_take_new_sub_process:
 * @test_directory: a directory includes sub process test.
 *
 * Creates sub cutter process that runs tests under
 * @test_directory and returns it. A created sub process
 * is owned by Cutter.
 *
 * Returns: a #CutSubProcess.
 *
 * Since: 1.0.4
 */
#define cut_take_new_sub_process(test_directory)                       \
    cut_utils_take_new_sub_process(test_directory,                     \
                                   cut_get_current_test_context())

/**
 * cut_sub_process_run:
 * @sub_process: a #CutSubProcess.
 *
 * Runs sub cutter process.
 *
 * Returns: %CUT_TRUE if @sub_process is completed
 * successfully, %CUT_FALSE otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_run                (CutSubProcess  *sub_process);

/**
 * cut_sub_process_run_async:
 * @sub_process: a #CutSubProcess.
 *
 * Runs sub cutter process asynchronously. The result of
 * @sub_process can be gotten by cut_sub_process_wait().
 *
 * Since: 1.0.4
 */
void           cut_sub_process_run_async          (CutSubProcess  *sub_process);

/**
 * cut_sub_process_wait:
 * @sub_process: a #CutSubProcess.
 *
 * Waits for sub cutter process that is ran asynchronously
 * to complete and returns the result.
 *
 * Returns: %CUT_TRUE if @sub_process is completed
 * successfully, %CUT_FALSE otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_wait               (CutSubProcess  *sub_process);

/**
 * cut_sub_process_is_success:
 * @sub_process: a #CutSubProcess.
 *
 * Returns whether @sub_process is completed successfully or
 * not.
 *
 * Returns: %CUT_TRUE if @sub_process is completed
 * successfully, %CUT_FALSE otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_is_success         (CutSubProcess  *sub_process);

/**
 * cut_sub_process_is_running:
 * @sub_process: a #CutSubProcess.
 *
 * Returns whether @sub_process is running or not.
 *
 * Returns: %CUT_TRUE if @sub_process is running, %CUT_FALSE
 * otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_is_running         (CutSubProcess  *sub_process);

/**
 * cut_sub_process_get_test_directory:
 * @sub_process: a #CutSubProcess.
 *
 * Returns a test directory that has tests to be ran.
 *
 * Returns: a test directory.
 *
 * Since: 1.0.4
 */
const char    *cut_sub_process_get_test_directory (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_test_directory:
 * @sub_process: a #CutSubProcess.
 * @test_directory: a test directory.
 *
 * Sets @test_directory as a test directory that has tests
 * to be ran. This is same as TEST_DIRECTORY required
 * command line argument.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_set_test_directory (CutSubProcess  *sub_process,
                                                   const char     *test_directory);

/**
 * cut_sub_process_get_source_directory:
 * @sub_process: a #CutSubProcess.
 *
 * Returns a source directory that has source files.
 *
 * Returns: a source directory.
 *
 * Since: 1.0.4
 */
const char    *cut_sub_process_get_source_directory
                                                  (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_source_directory:
 * @sub_process: a #CutSubProcess.
 * @source_directory: a source directory.
 *
 * Sets @source_directory as a source directory that has
 * source files. This is same as --source-directory command
 * line option.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_set_source_directory
                                                  (CutSubProcess  *sub_process,
                                                   const char     *source_directory);

/**
 * cut_sub_process_get_multi_thread:
 * @sub_process: a #CutSubProcess.
 *
 * Returns whether @sub_process is ran in multi-thread mode.
 *
 * Returns: %CUT_TRUE if @sub_process is ran in multi-thread
 * mode, %CUT_FALSE otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_get_multi_thread   (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_multi_thread:
 * @sub_process: a #CutSubProcess.
 * @multi_thread: %CUT_TRUE to be ran in multi-thread mode.
 *
 * Sets whether @sub_process is ran in multi-thread mode or
 * not. This is same as --multi-thread command line option.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_set_multi_thread   (CutSubProcess  *sub_process,
                                                   cut_boolean     multi_thread);

/**
 * cut_sub_process_get_max_threads:
 * @sub_process: a #CutSubProcess.
 *
 * Returns how many threads are used concurrently at a
 * maximum in @sub_process.
 *
 * Returns: max number of threads used concurrently at a
 * maximum in @sub_process.
 *
 * Since: 1.0.5
 */
int            cut_sub_process_get_max_threads    (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_max_threads:
 * @sub_process: a #CutSubProcess.
 * @max_threads: max number of threads used concurrently at
 *               a maximum.
 *
 * Sets how many threads are used concurrently at a
 * maximum in @sub_process. -1 means no limit. This is same
 * as --max-threads command line option.
 *
 * Since: 1.0.5
 */
void           cut_sub_process_set_max_threads    (CutSubProcess  *sub_process,
                                                   int             max_threads);

/**
 * cut_sub_process_get_exclude_files:
 * @sub_process: a #CutSubProcess.
 *
 * Returns file names that are excluded from target test
 * files.
 *
 * Returns: file names that are excluded from target test files.
 *
 * Since: 1.0.4
 */
const char   **cut_sub_process_get_exclude_files  (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_exclude_files:
 * @sub_process: a #CutSubProcess.
 * @files: file names that are excluded from target test
 * files.
 *
 * Sets file names that are excluded from target test files.
 * This is same as --exclude-file command line option.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_set_exclude_files  (CutSubProcess  *sub_process,
                                                   const char    **files);

/**
 * cut_sub_process_get_exclude_directories:
 * @sub_process: a #CutSubProcess.
 *
 * Returns directory names that are excluded from target
 * test directories.
 *
 * Returns: directory names that are excluded from target
 * test directories.
 *
 * Since: 1.0.4
 */
const char   **cut_sub_process_get_exclude_directories
                                                  (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_exclude_directories:
 * @sub_process: a #CutSubProcess.
 * @directories: directory names that are excluded from
 * target test directories.
 *
 * Sets directory names that are excluded from target test
 * directories. This is same as --exclude-directory command line
 * option.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_set_exclude_directories
                                                  (CutSubProcess  *sub_process,
                                                   const char    **directories);

/**
 * cut_sub_process_get_target_test_case_names:
 * @sub_process: a #CutSubProcess.
 *
 * Returns test case names that are ran.
 *
 * Returns: test case names that are ran.
 *
 * Since: 1.0.4
 */
const char   **cut_sub_process_get_target_test_case_names
                                                  (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_target_test_case_names:
 * @sub_process: a #CutSubProcess.
 * @names: test case names that are ran.
 *
 * Sets test case names that are ran. This is same as
 * --test-case command line option.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_set_target_test_case_names
                                                  (CutSubProcess  *sub_process,
                                                   const char    **names);

/**
 * cut_sub_process_get_target_test_names:
 * @sub_process: a #CutSubProcess.
 *
 * Returns test names that are ran.
 *
 * Returns: test names that are ran.
 *
 * Since: 1.0.4
 */
const char   **cut_sub_process_get_target_test_names
                                                  (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_target_test_names:
 * @sub_process: a #CutSubProcess.
 * @names: test names that are ran.
 *
 * Sets test names that are ran. This is same as --test
 * command line option.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_set_target_test_names
                                                  (CutSubProcess  *sub_process,
                                                   const char    **names);

/**
 * cut_sub_process_get_elapsed:
 * @sub_process: a #CutSubProcess.
 *
 * Gets the time while @sub_process was running.
 *
 * Returns: the time while @sub_process was running.
 *
 * Since: 1.0.4
 */
double         cut_sub_process_get_elapsed        (CutSubProcess  *sub_process);

/**
 * cut_sub_process_get_total_elapsed:
 * @sub_process: a #CutSubProcess.
 *
 * Gets the sum of times that are used by each test.
 *
 * Returns: the sum of times that are used by each test.
 *
 * Since: 1.0.4
 */
double         cut_sub_process_get_total_elapsed  (CutSubProcess  *sub_process);

/**
 * cut_sub_process_is_crashed:
 * @sub_process: a #CutSubProcess.
 *
 * Returns whether @sub_process was crashed or not.
 *
 * Returns: %CUT_TRUE if @sub_process was crashed, %CUT_FALSE
 * otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_is_crashed         (CutSubProcess  *sub_process);

/**
 * cut_sub_process_get_fatal_failures:
 * @sub_process: a #CutSubProcess.
 *
 * Returns whether @sub_process is ran in fatal-failures
 * mode. See cut_sub_process_set_fatal_failures() more
 * details of fatal-failures mode.
 *
 * Returns: %CUT_TRUE if @sub_process is ran in fatal-failures
 * mode, %CUT_FALSE otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_get_fatal_failures (CutSubProcess  *sub_process);

/**
 * cut_sub_process_set_fatal_failures:
 * @sub_process: a #CutSubProcess.
 * @fatal_failures: %CUT_TRUE to be ran in fatal-failures mode.
 *
 * Sets whether @sub_process is ran in fatal-failures mode or
 * not. In this mode, all failures are treated as fatal
 * problems. It means that test is aborted on failure. On
 * some environments, breakpoint is set.
 *
 * This is same as --fatal-failures command line option.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_set_fatal_failures (CutSubProcess  *sub_process,
                                                   cut_boolean     fatal_failures);

/**
 * cut_take_new_sub_process_group:
 *
 * Creates a group of sub cutter process. A created group
 * is owned by Cutter.
 *
 * Returns: a #CutSubProcessGroup.
 *
 * Since: 1.0.4
 */
#define cut_take_new_sub_process_group()                                \
    cut_utils_take_new_sub_process_group(cut_get_current_test_context())

/**
 * cut_sub_process_group_add:
 * @group: a #CutSubProcessGroup.
 * @sub_process: a #CutSubProcess.
 *
 * Adds @sub_process to @group.
 *
 * Since: 1.0.4
 */
void           cut_sub_process_group_add          (CutSubProcessGroup  *group,
                                                   CutSubProcess       *sub_process);

/**
 * cut_sub_process_group_run:
 * @group: a #CutSubProcessGroup.
 *
 * Runs all sub cutter processes of @group and returns the
 * result of them.
 *
 * Returns: %CUT_TRUE if all sub cutter processes of @group
 * are completed successfully, %CUT_FALSE otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_group_run          (CutSubProcessGroup  *group);

/**
 * cut_sub_process_group_run_async:
 * @group: a #CutSubProcessGroup.
 *
 * Runs all sub cutter processes of @group
 * asynchronously. The result of them can be gotten by
 * cut_sub_process_group_wait().
 *
 * Since: 1.0.4
 */
void           cut_sub_process_group_run_async    (CutSubProcessGroup  *group);

/**
 * cut_sub_process_group_wait:
 * @group: a #CutSubProcessGroup.
 *
 * Waits for all sub cutter processes of @group that are ran
 * asynchronously to complete and returns the result.
 *
 * Returns: %CUT_TRUE if all sub cutter processes of @group
 * are completed successfully, %CUT_FALSE otherwise.
 *
 * Since: 1.0.4
 */
cut_boolean    cut_sub_process_group_wait         (CutSubProcessGroup  *group);


#ifdef __cplusplus
}
#endif

#endif /* __CUT_MULTI_PROCESS_H__ */

/*
vi:nowrap:ai:expandtab:sw=4
*/