Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  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
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
// Copyright 2012 Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
//   notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the
//   documentation and/or other materials provided with the distribution.
// * Neither the name of Google Inc. nor the names of its contributors
//   may be used to endorse or promote products derived from this software
//   without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "cli.h"

#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <atf-c.h>

#include "defs.h"
#include "error.h"
#include "run.h"


/// Dumps the contents of a run_params object to stdout.
///
/// We only print the settings that are relevant for testing purposes.
///
/// \param run_params The run parameters to be printed.
static void
dump_run_params(const kyua_run_params_t* run_params)
{
    printf("timeout_seconds: %lu\n", run_params->timeout_seconds);

    if (run_params->unprivileged_user == getuid())
        printf("unprivileged_user: self\n");
    else
        printf("unprivileged_user: %ld\n", (long)run_params->unprivileged_user);

    if (run_params->unprivileged_group == getgid())
        printf("unprivileged_group: self\n");
    else
        printf("unprivileged_group: %ld\n",
               (long)run_params->unprivileged_group);
}


/// Helper to validate argument passing to the list_test_cases method.
///
/// This prints the value of all arguments to stdout so that the caller can
/// compare the printed output to the expected values.
///
/// \param test_program Test program path.
/// \param run_params Execution parameters to configure the test process.
///
/// \return An error if the test_program is set to the magic keyword 'error'; OK
/// otherwise.
static kyua_error_t
list_test_cases(const char* test_program, const kyua_run_params_t* run_params)
{
    if (strcmp(test_program, "error") == 0)
        return kyua_oom_error_new();
    else {
        printf("test_program: %s\n", test_program);
        dump_run_params(run_params);
        return kyua_error_ok();
    }
}


/// Helper to validate argument passing to the run_test_cases method.
///
/// This prints the value of all arguments to stdout so that the caller can
/// compare the printed output to the expected values.
///
/// \param test_program Test program path.
/// \param test_case Test case name.
/// \param result_file Path to the result file.
/// \param user_variables User configuration variables.
/// \param run_params Execution parameters to configure the test process.
/// \param [out] success Whether the test case returned with a successful result
///     or not.  Set to true if result_file is the magic word 'pass'.
///
/// \return An error if the test_program is set to the magic keyword 'error'; OK
/// otherwise.
static kyua_error_t
run_test_case(const char* test_program, const char* test_case,
              const char* result_file, const char* const user_variables[],
              const kyua_run_params_t* run_params, bool* success)
{
    if (strcmp(test_program, "error") == 0)
        return kyua_oom_error_new();
    else {
        printf("test_program: %s\n", test_program);
        printf("test_case: %s\n", test_case);
        printf("result_file: %s\n", result_file);
        const char* const* iter;
        for (iter = user_variables; *iter != NULL; ++iter)
            printf("variable: %s\n", *iter);
        dump_run_params(run_params);
        *success = strcmp(result_file, "pass") == 0;
        return kyua_error_ok();
    }
}


/// Definition of a mock tester.
static kyua_cli_tester_t mock_tester = {
    .list_test_cases = list_test_cases,
    .run_test_case = run_test_case,
};


/// Definition of a tester with invalid values.
///
/// This is to be used when the called code is not supposed to invoke any of the
/// tester methods.
static kyua_cli_tester_t unused_tester = {
    .list_test_cases = NULL,
    .run_test_case = NULL,
};


/// Counts the number of arguments in an argv vector.
///
/// \param argv The NULL-terminated arguments vector to be passed to the
///     kyua_cli_main function.
///
/// \return The number of arguments in argv.
static int
count_argv(char* const* const argv)
{
    int argc = 0;
    char* const* arg;
    for (arg = argv; *arg != NULL; arg++)
        argc++;
    return argc;
}


