Skip to content

Commit

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

* coverage

* coverage

* added sompy

* added sompy

* pre-commit

* check of pre-commit

* test

* test

* test

* test

* removed pass()

* removed pass()

* review rework

* review rework

* Squashed commit of the following:

commit 1491ebc943d1c2da1dc9d5d22796250a916629ae
Author: sorgom <[email protected]>
Date:   Sun Oct 13 18:53:18 2024 +0200

    merge SOM_DEVEL_20

* bullseye build & run

* include guards I

* include guards I

* include guards I

* minor corrections

* pre-commit

* type check without type() method
  • Loading branch information
sorgom authored Oct 14, 2024
1 parent 7d016c6 commit 78dba94
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 53 deletions.
6 changes: 1 addition & 5 deletions .gitHooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@ for file in `git diff-index --cached --name-only HEAD`;
do
if [[ -f $file ]]
then
add=1
if [[ $file == *.mdj ]]; then mdjs="$mdjs $file"
elif [[ $file == *.svg ]]; then svgs="$svgs $file"
elif [[ $file == *.py ]] || [[ $file == *.cpp ]] || [[ $file == *.h ]] || [[ $file == *.cmd ]]
then
txts="$txts $file"
else
add=0
fi

if [[ $add -eq 1 ]]; then git add $file; fi
fi
done

Expand All @@ -45,3 +40,4 @@ if [[ -n $txts ]]; then
echo cleaning text files
$py $sompy/cleanTxt.py $txts
fi
for file in $mdjs $svgs $txts; do git add $file; done
4 changes: 0 additions & 4 deletions application/components/LCR/LCR_X.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ class LCR : public LCR_X
void fromFld(const ComData& data) override;
void toGui() const override;

inline E_Type type() const override { return TYPE_LCR; }

NOCOPY(LCR)
NODEF(LCR)
};
Expand All @@ -68,8 +66,6 @@ class LCR_UBK : public LCR_X
void fromFld(const ComData& data) override;
void toGui() const override;

inline E_Type type() const override { return TYPE_LCR_UBK; }

NOCOPY(LCR_UBK)
NODEF(LCR_UBK)

Expand Down
6 changes: 0 additions & 6 deletions application/components/SIG/SIG_X.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class SIG_H : public SIG_X
void fromFld(const ComData& data) override;
void fromGui(const ComData& data) override;

inline E_Type type() const override { return TYPE_SIG_H; }

NOCOPY(SIG_H)
NODEF(SIG_H)

Expand All @@ -100,8 +98,6 @@ class SIG_N : public SIG_XS
void fromFld(const ComData& data) override;
void fromGui(const ComData& data) override;

inline E_Type type() const override { return TYPE_SIG_N; }

NOCOPY(SIG_N)
NODEF(SIG_N)

Expand All @@ -127,8 +123,6 @@ class SIG_H_N : public SIG_XS
void fromFld(const ComData& data) override;
void fromGui(const ComData& data) override;

inline E_Type type() const override { return TYPE_SIG_H_N; }

NOCOPY(SIG_H_N)
NODEF(SIG_H_N)

Expand Down
2 changes: 0 additions & 2 deletions application/components/TSW/TSW.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class TSW : public I_Elem
void fromFld(const ComData& data) override;
void fromGui(const ComData& data) override;

inline E_Type type() const { return TYPE_TSW; }

NOCOPY(TSW)
NODEF(TSW)
private:
Expand Down
5 changes: 3 additions & 2 deletions make/bullseye/covBuildAndRun.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,15 @@ call %executable% >NUL

if %_update% == 1 exit /b 0

call covselect -qd
call covselect -q --import %excludeFile%

if %_genhtml% == 1 (
echo - html
call covhtml -q --allNum %covHtmlDir%
)

echo - report
call covselect -qd
call covselect -q --import %excludeFile%

cd %dstwDir%
call covdir -q --by-name --srcdir . | tee %covLog%
Expand Down
9 changes: 0 additions & 9 deletions scripts/preCommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@
# created by Manfred Sorgo

from projectDirs import *
from cleanMdj import cleanMdj
from cleanSvg import cleanSvg
from modGenCloc import genCloc
from runGcov import gcovToMd
from modUtilz import checkLinux

from glob import glob
from sys import argv, exit

print("* cleanMdj")
cleanMdj(glob(f'{docDir}/*.mdj'))
print("* cleanSvg")
cleanSvg(glob(f'{docDir}/*.svg'))

if len(argv) > 1: exit()

# linux only
checkLinux()
print("* genCloc")
Expand Down
3 changes: 1 addition & 2 deletions specification/ifs/I_Elem.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class I_Elem
// re-send current state to GUI
virtual void toGui() const = 0;

