diff options
author | Mauro Sardara <msardara+fdio@cisco.com> | 2018-12-18 11:05:49 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2018-12-18 11:05:49 +0000 |
commit | cada1143501a48effc483e3873596c22849926b5 (patch) | |
tree | 93a1da95d69b69328a1e7d3621447797f65137c9 /longbow/src/LongBow/Reporting/TextPlain | |
parent | 726949d76a7207694d5a1eee84ef134a8e539115 (diff) | |
parent | a45edf23c2463ac9a4723a24792a6c5c89b1e021 (diff) |
Merge "Adding gitreview config file for this branch sub project"
Diffstat (limited to 'longbow/src/LongBow/Reporting/TextPlain')
4 files changed, 386 insertions, 0 deletions
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); +} |