ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
586 stars 246 forks source link

code coverage for embded applciation using xc16-gcc v1.31 compiler #581

Open sabhizakaria opened 3 years ago

sabhizakaria commented 3 years ago

Greeting, I m new when it comes using ceedling to ensure some unit test of my embeded application though after a lot of researchs and trials I failed producing a test converage for my app :

image

these are screenshots of my configuration : image image image and here is my yml project configuration for ceedling project .txt

Thank you

JuPrgn commented 3 years ago

Hi

You can adapt my project config to your microcontroller :

sim_instructions.txt in \test\simulation\ (I don't remember where this one is used...) :

LD dspic33epsuper 
LC build_test/release/TestBuild.out
IO NULL test/simulation/out.txt
RP
E
quit

mdb_instructions.txt in \test\simulation\ :

Device dsPIC33EP256MC506
Hwtool SIM
set oscillator.frequency 60
set oscillator.frequencyunit Mega
set oscillator.rcfrequency 250
set oscillator.rcfrequencyunit Kilo
Set uart1io.uartioenabled true
Set uart1io.output file
Set uart1io.outputfile "test/simulation/out.txt"
Program "build_test/release/TestBuild.out"
Run
Wait
Quit

sim_test_fixture.rb in \test\simulation\ :

require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)

OUT_FILE = "test/simulation/out.txt"
File.delete OUT_FILE if File.exists? OUT_FILE 

#print "no match print"
#abort "no match"

#$stderr.puts("err")

#$stdout.puts "Return error\n"
#exit(2)

sim_io = IO.popen('"C:\Program Files (x86)\Microchip\MPLABX\v5.10\mplab_platform\bin\mdb.bat" test/simulation/mdb_instructions.txt')

Process.wait(sim_io.pid)
#exit_status = $?

#while line = sim_io.gets
#  line.chomp!
#  puts line
#end

#pid, status = Process.wait2(sim_io.pid)
#exit_status = status.exitstatus

#line = sim_io.gets
#puts "#{line}"

#$stderr.puts("exit")
#exit(2)

if File.exists? OUT_FILE 
    file_contents = File.read OUT_FILE
    print file_contents
end

and project.yml :

---
#
:project:
  :use_exceptions: FALSE
  :use_test_preprocessor: TRUE
  :use_deep_dependencies: TRUE
  :use_auxiliary_dependencies: TRUE
  :build_root: build_test
  :test_file_prefix: test_
  :which_ceedling: vendor/ceedling
  :default_tasks:
    - test:all

:extension:
  :executable: .hex

