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

Modernize and Refurbish #3

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store

34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,38 @@ Edit: 11/01/2021

* You only need to change XC16 compiler path (line 34) inside "project.yml" file to yours.

Edit: 2022-12-07
* Update to use XC16 v2.00
* Ceedling updated to 0.31.1
* Update Simulation configuration located in test/simulation

Edit: 2023-01-04
* Vendor directories removed
* sim_test_fixture.rd now programs and runs the test binary
* [UnityDeadLoop](http://www.throwtheswitch.org/build/cross) configuation added
* Fixture configuration moved to `:text_fixture:` section of the `project.yml` file.
- The first 6 arguments are required, and must be supplied in the given order.
- Set options must be supplied as `option value` pairs.

```yaml
:test_fixture:
:executable: ruby
:name: "Microchip simulator test fixture"
:stderr_redirect: :auto #inform Ceedling what model of $stderr capture to use
:arguments:
- test/simulation/sim_test_fixture.rb
- ${1}
# MDB command
- "mdb.sh"
# MDB timeout - fail safe
- "30000"
# Device
- PIC24HJ128GP202
# HWTOOL
- SIM
# Set options
- "warningmessagebreakoptions.W0011_CORE_SIM32_UNIMPLEMENTED_RAMACCESS break"
- "uart1io.output window"
- "uart1io.uartioenabled true"
```

90 changes: 75 additions & 15 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,28 @@
:use_test_preprocessor: TRUE
:use_auxiliary_dependencies: TRUE
:build_root: build
:release_build: TRUE
# :release_build: TRUE
:test_file_prefix: test_
:which_ceedling: gem
:ceedling_version: 0.31.1
:default_tasks:
- test:all

:release_build:
:output: MyPicApp.out
:use_assembly: FALSE
#:test_build:
# :use_assembly: TRUE

#:release_build:
# :output: MyApp.out
# :use_assembly: FALSE

:environment:
# - :mch_root: "/Applications/microchip"
# - :mplabx_vers: "v6.05"
# - :xc: "xc16"
# - :xc_version: "v2.00"

:extension:
:executable: .out
:executable: .elf

:paths:
:test:
Expand All @@ -31,13 +42,15 @@
:support:
- test/support
:include:
- "C:/ProgramFiles/Microchip/xc16/v1.61/support/PIC24H/h/"
- "/Applications/microchip/xc16/v2.00/support/PIC24H/h/"
#- "C:/ProgramFiles/Microchip/xc16/v1.61/support/PIC24H/h/"


:defines:
# in order to add common defines:
# 1) remove the trailing [] from the :common: section
# 2) add entries to the :common: section (e.g. :test: has TEST defined)
:commmon: &common_defines
:common: &common_defines
- __PIC24HJ128GP202__
- UNITY_INT_WIDTH=16
- CMOCK_MEM_INDEX_TYPE=uint16_t
Expand All @@ -47,6 +60,7 @@
:test:
- *common_defines
- TEST
- UNITY_INCLUDE_CONFIG_H
:test_preprocess:
- *common_defines
- TEST
Expand All @@ -65,35 +79,67 @@
int8: INT8
bool: UINT8

# 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:
:reports:
- HtmlDetailed
:gcovr:
:html_medium_threshold: 75
:html_high_threshold: 90

#:tools:
# Ceedling defaults to using gcc for compiling, linking, etc.
# As [:tools] is blank, gcc will be used (so long as it's in your system path)
# See documentation to configure a given toolchain for use

:tools:
:test_compiler:
:executable: xc16-gcc
:arguments:
- -mcpu=24HJ128GP202
- -x c
- -c
- -g
- "${1}"
- -o "${2}"
- -D__DEBUG=__DEBUG
- -D__MPLAB_DEBUGGER_SIMULATOR=1
- -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
- -Wall
#- -Werror # We can't keep this on during test becuase of a CMock pointer issue
# - -Os # This works only with paid XC16 compiler versions
- -mlarge-code
- -mlarge-arrays
# - -mlarge-code
# - -mlarge-arrays
:test_linker:
:executable: xc16-gcc
:arguments:
- -mcpu=24HJ128GP202
- ${1}
- -o "./build/release/TestBuild.out"
- -Wl,-Tp24HJ128GP202.gld,-Map=./build/release/TestOutput.map,--report-mem
- -o ${2}
- "-Wl,-Tp24HJ128GP202.gld,--heap=0,--defsym=__MPLAB_BUILD=1,--defsym=__MPLAB_DEBUG=1,--defsym=__DEBUG=1,-D__DEBUG=__DEBUG,--defsym=__MPLAB_DEBUGGER_SIMULATOR=1"

:test_fixture:
:executable: ruby
:name: "Microchip simulator test fixture"
:stderr_redirect: :win #inform Ceedling what model of $stderr capture to use
:stderr_redirect: :auto #inform Ceedling what model of $stderr capture to use
:arguments:
- test/simulation/sim_test_fixture.rb
- ${1}
# MDB command
- "mdb.sh"
# MDB timeout - fail safe
- "30000"
# Device
- PIC24HJ128GP202
# HWTOOL
- SIM
# Set options
- "warningmessagebreakoptions.W0011_CORE_SIM32_UNIMPLEMENTED_RAMACCESS break"
- "uart1io.output window"
- "uart1io.uartioenabled true"

:release_compiler:
:executable: xc16-gcc
Expand All @@ -109,8 +155,9 @@
- -Wall
- -Werror
# - -Os # This works only with paid XC16 compiler versions
- -mlarge-code
- -mlarge-arrays
# - -mlarge-code
# - -mlarge-arrays

:release_linker:
:executable: xc16-gcc
:arguments:
Expand All @@ -119,9 +166,22 @@
- -o "${2}"
- -Wl,-Tp24HJ128GP202.gld,-Map=./build/release/MyPicApp.map,--report-mem


# LIBRARIES
# These libraries are automatically injected into the build process. Those specified as
# common will be used in all types of builds. Otherwise, libraries can be injected in just
# tests or releases. These options are MERGED with the options in supplemental yaml files.
:libraries:
:placement: :end
:flag: "-l${1}"
:path_flag: "-L ${1}"
:system: [] # for example, you might list 'm' to grab the math library
:test: []
:release: []

:plugins:
:load_paths:
- vendor/ceedling/plugins
- "#{Ceedling.load_path}"
:enabled:
- stdout_pretty_tests_report
- module_generator
Expand Down
4 changes: 0 additions & 4 deletions rakefile.rb

This file was deleted.

4 changes: 0 additions & 4 deletions test/simulation/out.txt

This file was deleted.

6 changes: 0 additions & 6 deletions test/simulation/sim_instructions.txt

This file was deleted.

51 changes: 43 additions & 8 deletions test/simulation/sim_test_fixture.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
OUT_FILE = "test/simulation/out.txt"
File.delete OUT_FILE if File.exists? OUT_FILE
IO.popen("sim30 test/simulation/sim_instructions.txt")
sleep 1
if File.exists? OUT_FILE
file_contents = File.read OUT_FILE
print file_contents
end
require 'open3'

test_file = ARGV.shift
mdb_command = ARGV.shift
timeout = ARGV.shift

stdin, stdout, stderr, wait_thr = Open3.popen3(mdb_command)

stdin.puts "Device #{ARGV.shift}"
stdin.puts "Hwtool #{ARGV.shift}"

ARGV.each_slice(2) do | opt, val |
stdin.puts "set #{opt} #{val}"
end

stdin.puts "Program #{test_file}"

stdin.puts "Break UnityHelperDeadLoop"
stdin.puts "Run"
stdin.puts "Wait #{timeout}"
stdin.puts "Quit"


# Filter out MDB Java logr and NetBeans errors
errors = stderr.readlines.reject { | line | line.match(/(logr|dumb|Preferences)/)}
result = stdout.readlines

Process.waitall

# Remove command prompts
result = result.map {|s| s.gsub(/^>/, "")}

# Results start 2 lines after Running, and end with OK or FAIL
test_start = result.find_index { |line| line.match(/^Running/) }
test_status = result.find_index { |line| line.match(/^(?:OK|FAIL)\n/) }

if (test_start != nil) & (test_status != nil)
result = result[test_start + 2 , (test_status - test_start - 1)]
end

STDOUT.print result.join()
STDERR.print errors.join()

4 changes: 4 additions & 0 deletions test/support/UnityHelper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void UnityHelperDeadLoop(void){
while(1){};
}

6 changes: 6 additions & 0 deletions test/support/UnityHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef UNITY_HELPER_H
#define UNITY_HELPER_H

void UnityHelperDeadLoop(void);

#endif
8 changes: 8 additions & 0 deletions test/support/unity_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef UNITY_CONFIG_H
#define UNITY_CONFIG_H

#include "UnityHelper.h"

#define UNITY_OUTPUT_COMPLETE() UnityHelperDeadLoop()

#endif
1 change: 1 addition & 0 deletions test/test_gpio_access.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "unity.h"
#include "UnityHelper.h"
#include "gpio_access.h"
#include "p24HJ128GP202.h"
#include <string.h> // for memset()
Expand Down
1 change: 1 addition & 0 deletions test/test_led_control.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "unity.h"
#include "UnityHelper.h"
#include "led_control.h"
#include "mock_gpio_access.h"

Expand Down
1 change: 1 addition & 0 deletions test/test_main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "unity.h"
#include "UnityHelper.h"
#include "main.h"
#include "mock_system.h"
#include "mock_led_control.h"
Expand Down
3 changes: 3 additions & 0 deletions test/test_system.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "unity.h"
#include "UnityHelper.h"
#include "system.h"

void setUp(void)
Expand All @@ -12,4 +13,6 @@ void tearDown(void)
void test_ShouldAbortApp_should_return_false_for_now(void)
{
TEST_ASSERT_FALSE(ShouldAbortApp());

}

Binary file removed vendor/ceedling/docs/CExceptionSummary.pdf
Binary file not shown.
Binary file removed vendor/ceedling/docs/CMock Summary.pdf
Binary file not shown.
Binary file removed vendor/ceedling/docs/CeedlingPacket.pdf
Binary file not shown.
Binary file removed vendor/ceedling/docs/Unity Summary.pdf
Binary file not shown.
27 changes: 0 additions & 27 deletions vendor/ceedling/lib/build_invoker_utils.rb

This file was deleted.

Loading