aboutsummaryrefslogtreecommitdiffstats
path: root/longbow/src/LongBow/Reporting
diff options
context:
space:
mode:
Diffstat (limited to 'longbow/src/LongBow/Reporting')
-rw-r--r--longbow/src/LongBow/Reporting/ANSITerm/longBowReportANSITerminal_About.c44
-rwxr-xr-xlongbow/src/LongBow/Reporting/ANSITerm/longBowReportANSITerminal_About.h54
-rw-r--r--longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Runtime.c291
-rwxr-xr-xlongbow/src/LongBow/Reporting/ANSITerm/longBowReport_Runtime.h67
-rw-r--r--longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Testing.c191
-rw-r--r--longbow/src/LongBow/Reporting/Android/longBowReportAndroid_About.c44
-rwxr-xr-xlongbow/src/LongBow/Reporting/Android/longBowReportAndroid_About.h54
-rw-r--r--longbow/src/LongBow/Reporting/Android/longBowReport_Runtime.c92
-rwxr-xr-xlongbow/src/LongBow/Reporting/Android/longBowReport_Testing.c198
-rw-r--r--longbow/src/LongBow/Reporting/TextPlain/longBowReportTextPlain_About.c44
-rwxr-xr-xlongbow/src/LongBow/Reporting/TextPlain/longBowReportTextPlain_About.h54
-rwxr-xr-xlongbow/src/LongBow/Reporting/TextPlain/longBowReport_Runtime.c95
-rwxr-xr-xlongbow/src/LongBow/Reporting/TextPlain/longBowReport_Testing.c193
-rwxr-xr-xlongbow/src/LongBow/Reporting/longBowReport_Runtime.c50
-rwxr-xr-xlongbow/src/LongBow/Reporting/longBowReport_Runtime.h146
-rwxr-xr-xlongbow/src/LongBow/Reporting/longBowReport_Testing.c22
-rwxr-xr-xlongbow/src/LongBow/Reporting/longBowReport_Testing.h71
17 files changed, 1710 insertions, 0 deletions
diff --git a/longbow/src/LongBow/Reporting/ANSITerm/longBowReportANSITerminal_About.c b/longbow/src/LongBow/Reporting/ANSITerm/longBowReportANSITerminal_About.c
new file mode 100644
index 00000000..e12c7b37
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/ANSITerm/longBowReportANSITerminal_About.c
@@ -0,0 +1,44 @@
+// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
+// longbow-generate-about 1.0.20170214.46e2c73a 2017-02-14T20:35:31Z
+
+#include "longBowReportANSITerminal_About.h"
+
+const char *longBowReportANSITerminal_What = "@(#)" "LongBow ANSI Terminal Reporter " RELEASE_VERSION " 2017-02-14T21:39:44.348378"
+ "@(#)" "\tCopyright (c) 2017 Cisco and/or its affiliates.";
+
+const char *
+longBowReportANSITerminalAbout_Name(void)
+{
+ return "LongBow ANSI Terminal Reporter";
+}
+
+const char *
+longBowReportANSITerminalAbout_Version(void)
+{
+ return RELEASE_VERSION;
+}
+
+const char *
+longBowReportANSITerminalAbout_About(void)
+{
+ return "LongBow ANSI Terminal Reporter "RELEASE_VERSION " 2017-02-14T21:39:44.348378" "\nCopyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportANSITerminalAbout_MiniNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportANSITerminalAbout_ShortNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportANSITerminalAbout_LongNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n\n";
+}
+
diff --git a/longbow/src/LongBow/Reporting/ANSITerm/longBowReportANSITerminal_About.h b/longbow/src/LongBow/Reporting/ANSITerm/longBowReportANSITerminal_About.h
new file mode 100755
index 00000000..8dd3230c
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/ANSITerm/longBowReportANSITerminal_About.h
@@ -0,0 +1,54 @@
+// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
+// longbow-generate-about 1.0.20170214.46e2c73a 2017-02-14T20:35:31Z
+
+#ifndef longBowReportANSITerminal_About_h
+#define longBowReportANSITerminal_About_h
+/**
+ * Embedded string containing information for the what(1) command.
+ *
+ */
+extern const char *longBowReportANSITerminal_What;
+
+/**
+ * Return the name as a C string.
+ *
+ * @return The name as a C string.
+ */
+const char *longBowReportANSITerminalAbout_Name(void);
+
+/**
+ * Return the version as a C string.
+ *
+ * @return The version as a C string.
+ */
+const char *longBowReportANSITerminalAbout_Version(void);
+
+/**
+ * Return the About text as a C string.
+ *
+ * @return The About text as a C string.
+ */
+const char *longBowReportANSITerminalAbout_About(void);
+
+/**
+ * Return the minimum copyright notice as a C string.
+ *
+ * @return The minimum copyright notice as a C string.
+ */
+const char *longBowReportANSITerminalAbout_MiniNotice(void);
+
+/**
+ * Return the short copyright notice as a C string.
+ *
+ * @return The short copyright notice as a C string.
+ */
+const char *longBowReportANSITerminalAbout_ShortNotice(void);
+
+/**
+ * Return the long copyright notice as a C string.
+ *
+ * @return The long copyright notice as a C string.
+ */
+const char *longBowReportANSITerminalAbout_LongNotice(void);
+
+#endif // longBowReportANSITerminal_About_h
diff --git a/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Runtime.c b/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Runtime.c
new file mode 100644
index 00000000..60ca4d42
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Runtime.c
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ */
+#include <config.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include <LongBow/Reporting/ANSITerm/longBowReport_Runtime.h>
+#include <LongBow/private/longBow_Memory.h>
+
+static const char *ansiRed = "\x1b[31m";
+static const char *ansiGreen = "\x1b[32m";
+static const char *ansiYellow = "\x1b[33m";
+static const char *ansiMagenta = "\x1b[35m";
+static const char *ansiReset = "\x1b[0m";
+
+static void
+_printGreen(void)
+{
+ printf("%s", ansiGreen);
+}
+
+static void
+_printYellow(void)
+{
+ printf("%s", ansiYellow);
+}
+
+static void
+_printMagenta(void)
+{
+ printf("%s", ansiMagenta);
+}
+
+static void
+_printReset(void)
+{
+ printf("%s", ansiReset);
+ fflush(stdout);
+}
+
+static void
+_longBowReportRuntime_RedPrintf(const char *format, va_list args)
+{
+ longBowReportRuntime_PrintRed();
+ vprintf(format, args);
+ _printReset();
+}
+
+static void
+_longBowReportRuntime_YellowPrintf(const char *format, va_list args)
+{
+ _printYellow();
+ vprintf(format, args);
+ _printReset();
+}
+
+void
+longBowReportRuntime_PrintRed(void)
+{
+ printf("%s", ansiRed);
+}
+
+void
+longBowReportRuntime_RedPrintf(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ _longBowReportRuntime_RedPrintf(format, args);
+ va_end(args);
+}
+
+void
+longBowReportRuntime_GreenPrintf(const char *format, ...)
+{
+ _printGreen();
+ va_list args;
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+ _printReset();
+}
+
+void
+longBowReportRuntime_MagentaPrintf(const char *format, ...)
+{
+ _printMagenta();
+ va_list args;
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+ _printReset();
+}
+
+void
+longBowReportRuntime_YellowPrintf(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+
+ _longBowReportRuntime_YellowPrintf(format, args);
+
+ va_end(args);
+}
+
+void
+longBowReportRuntime_ParseSuppress(LongBowReportConfig *result, const char *key)
+{
+ for (size_t i = 0; i < strlen(key); i++) {
+ if (*key == 'X') {
+ result->suppress_report.untested = 1;
+ } else if (*key == '.') {
+ result->suppress_report.succeeded = 1;
+ } else if (*key == 'S') {
+ result->suppress_report.skipped = 1;
+ } else if (*key == 'W') {
+ result->suppress_report.warned = 1;
+ } else if (*key == 's') {
+ result->suppress_report.setup_failed = 1;
+ } else if (*key == 't') {
+ result->suppress_report.teardown_failed = 1;
+ } else if (*key == 'w') {
+ result->suppress_report.teardown_warned = 1;
+ } else if (*key == 'F') {
+ result->suppress_report.failed = 1;
+ } else if (*key == 'T') {
+ result->suppress_report.stopped = 1;
+ } else if (*key == 'U') {
+ result->suppress_report.unimplemented = 1;
+ } else {
+ printf("Unknown suppression key '%c'\n", *key);
+ }
+ }
+}
+
+LongBowReportConfig *
+longBowReportRuntime_Create(int argc, char *argv[])
+{
+ static const char *prefix = "--report";
+ size_t prefixLength = strlen(prefix);
+
+ LongBowReportConfig *result = longBowMemory_Allocate(sizeof(LongBowReportConfig));
+
+ for (int i = 0; i < argc; i++) {
+ if (strncmp(prefix, argv[i], prefixLength) == 0) {
+ if (strcmp("--report-suppress", argv[i]) == 0) {
+ longBowReportRuntime_ParseSuppress(result, argv[i + 1]);
+ i++;
+ }
+ } else if (strcmp("--help", argv[i]) == 0) {
+ printf("Options for LongBow Report ANSI Terminal\n");
+ printf(" --report-suppress [STFU.XWstw] Suppress the display of specific reports.\n");
+ printf(" S - suppress the report of a skipped test.\n");
+ printf(" T - suppress the report of a stopped test.\n");
+ printf(" F - suppress the report of a failed test.\n");
+ printf(" U - suppress the report of an unimplemented test.\n");
+ printf(" . - suppress the report of a successful test.\n");
+ printf(" X - suppress the report of an untested test.\n");
+ printf(" W - suppress the report of a warned test.\n");
+ printf(" s - suppress the report of a setup failure.\n");
+ printf(" t - suppress the report of a tear-down failure.\n");
+ printf(" w - suppress the report of a tear-down warning.\n");
+ free(result);
+ return NULL;
+ }
+ }
+
+ return result;
+}
+
+void
+longBowReportRuntime_Destroy(LongBowReportConfig **reportPtr)
+{
+ longBowMemory_Deallocate((void **) reportPtr);
+}
+
+static void
+_EventPrint(const LongBowEvent *event)
+{
+ if (longBowEventType_IsSuppressAlert(longBowEvent_GetEventType(event)) == false) {
+ char *location = longBowLocation_ToString(longBowEvent_GetLocation(event));
+ printf("%s %s %s %s\r\n",
+ longBowEvent_GetName(event), location, longBowEvent_GetKind(event), longBowEvent_GetMessage(event));
+
+ if (longBowEventType_IsSuppressBacktrace(longBowEvent_GetEventType(event)) == false) {
+ char **strs = longBowEvent_CreateSymbolicCallstack(event);
+ if (strs != NULL) {
+ for (size_t i = 0; i < longBowEvent_GetCallStackLength(event); ++i) {
+ printf("%s\r\n", strs[i]);
+ }
+ free(strs);
+ }
+ }
+ fflush(stdout);
+ free(location);
+ }
+}
+
+void
+longBowReportRuntime_Event(const LongBowEvent *event)
+{
+ LongBowStatus status = longBowEventType_GetStatus(longBowEvent_GetEventType(event));
+ switch (status) {
+ case LongBowStatus_DONTCARE:
+ case LongBowStatus_UNTESTED:
+ break;
+
+ /* successful */
+ case LONGBOW_STATUS_SUCCEEDED:
+ // If this happens, there is an error in the encoding of the LongBowEventType.
+ longBowReportRuntime_PrintRed();
+ _EventPrint(event);
+ _printReset();
+ break;
+
+ case LongBowStatus_WARNED:
+ case LongBowStatus_TEARDOWN_WARNED:
+ case LONGBOW_STATUS_SKIPPED:
+ case LongBowStatus_UNIMPLEMENTED:
+ case LongBowStatus_IMPOTENT:
+ case LONGBOW_STATUS_MEMORYLEAK:
+ case LONGBOW_STATUS_SETUP_SKIPTESTS:
+ _printYellow();
+ _EventPrint(event);
+ _printReset();
+ break;
+
+ /* failure */
+ case LONGBOW_STATUS_FAILED:
+ case LongBowStatus_STOPPED:
+ case LONGBOW_STATUS_TEARDOWN_FAILED:
+ case LONGBOW_STATUS_SETUP_FAILED:
+ case LongBowStatus_SIGNALLED:
+ longBowReportRuntime_PrintRed();
+ _EventPrint(event);
+ _printReset();
+ break;
+
+ case LongBowStatus_LIMIT: // fall through
+ default:
+ _printYellow();
+ _EventPrint(event);
+ _printReset();
+ break;
+ }
+}
+
+void
+longBowReportRuntime_Message(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+}
+
+void
+longBowReportRuntime_Warning(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ longBowReportRuntime_YellowPrintf("WARNING ");
+ _longBowReportRuntime_YellowPrintf(format, args);
+ va_end(args);
+}
+
+void
+longBowReportRuntime_Error(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ longBowReportRuntime_RedPrintf("FAILURE ");
+ _longBowReportRuntime_RedPrintf(format, args);
+ va_end(args);
+}
diff --git a/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Runtime.h b/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Runtime.h
new file mode 100755
index 00000000..2e03f322
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Runtime.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file ANSITerm/longBowReport_Runtime.h
+ * @ingroup reporting
+ * @brief ANSI Terminal Reporting
+ *
+ */
+#ifndef LongBow_longBowReport_ANSITerm_Runtime_h
+#define LongBow_longBowReport_ANSITerm_Runtime_h
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include <LongBow/Reporting/longBowReport_Runtime.h>
+
+/**
+ * Begin printing in red.
+ *
+ */
+void longBowReportRuntime_PrintRed(void);
+
+/**
+ * Print the formatted string in red.
+ *
+ */
+void longBowReportRuntime_RedPrintf(const char *format, ...);
+
+/**
+ * Print the formatted string in green.
+ *
+ */
+void longBowReportRuntime_GreenPrintf(const char *format, ...);
+
+/**
+ * Print the formatted string in yellow.
+ *
+ */
+void longBowReportRuntime_YellowPrintf(const char *format, ...);
+
+/**
+ * Print the formatted string in magenta.
+ *
+ */
+void longBowReportRuntime_MagentaPrintf(const char *format, ...);
+
+/**
+ * Parse the given key and set the corresponding LongBowReportConfig to suppress reports.
+ *
+ * @param [in] config A valid LongBowReportConfig instance.
+ * @param [in] key A nul-terminated C string consisting of one or more of the characters, X.SWstwFTU
+ */
+void longBowReportRuntime_ParseSuppress(LongBowReportConfig *config, const char *key);
+#endif // LongBow_longBowReport_ANSITerm_Runtime_h
diff --git a/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Testing.c b/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Testing.c
new file mode 100644
index 00000000..d1952210
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/ANSITerm/longBowReport_Testing.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ */
+#include <config.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#include <LongBow/Reporting/ANSITerm/longBowReport_Runtime.h>
+#include <LongBow/Reporting/longBowReport_Testing.h>
+#include <LongBow/private/longBow_String.h>
+
+static const LongBowTestRunner *
+_testRunnerSilent(const LongBowTestRunner *testRunner)
+{
+ LongBowStatus status = longBowTestRunner_GetStatus(testRunner);
+ if (longBowStatus_IsSuccessful(status)) {
+ longBowReportRuntime_GreenPrintf("%s %s\n", longBowTestRunner_GetName(testRunner), longBowStatus_ToString(status));
+ } else if (longBowStatus_IsSuccessful(status)) {
+ longBowReportRuntime_YellowPrintf("%s %s\n", longBowTestRunner_GetName(testRunner), longBowStatus_ToString(status));
+ } else {
+ longBowReportRuntime_RedPrintf("%s %s\n", longBowTestRunner_GetName(testRunner), longBowStatus_ToString(status));
+ }
+ return testRunner;
+}
+
+static const LongBowTestRunner *
+_testRunnerDetail(const LongBowTestRunner *testRunner)
+{
+ size_t nFixtures = longBowTestRunner_GetFixtureCount(testRunner);
+
+ printf("\n");
+ printf("%s: %zd fixture%s\n", longBowTestRunner_GetName(testRunner), nFixtures, (nFixtures == 1 ? "" : "s"));
+
+ for (size_t i = 0; i < nFixtures; i++) {
+ LongBowTestFixture *fixture = longBowTestRunner_GetFixture(testRunner, i);
+ longBowReportTesting_TestFixture(fixture);
+ }
+ return testRunner;
+}
+
+const LongBowTestRunner *
+longBowReportTesting_TestRunner(const LongBowTestRunner *testRunner)
+{
+ if (longBowConfig_GetBoolean(longBowTestRunner_GetConfiguration(testRunner), false, "silent")) {
+ return _testRunnerSilent(testRunner);
+ } else {
+ return _testRunnerDetail(testRunner);
+ }
+}
+
+static unsigned int
+_totalSucceeded(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalSucceeded + summary->totalWarned + summary->totalTearDownWarned;
+}
+
+static unsigned int
+_totalWarned(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalWarned + summary->totalTearDownWarned;
+}
+
+static unsigned int
+_totalFailed(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalFailed + summary->totalSignalled + summary->totalStopped + summary->totalTearDownFailed;
+}
+
+static unsigned int
+_totalIncomplete(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalSetupFailed + summary->totalSkipped + summary->totalUnimplemented;
+}
+
+static void
+_reportSummary(const LongBowTestFixture *testFixture)
+{
+ const LongBowTestFixtureSummary *summary = longBowTestFixture_GetSummary(testFixture);
+
+ char *fixtureString = longBowTestFixture_ToString(testFixture);
+
+ printf("%s: Ran %u test case%s.", fixtureString, summary->totalTested, summary->totalTested == 1 ? "" : "s");
+ free(fixtureString);
+
+ if (summary->totalTested > 0) {
+ printf(" %d%% (%d) succeeded", _totalSucceeded(summary) * 100 / summary->totalTested, _totalSucceeded(summary));
+
+ if (_totalWarned(summary) > 0) {
+ printf(" %d%% (%d) with warnings", _totalWarned(summary) * 100 / _totalSucceeded(summary), _totalWarned(summary));
+ }
+ if (_totalFailed(summary) != 0) {
+ printf(", %d%% (%d) failed", _totalFailed(summary) * 100 / summary->totalTested, _totalFailed(summary));
+ }
+ if (_totalIncomplete(summary) > 0) {
+ printf(", %d%% (%d) incomplete", _totalIncomplete(summary) * 100 / summary->totalTested, _totalIncomplete(summary));
+ }
+ }
+
+ printf("\n");
+}
+
+const LongBowTestFixture *
+longBowReportTesting_TestFixture(const LongBowTestFixture *testFixture)
+{
+ size_t nTestCases = longBowTestFixture_GetTestCaseCount(testFixture);
+
+ _reportSummary(testFixture);
+
+ for (size_t i = 0; i < nTestCases; i++) {
+ LongBowTestCase *testCase = longBowTestFixture_GetTestCase(testFixture, i);
+ longBowReportTesting_TestCase(testCase);
+ }
+ return testFixture;
+}
+
+const LongBowTestCase *
+longBowReportTesting_TestCase(const LongBowTestCase *testCase)
+{
+ LongBowRuntimeResult *testCaseResult = longBowTestCase_GetActualResult(testCase);
+
+ char *rusageString = longBowReportRuntime_RUsageToString(longBowRuntimeResult_GetRUsage(testCaseResult));
+ char *elapsedTimeString = longBowReportRuntime_TimevalToString(longBowRuntimeResult_GetElapsedTime(testCaseResult));
+ char *statusString = longBowStatus_ToString(longBowRuntimeResult_GetStatus(testCaseResult));
+ char *testCaseString = longBowTestCase_ToString(testCase);
+
+ LongBowString *str = longBowString_CreateFormat("%s %s %s %zd %s\n",
+ testCaseString,
+ elapsedTimeString,
+ rusageString,
+ longBowRuntimeResult_GetEventEvaluationCount(longBowTestCase_GetActualResult(testCase)),
+ statusString);
+ char *string = longBowString_ToString(str);
+
+ if (longBowTestCase_IsFailed(testCase)) {
+ longBowReportRuntime_RedPrintf("%s", string);
+ } else if (longBowTestCase_IsWarning(testCase)) {
+ longBowReportRuntime_YellowPrintf("%s", string);
+ } else if (longBowTestCase_IsIncomplete(testCase)) {
+ longBowReportRuntime_YellowPrintf("%s", string);
+ } else if (longBowTestCase_IsSuccessful(testCase)) {
+ longBowReportRuntime_GreenPrintf("%s", string);
+ } else {
+ longBowReportRuntime_RedPrintf("%s", string);
+ }
+
+ free(string);
+ free(testCaseString);
+ free(statusString);
+ free(elapsedTimeString);
+ free(rusageString);
+
+ return testCase;
+}
+
+void
+longBowReportTesting_DisplayTestCaseResult(const LongBowTestCase *testCase __attribute__((unused)))
+{
+}
+
+void
+longBowReportTesting_Trace(const char *restrict format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ char *message;
+ if (vasprintf(&message, format, ap) == -1) {
+ va_end(ap);
+ return;
+ }
+ va_end(ap);
+
+ longBowReportRuntime_MagentaPrintf("%s\n", message);
+ fflush(stdout);
+ free(message);
+}
diff --git a/longbow/src/LongBow/Reporting/Android/longBowReportAndroid_About.c b/longbow/src/LongBow/Reporting/Android/longBowReportAndroid_About.c
new file mode 100644
index 00000000..db31ce82
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/Android/longBowReportAndroid_About.c
@@ -0,0 +1,44 @@
+// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
+// longbow-generate-about 1.0.20170214.46e2c73a 2017-02-14T20:35:31Z
+
+#include "longBowReportAndroid_About.h"
+
+const char *longBowReportAndroid_What = "@(#)" "LongBow Android Reporter " RELEASE_VERSION " 2017-02-14T21:38:07.631504"
+ "@(#)" "\tCopyright (c) 2017 Cisco and/or its affiliates.";
+
+const char *
+longBowReportAndroidAbout_Name(void)
+{
+ return "LongBow Android Reporter";
+}
+
+const char *
+longBowReportAndroidAbout_Version(void)
+{
+ return RELEASE_VERSION;
+}
+
+const char *
+longBowReportAndroidAbout_About(void)
+{
+ return "LongBow Android Reporter "RELEASE_VERSION " 2017-02-14T21:38:07.631504" "\nCopyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportAndroidAbout_MiniNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportAndroidAbout_ShortNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportAndroidAbout_LongNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n\n";
+}
+
diff --git a/longbow/src/LongBow/Reporting/Android/longBowReportAndroid_About.h b/longbow/src/LongBow/Reporting/Android/longBowReportAndroid_About.h
new file mode 100755
index 00000000..9a90f17e
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/Android/longBowReportAndroid_About.h
@@ -0,0 +1,54 @@
+// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
+// longbow-generate-about 1.0.20170214.46e2c73a 2017-02-14T20:35:31Z
+
+#ifndef longBowReportAndroid_About_h
+#define longBowReportAndroid_About_h
+/**
+ * Embedded string containing information for the what(1) command.
+ *
+ */
+extern const char *longBowReportAndroid_What;
+
+/**
+ * Return the name as a C string.
+ *
+ * @return The name as a C string.
+ */
+const char *longBowReportAndroidAbout_Name(void);
+
+/**
+ * Return the version as a C string.
+ *
+ * @return The version as a C string.
+ */
+const char *longBowReportAndroidAbout_Version(void);
+
+/**
+ * Return the About text as a C string.
+ *
+ * @return The About text as a C string.
+ */
+const char *longBowReportAndroidAbout_About(void);
+
+/**
+ * Return the minimum copyright notice as a C string.
+ *
+ * @return The minimum copyright notice as a C string.
+ */
+const char *longBowReportAndroidAbout_MiniNotice(void);
+
+/**
+ * Return the short copyright notice as a C string.
+ *
+ * @return The short copyright notice as a C string.
+ */
+const char *longBowReportAndroidAbout_ShortNotice(void);
+
+/**
+ * Return the long copyright notice as a C string.
+ *
+ * @return The long copyright notice as a C string.
+ */
+const char *longBowReportAndroidAbout_LongNotice(void);
+
+#endif // longBowReportAndroid_About_h
diff --git a/longbow/src/LongBow/Reporting/Android/longBowReport_Runtime.c b/longbow/src/LongBow/Reporting/Android/longBowReport_Runtime.c
new file mode 100644
index 00000000..4bf13482
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/Android/longBowReport_Runtime.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ */
+#include <config.h>
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <LongBow/Reporting/longBowReport_Runtime.h>
+#include <LongBow/private/longBow_Memory.h>
+
+LongBowReportConfig *
+longBowReportRuntime_Create(int argc, char *argv[argc])
+{
+ LongBowReportConfig *result = longBowMemory_Allocate(sizeof(LongBowReportConfig));
+
+ return result;
+}
+
+void
+longBowReportRuntime_Destroy(LongBowReportConfig **reportPtr)
+{
+ longBowMemory_Deallocate((void **) reportPtr);
+}
+
+void
+longBowReportRuntime_Event(const LongBowEvent *event)
+{
+ if (longBowEventType_IsSuppressAlert(longBowEvent_GetEventType(event)) == false) {
+ char *location = longBowLocation_ToString(longBowEvent_GetLocation(event));
+ printf("%s %s %s %s\r\n",
+ longBowEvent_GetName(event), location, longBowEvent_GetKind(event), longBowEvent_GetMessage(event));
+
+ if (longBowEventType_IsSuppressBacktrace(longBowEvent_GetEventType(event)) == false) {
+ char **strs = longBowEvent_CreateSymbolicCallstack(event);
+ if (strs != NULL) {
+ for (size_t i = 0; i < longBowEvent_GetCallStackLength(event); ++i) {
+ fputs(strs[i], stdout);
+ fputs("\r\n", stdout);
+ }
+ free(strs);
+ }
+ }
+ fflush(stdout);
+
+ free(location);
+ }
+}
+
+void
+longBowReportRuntime_Message(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+}
+
+void
+longBowReportRuntime_Warning(const char *format, ...)
+{
+ printf("WARNING");
+
+ va_list args;
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+}
+
+void
+longBowReportRuntime_Error(const char *format, ...)
+{
+ printf("ERROR");
+ va_list args;
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+}
diff --git a/longbow/src/LongBow/Reporting/Android/longBowReport_Testing.c b/longbow/src/LongBow/Reporting/Android/longBowReport_Testing.c
new file mode 100755
index 00000000..dd3835e8
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/Android/longBowReport_Testing.c
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ */
+#include <config.h>
+
+#include <stdio.h>
+#include <assert.h>
+
+#ifdef __ANDROID__
+#include <android/log.h>
+#define printf(...) __android_log_print(ANDROID_LOG_DEBUG, "CCNx", __VA_ARGS__);
+#endif
+
+#include <LongBow/Reporting/longBowReport_Testing.h>
+#include <LongBow/private/longBow_String.h>
+
+static const LongBowTestRunner *
+_testRunnerSilent(const LongBowTestRunner *testRunner)
+{
+ LongBowStatus status = longBowTestRunner_GetStatus(testRunner);
+
+ printf("%s %s\n", longBowTestRunner_GetName(testRunner), longBowStatus_ToString(status));
+ return testRunner;
+}
+
+static const LongBowTestRunner *
+_testRunnerDetail(const LongBowTestRunner *testRunner)
+{
+ size_t nFixtures = longBowTestRunner_GetFixtureCount(testRunner);
+
+ printf("\r\n");
+ printf("%s: %zd fixture%s\r\n", longBowTestRunner_GetName(testRunner), nFixtures, (nFixtures == 1 ? "" : "s"));
+
+ for (size_t i = 0; i < nFixtures; i++) {
+ LongBowTestFixture *fixture = longBowTestRunner_GetFixture(testRunner, i);
+ longBowReportTesting_TestFixture(fixture);
+ }
+ return testRunner;
+}
+
+const LongBowTestRunner *
+longBowReportTesting_TestRunner(const LongBowTestRunner *testRunner)
+{
+ if (longBowConfig_GetBoolean(longBowTestRunner_GetConfiguration(testRunner), false, "silent")) {
+ return _testRunnerSilent(testRunner);
+ } else {
+ return _testRunnerDetail(testRunner);
+ }
+}
+
+static unsigned int
+_totalSucceeded(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalSucceeded + summary->totalWarned + summary->totalTearDownWarned;
+}
+
+static unsigned int
+_totalWarned(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalWarned + summary->totalTearDownWarned;
+}
+
+static unsigned int
+_totalFailed(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalFailed + summary->totalSignalled + summary->totalStopped + summary->totalTearDownFailed;
+}
+
+static unsigned int
+_totalIncomplete(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalSetupFailed + summary->totalSkipped + summary->totalUnimplemented;
+}
+
+static void
+_reportSummary(const LongBowTestFixture *testFixture)
+{
+ const LongBowTestFixtureSummary *summary = longBowTestFixture_GetSummary(testFixture);
+
+ char *fixtureString = longBowTestFixture_ToString(testFixture);
+
+ printf("%s: Ran %u test case%s.", fixtureString, summary->totalTested, summary->totalTested == 1 ? "" : "s");
+ free(fixtureString);
+
+ if (summary->totalTested > 0) {
+ printf(" %d%% (%d) succeeded", _totalSucceeded(summary) * 100 / summary->totalTested, _totalSucceeded(summary));
+
+ if (_totalWarned(summary) > 0) {
+ printf(" %d%% (%d) with warnings", _totalWarned(summary) * 100 / _totalSucceeded(summary), _totalWarned(summary));
+ }
+ if (_totalFailed(summary) != 0) {
+ printf(", %d%% (%d) failed", _totalFailed(summary) * 100 / summary->totalTested, _totalFailed(summary));
+ }
+ if (_totalIncomplete(summary) > 0) {
+ printf(", %d%% (%d) incomplete", _totalIncomplete(summary) * 100 / summary->totalTested, _totalIncomplete(summary));
+ }
+ }
+ printf("\n");
+}
+
+const LongBowTestFixture *
+longBowReportTesting_TestFixture(const LongBowTestFixture *testFixture)
+{
+ size_t nTestCases = longBowTestFixture_GetTestCaseCount(testFixture);
+
+ _reportSummary(testFixture);
+
+ for (size_t i = 0; i < nTestCases; i++) {
+ LongBowTestCase *testCase = longBowTestFixture_GetTestCase(testFixture, i);
+ longBowReportTesting_TestCase(testCase);
+ }
+ return testFixture;
+}
+
+const LongBowTestCase *
+longBowReportTesting_TestCase(const LongBowTestCase *testCase)
+{
+ LongBowRuntimeResult *testCaseResult = longBowTestCase_GetActualResult(testCase);
+
+ char *rusageString = longBowReportRuntime_RUsageToString(longBowRuntimeResult_GetRUsage(testCaseResult));
+
+ char *elapsedTimeString = longBowReportRuntime_TimevalToString(longBowRuntimeResult_GetElapsedTime(testCaseResult));
+
+ char *statusString = longBowStatus_ToString(longBowTestCase_GetActualResult(testCase)->status);
+ char *testCaseString = longBowTestCase_ToString(testCase);
+
+ LongBowString *string = longBowString_CreateFormat("%10s %s %s %zd %s\n",
+ testCaseString,
+ elapsedTimeString,
+ rusageString,
+ longBowRuntimeResult_GetEventEvaluationCount(longBowTestCase_GetActualResult(testCase)),
+ statusString);
+ longBowString_Write(string, stdout);
+ longBowString_Destroy(&string);
+
+ free(testCaseString);
+ free(statusString);
+ free(elapsedTimeString);
+ free(rusageString);
+
+ return testCase;
+}
+
+void
+longBowReportTesting_DisplayTestCaseResult(const LongBowTestCase *testCase)
+{
+ const LongBowRuntimeResult *testCaseResult = longBowTestCase_GetActualResult(testCase);
+
+ switch (testCaseResult->status) {
+ case LongBowStatus_UNTESTED: printf("X"); break;
+ case LONGBOW_STATUS_SUCCEEDED: printf("."); break;
+ case LONGBOW_STATUS_SKIPPED: printf("S"); break;
+ case LongBowStatus_WARNED: printf("W"); break;
+ case LONGBOW_STATUS_SETUP_FAILED: printf("s"); break;
+ case LONGBOW_STATUS_TEARDOWN_FAILED: printf("t"); break;
+ case LongBowStatus_TEARDOWN_WARNED: printf("w"); break;
+ case LONGBOW_STATUS_FAILED: printf("F"); break;
+ case LongBowStatus_STOPPED: printf("T"); break;
+ case LongBowStatus_UNIMPLEMENTED: printf("U"); break;
+ case LongBowStatus_IMPOTENT: printf("I"); break;
+ default:
+ if (testCaseResult->status >= LongBowStatus_SIGNALLED) {
+ printf("K");
+ } else {
+ printf("?");
+ }
+ }
+ fflush(stdout);
+}
+
+void
+longBowReportTesting_Trace(const char *restrict format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ char *message;
+ if (vasprintf(&message, format, ap) == -1) {
+ return;
+ }
+ va_end(ap);
+
+ printf("%s\n", message);
+ free(message);
+}
diff --git a/longbow/src/LongBow/Reporting/TextPlain/longBowReportTextPlain_About.c b/longbow/src/LongBow/Reporting/TextPlain/longBowReportTextPlain_About.c
new file mode 100644
index 00000000..aa385033
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/TextPlain/longBowReportTextPlain_About.c
@@ -0,0 +1,44 @@
+// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
+// longbow-generate-about 1.0.20170214.46e2c73a 2017-02-14T20:35:31Z
+
+#include "longBowReportTextPlain_About.h"
+
+const char *longBowReportTextPlain_What = "@(#)" "LongBow Text Plain Reporter " RELEASE_VERSION " 2017-02-14T21:40:52.491677"
+ "@(#)" "\tCopyright (c) 2017 Cisco and/or its affiliates.";
+
+const char *
+longBowReportTextPlainAbout_Name(void)
+{
+ return "LongBow Text Plain Reporter";
+}
+
+const char *
+longBowReportTextPlainAbout_Version(void)
+{
+ return RELEASE_VERSION;
+}
+
+const char *
+longBowReportTextPlainAbout_About(void)
+{
+ return "LongBow Text Plain Reporter "RELEASE_VERSION " 2017-02-14T21:40:52.491677" "\nCopyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportTextPlainAbout_MiniNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportTextPlainAbout_ShortNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\n";
+}
+
+const char *
+longBowReportTextPlainAbout_LongNotice(void)
+{
+ return "Copyright (c) 2017 Cisco and/or its affiliates.\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at:\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n\n";
+}
+
diff --git a/longbow/src/LongBow/Reporting/TextPlain/longBowReportTextPlain_About.h b/longbow/src/LongBow/Reporting/TextPlain/longBowReportTextPlain_About.h
new file mode 100755
index 00000000..08f69eb2
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/TextPlain/longBowReportTextPlain_About.h
@@ -0,0 +1,54 @@
+// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
+// longbow-generate-about 1.0.20170214.46e2c73a 2017-02-14T20:35:31Z
+
+#ifndef longBowReportTextPlain_About_h
+#define longBowReportTextPlain_About_h
+/**
+ * Embedded string containing information for the what(1) command.
+ *
+ */
+extern const char *longBowReportTextPlain_What;
+
+/**
+ * Return the name as a C string.
+ *
+ * @return The name as a C string.
+ */
+const char *longBowReportTextPlainAbout_Name(void);
+
+/**
+ * Return the version as a C string.
+ *
+ * @return The version as a C string.
+ */
+const char *longBowReportTextPlainAbout_Version(void);
+
+/**
+ * Return the About text as a C string.
+ *
+ * @return The About text as a C string.
+ */
+const char *longBowReportTextPlainAbout_About(void);
+
+/**
+ * Return the minimum copyright notice as a C string.
+ *
+ * @return The minimum copyright notice as a C string.
+ */
+const char *longBowReportTextPlainAbout_MiniNotice(void);
+
+/**
+ * Return the short copyright notice as a C string.
+ *
+ * @return The short copyright notice as a C string.
+ */
+const char *longBowReportTextPlainAbout_ShortNotice(void);
+
+/**
+ * Return the long copyright notice as a C string.
+ *
+ * @return The long copyright notice as a C string.
+ */
+const char *longBowReportTextPlainAbout_LongNotice(void);
+
+#endif // longBowReportTextPlain_About_h
diff --git a/longbow/src/LongBow/Reporting/TextPlain/longBowReport_Runtime.c b/longbow/src/LongBow/Reporting/TextPlain/longBowReport_Runtime.c
new file mode 100755
index 00000000..b5cb4dfc
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/TextPlain/longBowReport_Runtime.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ */
+#include <config.h>
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <LongBow/Reporting/longBowReport_Runtime.h>
+#include <LongBow/private/longBow_Memory.h>
+
+LongBowReportConfig *
+longBowReportRuntime_Create(int argc, char *argv[argc])
+{
+ LongBowReportConfig *result = longBowMemory_Allocate(sizeof(LongBowReportConfig));
+
+ return result;
+}
+
+void
+longBowReportRuntime_Destroy(LongBowReportConfig **reportPtr)
+{
+ longBowMemory_Deallocate((void **) reportPtr);
+}
+
+void
+longBowReportRuntime_Event(const LongBowEvent *event)
+{
+ if (longBowEventType_IsSuppressAlert(longBowEvent_GetEventType(event)) == false) {
+ char *location = strdup("");
+ if (longBowEvent_GetLocation(event) != NULL) {
+ free(location);
+ location = longBowLocation_ToString(longBowEvent_GetLocation(event));
+ }
+ printf("%s %s %s %s\r\n",
+ longBowEvent_GetName(event), location, longBowEvent_GetKind(event), longBowEvent_GetMessage(event));
+
+ if (longBowEventType_IsSuppressBacktrace(longBowEvent_GetEventType(event)) == false) {
+ char **strs = longBowEvent_CreateSymbolicCallstack(event);
+ if (strs != NULL) {
+ for (size_t i = 0; i < longBowEvent_GetCallStackLength(event); ++i) {
+ fputs(strs[i], stdout);
+ fputs("\r\n", stdout);
+ }
+ free(strs);
+ }
+ }
+ fflush(stdout);
+
+ free(location);
+ }
+}
+
+void
+longBowReportRuntime_Message(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ vprintf(format, args);
+ va_end(args);
+}
+
+void
+longBowReportRuntime_Warning(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ printf("WARNING ");
+ vprintf(format, args);
+ va_end(args);
+}
+
+void
+longBowReportRuntime_Error(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ printf("ERROR ");
+ vprintf(format, args);
+ va_end(args);
+}
diff --git a/longbow/src/LongBow/Reporting/TextPlain/longBowReport_Testing.c b/longbow/src/LongBow/Reporting/TextPlain/longBowReport_Testing.c
new file mode 100755
index 00000000..3bed5cac
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/TextPlain/longBowReport_Testing.c
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ */
+#include <config.h>
+
+#include <stdio.h>
+#include <assert.h>
+
+#include <LongBow/Reporting/longBowReport_Testing.h>
+#include <LongBow/private/longBow_String.h>
+
+static const LongBowTestRunner *
+_testRunnerSilent(const LongBowTestRunner *testRunner)
+{
+ LongBowStatus status = longBowTestRunner_GetStatus(testRunner);
+
+ printf("%s %s\n", longBowTestRunner_GetName(testRunner), longBowStatus_ToString(status));
+ return testRunner;
+}
+
+static const LongBowTestRunner *
+_testRunnerDetail(const LongBowTestRunner *testRunner)
+{
+ size_t nFixtures = longBowTestRunner_GetFixtureCount(testRunner);
+
+ printf("\r\n");
+ printf("%s: %zd fixture%s\r\n", longBowTestRunner_GetName(testRunner), nFixtures, (nFixtures == 1 ? "" : "s"));
+
+ for (size_t i = 0; i < nFixtures; i++) {
+ LongBowTestFixture *fixture = longBowTestRunner_GetFixture(testRunner, i);
+ longBowReportTesting_TestFixture(fixture);
+ }
+ return testRunner;
+}
+
+const LongBowTestRunner *
+longBowReportTesting_TestRunner(const LongBowTestRunner *testRunner)
+{
+ if (longBowConfig_GetBoolean(longBowTestRunner_GetConfiguration(testRunner), false, "silent")) {
+ return _testRunnerSilent(testRunner);
+ } else {
+ return _testRunnerDetail(testRunner);
+ }
+}
+
+static unsigned int
+_totalSucceeded(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalSucceeded + summary->totalWarned + summary->totalTearDownWarned;
+}
+
+static unsigned int
+_totalWarned(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalWarned + summary->totalTearDownWarned;
+}
+
+static unsigned int
+_totalFailed(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalFailed + summary->totalSignalled + summary->totalStopped + summary->totalTearDownFailed;
+}
+
+static unsigned int
+_totalIncomplete(const LongBowTestFixtureSummary *summary)
+{
+ return summary->totalSetupFailed + summary->totalSkipped + summary->totalUnimplemented;
+}
+
+static void
+_reportSummary(const LongBowTestFixture *testFixture)
+{
+ const LongBowTestFixtureSummary *summary = longBowTestFixture_GetSummary(testFixture);
+
+ char *fixtureString = longBowTestFixture_ToString(testFixture);
+
+ printf("%s: Ran %u test case%s.", fixtureString, summary->totalTested, summary->totalTested == 1 ? "" : "s");
+ free(fixtureString);
+
+ if (summary->totalTested > 0) {
+ printf(" %d%% (%d) succeeded", _totalSucceeded(summary) * 100 / summary->totalTested, _totalSucceeded(summary));
+
+ if (_totalWarned(summary) > 0) {
+ printf(" %d%% (%d) with warnings", _totalWarned(summary) * 100 / _totalSucceeded(summary), _totalWarned(summary));
+ }
+ if (_totalFailed(summary) != 0) {
+ printf(", %d%% (%d) failed", _totalFailed(summary) * 100 / summary->totalTested, _totalFailed(summary));
+ }
+ if (_totalIncomplete(summary) > 0) {
+ printf(", %d%% (%d) incomplete", _totalIncomplete(summary) * 100 / summary->totalTested, _totalIncomplete(summary));
+ }
+ }
+ printf("\n");
+}
+
+const LongBowTestFixture *
+longBowReportTesting_TestFixture(const LongBowTestFixture *testFixture)
+{
+ size_t nTestCases = longBowTestFixture_GetTestCaseCount(testFixture);
+
+ _reportSummary(testFixture);
+
+ for (size_t i = 0; i < nTestCases; i++) {
+ LongBowTestCase *testCase = longBowTestFixture_GetTestCase(testFixture, i);
+ longBowReportTesting_TestCase(testCase);
+ }
+ return testFixture;
+}
+
+const LongBowTestCase *
+longBowReportTesting_TestCase(const LongBowTestCase *testCase)
+{
+ LongBowRuntimeResult *testCaseResult = longBowTestCase_GetActualResult(testCase);
+
+ char *rusageString = longBowReportRuntime_RUsageToString(longBowRuntimeResult_GetRUsage(testCaseResult));
+
+ char *elapsedTimeString = longBowReportRuntime_TimevalToString(longBowRuntimeResult_GetElapsedTime(testCaseResult));
+
+ char *statusString = longBowStatus_ToString(longBowTestCase_GetActualResult(testCase)->status);
+ char *testCaseString = longBowTestCase_ToString(testCase);
+
+ LongBowString *string = longBowString_CreateFormat("%10s %s %s %zd %s\n",
+ testCaseString,
+ elapsedTimeString,
+ rusageString,
+ longBowRuntimeResult_GetEventEvaluationCount(longBowTestCase_GetActualResult(testCase)),
+ statusString);
+ longBowString_Write(string, stdout);
+ longBowString_Destroy(&string);
+
+ free(testCaseString);
+ free(statusString);
+ free(elapsedTimeString);
+ free(rusageString);
+
+ return testCase;
+}
+
+void
+longBowReportTesting_DisplayTestCaseResult(const LongBowTestCase *testCase)
+{
+ const LongBowRuntimeResult *testCaseResult = longBowTestCase_GetActualResult(testCase);
+
+ switch (testCaseResult->status) {
+ case LongBowStatus_UNTESTED: printf("X"); break;
+ case LONGBOW_STATUS_SUCCEEDED: printf("."); break;
+ case LONGBOW_STATUS_SKIPPED: printf("S"); break;
+ case LongBowStatus_WARNED: printf("W"); break;
+ case LONGBOW_STATUS_SETUP_FAILED: printf("s"); break;
+ case LONGBOW_STATUS_TEARDOWN_FAILED: printf("t"); break;
+ case LongBowStatus_TEARDOWN_WARNED: printf("w"); break;
+ case LONGBOW_STATUS_FAILED: printf("F"); break;
+ case LongBowStatus_STOPPED: printf("T"); break;
+ case LongBowStatus_UNIMPLEMENTED: printf("U"); break;
+ case LongBowStatus_IMPOTENT: printf("I"); break;
+ default:
+ if (testCaseResult->status >= LongBowStatus_SIGNALLED) {
+ printf("K");
+ } else {
+ printf("?");
+ }
+ }
+ fflush(stdout);
+}
+
+void
+longBowReportTesting_Trace(const char *restrict format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ char *message;
+ if (vasprintf(&message, format, ap) == -1) {
+ return;
+ }
+ va_end(ap);
+
+ printf("%s\n", message);
+ free(message);
+}
diff --git a/longbow/src/LongBow/Reporting/longBowReport_Runtime.c b/longbow/src/LongBow/Reporting/longBowReport_Runtime.c
new file mode 100755
index 00000000..2671cf31
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/longBowReport_Runtime.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ */
+#include <config.h>
+
+#include <stdio.h>
+
+#include <LongBow/Reporting/longBowReport_Runtime.h>
+
+char *
+longBowReportRuntime_TimevalToString(const struct timeval time)
+{
+ char *string = NULL;
+ if (asprintf(&string, "%ld.%06lds", time.tv_sec, (long) time.tv_usec) == -1) {
+ return NULL;
+ }
+ return string;
+}
+
+char *
+longBowReportRuntime_RUsageToString(const struct rusage *rusage)
+{
+ char *string;
+
+ char *ru_utime = longBowReportRuntime_TimevalToString(rusage->ru_utime);
+ char *ru_stime = longBowReportRuntime_TimevalToString(rusage->ru_stime);
+
+ if (asprintf(&string, "%s %s", ru_utime, ru_stime) == -1) {
+ return NULL;
+ }
+
+ free(ru_utime);
+ free(ru_stime);
+
+ return string;
+}
diff --git a/longbow/src/LongBow/Reporting/longBowReport_Runtime.h b/longbow/src/LongBow/Reporting/longBowReport_Runtime.h
new file mode 100755
index 00000000..5682be15
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/longBowReport_Runtime.h
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file Reporting/longBowReport_Runtime.h
+ * @ingroup reporting
+ * @brief The LongBow Runtime Report Generator.
+ *
+ * This header specifies the interface for an implementation of a LongBow Test Report generator.
+ * Different implementations of a Test Report generator are used to connect to external environments to hook in
+ * LongBow unit tests within a larger framework like an IDE or continuous integration system.
+ *
+ * There may be many different ways to report the summary of a LongBow Unit Test,
+ * and the different ways implement the functions prescribed here.
+ * The resulting object files are then linked with the unit-test according to the kind of report needed.
+ *
+ */
+#ifndef LONGBOW_REPORT_RUNTIME_H_
+#define LONGBOW_REPORT_RUNTIME_H_
+
+#include <LongBow/longBow_Event.h>
+
+#include <LongBow/runtime.h>
+#include <LongBow/unit-test.h>
+
+struct longbow_report_config;
+/**
+ * @brief Configuration for a LongBow Test.
+ */
+typedef struct longbow_report_config LongBowReportConfig;
+
+/**
+ * @struct longbow_report_config
+ * @brief The configuration information for a LongBow Test Report.
+ */
+struct longbow_report_config {
+ struct {
+ unsigned int untested : 1;
+ unsigned int succeeded : 1;
+ unsigned int warned : 1;
+ unsigned int teardown_warned : 1;
+ unsigned int skipped : 1;
+ unsigned int unimplemented : 1;
+ unsigned int failed : 1;
+ unsigned int stopped : 1;
+ unsigned int teardown_failed : 1;
+ unsigned int setup_failed : 1;
+ unsigned int signalled : 1;
+ } suppress_report; /**< Bit fields representing which report to suppress. */
+};
+
+/**
+ * Create a LongBowReportConfiguration from a set of parameters.
+ *
+ * @param [in] argc The number of parameters in the argv array.
+ * @param [in] argv An array of C strings.
+ *
+ * @return An allocated LongBowReportConfiguration instance that must be dellocted via longBowReport_Destroy.
+ *
+ * Example:
+ * @code
+ * {
+ * char *argv[2] = { "arg1", "arg2" };
+ * LongBowReportConfig *report = longBowReport_Create(2, argv);
+ * }
+ * @endcode
+ */
+LongBowReportConfig *longBowReportRuntime_Create(int argc, char *argv[]);
+
+/**
+ * Destroy a LongBowReportConfig instance.
+ *
+ * @param [in,out] configPtr A pointer to a LongBowReportConfig pointer. The value of configPtr will be set to zero.
+ *
+ * Example:
+ * @code
+ * {
+ * char *argv[2] = { "arg1", "arg2" };
+ * LongBowReportConfig *report = longBowReport_Create(2, argv);
+ * LongBowReport_Destroy(&report);
+ * }
+ * @endcode
+ */
+void longBowReportRuntime_Destroy(LongBowReportConfig **configPtr);
+
+/**
+ * Report a LongBowEvent.
+ *
+ * @param [in] event A pointer to a valid LongBowEvent instance.
+ */
+void longBowReportRuntime_Event(const LongBowEvent *event);
+
+/**
+ * Report a message.
+ *
+ * @param [in] message A pointer to a nul-terminated C string.
+ */
+void longBowReportRuntime_Message(const char *message, ...);
+
+/**
+ * Report an error message.
+ *
+ * An error message reports an unrecoverable error.
+ *
+ * @param [in] message A pointer to a nul-terminated C string.
+ */
+void longBowReportRuntime_Error(const char *message, ...);
+
+/**
+ * Report an error message.
+ *
+ * An error message reports an recoverable warning.
+ *
+ * @param [in] message A pointer to a nul-terminated C string.
+ */
+void longBowReportRuntime_Warning(const char *message, ...);
+
+/**
+ * Format a struct timeval structure.
+ *
+ * @param [in] time A struct timeval value.
+ *
+ * @return An allocated nul-terminated C string that must be freed via stdlib free(3).
+ */
+char *longBowReportRuntime_TimevalToString(const struct timeval time);
+
+/**
+ * Format a struct rusage struture.
+ *
+ * @param [in] rusage A pointer to a valid `struct rusage` instance.
+ * @return An allocated nul-terminated C string that must be freed via stdlib free(3).
+ */
+char *longBowReportRuntime_RUsageToString(const struct rusage *rusage);
+#endif // LONGBOW_REPORT_RUNTIME_H_
diff --git a/longbow/src/LongBow/Reporting/longBowReport_Testing.c b/longbow/src/LongBow/Reporting/longBowReport_Testing.c
new file mode 100755
index 00000000..646a7a05
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/longBowReport_Testing.c
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ */
+#include <config.h>
+
+#include <stdio.h>
+
+#include <LongBow/Reporting/longBowReport_Testing.h>
diff --git a/longbow/src/LongBow/Reporting/longBowReport_Testing.h b/longbow/src/LongBow/Reporting/longBowReport_Testing.h
new file mode 100755
index 00000000..b4b2eaf8
--- /dev/null
+++ b/longbow/src/LongBow/Reporting/longBowReport_Testing.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file longBowReport_Testing.h
+ * @ingroup reporting
+ * @brief The LongBow Test Report Generator.
+ *
+ * This header specifies the interface for an implementation of a LongBow Test Report generator.
+ * Different implementations of a Test Report generator are used to connect to external environments to hook in
+ * LongBow unit tests within a larger framework like an IDE or continuous integration system.
+ *
+ */
+#ifndef LONGBOW_REPORT_TESTING_H_
+#define LONGBOW_REPORT_TESTING_H_
+
+#include <LongBow/Reporting/longBowReport_Runtime.h>
+
+#include <LongBow/runtime.h>
+#include <LongBow/unit-test.h>
+
+/**
+ * Produce a summary report for the given LongBowTestRunner.
+ *
+ * @param [in] testRunner A pointer to a valid LongBowTestRunner instance.
+ * @return The given LongBowTestRunner.
+ */
+const LongBowTestRunner *longBowReportTesting_TestRunner(const LongBowTestRunner *testRunner);
+
+/**
+ * Produce a summary report for the given LongBowTestFixture.
+ *
+ * @param [in] testFixture A pointer to a LongBowTestFixture instance.
+ * @return The given LongBowTestFixture.
+ */
+const LongBowTestFixture *longBowReportTesting_TestFixture(const LongBowTestFixture *testFixture);
+
+/**
+ * Produce a summary report for the given LongBowTestCase.
+ *
+ * @param [in] testCase A pointer to a LongBowTestCase instance.
+ * @return The pointer to the given LongBowTestCase.
+ */
+const LongBowTestCase *longBowReportTesting_TestCase(const LongBowTestCase *testCase);
+
+/**
+ * Produce a single character displaying the status of an individual test case.
+ *
+ * @param [in] testCase A pointer to a LongBowTestCase instance.
+ */
+void longBowReportTesting_DisplayTestCaseResult(const LongBowTestCase *testCase);
+
+/**
+ * Make a trace report.
+ *
+ * @param [in] format A printf-style format string.
+ */
+void longBowReportTesting_Trace(const char *restrict format, ...);
+#endif // LONGBOW_REPORT_TESTING_H_