ATF_TC_WITHOUT_HEAD(main__unknown_option);
ATF_TC_BODY(main__unknown_option, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "-Z";
        char* const argv[] = {arg0, arg1, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: Unknown option -Z\n");
}


ATF_TC_WITHOUT_HEAD(main__missing_option_argument);
ATF_TC_BODY(main__missing_option_argument, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "-t";
        char* const argv[] = {arg0, arg1, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: -t requires an "
                   "argument\n");
}


ATF_TC_WITHOUT_HEAD(main__unknown_command);
ATF_TC_BODY(main__unknown_command, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "foobar";
        char* const argv[] = {arg0, arg1, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: Unknown command "
                   "'foobar'\n");
}


ATF_TC_WITHOUT_HEAD(main__missing_command);
ATF_TC_BODY(main__missing_command, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char* const argv[] = {arg0, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: Must provide a "
                   "command\n");
}


/// Checks that a textual argument to a numerical flag raises an error.
///
/// \param flag The generic flag to test.
/// \param error_message The expected error message when the flag is invalid.
static void
check_flag_not_a_number(const char flag, const char *error_message)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "-?foo";
        arg1[1] = flag;
        char* const argv[] = {arg0, arg1, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    char experr[256];
    snprintf(experr, sizeof(experr), "cli_test: %s 'foo' (not a number)\n",
             error_message);
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", experr);
}


/// Checks that an out of range value to a numerical flag raises an error.
///
/// \param flag The generic flag to test.
/// \param error_message The expected error message when the flag is invalid.
static void
check_flag_out_of_range(const char flag, const char *error_message)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "-?99999999999999999999";
        arg1[1] = flag;
        char* const argv[] = {arg0, arg1, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    char experr[256];
    snprintf(experr, sizeof(experr), "cli_test: %s '99999999999999999999' "
             "(out of range)\n", error_message);
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", experr);
}


ATF_TC_WITHOUT_HEAD(main__gflag__not_a_number);
ATF_TC_BODY(main__gflag__not_a_number, tc)
{
    check_flag_not_a_number('g', "Invalid GID");
}


ATF_TC_WITHOUT_HEAD(main__gflag__out_of_range);
ATF_TC_BODY(main__gflag__out_of_range, tc)
{
    check_flag_out_of_range('g', "Invalid GID");
}


ATF_TC_WITHOUT_HEAD(main__tflag__not_a_number);
ATF_TC_BODY(main__tflag__not_a_number, tc)
{
    check_flag_not_a_number('t', "Invalid timeout value");
}


ATF_TC_WITHOUT_HEAD(main__tflag__out_of_range);
ATF_TC_BODY(main__tflag__out_of_range, tc)
{
    check_flag_out_of_range('t', "Invalid timeout value");
}


ATF_TC_WITHOUT_HEAD(main__uflag__not_a_number);
ATF_TC_BODY(main__uflag__not_a_number, tc)
{
    check_flag_not_a_number('u', "Invalid UID");
}


ATF_TC_WITHOUT_HEAD(main__uflag__out_of_range);
ATF_TC_BODY(main__uflag__out_of_range, tc)
{
    check_flag_out_of_range('u', "Invalid UID");
}


ATF_TC_WITHOUT_HEAD(list__ok);
ATF_TC_BODY(list__ok, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "list";
        char arg2[] = "the-program";
        char* const argv[] = {arg0, arg1, arg2, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &mock_tester));
    }
    atf_utils_wait(pid, EXIT_SUCCESS,
                   "test_program: the-program\n"
                   "timeout_seconds: 60\n"
                   "unprivileged_user: self\n"
                   "unprivileged_group: self\n",
                   "");
}


ATF_TC_WITHOUT_HEAD(list__custom_run_params);
ATF_TC_BODY(list__custom_run_params, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "-g987";
        char arg2[] = "-t123";
        char arg3[] = "-u45";
        char arg4[] = "list";
        char arg5[] = "the-program";
        char* const argv[] = {arg0, arg1, arg2, arg3, arg4, arg5, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &mock_tester));
    }
    atf_utils_wait(pid, EXIT_SUCCESS,
                   "test_program: the-program\n"
                   "timeout_seconds: 123\n"
                   "unprivileged_user: 45\n"
                   "unprivileged_group: 987\n",
                   "");
}


