X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tests%2Fexample_error.c;h=0d979db7fe50eb6e0fd0132ccf34c41403e030d0;hb=39d313d1d474dbe025270b9555a5dfb03286c8c9;hp=04eca8dcff611dea9a565ec4bfb384a6d4a626f2;hpb=7f9856c5dace35f8efe5a20ee1013815e67b9550;p=coloredstderr%2Fcoloredstderr.git diff --git a/tests/example_error.c b/tests/example_error.c index 04eca8d..0d979db 100644 --- a/tests/example_error.c +++ b/tests/example_error.c @@ -17,41 +17,65 @@ * along with this program. If not, see . */ +#include + #define _GNU_SOURCE /* for program_invocation_name */ -#include -#include #include #include +#include +#include +#include +#include +#include + +#include "../src/compiler.h" +#include "example.h" + void (*error_print_progname)(void); -static void print_prognmae(void) { +static void print_progname(void) { fprintf(stderr, "PROG"); } -int main(int argc, char **argv) { - program_invocation_name = "./example_error"; +int main(int argc unused, char **argv unused) { + pid_t pid; + + char name[] = "./example_error"; + program_invocation_name = name; error(0, 0, ""); error_at_line(0, 0, "file", 42, ""); + FORKED_TEST(pid) { error(1, 0, ""); } + FORKED_TEST(pid) { error_at_line(1, 0, "file", 42, ""); } error(0, ENOMEM, ""); error_at_line(0, ENOMEM, "file", 42, ""); error_at_line(0, ENOMEM, "file", 42, ""); + FORKED_TEST(pid) { error(1, ENOMEM, ""); } + FORKED_TEST(pid) { error_at_line(1, ENOMEM, "file", 42, ""); } + + fflush(stdout); + printf("\n\n"); + fflush(stdout); - error_print_progname = print_prognmae; + error_print_progname = print_progname; error_one_per_line = 1; error(0, 0, ""); error_at_line(0, 0, "file", 42, ""); + FORKED_TEST(pid) { error(1, 0, ""); } + FORKED_TEST(pid) { error_at_line(1, 0, "file", 42, ""); } error(0, ENOMEM, ""); error_at_line(0, ENOMEM, "file", 42, ""); error_at_line(0, ENOMEM, "file", 42, ""); + FORKED_TEST(pid) { error(1, ENOMEM, ""); } - /* Exit codes are not tested. */ + error_one_per_line = 0; + FORKED_TEST(pid) { error_at_line(1, ENOMEM, "file", 42, ""); } return EXIT_SUCCESS; }