static void check_event_1 (void) { static const char *NORMAL_ARGV[] = { "testlwes-event-counting-listener", "-m", TEST_LLOG_ADDRESS, "-p", TEST_LLOG_PORT, "-i", TEST_LLOG_INTERFACE, }; static int NORMAL_ARGC = NUM_ELEMS (NORMAL_ARGV); /* this will totally not work if the order changes, or the SenderPort SenderIP or ReceiptTime are not the lengths represented here */ const char *output = "TypeChecker[12]\n" "{\n" "\tanIPAddress = 224.0.0.100;\n" "\tanInt16 = -1;\n" "\tanInt64 = -1;\n" "\tReceiptTime = \1\1\1\1\1\1\1\1\1\1\1\1\1;\n" "\tSenderIP = \1\1\1\1\1\1\1\1\1;\n" "\taUInt32 = 4294967295;\n" "\taUInt16 = 65535;\n" "\taUInt64 = 18446744073709551615;\n" "\tSenderPort = \1\1\1\1\1;\n" "\taBoolean = true;\n" "\taString = \"http://www.test.com\";\n" "\tanInt32 = -1;\n" "}\n"; fork_and_wait (NORMAL_ARGC, NORMAL_ARGV, 500, TRUE, TRUE, TRUE, output, NULL); }
static void check_opt_help (void) { static const char *HELP_ARGV[] = { "testlwes-event-testing-emitter", "-h", }; static int HELP_ARGC = NUM_ELEMS (HELP_ARGV); fork_and_wait (HELP_ARGC, HELP_ARGV, 500, TRUE, FALSE, TRUE, NULL, help); }
ATF_TC_BODY(wait__invalid_stderr, tc) { const pid_t control = fork(); ATF_REQUIRE(control != -1); if (control == 0) fork_and_wait(123, "Some output\n", "Some error foo\n"); else { int status; ATF_REQUIRE(waitpid(control, &status, 0) != -1); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(EXIT_FAILURE, WEXITSTATUS(status)); } }
ATF_TC_BODY(wait__ok, tc) { const pid_t control = fork(); ATF_REQUIRE(control != -1); if (control == 0) fork_and_wait(123, "Some output\n", "Some error\n"); else { int status; ATF_REQUIRE(waitpid(control, &status, 0) != -1); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status)); } }
static void check_opt_bad (void) { static const char *BOGUS_ARGV[] = { "testlwes-event-testing-emitter", "-z", }; static int BOGUS_ARGC = NUM_ELEMS (BOGUS_ARGV); const char *error = "error: unrecognized command line option -z\n"; fork_and_wait (BOGUS_ARGC, BOGUS_ARGV, 500, TRUE, FALSE, TRUE, NULL, error); }
ATF_TC_BODY(wait__save_stderr, tc) { const pid_t control = fork(); ATF_REQUIRE(control != -1); if (control == 0) fork_and_wait(123, "Some output\n", "save:my-output.txt"); else { int status; ATF_REQUIRE(waitpid(control, &status, 0) != -1); ATF_REQUIRE(WIFEXITED(status)); ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status)); ATF_REQUIRE(atf_utils_compare_file("my-output.txt", "Some error\n")); } }
static void check_opt_bad (void) { static const char *BOGUS_ARGV[] = { "testlwes-event-printing-listener", "-z", }; static int BOGUS_ARGC = NUM_ELEMS (BOGUS_ARGV); const char *error = "error: unrecognized command line option -z\n"; /* It seems strange that lwes-event-printing-listener is supposed to go ahead and run when it gets a bad command-line argument, but that's the current behavior: */ fork_and_wait (BOGUS_ARGC, BOGUS_ARGV, 500, TRUE, FALSE, TRUE, NULL, error); }
static void check_event_1 (void) { static const char *NORMAL_ARGV[] = { "testlwes-event-testing-emitter", "-m", TEST_LLOG_ADDRESS, "-p", TEST_LLOG_PORT, "-i", TEST_LLOG_INTERFACE, }; static int NORMAL_ARGC = NUM_ELEMS (NORMAL_ARGV); /* this will totally not work if the order changes, or the SenderPort SenderIP or ReceiptTime are not the lengths represented here */ const char *output = "\1\1:\1\1:\1\1 \1\1/\1\1/\1\1\1\1 : 1\n"; fork_and_wait (NORMAL_ARGC, NORMAL_ARGV, 100000, TRUE, TRUE, TRUE, output, NULL); }
static void check_opt_c_and_q (void) { static const char *NORMAL_ARGV[] = { "testlwes-event-counting-listener", "-c", "-q", "-m", TEST_LLOG_ADDRESS, "-p", TEST_LLOG_PORT, "-i", TEST_LLOG_INTERFACE, }; static int NORMAL_ARGC = NUM_ELEMS (NORMAL_ARGV); /* this may prove to be a flakey test, we are trying to wait for one second using the usleep() calls in fork_and_wait, keeping fingers crossed this will work on different platforms */ const char *output = "\1\1:\1\1:\1\1 \1\1/\1\1/\1\1\1\1 : 1\n" ; fork_and_wait (NORMAL_ARGC, NORMAL_ARGV, 90000, TRUE, TRUE, TRUE, output, NULL); }