:paths:
  :test:
    - +:test/**
    - -:test/support
  :source:
    - src/**
  :support:
    - test/support  
  :include:
    - test/support 

:defines:
  :commmon: &common_defines
    - UNITY_INT_WIDTH=16
    - CMOCK_MEM_INDEX_TYPE=uint16_t
    # - CMOCK_MEM_PTR_AS_INT=uint16_t # segmentation fault avec GCC dès l'utilisation de ExpectAndReturn si spécifié
    - CMOCK_MEM_ALIGN=1
    - CMOCK_MEM_SIZE=4096
    - __dsPIC33EP256MC506__
  :test:
    - *common_defines
    - TEST
  :test_preprocess:
    - *common_defines
    - TEST

:cmock:
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :plugins:
    - :ignore
    - :callback
  :treat_as:
    uint8:    HEX8
    uint16:   HEX16
    uint32:   UINT32
    uint64:   UINT64
    int8:     INT8
    bool:     UINT8

:environment:
  - :mcpu: 33EP256MC506
  - :XC16PATH: "C:/Program Files (x86)/Microchip/xc16/v1.35"
  - :XC16GCC: "#{ENV['XC16PATH']}/bin/xc16-gcc.exe"
  - :XC16P1: "#{ENV['XC16PATH']}/support/dsPIC33E/h"
  - :XC16P2: "#{ENV['XC16PATH']}/support/generic/h"
  - :XC16P3: "#{ENV['XC16PATH']}/include/lega-c"

:paths:
  :include:
    - "#{ENV['XC16P1']}"
    - "#{ENV['XC16P2']}"
    - "#{ENV['XC16P3']}"

:tools:
  :test_dependencies_generator:
    :executable: "#{ENV['XC16GCC']}"
    :name: 'XC 16 Test Dependencies Generator'
    :arguments:
      - -E
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
      - -D$: DEFINES_TEST_PREPROCESS
      - -DGNU_COMPILER
      - -MT "${3}"
      - -MM
      - -MD
      - -MG
      - -MF"${2}"
      - -c "${1}"
  :test_includes_preprocessor:
    :executable: "#{ENV['XC16GCC']}"
    :name: 'XC 16 Test Include Preprocessor'
    :arguments:
      - -mcpu=#{ENV['MCPU']}
      - -E
      - -MM
      - -MG
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
      - -D$: DEFINES_TEST_PREPROCESS
      - -DGNU_COMPILER
      - "${1}"
  :test_file_preprocessor:
    :executable: "#{ENV['XC16GCC']}"
    :name: 'XC 16 Test File Preprocessor'
    :arguments:
      - -mcpu=#{ENV['MCPU']}
      - -E
      - -DGNU_COMPILER
      - "${1}"
      - -o "${2}"
      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
      - -D$: DEFINES_TEST_PREPROCESS
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
  :test_file_preprocessor_directives:
    :executable: "#{ENV['XC16GCC']}"
    :name: 'XC 16 Test File Preprocessor Directives'
    :arguments:
      - -mcpu=#{ENV['MCPU']}
      - -E
      - -DGNU_COMPILER
      - "${1}"
      - -o "${2}"
      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
      - -D$: DEFINES_TEST_PREPROCESS
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE
      - -fdirectives-only
  :test_compiler:
    :executable: "#{ENV['XC16GCC']}"
    :arguments:
      - -mcpu=#{ENV['MCPU']}
      - -x c
      - -omf=elf
      - -msmart-io=1
      - -mno-eds-warn  
      - -msfr-warn=off
      - -legacy-libc
      - -c
      - "${1}"
      - -o "${2}"
      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR
      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR
      - -Wall
      - -mlarge-code
      - -mlarge-data
      - -mlarge-scalar
      - -mconst-in-data
      - -std=gnu99
  :test_linker:
    :executable: "#{ENV['XC16GCC']}"
    :arguments:
      - -mcpu=#{ENV['MCPU']}
      - -omf=elf 
      - -DXPRJ_default=default  
      - -legacy-libc 
      - ${1}
      - -o "./build_test/release/TestBuild.out"
      - -Wl,-Tp#{ENV['MCPU']}.gld,--heap=0,--stack=16,--local-stack,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map=./build_test/release/TestOutput.map,--report-mem,--memorysummary,./build_test/release/memoryfile.xml
  :test_fixture:
    :executable: ruby
    :name: "Microchip simulator test fixture"
    :stderr_redirect: :win #inform Ceedling what model of $stderr capture to use
    :arguments:
      - test/simulation/sim_test_fixture.rb
  :release_compiler:
    :executable: "#{ENV['XC16GCC']}"
    :arguments:
      - -mcpu=#{ENV['MCPU']}
      - -x c
      - -omf=hex
      - -msmart-io=1
      - -mno-eds-warn  
      - -msfr-warn=off
      - -legacy-libc
      - -c
      - "${1}"
      - -o "${2}"
      - -I"$": COLLECTION_PATHS_SOURCE_INCLUDE_VENDOR
      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE
      - -D$: COLLECTION_DEFINES_RELEASE_AND_VENDOR
      - -Wall
      - -mlarge-code
      - -mlarge-data
      - -mlarge-scalar
      - -mconst-in-data
  :release_linker:
    :executable: "#{ENV['XC16GCC']}"
    :arguments:
      - -mcpu=#{ENV['MCPU']}
      - -legacy-libc
      - ${1}
      - -o "${2}"
      - -Wl,-Tp#{ENV['MCPU']}.gld,--heap=0,--stack=16,--local-stack,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map=./build_test/release/ReleaseOutput.map,--report-mem,--memorysummary,./build_test/release/memoryfile.xml

# 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:
  :html_report: TRUE
  :html_report_type: detailed
  :html_medium_threshold: 75
  :html_high_threshold: 90
  :xml_report: FALSE
  :reports:
    - SonarQube

# 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: "${1}"  # or "-L ${1}" for example
  :common: &common_libraries []
  :test:
    - *common_libraries
  :release:
    - *common_libraries

:plugins:
  :load_paths:
    - vendor/ceedling/plugins
  :enabled:
    - stdout_pretty_tests_report
    - module_generator
    - raw_output_report

:module_generator:
  # use template files because direct boilerplates are not interpreted as UTF-8
  :boilerplate_files:
    :src: 'template\src_boilerplate.txt'
    :inc: 'template\inc_boilerplate.txt'
    :tst: 'template\tst_boilerplate.txt'
...
JuPrgn commented 3 years ago

Please note that I have to manually create build_test\release\ if this does not exist because this folder is not created automatically and tests fails.

sabhizakaria commented 3 years ago

Thank you i ll try it out and get back to you

Le jeu. 8 avr. 2021 à 15:12, JuPrgn @.***> a écrit :

Please note that I have to manually create build_test\release\ if this does not exist because this folder is not created automatically and tests fails.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ThrowTheSwitch/Ceedling/issues/581#issuecomment-815812452, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJRO2DVUMA22S3FLMLNQWLTHWTS5ANCNFSM42SYZXCQ .

--

Zakaria Sabhi 06 65 92 16 17

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail Garanti sans virus. www.avast.com https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

sabhizakaria commented 3 years ago

still no succes, i have another problem regarding ceedling this time : image

sim_instructions.txt in \test\simulation\

LC build/release/TestBuild.out
IO NULL test/simulation/out.txt
RP
E
quit

mdb_instructions.txt in \test\simulation\ :

# mdbscript.conf
device PIC24FJ256GA110
hwtool SIM
set oscillator.frequency 60

set oscillator.frequencyunit Mega

set oscillator.rcfrequency 250

set oscillator.rcfrequencyunit Kilo

Set uart1io.uartioenabled true

Set uart1io.output file

Set uart1io.outputfile "test/simulation/out.txt"

Program "build_test/release/TestBuild.out"

Run

Wait

Quit

sim_test_fixture.rb in \test\simulation\

require 'rbconfig'

is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)

OUT_FILE = "test/simulation/out.txt"
File.delete OUT_FILE if File.exists? OUT_FILE 

sim_io = IO.popen('"C:\Program Files (x86)\Microchip\MPLABX\v5.25\mplab_platform\bin\mdb.bat" test/simulation/configuration.txt')
Process.wait(sim_io.pid)

if File.exists? OUT_FILE 
    file_contents = File.read OUT_FILE
    print file_contents
end

and project.yml :

:project:

  :use_exceptions: FALSE

  :use_test_preprocessor: TRUE

  :use_deep_dependencies: TRUE

  :use_auxiliary_dependencies: TRUE

  :build_root: build_test

  :test_file_prefix: test_

  :which_ceedling: vendor/ceedling

  :default_tasks:

    - test:all

:extension:

  :executable: .hex

:paths:

  :test:

    - +:test/**

    - -:test/support

  :source:

    - src/**

  :support:

    - test/support  

  :include:

    - test/support 

:defines:

  :commmon: &common_defines

    - UNITY_INT_WIDTH=16

    - CMOCK_MEM_INDEX_TYPE=uint16_t

    # - CMOCK_MEM_PTR_AS_INT=uint16_t # segmentation fault avec GCC dès l'utilisation de ExpectAndReturn si spécifié

    - CMOCK_MEM_ALIGN=1

    - CMOCK_MEM_SIZE=4096

    - __PIC24FJ256GA110__

    - CO_VERSION_MAJOR=4

    - CO_USE_GLOBALS

    - CO_CONFIG_SRDO=0

    - CO_CONFIG_TRACE=0

  :test:

    - *common_defines

    - TEST

  :test_preprocess:

    - *common_defines

    - TEST

:cmock:

  :mock_prefix: mock_

  :when_no_prototypes: :warn

  :enforce_strict_ordering: TRUE

  :plugins:

    - :ignore

    - :callback

  :treat_as:

    uint8:    HEX8

    uint16:   HEX16

    uint32:   UINT32

    uint64:   UINT64

    int8:     INT8

    bool:     UINT8

:environment:

  - :mcpu: 24FJ256GA110

  - :XC16PATH: "C:/Program Files (x86)/Microchip/xc16/v1.31"

  - :XC16GCC: "#{ENV['XC16PATH']}/bin/xc16-gcc.exe"

  - :XC16P1: "#{ENV['XC16PATH']}/support/PIC24F/h"

  - :XC16P2: "#{ENV['XC16PATH']}/support/generic/h"

  - :XC16P3: "#{ENV['XC16PATH']}/include/lega-c"

:paths:

  :include:

    - "#{ENV['XC16P1']}"

    - "#{ENV['XC16P2']}"

    - "#{ENV['XC16P3']}"

:tools:

  :test_dependencies_generator:

    :executable: "#{ENV['XC16GCC']}"

    :name: 'XC 16 Test Dependencies Generator'

    :arguments:

      - -E

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -D$: DEFINES_TEST_PREPROCESS

      - -DGNU_COMPILER

      - -MT "${3}"

      - -MM

      - -MD

      - -MG

      - -MF"${2}"

      - -c "${1}"

  :test_includes_preprocessor:

    :executable: "#{ENV['XC16GCC']}"

    :name: 'XC 16 Test Include Preprocessor'

    :arguments:

      - -mcpu=#{ENV['MCPU']}

      - -E

      - -MM

      - -MG

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -D$: DEFINES_TEST_PREPROCESS

      - -DGNU_COMPILER

      - "${1}"

  :test_file_preprocessor:

    :executable: "#{ENV['XC16GCC']}"

    :name: 'XC 16 Test File Preprocessor'

    :arguments:

      - -mcpu=#{ENV['MCPU']}

      - -E

      - -DGNU_COMPILER

      - "${1}"

      - -o "${2}"

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -D$: DEFINES_TEST_PREPROCESS

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE

  :test_file_preprocessor_directives:

    :executable: "#{ENV['XC16GCC']}"

    :name: 'XC 16 Test File Preprocessor Directives'

    :arguments:

      - -mcpu=#{ENV['MCPU']}

      - -E

      - -DGNU_COMPILER

      - "${1}"

      - -o "${2}"

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -D$: DEFINES_TEST_PREPROCESS

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE

      - -fdirectives-only

  :test_compiler:

    :executable: "#{ENV['XC16GCC']}"

    :arguments:

      - -mcpu=#{ENV['MCPU']}

      - -x c

      - -omf=elf

      - -msmart-io=1

      - -mno-eds-warn  

      - -msfr-warn=off

      - -legacy-libc

      - -c

      - "${1}"

      - -o "${2}"

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -Wall

      - -mlarge-code

      - -mlarge-data

      - -mlarge-scalar

      - -mconst-in-data

      - -std=gnu99

  :test_linker:

    :executable: "#{ENV['XC16GCC']}"

    :arguments:

      - -mcpu=#{ENV['MCPU']}

      - -omf=elf 

      - -DXPRJ_default=default  

      - -legacy-libc 

      - ${1}

      - -o "./build_test/release/TestBuild.out"

      - -Tp#{ENV['MCPU']}.gld,--heap=0,--stack=16,--local-stack,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map=./build_test/release/TestOutput.map,--report-mem,--memorysummary,./build_test/release/memoryfile.xml

  :test_fixture:

    :executable: ruby

    :name: "Microchip simulator test fixture"

    :stderr_redirect: :win #inform Ceedling what model of $stderr capture to use

    :arguments:

      - test/simulation/sim_test_fixture.rb

  :release_compiler:

    :executable: "#{ENV['XC16GCC']}"

    :arguments:

      - -mcpu=#{ENV['MCPU']}

      - -x c

      - -omf=hex

      - -msmart-io=1

      - -mno-eds-warn  

      - -msfr-warn=off

      - -legacy-libc

      - -c

      - "${1}"

      - -o "${2}"

      - -I"$": COLLECTION_PATHS_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_RELEASE_AND_VENDOR

      - -Wall

      - -mlarge-code

      - -mlarge-data

      - -mlarge-scalar

      - -mconst-in-data

  :release_linker:

    :executable: "#{ENV['XC16GCC']}"

    :arguments:

      - -mcpu=#{ENV['MCPU']}

      - -legacy-libc

      - ${1}

      - -o "${2}"

      - -Tp#{ENV['MCPU']}.gld,--heap=0,--stack=16,--local-stack,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map=./build_test/release/ReleaseOutput.map,--report-mem,--memorysummary,./build_test/release/memoryfile.xml

# 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:

  :html_report: TRUE

  :html_report_type: detailed

  :html_medium_threshold: 75

  :html_high_threshold: 90

  :xml_report: FALSE

  :reports:

    - SonarQube

# 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: "${1}"  # or "-L ${1}" for example

  :common: &common_libraries []

  :test:

    - *common_libraries

  :release:

    - *common_libraries

:plugins:

  :load_paths:

    - vendor/ceedling/plugins

  :enabled:

    - stdout_pretty_tests_report

    - module_generator

    - raw_output_report
JuPrgn commented 3 years ago

I guess the first line is missing in your sim_instructions.txt : LD pic24super

Never got this error which versions are you using ? Maybe you can disable pretty_tests_report to test ?

sabhizakaria commented 3 years ago

I m using

Ceedling:: 0.10.226
CException:: 1.2.16
CMock:: 2.0.212
Unity:: 2.1.0.118

after modifying the project.yml ( see below ) i got a new error

image

project.yml

:project:

  :use_exceptions: FALSE

  :use_test_preprocessor: TRUE

  :use_deep_dependencies: TRUE

  :use_auxiliary_dependencies: TRUE

  :build_root: build

  :test_file_prefix: test_

  :which_ceedling: vendor/ceedling

  :default_tasks:

    - test:all

:extension:

  :executable: .hex

:paths:

  :test:

    - +:test/**

    - -:test/support

  :source:

    - src/**

  :support:

    - test/support  

  :include:

    - test/support 

:defines:

  :commmon: &common_defines

    - UNITY_INT_WIDTH=16

    - CMOCK_MEM_INDEX_TYPE=uint16_t

    # - CMOCK_MEM_PTR_AS_INT=uint16_t # segmentation fault avec GCC dès l'utilisation de ExpectAndReturn si spécifié

    - CMOCK_MEM_ALIGN=1

    - CMOCK_MEM_SIZE=4096

    - __PIC24FJ256GA110__

    - CO_VERSION_MAJOR=4

    - CO_USE_GLOBALS

    - CO_CONFIG_SRDO=0

    - CO_CONFIG_TRACE=0

  :test:

    - *common_defines

    - TEST

  :test_preprocess:

    - *common_defines

    - TEST

:cmock:

  :mock_prefix: mock_

  :when_no_prototypes: :warn

  :enforce_strict_ordering: TRUE

  :plugins:

    - :ignore

    - :callback

  :treat_as:

    uint8:    HEX8

    uint16:   HEX16

    uint32:   UINT32

    uint64:   UINT64

    int8:     INT8

    bool:     UINT8

:environment:

  - :mcpu: 24FJ256GA110

  - :XC16PATH: 'C:/Program Files (x86)/Microchip/xc16/v1.31'

  - :XC16GCC: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

  - :XC16P1: 'C:/Program Files (x86)/Microchip/xc16/v1.31/support/PIC24F/h'

  - :XC16P2: 'C:/Program Files (x86)/Microchip/xc16/v1.31/support/generic/h'

  - :XC16P3: 'C:/Program Files (x86)/Microchip/xc16/v1.31/include/lega-c'

:tools:

  :test_dependencies_generator:

    :executable: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

    :name: 'XC 16 Test Dependencies Generator'

    :arguments:

      - -E

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -D$: DEFINES_TEST_PREPROCESS

      - -DGNU_COMPILER

      - -MT "${3}"

      - -MM

      - -MD

      - -MG

      - -MF"${2}"

      - -c "${1}"

  :test_includes_preprocessor:

    :executable: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

    :name: 'XC 16 Test Include Preprocessor'

    :arguments:

      - -mcpu=24FJ256GA110

      - -E

      - -MM

      - -MG

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -D$: DEFINES_TEST_PREPROCESS

      - -DGNU_COMPILER

      - "${1}"

  :test_file_preprocessor:

    :executable: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

    :name: 'XC 16 Test File Preprocessor'

    :arguments:

      - -mcpu=24FJ256GA110

      - -E

      - -DGNU_COMPILER

      - "${1}"

      - -o "${2}"

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -D$: DEFINES_TEST_PREPROCESS

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE

  :test_file_preprocessor_directives:

    :executable: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

    :name: 'XC 16 Test File Preprocessor Directives'

    :arguments:

      - -mcpu=24FJ256GA110

      - -E

      - -DGNU_COMPILER

      - "${1}"

      - -o "${2}"

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -D$: DEFINES_TEST_PREPROCESS

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE

      - -fdirectives-only

  :test_compiler:

    :executable: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

    :arguments:

      - -mcpu=24FJ256GA110

      - -x c

      - -omf=elf

      - -msmart-io=1

      - -mno-eds-warn  

      - -msfr-warn=off

      - -legacy-libc

      - -c

      - "${1}"

      - -o "${2}"

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -Wall

      - -mlarge-code

      - -mlarge-data

      - -mlarge-scalar

      - -mconst-in-data

      - -std=gnu99

  :test_linker:

    :executable: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

    :arguments:

      - -mcpu=24FJ256GA110

      - -omf=elf 

      - -DXPRJ_default=default  

      - -legacy-libc 

      - ${1}

      - -o "./build_test/release/TestBuild.out"

      - -Tp24FJ256GA110.gld,--heap=0,--stack=16,--local-stack,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map=./build_test/release/TestOutput.map,--report-mem,--memorysummary,./build_test/release/memoryfile.xml

  :test_fixture:

    :executable: ruby

    :name: "Microchip simulator test fixture"

    :stderr_redirect: :win #inform Ceedling what model of $stderr capture to use

    :arguments:

      - test/simulation/sim_test_fixture.rb

  :release_compiler:

    :executable: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

    :arguments:

      - -mcpu=24FJ256GA110

      - -x c

      - -omf=hex

      - -msmart-io=1

      - -mno-eds-warn  

      - -msfr-warn=off

      - -legacy-libc

      - -c

      - "${1}"

      - -o "${2}"

      - -I"$": COLLECTION_PATHS_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_RELEASE_AND_VENDOR

      - -Wall

      - -mlarge-code

      - -mlarge-data

      - -mlarge-scalar

      - -mconst-in-data

  :release_linker:

    :executable: 'C:/Program Files (x86)/Microchip/xc16/v1.31/bin/xc16-gcc.exe'

    :arguments:

      - -mcpu=24FJ256GA110

      - -legacy-libc

      - ${1}

      - -o "${2}"

      - -Tp24FJ256GA110.gld,--heap=0,--stack=16,--local-stack,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map=./build_test/release/ReleaseOutput.map,--report-mem,--memorysummary,./build_test/release/memoryfile.xml

# 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:

  :html_report: TRUE

  :html_report_type: detailed

  :html_medium_threshold: 75

  :html_high_threshold: 90

  :xml_report: FALSE

  :reports:

    - SonarQube

# 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: "${1}"  # or "-L ${1}" for example

  :common: &common_libraries []

  :test:

    - *common_libraries

  :release:

    - *common_libraries

:plugins:

  :load_paths:

    - vendor/ceedling/plugins

  :enabled:

    #- stdout_pretty_tests_report

    - module_generator
    # gcov
    #- raw_output_report
JuPrgn commented 3 years ago

Your versions are really old can you please upgrade to latest ?

sabhizakaria commented 3 years ago

I have updated ceedling to the latest :
image

JuPrgn commented 3 years ago

This is not the latest(0.31) but the latest on your local installation that updates your vendor directory

JuPrgn commented 3 years ago

You should first run gem update ceedling

JuPrgn commented 3 years ago

You can also remove the 4 latest defines in yml CO.. they are specific to my project and I edited my post to remove them.

sabhizakaria commented 3 years ago

Thank you I shall try this as soon as possible

sabhizakaria commented 3 years ago

Maybe it is a naive question but with your project whch command do you use to generate xml reports for code coverage ?

JuPrgn commented 3 years ago

My project is a bit more complex I have one main project.yml and 2 other projects : one is configured for XC16 and defines tools configuration and the second is for GCC. I then run GCOV with GCC config : ceedling project:project_GCC gcov:all utils:gcov

sabhizakaria commented 3 years ago

so without gcc as a compiler i can not run gcov and thus i can't have my report ?

Testing goes well : image

Buet when i try to call gcov :

image Capture d’écran 2021-04-12 112822

sabhizakaria commented 3 years ago

My project.yml :

---

# Notes:
# Sample project C code is not presently written to produce a release artifact.
# As such, release build options are disabled.
# This sample, therefore, only demonstrates running a collection of unit tests.

:project:
  :use_exceptions: FALSE
  :use_test_preprocessor: TRUE
  :use_auxiliary_dependencies: TRUE
  :build_root: build
  :release_build: TRUE
  :test_file_prefix: test_

:release_build:
 :output: MyPicApp.out
 :use_assembly: FALSE

:environment:

:extension:
  :executable: .out

:paths:
  :test:
    - +:test/**
    - -:test/support
  :source:
    - src/**
  :support:
    - test/support
  :include:
    - 'C:/Program Files (x86)/Microchip/xc16/v1.31/support/PIC24H/h/'
    - 'C:/Program Files (x86)/Microchip/xc16/v1.31/support/PIC24F/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
    - __PIC24HJ128GP202__
    - UNITY_INT_WIDTH=16
    - CMOCK_MEM_INDEX_TYPE=uint16_t
    - CMOCK_MEM_PTR_AS_INT=uint16_t
    - CMOCK_MEM_ALIGN=1
    - CMOCK_MEM_SIZE=4096
  :test:
    - *common_defines
    - TEST
  :test_preprocess:
    - *common_defines
    - TEST

:cmock:
  :mock_prefix: mock_
  :when_no_prototypes: :warn
  :enforce_strict_ordering: TRUE
  :plugins:
    - :ignore
    - :callback
  :treat_as:
    uint8:    HEX8
    uint16:   HEX16
    uint32:   UINT32
    int8:     INT8
    bool:     UINT8

:tools:
  :test_compiler:
    :executable: xc16-gcc
    :arguments:
      - -mcpu=24HJ128GP202
      - -x c
      - -c

      - -omf=elf

      - -msmart-io=1

      - -mno-eds-warn  

      - -msfr-warn=off

      - -legacy-libc

      - -c

      - "${1}"

      - -o "${2}"

      - -D$: COLLECTION_DEFINES_TEST_AND_VENDOR

      - -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR

      - -Wall

      - -mlarge-code

      - -mlarge-data

      - -mlarge-scalar

      - -mconst-in-data

      - -std=gnu99

  :test_linker:
    :executable: xc16-gcc
    :arguments:
      - -mcpu=24HJ128GP202

      - -omf=elf 
      - -DXPRJ_default=default  
      - -legacy-libc 
      - ${1}
      - -o "./build/release/TestBuild.out"
      - -Wl,-Tp24HJ128GP202.gld,-Map=./build/release/TestOutput.map,--report-mem
  :test_fixture:
    :executable: ruby
    :name: "Microchip simulator test fixture"
    :stderr_redirect: :win #inform Ceedling what model of $stderr capture to use
    :arguments:
      - test/simulation/sim_test_fixture.rb

  :release_compiler:
    :executable: xc16-gcc
    :arguments:
      - -mcpu=24HJ128GP202
      - -x c
           - -omf=hex

      - -msmart-io=1

      - -mno-eds-warn  

      - -msfr-warn=off

      - -legacy-libc

      - -c

      - "${1}"

      - -o "${2}"

      - -I"$": COLLECTION_PATHS_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_RELEASE_AND_VENDOR

      - -Wall

      - -mlarge-code

      - -mlarge-data

      - -mlarge-scalar

      - -mconst-in-data
  :release_linker:
    :executable: xc16-gcc
    :arguments:
      - -mcpu=24HJ128GP202
      - ${1}
      - -legacy-libc
      - -o "${2}"
      - -Wl, -Tp24FJ256GA110.gld,--heap=0,--stack=16,--local-stack,--check-sections,--data-init,--pack-data,--handles,--isr,--no-gc-sections,--fill-upper=0,--stackguard=16,--no-force-link,--smart-io,-Map=./build_test/release/ReleaseOutput.map,--report-mem,--memorysummary,./build_test/release/memoryfile.xml
# 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:

  :html_report: TRUE

  :html_report_type: detailed

  :html_medium_threshold: 75

  :html_high_threshold: 90

  :xml_report: FALSE

  :reports:

    - SonarQube

# 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: "${1}"  # or "-L ${1}" for example

  :common: &common_libraries []

  :test:

    - *common_libraries

  :release:

    - *common_libraries

:plugins:
  :load_paths:
   #- vendor/plugins
  :enabled:
    - stdout_pretty_tests_report
    - module_generator
    - raw_output_report
    - gcov
...
JuPrgn commented 3 years ago

If I remember well XC16 was not compatible with GCOV or I failed to configure this and then I switched to GCC.

JuPrgn commented 3 years ago

I still run tests on XC16 and my CI pipeline runs tests for both XC16 and GCC compiler with GCOV on GCC.

sabhizakaria commented 3 years ago

yeah GCOV is only compatible with gcc, and without it i can't generate a coverage code report, and i can only use xc16 as a compiler

Letme commented 3 years ago

since you use test_compiler, etc you could also use :gcov_compiler: :gcov_linker: and even :gcov_report: and :gcov_post_report:

What you need is a gcc compiler that is able to pass:

      - -fprofile-arcs
      - -ftest-coverage

You need gcc linker that can pass

      - -lgcov
      - --coverage

Then the fixture I assume is execution of the compiled and linked test binary (so here you have your simulator in the above cases, or just run ${1} if you use non-target run):

  :gcov_fixture:
    :executable: ${1}

I have setup this for gcc and clang...

sabhizakaria commented 3 years ago

Even after modifying my project.yml to add gcc compiler i still get the same error Project.yml modification :

 :gcov_compiler:
    :executable: gcc
    :arguments:
      - -legacy-libc
      - -fprofile-arcs
      - -ftest-coverage
      - -x c
      - -omf=hex
      - -legacy-libc

      - -c

      - "${1}"

      - -o "${2}"

      - -I"$": COLLECTION_PATHS_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_RELEASE_AND_VENDOR

      - -Wall

  :gcov_linker:
    :executable: gcc
    :arguments:
      - -x c
      - -omf=hex
      - -legacy-libc

      - -c

      - "${1}"

      - -o "${2}"

      - -I"$": COLLECTION_PATHS_SOURCE_INCLUDE_VENDOR

      - -I"$": COLLECTION_PATHS_RELEASE_TOOLCHAIN_INCLUDE

      - -D$: COLLECTION_DEFINES_RELEASE_AND_VENDOR

      - -Wall
      - -lgcov
      - --coverage
  :gcov_fixture:
    :executable: ${1}