Skip to content
Merged
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
36 changes: 36 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Coverage CI

on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: prepare
run: aclocal && autoconf && automake --add-missing
working-directory: tests
- name: generate gcov report
run: make -f coverage.mk gcov
working-directory: cov
- name: Install lcov
run: sudo apt install -y lcov
- name: generate lcov report
run: make -f coverage.mk esp32basic.info
working-directory: cov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: cov
- name: Upload coverage report to Codacy
uses: codacy/codacy-coverage-reporter-action@v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: cov/esp32basic.info
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ missing
/nbproject/
/dist/
**/Makefile.in
/autom4te.cache/
autom4te.cache/
19 changes: 0 additions & 19 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ AC_ARG_WITH([binaries], AS_HELP_STRING([--without-binaries], [Do not generate .b
AM_CONDITIONAL([WITH_BINARIES], [test x$with_binaries != xno])
AM_COND_IF([WITH_BINARIES],[ AC_MSG_NOTICE([generate .bin images]) ])

AC_CONFIG_SUBDIRS([src])
AC_CONFIG_SUBDIRS([modules])
AC_CONFIG_SUBDIRS([examples])
AC_CONFIG_SUBDIRS([examples/0blink])
AC_CONFIG_SUBDIRS([examples/0hello])
AC_CONFIG_SUBDIRS([examples/0ledctrl])
AC_CONFIG_SUBDIRS([examples/0timgalarm])
AC_CONFIG_SUBDIRS([examples/0uart])
AC_CONFIG_SUBDIRS([examples/0udma])
AC_CONFIG_SUBDIRS([examples/1i2cssd1306])
AC_CONFIG_SUBDIRS([examples/1rmtblink])
AC_CONFIG_SUBDIRS([examples/1rmtdht])
AC_CONFIG_SUBDIRS([examples/1rmtmorse])
AC_CONFIG_SUBDIRS([examples/1rmtmusic])
AC_CONFIG_SUBDIRS([examples/1rmttm1637])
AC_CONFIG_SUBDIRS([examples/1rmtws2812])
AC_CONFIG_SUBDIRS([examples/3prog1])
AC_CONFIG_SUBDIRS([ld])

AC_CONFIG_FILES([
Makefile
src/Makefile
Expand Down
89 changes: 89 additions & 0 deletions cov/coverage.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
SELF_MKFILE := $(lastword $(MAKEFILE_LIST))

PROJ=esp32basic

##progs
GCOV=gcov

## paths
HTML=html/index.html
SRCDIR=../src
MODDIR=../modules

## we get direct information about modification time
## note: I do not like wildcard, but could not find better solution
SOURCES=$(wildcard $(SRCDIR)/*.c)
HEADERS=$(wildcard $(SRCDIR)/*.h)
OBJS=$(addprefix src/, $(notdir $(SOURCES:.c=.o)))

SOURCES_UTILS=$(wildcard $(SRCDIR)/utils/*.c)
HEADERS_UTILS=$(wildcard $(SRCDIR)/utils/*.h)
OBJS_UTILS=$(addprefix src/utils/, $(notdir $(SOURCES_UTILS:.c=.o)))

SOURCES_MODULES=$(wildcard $(MODDIR)/*.c)
HEADERS_MODULES=$(wildcard $(MODDIR)/*.h)
OBJS_MODULES=$(addprefix modules/, $(notdir $(SOURCES_MODULES:.c=.o)))

GCDA=$(OBJS:.o=.gcda) $(OBJS_UTILS:.o=.gcda) $(OBJS_MODULES:.o=.gcda)
GCNO=$(OBJS:.o=.gcno) $(OBJS_UTILS:.o=.gcno) $(OBJS_MODULES:.o=.gcda)

GCDA_EXIST := $(foreach gcda,$(GCDA),$(wildcard $(gcda)))
GCNO_EXIST := $(foreach gcno,$(GCNO),$(wildcard $(gcno)))

$(info $$GCNO = $(GCNO))
$(info $$GCNO_EXIST = $(GCNO_EXIST))

all: $(HTML)

gcov: testrun
$(MAKE) -f $(SELF_MKFILE) _gcov

_gcov: $(GCNO_EXIST:%.gcno=%.c.gcov)

src/%.c.gcov: src/%.gcno
cd src && $(GCOV) -wrabcfu -s ../.. $(<:src/%.gcno=%.o)
[ -f $@ ] || mv src/$(notdir $@) $@

$(HTML): $(PROJ).info
genhtml -s --branch-coverage $(PROJ).info --output-directory $(dir $(HTML))

$(PROJ).info: $(PROJ).pre.info
lcov --ignore-errors unused --rc lcov_branch_coverage=1 -r $< "/usr*" -o $@

$(PROJ).pre.info: $(PROJ).base.info $(PROJ).test.info
lcov --rc lcov_branch_coverage=1 -a $(PROJ).base.info -a $(PROJ).test.info -o $@

$(PROJ).base.info: testrun
lcov -z -d src
lcov --rc lcov_branch_coverage=1 -c -i -d src -o $@

$(PROJ).test.info: $(PROJ).base.info
$(MAKE) -C tests check
lcov --rc lcov_branch_coverage=1 -c -d src -o $@


testrun: tests/Makefile FORCE
$(MAKE) -C tests check

tests/Makefile:
mkdir -p tests
(cd tests && ../../tests/configure CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="-fprofile-arcs -ftest-coverage")

FORCE:

clean:
rm -f $(PROJ).info
rm -f $(PROJ).pre.info
rm -f $(PROJ).base.info
rm -f $(PROJ).test.info
rm -rf $(dir $(HTML))
rm -f src/*.gcda
rm -f tests/*.gcda
$(MAKE) -C tests clean

distclean: clean
$(MAKE) -C tests distclean
rm -rf src
rm -rf tests

.PHONY: clean distclean source testrun gcov _gcov
21 changes: 20 additions & 1 deletion src/utils/generators.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,26 @@ void pwmgen_reset(SPwmGenState *psState) {
psState->u8PhaseIdx = PWMPHASE_END;
}

// (Faster) PWM Generator section
// (Faster) 16bit PWM Generator section

SBitPwmGenState bitpwmgen_init(uint8_t u8HiUpper, uint8_t u8LoUpper, uint8_t u8PeriodLen,
bool bUp, uint8_t u8HiLower, uint8_t u8LoLower,
size_t szInputLen, uint8_t *pu8Input) {
SBitPwmGenState sBPGState = {
.sBitGenState = bitgen_init(0x00, bUp, u8HiLower, u8LoLower),
.sByteGenState = bytegen_init(pu8Input, szInputLen),
.sPwmXGenState = (SPwmXGenState)
{
.u8CurValue = 0x01, // ignored
.u8HiUpper = u8HiUpper,
.u8LoUpper = u8LoUpper,
.u8PeriodLen = u8PeriodLen,
.u8PhaseIdx = 2 // to force reset at first call of ~_next()
}
};
sBPGState.sBitGenState.u8BitIdx = 8; // to force reset at first call of ~_next()
return sBPGState;
}

uint16_t bitpwmgen_next(SBitPwmGenState *psState) {
SPwmXGenState *px = &psState->sPwmXGenState; // alias, for writing shorter lines
Expand Down
7 changes: 5 additions & 2 deletions src/utils/generators.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C" {
union {
FToXReset fReset;
FByteToXResetV fResetV;
};
} ;
} SToByteFunctions;

typedef struct {
Expand All @@ -68,7 +68,7 @@ extern "C" {
union {
FToXReset fReset;
FWordToXResetV fResetV;
};
} ;
} SToWordFunctions;

/**
Expand Down Expand Up @@ -154,6 +154,9 @@ extern "C" {
bool pwmgen_end(const SPwmGenState *psState);
void pwmgen_reset(SPwmGenState *psState);

SBitPwmGenState bitpwmgen_init(uint8_t u8HiUpper, uint8_t u8LoUpper, uint8_t u8PeriodLen,
bool bUp, uint8_t u8HiLower, uint8_t u8LoLower,
size_t szInputLen, uint8_t *pu8Input);
uint16_t bitpwmgen_next(SBitPwmGenState *psState);
bool bitpwmgen_end(const SBitPwmGenState *psState);
void bitpwmgen_reset(SBitPwmGenState *psState);
Expand Down
Empty file added tests/AUTHORS
Empty file.
Loading
Loading