Skip to content

Commit

Permalink
Som devel 20 (#64)
Browse files Browse the repository at this point in the history
* coverage

* coverage

* coverage
  • Loading branch information
sorgom authored Aug 19, 2024
1 parent 2830538 commit dd03385
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 60 deletions.
2 changes: 1 addition & 1 deletion CppUTestSteps
1 change: 0 additions & 1 deletion application/components/COM/Com.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// ============================================================
// class Com implements I_Com
// - currently without functionality
// ============================================================
// created by Manfred Sorgo

Expand Down
12 changes: 6 additions & 6 deletions specification/codebase/Mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class Mem
return std::memcmp(c1, c2, N);
}

// compare two objects
template <typename T>
inline static auto cmp(const T& c1, const T& c2)
{
return std::memcmp(&c1, &c2, sizeof(T));
}
// // compare two objects
// template <typename T>
// inline static auto cmp(const T& c1, const T& c2)
// {
// return std::memcmp(&c1, &c2, sizeof(T));
// }
};
57 changes: 21 additions & 36 deletions testing/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,28 @@ It's available for Windows and Linux.

Bullseye is not for free - but they provide a free trial period.

Sample (and very outdated) text summary output:
Sample text summary output:
```
Source Function Coverage C/D Coverage
---------------- ----------------- ----------------
Com.h 3 / 3 = 100% 0 / 0
Dispatcher.cpp 7 / 7 = 100% 20 / 20 = 100%
Dispatcher.h 1 / 1 = 100% 0 / 0
I_Array.h 3 / 3 = 100% 18 / 18 = 100%
LCR_Hub.cpp 4 / 4 = 100% 4 / 4 = 100%
LCR_Hub.h 1 / 1 = 100% 0 / 0
LCR_Provider.cpp 1 / 1 = 100% 15 / 15 = 100%
LCR_Provider.h 3 / 3 = 100% 0 / 0
LCR_X.cpp 9 / 9 = 100% 37 / 37 = 100%
LCR_X.h 7 / 7 = 100% 0 / 0
Loader.cpp 1 / 1 = 100% 0 / 0
Loader.h 1 / 1 = 100% 0 / 0
Log.h 2 / 2 = 100% 0 / 0
Mem.h 4 / 4 = 100% 0 / 0
NtpArray.cpp 1 / 1 = 100% 0 / 0
NtpArray.h 4 / 4 = 100% 0 / 0
SIG_Hub.cpp 4 / 4 = 100% 4 / 4 = 100%
SIG_Hub.h 1 / 1 = 100% 0 / 0
SIG_Provider.cpp 1 / 1 = 100% 16 / 16 = 100%
SIG_Provider.h 3 / 3 = 100% 0 / 0
SIG_X.cpp 18 / 18 = 100% 93 / 93 = 100%
SIG_X.h 9 / 9 = 100% 0 / 0
StackArray.cpp 1 / 1 = 100% 0 / 0
StackArray.h 26 / 26 = 100% 2 / 2 = 100%
TSW.cpp 7 / 7 = 100% 22 / 22 = 100%
TSW.h 1 / 1 = 100% 0 / 0
TSW_Hub.cpp 4 / 4 = 100% 4 / 4 = 100%
TSW_Hub.h 1 / 1 = 100% 0 / 0
TSW_Provider.cpp 1 / 1 = 100% 12 / 12 = 100%
TSW_Provider.h 3 / 3 = 100% 0 / 0
coding.h 1 / 1 = 100% 0 / 0
---------------- ----------------- ----------------
Total 133 / 133 = 100% 247 / 247 = 100%
Directory Function Coverage C/D Coverage
------------------------------- ----------------- ----------------
application/components/ 135 / 135 = 100% 311 / 312 = 99%
application/components/BAS/ 26 / 26 = 100% 35 / 35 = 100%
application/components/BAS/src/ 1 / 1 = 100% 10 / 10 = 100%
application/components/COM/ 32 / 32 = 100% 79 / 80 = 98%
application/components/COM/src/ 31 / 31 = 100% 79 / 80 = 98%
application/components/LCR/ 17 / 17 = 100% 40 / 40 = 100%
application/components/LCR/src/ 11 / 11 = 100% 40 / 40 = 100%
application/components/SIG/ 33 / 33 = 100% 95 / 95 = 100%
application/components/SIG/src/ 24 / 24 = 100% 95 / 95 = 100%
application/components/SYS/ 15 / 15 = 100% 40 / 40 = 100%
application/components/SYS/src/ 13 / 13 = 100% 40 / 40 = 100%
application/components/TSW/ 12 / 12 = 100% 22 / 22 = 100%
application/components/TSW/src/ 8 / 8 = 100% 22 / 22 = 100%
specification/ 6 / 6 = 100% 0 / 0
specification/codebase/ 3 / 3 = 100% 0 / 0
specification/ifs/ 3 / 3 = 100% 0 / 0
------------------------------- ----------------- ----------------
Total 141 / 141 = 100% 311 / 312 = 99%
```
For details see [bullseye html report](http://dstw.sorgo.de/bullseye/)

Expand Down
16 changes: 8 additions & 8 deletions testing/testenv/testlib/TestLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ namespace test
return Mem::cmp(n1.chars, n2.chars) == 0;
}