ATF_TC_WITHOUT_HEAD(list__error);
ATF_TC_BODY(list__error, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "list";
        char arg2[] = "error";
        char* const argv[] = {arg0, arg1, arg2, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &mock_tester));
    }
    atf_utils_wait(pid, EXIT_INTERNAL_ERROR, "", "cli_test: Not enough "
                   "memory\n");
}


ATF_TC_WITHOUT_HEAD(list__missing_arguments);
ATF_TC_BODY(list__missing_arguments, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "list";
        char* const argv[] = {arg0, arg1, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: No test program "
                   "provided\n");
}


ATF_TC_WITHOUT_HEAD(list__too_many_arguments);
ATF_TC_BODY(list__too_many_arguments, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "list";
        char arg2[] = "first";
        char arg3[] = "second";
        char* const argv[] = {arg0, arg1, arg2, arg3, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: Only one test program "
                   "allowed\n");
}


ATF_TC_WITHOUT_HEAD(test__ok__pass);
ATF_TC_BODY(test__ok__pass, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "test";
        char arg2[] = "the-program";
        char arg3[] = "the-test-case";
        char arg4[] = "pass";
        char* const argv[] = {arg0, arg1, arg2, arg3, arg4, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &mock_tester));
    }
    atf_utils_wait(pid, EXIT_SUCCESS,
                   "test_program: the-program\n"
                   "test_case: the-test-case\n"
                   "result_file: pass\n"
                   "timeout_seconds: 60\n"
                   "unprivileged_user: self\n"
                   "unprivileged_group: self\n",
                   "");
}


ATF_TC_WITHOUT_HEAD(test__ok__fail);
ATF_TC_BODY(test__ok__fail, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "test";
        char arg2[] = "the-program";
        char arg3[] = "the-test-case";
        char arg4[] = "fail";
        char* const argv[] = {arg0, arg1, arg2, arg3, arg4, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &mock_tester));
    }
    atf_utils_wait(pid, EXIT_FAILURE,
                   "test_program: the-program\n"
                   "test_case: the-test-case\n"
                   "result_file: fail\n"
                   "timeout_seconds: 60\n"
                   "unprivileged_user: self\n"
                   "unprivileged_group: self\n",
                   "");
}


ATF_TC_WITHOUT_HEAD(test__custom_run_params);
ATF_TC_BODY(test__custom_run_params, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "-g987";
        char arg2[] = "-t123";
        char arg3[] = "-u45";
        char arg4[] = "test";
        char arg5[] = "the-program";
        char arg6[] = "the-test-case";
        char arg7[] = "pass";
        char* const argv[] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7,
                              NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &mock_tester));
    }
    atf_utils_wait(pid, EXIT_SUCCESS,
                   "test_program: the-program\n"
                   "test_case: the-test-case\n"
                   "result_file: pass\n"
                   "timeout_seconds: 123\n"
                   "unprivileged_user: 45\n"
                   "unprivileged_group: 987\n",
                   "");
}


ATF_TC_WITHOUT_HEAD(test__config_variables);
ATF_TC_BODY(test__config_variables, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "test";
        char arg2[] = "-vfoo=bar";
        char arg3[] = "-va=c";
        char arg4[] = "the-program";
        char arg5[] = "the-test-case";
        char arg6[] = "pass";
        char* const argv[] = {arg0, arg1, arg2, arg3, arg4, arg5, arg6, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &mock_tester));
    }
    atf_utils_wait(pid, EXIT_SUCCESS,
                   "test_program: the-program\n"
                   "test_case: the-test-case\n"
                   "result_file: pass\n"
                   "variable: foo=bar\n"
                   "variable: a=c\n"
                   "timeout_seconds: 60\n"
                   "unprivileged_user: self\n"
                   "unprivileged_group: self\n",
                   "");
}


