-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update sample project to include a couple integration tests.
Update sample project to include test-specific defines. Add manual stress test. Bump vendor versions.
- Loading branch information
1 parent
e06f844
commit 847fcff
Showing
9 changed files
with
207 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# ========================================================================= | ||
# Ceedling - Test-Centered Build System for C | ||
# ThrowTheSwitch.org | ||
# Copyright (c) 2010-24 Mike Karlesky, Mark VanderVoord, & Greg Williams | ||
# SPDX-License-Identifier: MIT | ||
# ========================================================================= | ||
|
||
--- | ||
|
||
# Enable gcov plugin | ||
:plugins: | ||
:enabled: | ||
- gcov | ||
|
||
# Add -gcov to the plugins list to make sure of the gcov plugin | ||
# You will need to have gcov and gcovr both installed to make it work. | ||
# For more information on these options, see docs in plugins/gcov | ||
:gcov: | ||
:utilities: | ||
- gcovr # Use gcovr to create the specified reports (default). | ||
#- ReportGenerator # Use ReportGenerator to create the specified reports. | ||
:reports: # Specify one or more reports to generate. | ||
# Make an HTML summary report. | ||
# - HtmlBasic | ||
- HtmlDetailed | ||
# - Text | ||
# - Cobertura | ||
# - SonarQube | ||
# - JSON | ||
# - HtmlInline | ||
# - HtmlInlineAzure | ||
# - HtmlInlineAzureDark | ||
# - HtmlChart | ||
# - MHtml | ||
# - Badges | ||
# - CsvSummary | ||
# - Latex | ||
# - LatexSummary | ||
# - PngChart | ||
# - TeamCitySummary | ||
# - lcov | ||
# - Xml | ||
# - XmlSummary | ||
:gcovr: | ||
# :html_artifact_filename: TestCoverageReport.html | ||
# :html_title: Test Coverage Report | ||
:html_medium_threshold: 75 | ||
:html_high_threshold: 90 | ||
# :html_absolute_paths: TRUE | ||
# :html_encoding: UTF-8 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* ========================================================================= | ||
Ceedling - Test-Centered Build System for C | ||
ThrowTheSwitch.org | ||
Copyright (c) 2010-24 Mike Karlesky, Mark VanderVoord, & Greg Williams | ||
SPDX-License-Identifier: MIT | ||
========================================================================= */ | ||
|
||
#include "unity.h" | ||
#include "Types.h" | ||
#include "TimerConductor.h" | ||
#include "TimerHardware.h" | ||
#include "TimerModel.h" | ||
#include "MockTimerConfigurator.h" | ||
#include "MockTimerInterruptHandler.h" | ||
#include "MockTaskScheduler.h" | ||
|
||
/* NOTE: we probably wouldn't actually perform this test on our own projects | ||
but it's a good example of testing the same module(s) from multiple test | ||
files, and therefore we like having it in this example. | ||
*/ | ||
|
||
void setUp(void) | ||
{ | ||
} | ||
|
||
void tearDown(void) | ||
{ | ||
} | ||
|
||
void testInitShouldCallHardwareInit(void) | ||
{ | ||
Timer_EnablePeripheralClocks_Expect(); | ||
Timer_Reset_Expect(); | ||
Timer_ConfigureMode_Expect(); | ||
Timer_ConfigurePeriod_Expect(); | ||
Timer_EnableOutputPin_Expect(); | ||
Timer_Enable_Expect(); | ||
Timer_ConfigureInterruptHandler_Expect(); | ||
Timer_Start_Expect(); | ||
|
||
TimerConductor_Init(); | ||
} | ||
|
||
void testRunShouldGetSystemTimeAndPassOnToModelForEventScheduling(void) | ||
{ | ||
Timer_GetSystemTime_ExpectAndReturn(1230); | ||
TaskScheduler_Update_Expect(1230); | ||
TimerConductor_Run(); | ||
|
||
Timer_GetSystemTime_ExpectAndReturn(837460); | ||
TaskScheduler_Update_Expect(837460); | ||
TimerConductor_Run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* ========================================================================= | ||
Ceedling - Test-Centered Build System for C | ||
ThrowTheSwitch.org | ||
Copyright (c) 2010-24 Mike Karlesky, Mark VanderVoord, & Greg Williams | ||
SPDX-License-Identifier: MIT | ||
========================================================================= */ | ||
|
||
#include "unity.h" | ||
#include "Types.h" | ||
#include "UsartConductor.h" | ||
#include "UsartModel.h" | ||
#include "UsartHardware.h" | ||
#include "ModelConfig.h" | ||
#include "MockTaskScheduler.h" | ||
#include "MockUsartConfigurator.h" | ||
#include "MockUsartPutChar.h" | ||
#include "MockTemperatureFilter.h" | ||
#include "MockUsartBaudRateRegisterCalculator.h" | ||
#include <math.h> | ||
|
||
/* NOTE: we probably wouldn't actually perform this test on our own projects | ||
but it's a good example of testing the same module(s) from multiple test | ||
files, and therefore we like having it in this example. | ||
*/ | ||
|
||
#ifndef TEST_USART_INTEGRATED_STRING | ||
#define TEST_USART_INTEGRATED_STRING "THIS WILL FAIL" | ||
#endif | ||
|
||
void setUp(void) | ||
{ | ||
} | ||
|
||
void tearDown(void) | ||
{ | ||
} | ||
|
||
void testShouldInitializeHardwareWhenInitCalled(void) | ||
{ | ||
size_t i; | ||
const char* test_str = TEST_USART_INTEGRATED_STRING; | ||
|
||
UsartModel_CalculateBaudRateRegisterSetting_ExpectAndReturn(MASTER_CLOCK, USART0_BAUDRATE, 4); | ||
Usart_ConfigureUsartIO_Expect(); | ||
Usart_EnablePeripheralClock_Expect(); | ||
Usart_Reset_Expect(); | ||
Usart_ConfigureMode_Expect(); | ||
Usart_SetBaudRateRegister_Expect(4); | ||
Usart_Enable_Expect(); | ||
for (i=0; i < strlen(test_str); i++) | ||
{ | ||
Usart_PutChar_Expect(test_str[i]); | ||
} | ||
|
||
UsartConductor_Init(); | ||
} | ||
|
||
void testRunShouldNotDoAnythingIfSchedulerSaysItIsNotTimeYet(void) | ||
{ | ||
TaskScheduler_DoUsart_ExpectAndReturn(FALSE); | ||
|
||
UsartConductor_Run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
iterations = (ARGV[0] || 25).to_i | ||
puts "Stress Testing Each Scenario #{iterations} times..." | ||
|
||
require 'open3' | ||
|
||
defaults = { :dir => File.expand_path(File.dirname(__FILE__)) + '/../../examples/temp_sensor' } | ||
|
||
tasks = { | ||
'ceedling clobber test:all' => defaults, | ||
'ceedling -v=4 clobber test:all' => defaults, | ||
'ceedling test:all' => defaults, | ||
'ceedling --verbosity=obnoxious --mixin=add_unity_helper --mixin=add_gcov clobber test:all' => defaults, | ||
} | ||
|
||
tasks.each_pair do |k,v| | ||
Dir.chdir(v[:dir]) do | ||
iterations.times do |i| | ||
puts "=============== RUNNING ITERATION #{i+1}:\n#{k.to_s}\n===============\n\n" | ||
stdout, stderr, status = Open3.capture3(k) | ||
puts stdout,stderr,status | ||
raise "\n\nCrashed on #{k} Iteration #{i+1}" unless status.success? | ||
end | ||
end | ||
end |
Submodule cmock
updated
63 files
Submodule unity
updated
14 files
+1 −1 | .github/workflows/main.yml | |
+1 −1 | README.md | |
+1 −1 | auto/generate_module.rb | |
+8 −6 | auto/generate_test_runner.rb | |
+1 −6 | auto/stylize_as_junit.rb | |
+1 −0 | docs/UnityChangeLog.md | |
+1 −1 | docs/UnityHelperScriptsGuide.md | |
+1 −1 | examples/unity_config.h | |
+30 −17 | src/unity.c | |
+47 −34 | src/unity_internals.h | |
+1 −0 | test/Makefile | |
+5 −5 | test/tests/self_assessment_utils.h | |
+63 −21 | test/tests/test_generate_test_runner.rb | |
+4 −3 | test/tests/test_unity_core.c |