summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-04-05 13:26:37 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-04-05 13:26:37 +0300
commita8de6acf2df23104be8907b9e3ed8647b33df6e2 (patch)
tree7246f8d4607220cd3e6770907699e40431519323 /tests
parent7880f308ea996292d5e28a81618370d79e2bdf26 (diff)
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile15
-rw-r--r--tests/SConstruct4
-rw-r--r--tests/buffer_only/SConscript12
-rw-r--r--tests/field_size_16/SConscript12
-rw-r--r--tests/field_size_32/SConscript12
-rw-r--r--tests/no_errmsg/SConscript12
6 files changed, 49 insertions, 18 deletions
diff --git a/tests/Makefile b/tests/Makefile
index fb37e630..3c4e0b04 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -4,3 +4,18 @@ all:
clean:
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
diff --git a/tests/SConstruct b/tests/SConstruct
index b6b877f7..e7aa4717 100644
--- a/tests/SConstruct
+++ b/tests/SConstruct
@@ -91,9 +91,9 @@ if 'gcc' in env['CC']:
# GNU Compiler Collection
# 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(LINKFLAGS = '--coverage')
+ env.Append(LINKFLAGS = '-g --coverage')
# We currently need uint64_t anyway, even though ANSI C90 otherwise..
env.Append(CFLAGS = '-Wno-long-long')
diff --git a/tests/buffer_only/SConscript b/tests/buffer_only/SConscript
index db86d377..cddbb04f 100644
--- a/tests/buffer_only/SConscript
+++ b/tests/buffer_only/SConscript
@@ -4,8 +4,6 @@ Import("env")
# Take copy of the files for custom build.
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.c", "$BUILD/alltypes/alltypes.pb.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.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.
-enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode.c"])
-dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode.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_bufonly.o"])
env.RunTest(enc)
env.RunTest([dec, "encode_alltypes.output"])
diff --git a/tests/field_size_16/SConscript b/tests/field_size_16/SConscript
index 15dc0f5d..8fee0049 100644
--- a/tests/field_size_16/SConscript
+++ b/tests/field_size_16/SConscript
@@ -5,8 +5,6 @@ Import("env")
# Take copy of the files for custom build.
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("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
@@ -16,9 +14,15 @@ env.NanopbProto(["alltypes", "alltypes.options"])
opts = env.Clone()
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.
-enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode.c"])
-dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode.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_fields16.o"])
env.RunTest(enc)
env.RunTest([dec, "encode_alltypes.output"])
diff --git a/tests/field_size_32/SConscript b/tests/field_size_32/SConscript
index 25ef3546..2a64c6c5 100644
--- a/tests/field_size_32/SConscript
+++ b/tests/field_size_32/SConscript
@@ -5,8 +5,6 @@ Import("env")
# Take copy of the files for custom build.
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("decode_alltypes.c", "$BUILD/alltypes/decode_alltypes.c", c)
@@ -16,9 +14,15 @@ env.NanopbProto(["alltypes", "alltypes.options"])
opts = env.Clone()
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.
-enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode.c"])
-dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode.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_fields32.o"])
env.RunTest(enc)
env.RunTest([dec, "encode_alltypes.output"])
diff --git a/tests/no_errmsg/SConscript b/tests/no_errmsg/SConscript
index 2b9815d1..ed467051 100644
--- a/tests/no_errmsg/SConscript
+++ b/tests/no_errmsg/SConscript
@@ -4,8 +4,6 @@ Import("env")
# Take copy of the files for custom build.
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.c", "$BUILD/alltypes/alltypes.pb.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.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.
-enc = opts.Program(["encode_alltypes.c", "alltypes.pb.c", "pb_encode.c"])
-dec = opts.Program(["decode_alltypes.c", "alltypes.pb.c", "pb_decode.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_noerr.o"])
env.RunTest(enc)
env.RunTest([dec, "encode_alltypes.output"])