1 // Copyright 2012 Google Inc.
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Google Inc. nor the names of its contributors
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 /// Exit code to report internal, unexpected errors.
39 static const int EXIT_BOGUS
= 123;
42 /// Test case that always fails.
46 fprintf(stdout
, "First line to stdout\n");
47 fprintf(stderr
, "First line to stderr\n");
52 /// Test case that always passes.
56 fprintf(stdout
, "First line to stdout\n");
57 fprintf(stdout
, "Second line to stdout\n");
58 fprintf(stderr
, "First line to stderr\n");
59 fprintf(stderr
, "Second line to stderr\n");
64 /// Test case that always dies due to a signal and dumps core.
68 fprintf(stderr
, "About to die due to SIGABRT!\n");
73 /// Test case that sleeps for a long time.
82 /// Dispatcher for individual testers based on the HELPER environment variable.
84 /// \param argc Number of arguments to the command.
85 /// \param unused_argv Arguments to the command.
87 /// \return An exit code.
89 main(const int argc
, char* const* const KYUA_DEFS_UNUSED_PARAM(argv
))
92 errx(EXIT_BOGUS
, "No arguments allowed");
94 const char* helper_name
= getenv("HELPER");
95 if (helper_name
== NULL
) {
96 errx(EXIT_BOGUS
, "Must set HELPER to the name of the desired helper");
99 if (strcmp(helper_name
, "fail") == 0) {
100 return fail_helper();
101 } else if (strcmp(helper_name
, "pass") == 0) {
102 return pass_helper();
103 } else if (strcmp(helper_name
, "signal") == 0) {
104 return signal_helper();
105 } else if (strcmp(helper_name
, "sleep") == 0) {
106 return sleep_helper();
108 errx(EXIT_BOGUS
, "Unknown helper '%s'", helper_name
);