Skip to content
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

Unit Testing Framework #405

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
084e238
So make unittest TEST_LEADER=HelloWorld works...
KnockbackNemo Dec 30, 2023
9450609
Messing with makefiles and new unit testing structure; testing the ad…
KnockbackNemo Dec 31, 2023
8206ae3
Makefile unitclean
diyarajon Dec 31, 2023
bf0c830
Unit Test for Contactors written, not working
diyarajon Dec 31, 2023
409b67f
Changed Makefile to use variable TEST instead of TEST_LEADER since TE…
KnockbackNemo Jan 2, 2024
e33eee1
C Source looks for the right (hopefully) file, also added mocking fla…
KnockbackNemo Jan 3, 2024
2aa882c
working pedals and contactors without OS mocking
diyarajon Jan 4, 2024
9f4bb42
Created Mock folder structure and reflected restructure in the makefile
diyarajon Jan 6, 2024
e122e69
Created Mock folder structure and reflected restructure in the makefi…
diyarajon Jan 6, 2024
eb426b7
Moved fff globals and fff.h files in BSP_ADC test files, small fix to…
KnockbackNemo Jan 6, 2024
1e34a3c
Fixed Tests/Test_Pedals.c not found error by removing the TOCOMPILE v…
KnockbackNemo Jan 7, 2024
c710daa
Made BSP_ADC_Init non-static so that leader compiles. The function is…
KnockbackNemo Jan 7, 2024
a2a0eab
Changed Makefile and got Test_Contactors working! Makefile changes: C…
KnockbackNemo Jan 8, 2024
7804bbd
added new mocks to define and declare OS fucntions and macros require…
diyarajon Jan 10, 2024
41a6a18
Continued working on ReadCarCAN unit test, currently not working with…
diyarajon Jan 10, 2024
9f8b490
Fixed problem of gcc including the incorrect Tasks.h. Issue was that …
KnockbackNemo Jan 10, 2024
54594c8
Wrote two tests for ReadCarCAN, mocked UpdateDisplay and Display, cha…
KnockbackNemo Jan 11, 2024
8e45932
Mocked the rest of the relevant os functions; currently doesn't expan…
KnockbackNemo Jan 15, 2024
7efeb40
Fixed mocked os (wrote DECLARE instead of DEFINE), added semicolon to…
KnockbackNemo Jan 16, 2024
667aaec
Uncommented OS functions in ReadCarCAN, still compiles.
KnockbackNemo Jan 16, 2024
163f877
Moved task prototypes to their respective header files.
KnockbackNemo Jan 16, 2024
72fd00c
Mocked/stubbed BSP stm32f4xx.h and _gpio.h/c files from CMSIS- this s…
KnockbackNemo Jan 16, 2024
13265b3
Cleaning up unneeded file changes to decrease the size of the PR.
KnockbackNemo Jan 18, 2024
392c6d6
Merge branch 'master' into feature/unit-testing-framework-394
KnockbackNemo Jan 19, 2024
0d89370
Cleaned up files a bit / added MOCK to mock files because I am easily…
KnockbackNemo Jan 20, 2024
b0e2a36
Finished mocking BSP
KnockbackNemo Jan 20, 2024
4ca872b
Finished mocking the rest of the necessary drivers.
KnockbackNemo Jan 20, 2024
8c177de
Mocked apps, define a LOOP macro which is either '' or while(1) depen…
KnockbackNemo Jan 20, 2024
d0bc272
Dev/code cleanup again (#404)
NathanielDelgado Jan 20, 2024
f0227bd
Cleaned up driver mocks by including real header to avoid copy-pastin…
KnockbackNemo Jan 20, 2024
26f4835
Cleaned up app mocks by including real header to avoid copy-pasting a…
KnockbackNemo Jan 20, 2024
21ddd2b
Cleaned and deleted shared initializations by including it from non-m…
diyarajon Jan 20, 2024
69f956d
Cleaned and deleted shared initializations by including it from non-m…
diyarajon Jan 20, 2024
972caef
Modifed workflow to enforce clang and format (#408)
NathanielDelgado Jan 20, 2024
d8a31ac
Began working on a more thorough unit test example for Contactors.
KnockbackNemo Jan 20, 2024
edb8fdd
Pedals and Contactors Unit Tests working post merge
diyarajon Jan 22, 2024
24abdf6
Merge branch 'feature/unit-testing-framework-394' of github.com:lhr-s…
KnockbackNemo Jan 23, 2024
47e5b4a
Modified mocks used by RCC. RCC unit test merge in progress.
diyarajon Jan 23, 2024
900d269
Merge branch 'feature/unit-testing-framework-394' of github.com:lhr-s…
KnockbackNemo Jan 23, 2024
4fd024b
Renamed functions, tasks, and mock test file and otherwise made chang…
KnockbackNemo Jan 23, 2024
b1a8afe
Added back in the LOOP macro so that we don't infinite loop in unit t…
KnockbackNemo Jan 24, 2024
b50d3d0
Completed (ish?) Contactors unit test. Probably could be improved, bu…
KnockbackNemo Jan 27, 2024
1cef3f2
Used clang checks. Still fails at ASSERT_OS_ERROR.
KnockbackNemo Jan 27, 2024
aa23619
Finished making checks; things now formatted properly
KnockbackNemo Jan 27, 2024
c765def
Small comment changes.
KnockbackNemo Jan 27, 2024
25b2669
Update README.md (#412)
KnockbackNemo Jan 27, 2024
d6520c4
Added more annotations to the test files.
KnockbackNemo Jan 31, 2024
3403375
Merge branch 'master' into feature/unit-testing-framework-394
KnockbackNemo Jan 31, 2024
d2c2c7a
Reversed polarity on minion ignition readings (#417)
NathanielDelgado Feb 10, 2024
cd3403e
Removed/restored files that were committed by accident.
KnockbackNemo Mar 2, 2024
b0cc9e3
Changed conditional while(1) to add a break if MOCKING instead of usi…
KnockbackNemo Mar 2, 2024
0bd0a33
Ran make check and make format.
KnockbackNemo Mar 2, 2024
1f4a1c1
Re-removed workspace file associations.
KnockbackNemo Mar 2, 2024
3a02e62
Renamed example unit tests.
KnockbackNemo Mar 2, 2024
7f37ccb
Changed build directory for the unit tests to be the same as the gene…
KnockbackNemo Mar 2, 2024
1b2611a
Added call to lock scheduler in AssertOsError. (#421)
KnockbackNemo Mar 2, 2024
19f0726
Deleted unnecessary mocks that were only defining things.
KnockbackNemo Mar 2, 2024
18baf1c
Removed defines from mock os.h and used original os.h instead.
KnockbackNemo Mar 2, 2024
0257ebc
Created cpu core function mocks and deleted defines by using them fro…
diyarajon Mar 2, 2024
e967b8d
re-add workspace
diyarajon Mar 2, 2024
834eb41
Added debug macro to BSP makefile to use when testing, but not unit-t…
diyarajon Mar 2, 2024
a61bd83
Updated the ReadMe to include the DEBUG_TESTFILE and created an examp…
diyarajon Mar 2, 2024
28cc35d
Merge branch 'master' into feature/unit-testing-framework-394
KnockbackNemo Mar 10, 2024
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
270 changes: 270 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAfterAttributes: Never
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
PPIndentWidth: -1
QualifierAlignment: Leave
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: pb
BasedOnStyle: google
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Auto
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...

59 changes: 59 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,
bugprone-*, cppcoreguidelines-*, readability-*,
-cppcoreguidelines-avoid-non-const-global-variables,
-bugprone-easily-swappable-parameters,
-clang-analyzer-security.insecureAPI.*'
WarningsAsErrors: ''
HeaderFileExtensions:
- ''
- h
- hh
- hpp
- hxx
ImplementationFileExtensions:
- c
- cc
- cpp
- cxx
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: nate
CheckOptions:
cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues: 1;2;3;4;100
readability-magic-numbers.IgnoredIntegerValues: 1;2;3;4;100
readability-identifier-naming.EnumCase: CamelCase
readability-identifier-naming.EnumConstantCase: CamelCase
readability-identifier-naming.EnumConstantPrefix: k
readability-identifier-naming.FunctionCase: camelBack
readability-identifier-naming.GlobalConstantCase: CamelCase
readability-identifier-naming.GlobalConstantPrefix: k
readability-identifier-naming.GlobalConstantPointerCase: CamelCase
readability-identifier-naming.GlobalConstantPointerPrefix: k
readability-identifier-naming.GlobalFunctionCase: CamelCase
readability-identifier-naming.GlobalPointerCase: lower_case
readability-identifier-naming.GlobalVariableCase: lower_case
readability-identifier-naming.LocalConstantCase: CamelCase
readability-identifier-naming.LocalConstantPrefix: k
readability-identifier-naming.LocalConstantPointerCase: CamelCase
readability-identifier-naming.LocalConstantPointerPrefix: k
readability-identifier-naming.LocalPointerCase: lower_case
readability-identifier-naming.LocalVariableCase: lower_case
readability-identifier-naming.MacroDefinitionCase: UPPER_CASE
readability-identifier-naming.ParameterCase: lower_case
readability-identifier-naming.PointerParameterCase: lower_case
readability-identifier-naming.StaticConstantCase: CamelCase
readability-identifier-naming.StaticConstantPrefix: k
readability-identifier-naming.StaticVariableCase: lower_case
readability-identifier-naming.TypedefCase: CamelCase
readability-identifier-naming.StructCase: lower_case
readability-identifier-naming.UnionCase: CamelCase
readability-identifier-naming.VariableCase: lower_case
readability-identifier-naming.IgnoreMainLikeFunctions: false
readability-identifier-length.MinimumVariableNameLength: 2
readability-identifier-length.MinimumParameterNameLength: 2
readability-function-cognitive-complexity.Threshold: 32
SystemHeaders: false
...

9 changes: 9 additions & 0 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ jobs:
run: make clean
- name: make leader
run: make leader
# Check that format was ran and has no errors
- name: format-check
run: make format-check
# Apply format in case newline changes create tidy warnings (NOLINT comments change lines)
- name: format
run: make format
# Check that tidy was ran and has no errors
- name: tidy-check
run: make tidy-check
Loading
Loading