Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 1 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.a
*.lo
*.la
*.out

# Visual Studio temp/user files
*.user
Expand Down
1 change: 1 addition & 0 deletions 1 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ UnitTest++ is a lightweight unit testing framework for C++. It was designed to d
* Windows
* Linux
* Mac OS X
* VxWorks 5.5

Documentation
--------------
Expand Down
4 changes: 4 additions & 0 deletions 4 UnitTest++/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#define UNITTEST_POSIX
#endif

#if defined (_WRS_VXWORKS_5_X)
#define UNITTEST_VXWORKS
#endif

#if defined(__MINGW32__)
#define UNITTEST_MINGW
#endif
Expand Down
6 changes: 5 additions & 1 deletion 6 UnitTest++/TimeHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
#if defined UNITTEST_POSIX
#include "Posix/TimeHelpers.h"
#else
#include "Win32/TimeHelpers.h"
#if defined UNITTEST_VXWORKS
#include "VxWorks/TimeHelpers.h"
#else
#include "Win32/TimeHelpers.h"
#endif
#endif
36 changes: 36 additions & 0 deletions 36 UnitTest++/VxWorks/TimeHelpers.cpp
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;

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Author

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.

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, &currentTime);

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);
}

}
28 changes: 28 additions & 0 deletions 28 UnitTest++/VxWorks/TimeHelpers.h
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
12 changes: 6 additions & 6 deletions 12 tests/TestDeferredTestReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace UnitTest
{
reporter.ReportTestStart(details);

DeferredTestResult const& result = reporter.GetResults().at(0);
DeferredTestResult const& result = reporter.GetResults()[0];

@pjohnmeyer pjohnmeyer Aug 17, 2016

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

@sulemankm sulemankm Aug 18, 2016

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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());
}
Expand All @@ -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);
}

Expand All @@ -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());
}
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
15 changes: 15 additions & 0 deletions 15 vxworks/utppvxw.wsp
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>

21 changes: 21 additions & 0 deletions 21 vxworks/utppvxwlib/prjObjs.lst
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
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.