inline bool operator==(const ComData& d1, const ComData& d2)
{
return Mem::cmp(d1, d2) == 0;
}
// inline bool operator==(const ComData& d1, const ComData& d2)
// {
// return Mem::cmp(d1, d2) == 0;
// }

inline bool operator==(const ComTele& t1, const ComTele& t2)
{
return Mem::cmp(t1, t2) == 0;
}
// inline bool operator==(const ComTele& t1, const ComTele& t2)
// {
// return Mem::cmp(t1, t2) == 0;
// }

// avoid "not used" warning
template<typename T>
Expand Down
17 changes: 13 additions & 4 deletions testing/tests/moduletests/BAS/BAS_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,13 @@ namespace test
{
public:
const Key key;
const int data[5];
inline Cont(int k, int d=0) : key(k), data{d, d, d, d, d} { ++cnt; }
const int cdata[5];
int vdata[5];
inline Cont(int k, int d=0) :
key(k),
cdata{d, d, d, d, d},
vdata{0, 0, 0, 0, 0}
{ ++cnt; }
inline ~Cont() { --cnt; }
inline static UINT32 count() { return cnt; }
NODEF(Cont)
Expand All @@ -206,7 +211,7 @@ namespace test
protected:
inline int getKey(const Cont& cont) const final
{
return cont.data[0];
return cont.cdata[0];
}
};

Expand Down Expand Up @@ -289,7 +294,11 @@ namespace test
const PosRes res2 = cxi.find(n);
L_CHECK_TRUE(res2.valid);
const Cont& c2 = cxi.at(res2);
L_CHECK_EQUAL(n, c2.data[0]);
L_CHECK_EQUAL(n, c2.cdata[0]);

// coverage: non const at position
Cont& c3 = mxi.at(res2.pos);
c3.vdata[0] = 123;
}
ENDSTEPS()

Expand Down
20 changes: 16 additions & 4 deletions testing/tests/moduletests/SYS/SYS_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ namespace test
m_Log().expectLog(COMP_SYS, RET_ERR_STARTUP);
}

void wrongSize(int dev)
void wrongSize(int dev, const UINT32 n = 1)
{
std::ofstream os(fname, std::ios::binary);
constexpr static const UINT32 nums[] = { 1, 1, 1, 1 };
const UINT32 nums[] = { n, n, n, n };
os.write(reinterpret_cast<const CHAR*>(nums), 4 * sizeof(UINT32));

constexpr static const size_t wSize = sizeof(ProjItem) * 4;
const size_t wSize = sizeof(ProjItem) * n * 4 + sizeof(ComSetup) + dev;

for (size_t n = 0; n < wSize + dev; ++n)
for (size_t n = 0; n < wSize; ++n)
{
os << ' ';
}
Expand Down Expand Up @@ -66,6 +66,13 @@ namespace test
data.dump(fname);
rdr.read(fname);
CHECK_N_CLEAR()

STEP(2)
const ComSetup& cs = rdr.getComSetup();
L_CHECK_EQUAL(tcpPortFld, cs.portFld)
L_CHECK_EQUAL(tcpPortGui, cs.portGui)
L_CHECK_EQUAL(tcpPortCtrl, cs.portCtrl)
L_CHECK_EQUAL(tcpTimeout, cs.timeout)
}

// test type: equivalence class test
Expand Down Expand Up @@ -94,6 +101,11 @@ namespace test
// too large
wrongSize(+1);
CHECK_N_CLEAR()

STEP(3)
// no data
wrongSize(0, 0);
CHECK_N_CLEAR()
}

// test type: equivalence class test
Expand Down
4 changes: 4 additions & 0 deletions testing/tests/moduletests/TSW/TSW_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,9 @@ namespace test
STEP(2)
m_Log().expectLog(COMP_TSW, RET_ERR_MATCH);
FLD(PARAM_UNKNOWN);

STEP(3)
// coverage
L_CHECK_EQUAL(TYPE_TSW, mSUT.type())
}
}

0 comments on commit dd03385

Please sign in to comment.