ATF_TC_WITHOUT_HEAD(test__error);
ATF_TC_BODY(test__error, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "test";
        char arg2[] = "error";
        char* const argv[] = {arg0, arg1, arg2, arg2, arg2, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &mock_tester));
    }
    atf_utils_wait(pid, EXIT_INTERNAL_ERROR, "", "cli_test: Not enough "
                   "memory\n");
}


/// Checks that the test command validates the right number of arguments.
///
/// \param count Number of arguments to pass to the test command.
static void
check_test_invalid_arguments(const unsigned int count)
{
    printf("Checking with %d arguments\n", count);
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "test";
        char argX[] = "arg";
        assert(count <= 4);
        char* argv[] = {arg0, arg1, argX, argX, argX, argX, NULL};
        argv[2 + count] = NULL;
        exit(kyua_cli_main(2 + count, argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: Must provide a test "
                   "program, a test case name and a result file\n");
}


ATF_TC_WITHOUT_HEAD(test__invalid_arguments);
ATF_TC_BODY(test__invalid_arguments, tc)
{
    check_test_invalid_arguments(0);
    check_test_invalid_arguments(1);
    check_test_invalid_arguments(2);
    check_test_invalid_arguments(4);
}


ATF_TC_WITHOUT_HEAD(test__unknown_option);
ATF_TC_BODY(test__unknown_option, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "test";
        char arg2[] = "-Z";
        char* const argv[] = {arg0, arg1, arg2, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: Unknown test option "
                   "-Z\n");
}


ATF_TC_WITHOUT_HEAD(test__missing_option_argument);
ATF_TC_BODY(test__missing_option_argument, tc)
{
    const pid_t pid = atf_utils_fork();
    if (pid == 0) {
        char arg0[] = "unused-progname";
        char arg1[] = "test";
        char arg2[] = "-v";
        char* const argv[] = {arg0, arg1, arg2, NULL};
        exit(kyua_cli_main(count_argv(argv), argv, &unused_tester));
    }
    atf_utils_wait(pid, EXIT_USAGE_ERROR, "", "cli_test: test's -v requires an "
                   "argument\n");
}


ATF_TP_ADD_TCS(tp)
{
    ATF_TP_ADD_TC(tp, main__unknown_option);
    ATF_TP_ADD_TC(tp, main__missing_option_argument);
    ATF_TP_ADD_TC(tp, main__unknown_command);
    ATF_TP_ADD_TC(tp, main__missing_command);
    ATF_TP_ADD_TC(tp, main__gflag__not_a_number);
    ATF_TP_ADD_TC(tp, main__gflag__out_of_range);
    ATF_TP_ADD_TC(tp, main__tflag__not_a_number);
    ATF_TP_ADD_TC(tp, main__tflag__out_of_range);
    ATF_TP_ADD_TC(tp, main__uflag__not_a_number);
    ATF_TP_ADD_TC(tp, main__uflag__out_of_range);

    ATF_TP_ADD_TC(tp, list__ok);
    ATF_TP_ADD_TC(tp, list__custom_run_params);
    ATF_TP_ADD_TC(tp, list__error);
    ATF_TP_ADD_TC(tp, list__missing_arguments);
    ATF_TP_ADD_TC(tp, list__too_many_arguments);

    ATF_TP_ADD_TC(tp, test__ok__pass);
    ATF_TP_ADD_TC(tp, test__ok__fail);
    ATF_TP_ADD_TC(tp, test__custom_run_params);
    ATF_TP_ADD_TC(tp, test__config_variables);
    ATF_TP_ADD_TC(tp, test__error);
    ATF_TP_ADD_TC(tp, test__invalid_arguments);
    ATF_TP_ADD_TC(tp, test__unknown_option);
    ATF_TP_ADD_TC(tp, test__missing_option_argument);

    return atf_no_error();
}