Skip to content

Commit

Permalink
Merged #105 (more or less)
Browse files Browse the repository at this point in the history
  • Loading branch information
mouse07410 committed Jan 31, 2017
1 parent 503c21a commit c568d29
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

ACLOCAL_AMFLAGS = -I m4

@CODE_COVERAGE_RULES@
CODE_COVERAGE_IGNORE_PATTERN="tests/*" "lex.yy.c" "y.tab.c" "asn1p_l.l" "asn1p_y.y"

@CODE_COVERAGE_RULES@
CODE_COVERAGE_IGNORE_PATTERN="tests/*" "lex.yy.c" "y.tab.c" "asn1p_l.l" "asn1p_y.y"

SUBDIRS = \
libasn1parser libasn1fix \
libasn1print libasn1compiler \
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

[![Coverage Status](https://coveralls.io/repos/github/velichkov/asn1c/badge.svg?branch=master)](https://coveralls.io/github/velichkov/asn1c?branch=master)

# About

ASN.1 to C compiler takes the ASN.1 module files (example) and generates
Expand Down
1 change: 1 addition & 0 deletions asn1c/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@CODE_COVERAGE_RULES@

SUBDIRS = . tests

Expand Down
1 change: 1 addition & 0 deletions asn1c/tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@CODE_COVERAGE_RULES@

SUBDIRS = check-src

Expand Down
6 changes: 3 additions & 3 deletions asn1c/tests/check-assembly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cat > "$testdir/Makefile" <<EOM
# This file is autogenerated by ../$0
COMMON_FLAGS= -I.
CFLAGS = \${COMMON_FLAGS} ${CFLAGS:-} -g -O0
CFLAGS = \${COMMON_FLAGS} ${CFLAGS:-} -g -O0 -I ${abs_top_srcdir}/skeletons
CPPFLAGS = -DSRCDIR=../${srcdir}
CXXFLAGS = \${COMMON_FLAGS} ${CXXFLAGS}
Expand All @@ -63,12 +63,12 @@ CC ?= ${CC}
all: check-executable
check-executable: compiled-module *.c*
@rm -f *.core
\$(CC) \$(CPPFLAGS) \$(CFLAGS) -o check-executable *.c* -lm
\$(CC) \$(CPPFLAGS) \$(CFLAGS) -o check-executable *.c* -L${abs_top_builddir}/skeletons/.libs -lasn1cskeletons -lm
# Compile the corresponding .asn1 spec.
compiled-module: ${asn_module} ${abs_top_builddir}/asn1c/asn1c
${abs_top_builddir}/asn1c/asn1c \\
-S ${abs_top_srcdir}/skeletons \\
-S /tmp/do/not/copy/skeletons \\
-Wdebug-compiler \\
${AFLAGS} ${asn_module}
rm -f converter-sample.c
Expand Down
23 changes: 22 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ AC_ARG_ENABLE(test-Werror,
TESTSUITE_CFLAGS="-Werror -W -Wpointer-arith"
])

AX_CODE_COVERAGE
AS_IF([test x$enable_code_coverage != xno], [
CFLAGS="$CFLAGS $CODE_COVERAGE_CFLAGS"
# The CODE_COVERAGE_CPPFLAGS contains -DNDEBUG flag
# which removes assert(...) macros from code coverage and improves the
# branches score. But when it is defined it results in few
# unsed-but-set-variable warnings that are treated as errors in the travis-ci
# build because these variables are only used inside assert macros.
# error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]
#CPPFLAGS="$CPPFLAGS $CODE_COVERAGE_CPPFLAGS"
CXXFLAGS="$CXXFLAGS $CODE_COVERAGE_CXXFLAGS"
LDFLAGS="$LDFLAGS $CODE_COVERAGE_LDFLAGS"
])

AC_SUBST(ADD_CFLAGS)
AC_SUBST(TESTSUITE_CFLAGS)

Expand All @@ -87,7 +101,14 @@ SKELETONS_CFLAGS="${ADD_CFLAGS} ${SKELETONS_CFLAGS}"
AX_CHECK_COMPILE_FLAG([-std=c99],
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -std=c99"])
AX_CHECK_COMPILE_FLAG([-Wpedantic],
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wpedantic"])
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wpedantic"],
[
dnl When -Wpedantic is not supported try the -pedantic instead. (gcc-4.7)
dnl See https://gcc.gnu.org/gcc-4.8/changes.html
AX_CHECK_COMPILE_FLAG([-pedantic],
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -pedantic"], [], [-Werror])
],
[-Werror]) #clang 3.0 prints warning when the flag is not supported
AX_CHECK_COMPILE_FLAG([-Wno-duplicate-decl-specifier],
[SKELETONS_CFLAGS="$SKELETONS_CFLAGS -Wno-duplicate-decl-specifier"])
AC_SUBST(SKELETONS_CFLAGS)
Expand Down
1 change: 1 addition & 0 deletions libasn1fix/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@CODE_COVERAGE_RULES@

AM_CFLAGS = @ADD_CFLAGS@
AM_CPPFLAGS = \
Expand Down
2 changes: 2 additions & 0 deletions skeletons/GeneralizedTime.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
*/
#define _POSIX_PTHREAD_SEMANTICS /* for Sun */
#define _REENTRANT /* for Sun */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE /* for timegm(3) */
#endif
#include <asn_internal.h>
#include <GeneralizedTime.h>

Expand Down
2 changes: 2 additions & 0 deletions skeletons/REAL.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
* Redistribution and modifications are permitted subject to BSD license.
*/
#define _ISOC99_SOURCE /* For ilogb() and quiet NAN */
#ifndef _BSD_SOURCE
#define _BSD_SOURCE /* To reintroduce finite(3) */
#endif
#if defined(__alpha)
#include <sys/resource.h> /* For INFINITY */
#endif
Expand Down
2 changes: 2 additions & 0 deletions skeletons/tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@CODE_COVERAGE_RULES@

check_PROGRAMS = \
check-ber_tlv_tag \
check-length \
Expand Down

4 comments on commit c568d29

@johanhedin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mouse07410 any reason why this merge contain duplicate

+@CODE_COVERAGE_RULES@
+CODE_COVERAGE_IGNORE_PATTERN="tests/*" "lex.yy.c" "y.tab.c" "asn1p_l.l" "asn1p_y.y"

in Makefile.am when the original PR does not?

I get a warning when building from your branch:

Makefile.am:8: warning: CODE_COVERAGE_IGNORE_PATTERN multiply defined in condition TRUE ...
Makefile.am:5: ... 'CODE_COVERAGE_IGNORE_PATTERN' previously defined here

@mouse07410
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding this problem, and my apologies for letting it go unnoticed. Fixed in the master.

@johanhedin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick response, and many thanks for the work you are doing in helping #99 and #125 mature! APER and Information Object Classes are much needed!

While at your merge of #105, I noted that you choose not to add the file m4/ax_code_coverage.m4. Due to this, I'm not able to build your branch on my old Fedora 20 without modifications (adding the file back to the m4 dir).

The autoconf-archive package on Fedora 20 does not contain ax_code_coverage.m4 (but it does in later releases) so installing autoconf-archive does not get me anywhere.

I guess you removed the file since it is available on your platforms and the bundled one clashes with the system one!? Is there any way to handle both situations? Perhaps some conditional checking if the functions that ax_code_coverage.m4 introduces are present before trying to use them?

@mouse07410
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, please stop commenting here - it's a gross inconvenience for me to track this line. As one possible alternative, feel free to post an issue to my fork. Or to the #105 PR in the original repo. But not at an individual commit.

Second - I see that the original repo has the entire m4/ directory ignored (i.e., not source-controlled by the Github). The author probably had good reasons to do so. While I can "un-ignore" that directory and its files - I don't have a good feel for the consequences, and therefore am reluctant do to so.

The file ax_code_coverage.m4 is easy to locate, for example, here: https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html

Please sign in to comment.