aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-21 23:00:24 +0100
committerMattias Andrée <maandree@kth.se>2022-02-21 23:00:24 +0100
commitd127dd5cab51a869d6f6bb6c2a0860c458d3fecd (patch)
tree87d05afe908afa23afb3ede93ae2c1ec10672194
parentAdd tests (diff)
downloadblakesum-d127dd5cab51a869d6f6bb6c2a0860c458d3fecd.tar.gz
blakesum-d127dd5cab51a869d6f6bb6c2a0860c458d3fecd.tar.bz2
blakesum-d127dd5cab51a869d6f6bb6c2a0860c458d3fecd.tar.xz
Add coverage test
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--Makefile7
-rw-r--r--config-coverage-gcc.mk11
-rw-r--r--test.c8
3 files changed, 23 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index be1a6ca..2660901 100644
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@
CONFIGFILE = config.mk
include $(CONFIGFILE)
+
BIN =\
bsum\
b2sum
@@ -22,6 +23,11 @@ ALIASES =\
b384sum\
b512sum
+SRC =\
+ $(OBJ:.o=.c)\
+ $(HDR)\
+ test.c
+
# Known answers tests
KAT_FILES =\
kat/blake2b\
@@ -31,6 +37,7 @@ KAT_FILES =\
kat/blake2xb\
kat/blake2xs
+
all: $(BIN) test
$(OBJ): $(HDR)
diff --git a/config-coverage-gcc.mk b/config-coverage-gcc.mk
new file mode 100644
index 0000000..a505279
--- /dev/null
+++ b/config-coverage-gcc.mk
@@ -0,0 +1,11 @@
+CONFIGFILE_PROPER = config.mk
+include $(CONFIGFILE_PROPER)
+
+CC = $(CC_PREFIX)gcc -std=c99
+GCOV = gcov
+
+CFLAGS = -g -O0 -pedantic -fprofile-arcs -ftest-coverage
+LDFLAGS = -lblake -lgcov -fprofile-arcs
+
+coverage: check
+ $(GCOV) -pr $(SRC) 2>&1
diff --git a/test.c b/test.c
index 8f66b0e..3bd23ef 100644
--- a/test.c
+++ b/test.c
@@ -235,20 +235,22 @@ hashx(unsigned char **msg, size_t msglen, size_t *msgsize,
ERROR("Internal test error: %s\n", strerror(errno)); /* $covered$ */
if (!pid) {
+ /* $covered{$ */
close(input_pipe[1]);
close(output_pipe[0]);
if (input_pipe[0] != STDIN_FILENO) {
if (dup2(input_pipe[0], STDIN_FILENO) != STDIN_FILENO)
- ERROR("Internal test error: %s\n", strerror(errno)); /* $covered$ */
+ ERROR("Internal test error: %s\n", strerror(errno));
close(input_pipe[0]);
}
if (output_pipe[1] != STDOUT_FILENO) {
if (dup2(output_pipe[1], STDOUT_FILENO) != STDOUT_FILENO)
- ERROR("Internal test error: %s\n", strerror(errno)); /* $covered$ */
+ ERROR("Internal test error: %s\n", strerror(errno));
close(output_pipe[1]);
}
execv(argv[0], (void *const)argv);
- ERROR("Internal test error: %s\n", strerror(errno)); /* $covered$ */
+ ERROR("Internal test error: %s\n", strerror(errno));
+ /* $covered}$ */
} else {
close(input_pipe[0]);