Add rule for building coverage summary using lcov.
Also modified a few tests to be more compatible with coverage information, so that they use the same pb_encode/decode.c instead of making a copy.
This commit is contained in:
@@ -4,3 +4,18 @@ all:
|
|||||||
clean:
|
clean:
|
||||||
scons -c
|
scons -c
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
rm -rf build coverage
|
||||||
|
|
||||||
|
# LCOV does not like the newer gcov format
|
||||||
|
scons CC=gcc-4.6 CXX=gcc-4.6
|
||||||
|
|
||||||
|
# We are only interested in pb_encode.o and pb_decode.o
|
||||||
|
find build -name '*.gcda' -and \! \( -name '*pb_encode*' -or -name '*pb_decode*' \) -exec rm '{}' \;
|
||||||
|
|
||||||
|
# Collect the data
|
||||||
|
mkdir build/coverage
|
||||||
|
lcov --base-directory . --directory build/ --gcov-tool gcov-4.6 -c -o build/coverage/nanopb.info
|
||||||
|
|
||||||
|
# Generate HTML
|
||||||
|
genhtml -o build/coverage build/coverage/nanopb.info
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ if 'gcc' in env['CC']:
|
|||||||
# GNU Compiler Collection
|
# GNU Compiler Collection
|
||||||
|
|
||||||
# Debug info, warnings as errors
|
# Debug info, warnings as errors
|
||||||
env.Append(CFLAGS = '-ansi -pedantic -g -O0 -Wall -Werror --coverage -fstack-protector-all')
|
env.Append(CFLAGS = '-ansi -pedantic -g -O0 -Wall -Werror -fprofile-arcs -ftest-coverage -fstack-protector-all')
|
||||||
env.Append(CORECFLAGS = '-Wextra')
|
env.Append(CORECFLAGS = '-Wextra')
|
||||||
env.Append(LINKFLAGS = '--coverage')
|
env.Append(LINKFLAGS = '-g --coverage')
|
||||||
|
|
||||||
# We currently need uint64_t anyway, even though ANSI C90 otherwise..
|
# We currently need uint64_t anyway, even though ANSI C90 otherwise..
|
||||||
env.Append(CFLAGS = '-Wno-long-long')
|
env.Append(CFLAGS = '-Wno-long-long')
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ Import("env")
|
|||||||
|
|
||||||
# Take copy of the files for custom build.
|
# Take copy of the files for custom build.
|
||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
|
||||||
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
|
||||||
env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c)
|
env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c)
|
||||||
env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c)
|
env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c)
|
||||||
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
@@ -15,9 +13,15 @@ env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
|||||||
opts = env.Clone()
|
opts = env.Clone()
|
||||||
opts.Append(CPPDEFINES = {'PB_BUFFER_ONLY': 1})
|
opts.Append(CPPDEFINES = {'PB_BUFFER_ONLY': 1})
|
||||||
|
|
||||||
|
# Build new version of core
|
||||||
|
strict = opts.Clone()
|
||||||
|
strict.Append(CFLAGS = strict['CORECFLAGS'])
|
||||||
|
strict.Object("pb_decode_bufonly.o", "$NANOPB/pb_decode.c")
|
||||||
|
strict.Object("pb_encode_bufonly.o", "$NANOPB/pb_encode.c")
|
||||||
|
|
||||||
# Now build and run the test normally.
|
# Now build and run the test normally.
|
||||||
enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode.c"])
|
enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_bufonly.o"])
|
||||||
dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode.c"])
|
dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_bufonly.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_alltypes.output"])
|
env.RunTest([dec, "encode_alltypes.output"])
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ Import("env")
|
|||||||
|
|
||||||
# Take copy of the files for custom build.
|
# Take copy of the files for custom build.
|
||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
|
||||||
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
|
||||||
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
||||||
|
|
||||||
@@ -16,9 +14,15 @@ env.NanopbProto(["alltypes", "alltypes.options"])
|
|||||||
opts = env.Clone()
|
opts = env.Clone()
|
||||||
opts.Append(CPPDEFINES = {'PB_FIELD_16BIT': 1})
|
opts.Append(CPPDEFINES = {'PB_FIELD_16BIT': 1})
|
||||||
|
|
||||||
|
# Build new version of core
|
||||||
|
strict = opts.Clone()
|
||||||
|
strict.Append(CFLAGS = strict['CORECFLAGS'])
|
||||||
|
strict.Object("pb_decode_fields16.o", "$NANOPB/pb_decode.c")
|
||||||
|
strict.Object("pb_encode_fields16.o", "$NANOPB/pb_encode.c")
|
||||||
|
|
||||||
# Now build and run the test normally.
|
# Now build and run the test normally.
|
||||||
enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode.c"])
|
enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_fields16.o"])
|
||||||
dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode.c"])
|
dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_fields16.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_alltypes.output"])
|
env.RunTest([dec, "encode_alltypes.output"])
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ Import("env")
|
|||||||
|
|
||||||
# Take copy of the files for custom build.
|
# Take copy of the files for custom build.
|
||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
|
||||||
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
|
||||||
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
||||||
|
|
||||||
@@ -16,9 +14,15 @@ env.NanopbProto(["alltypes", "alltypes.options"])
|
|||||||
opts = env.Clone()
|
opts = env.Clone()
|
||||||
opts.Append(CPPDEFINES = {'PB_FIELD_32BIT': 1})
|
opts.Append(CPPDEFINES = {'PB_FIELD_32BIT': 1})
|
||||||
|
|
||||||
|
# Build new version of core
|
||||||
|
strict = opts.Clone()
|
||||||
|
strict.Append(CFLAGS = strict['CORECFLAGS'])
|
||||||
|
strict.Object("pb_decode_fields32.o", "$NANOPB/pb_decode.c")
|
||||||
|
strict.Object("pb_encode_fields32.o", "$NANOPB/pb_encode.c")
|
||||||
|
|
||||||
# Now build and run the test normally.
|
# Now build and run the test normally.
|
||||||
enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode.c"])
|
enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_fields32.o"])
|
||||||
dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode.c"])
|
dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_fields32.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_alltypes.output"])
|
env.RunTest([dec, "encode_alltypes.output"])
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ Import("env")
|
|||||||
|
|
||||||
# Take copy of the files for custom build.
|
# Take copy of the files for custom build.
|
||||||
c = Copy("$TARGET", "$SOURCE")
|
c = Copy("$TARGET", "$SOURCE")
|
||||||
env.Command("pb_encode.c", "#../pb_encode.c", c)
|
|
||||||
env.Command("pb_decode.c", "#../pb_decode.c", c)
|
|
||||||
env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c)
|
env.Command("alltypes.pb.h", "$BUILD/alltypes/alltypes.pb.h", c)
|
||||||
env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c)
|
env.Command("alltypes.pb.c", "$BUILD/alltypes/alltypes.pb.c", c)
|
||||||
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
env.Command("encode_alltypes.c", "$BUILD/alltypes/encode_alltypes.c", c)
|
||||||
@@ -15,9 +13,15 @@ env.Command("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
|
|||||||
opts = env.Clone()
|
opts = env.Clone()
|
||||||
opts.Append(CPPDEFINES = {'PB_NO_ERRMSG': 1})
|
opts.Append(CPPDEFINES = {'PB_NO_ERRMSG': 1})
|
||||||
|
|
||||||
|
# Build new version of core
|
||||||
|
strict = opts.Clone()
|
||||||
|
strict.Append(CFLAGS = strict['CORECFLAGS'])
|
||||||
|
strict.Object("pb_decode_noerr.o", "$NANOPB/pb_decode.c")
|
||||||
|
strict.Object("pb_encode_noerr.o", "$NANOPB/pb_encode.c")
|
||||||
|
|
||||||
# Now build and run the test normally.
|
# Now build and run the test normally.
|
||||||
enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode.c"])
|
enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode_noerr.o"])
|
||||||
dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode.c"])
|
dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode_noerr.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_alltypes.output"])
|
env.RunTest([dec, "encode_alltypes.output"])
|
||||||
|
|||||||
Reference in New Issue
Block a user