-
Notifications
You must be signed in to change notification settings - Fork 179
Initial port of UnitTest++ to VxWorks 5.5. #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
183e1b1
9923f47
50db40a
103afb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*.a | ||
*.lo | ||
*.la | ||
*.out | ||
|
||
# Visual Studio temp/user files | ||
*.user | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "TimeHelpers.h" | ||
|
||
namespace UnitTest { | ||
|
||
Timer::Timer() | ||
{ | ||
m_startTime.tv_sec = 0; | ||
m_startTime.tv_nsec = 0; | ||
} | ||
|
||
void Timer::Start() | ||
{ | ||
clock_gettime(CLOCK_REALTIME, &m_startTime); | ||
} | ||
|
||
double Timer::GetTimeInMs() const | ||
{ | ||
struct timespec currentTime; | ||
clock_gettime(CLOCK_REALTIME, ¤tTime); | ||
|
||
double const dsecs = currentTime.tv_sec - m_startTime.tv_sec; | ||
double const dns = currentTime.tv_nsec - m_startTime.tv_nsec; | ||
|
||
return (dsecs * 1000.0) + (dns / 1000000.0); | ||
} | ||
|
||
void TimeHelpers::SleepMs(int ms) | ||
{ | ||
struct timespec sleepTime; | ||
sleepTime.tv_sec = 0; | ||
sleepTime.tv_nsec = ms * 1000000; | ||
|
||
nanosleep(&sleepTime, NULL); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef UNITTEST_TIMEHELPERS_H | ||
#define UNITTEST_TIMEHELPERS_H | ||
|
||
#include <timers.h> | ||
|
||
namespace UnitTest { | ||
|
||
class Timer | ||
{ | ||
public: | ||
Timer(); | ||
void Start(); | ||
double GetTimeInMs() const; | ||
|
||
private: | ||
struct timespec m_startTime; | ||
}; | ||
|
||
|
||
namespace TimeHelpers | ||
{ | ||
void SleepMs(int ms); | ||
} | ||
|
||
|
||
} | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ namespace UnitTest | |
{ | ||
reporter.ReportTestStart(details); | ||
|
||
DeferredTestResult const& result = reporter.GetResults().at(0); | ||
DeferredTestResult const& result = reporter.GetResults()[0]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to lose the bounds-checking behavior of .at in these tests. If this is truly necessary, then we may need another way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The STL version in VxWorks doesn't implement the .at() method. That's why I had to modify the this test file. You may suggest a better way of handling this problem, if possible. |
||
CHECK_EQUAL(testName.c_str(), result.testName.c_str()); | ||
CHECK_EQUAL(testSuite.c_str(), result.suiteName.c_str()); | ||
} | ||
|
@@ -65,7 +65,7 @@ namespace UnitTest | |
reporter.ReportTestStart(details); | ||
reporter.ReportTestFinish(details, elapsed); | ||
|
||
DeferredTestResult const& result = reporter.GetResults().at(0); | ||
DeferredTestResult const& result = reporter.GetResults()[0]; | ||
CHECK_CLOSE(elapsed, result.timeElapsed, 0.0001f); | ||
} | ||
|
||
|
@@ -76,7 +76,7 @@ namespace UnitTest | |
reporter.ReportTestStart(details); | ||
reporter.ReportFailure(details, failure); | ||
|
||
DeferredTestResult const& result = reporter.GetResults().at(0); | ||
DeferredTestResult const& result = reporter.GetResults()[0]; | ||
CHECK(result.failed == true); | ||
CHECK_EQUAL(fileName.c_str(), result.failureFile.c_str()); | ||
} | ||
|
@@ -90,7 +90,7 @@ namespace UnitTest | |
reporter.ReportFailure(details, failure1); | ||
reporter.ReportFailure(details, failure2); | ||
|
||
DeferredTestResult const& result = reporter.GetResults().at(0); | ||
DeferredTestResult const& result = reporter.GetResults()[0]; | ||
CHECK_EQUAL(2, (int)result.failures.size()); | ||
CHECK_EQUAL(failure1, result.failures[0].failureStr); | ||
CHECK_EQUAL(failure2, result.failures[1].failureStr); | ||
|
@@ -110,8 +110,8 @@ namespace UnitTest | |
reporter.ReportFailure(details, failureMessage); | ||
strcpy(failureMessage, badStr); | ||
|
||
DeferredTestResult const& result = reporter.GetResults().at(0); | ||
DeferredTestFailure const& failure = result.failures.at(0); | ||
DeferredTestResult const& result = reporter.GetResults()[0]; | ||
DeferredTestFailure const& failure = result.failures[0]; | ||
CHECK_EQUAL(goodStr, failure.failureStr); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Document file - DO NOT EDIT | ||
|
||
<BEGIN> CORE_INFO_TYPE | ||
Workspace | ||
<END> | ||
|
||
<BEGIN> CORE_INFO_VERSION | ||
2.2 | ||
<END> | ||
|
||
<BEGIN> projectList | ||
$(PRJ_DIR)/utppvxwlib/utppvxwlib.wpj \ | ||
$(PRJ_DIR)/utppvxwtests/utppvxwtests.wpj | ||
<END> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
AssertException.o | ||
Checks.o | ||
CompositeTestReporter.o | ||
CurrentTest.o | ||
DeferredTestResult.o | ||
MemoryOutStream.o | ||
ReportAssert.o | ||
RequiredCheckException.o | ||
RequiredCheckTestReporter.o | ||
Test.o | ||
TestDetails.o | ||
TestList.o | ||
TestReporter.o | ||
TestReporterStdout.o | ||
TestResults.o | ||
TestRunner.o | ||
ThrowingTestReporter.o | ||
TimeConstraint.o | ||
XmlTestReporter.o | ||
TimeHelpers.o | ||
DeferredTestReporter.o |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer initializing members in the constructor initializer list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that can be done but I just implemented it in the same way as done in the Posix version of TimeHelpers.cpp.