// this is test code: type info if relevant
virtual E_Type type() const = 0;
inline virtual ~I_Elem() = default;
};
#endif // _H
14 changes: 7 additions & 7 deletions testing/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ Sample text summary output:
```
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/ 128 / 128 = 100% 315 / 316 = 99%
application/components/BAS/ 25 / 25 = 100% 39 / 39 = 100%
application/components/BAS/src/ 1 / 1 = 100% 14 / 14 = 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/ 15 / 15 = 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/ 30 / 30 = 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/ 11 / 11 = 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%
Total 134 / 134 = 100% 315 / 316 = 99%
```
For details see [bullseye html report](http://dstw.sorgo.de/bullseye/)

Expand Down
2 changes: 0 additions & 2 deletions testing/testenv/mocks/M_Elem.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ namespace test
{
expect(num, "toGui");
}

inline E_Type type() const override { return TYPE_UNDEF; }
};

// mock TSW
Expand Down
10 changes: 9 additions & 1 deletion testing/testenv/testlib/TestLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#pragma once

#include <ifs/DataTypes.h>
#include <ifs/I_Elem.h>
#include <codebase/Mem.h>
#include <BAS/coding.h>

Expand Down Expand Up @@ -53,5 +54,12 @@ namespace test
private:
T* mPtr;
};
}

// check if element is of type T
template <class T>
inline bool istype(const I_Elem& elem)
{
return dynamic_cast<const T*>(&elem) != nullptr;
}
#define L_CHECK_ELEM_TYPE(TYPE, ELEM) L_CHECK_TRUE(istype<TYPE>(ELEM))
}
5 changes: 3 additions & 2 deletions testing/tests/moduletests/LCR/LCR_02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <testlib/TestGroupBase.h>
#include <LCR/LCR_Provider.h>
#include <LCR/LCR_X.h>

namespace test
{
Expand Down Expand Up @@ -32,8 +33,8 @@ namespace test
prv.load(mData.pLCR(), mData.numLCR());
CHECK_N_CLEAR()
L_CHECK_EQUAL(2, prv.size())
L_CHECK_EQUAL(TYPE_LCR, prv.at(0).type())
L_CHECK_EQUAL(TYPE_LCR_UBK, prv.at(1).type())
L_CHECK_ELEM_TYPE(LCR, prv.at(0))
L_CHECK_ELEM_TYPE(LCR_UBK, prv.at(1))
}

// test type: equivalence class test
Expand Down
15 changes: 8 additions & 7 deletions testing/tests/moduletests/SIG/SIG_02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

#include <testlib/TestGroupBase.h>
#include <SIG/SIG_Provider.h>
#include <SIG/SIG_X.h>

namespace test
{
TEST_GROUP_BASE(SIG_03, TestGroupBase)
TEST_GROUP_BASE(SIG_02, TestGroupBase)
{
protected:
GenProjData<1, 3, 1, 1> mData;
Expand All @@ -22,7 +23,7 @@ namespace test

// test type: equivalence class test
// load valid ProjData SIG
TEST(SIG_03, T01)
TEST(SIG_02, T01)
{
SETUP()
I_Provider& prv = SIG_Provider::instance();
Expand All @@ -34,14 +35,14 @@ namespace test
prv.load(mData.pSIG(), mData.numSIG());
CHECK_N_CLEAR()
L_CHECK_EQUAL(3, prv.size())
L_CHECK_EQUAL(TYPE_SIG_H, prv.at(0).type())
L_CHECK_EQUAL(TYPE_SIG_N, prv.at(1).type())
L_CHECK_EQUAL(TYPE_SIG_H_N, prv.at(2).type())
L_CHECK_ELEM_TYPE(SIG_H, prv.at(0))
L_CHECK_ELEM_TYPE(SIG_N, prv.at(1))
L_CHECK_ELEM_TYPE(SIG_H_N, prv.at(2))
}

// test type: equivalence class test
// load invalid ProjData SIG (unknown type)
TEST(SIG_03, T02)
TEST(SIG_02, T02)
{
SETUP()
I_Provider& prv = SIG_Provider::instance();
Expand All @@ -59,7 +60,7 @@ namespace test

// test type: equivalence class test
// load valid ProjData SIG Dispatcher returns negative value
TEST(SIG_03, T03)
TEST(SIG_02, T03)
{
SETUP()
I_Provider& prv = SIG_Provider::instance();
Expand Down
4 changes: 0 additions & 4 deletions testing/tests/moduletests/TSW/TSW_01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,5 @@ 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 78dba94

Please sign in to comment.