From d27c90a13edcc64e17c4dd64fd28702f2d58bc43 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 25 Jun 2018 01:02:39 +0200 Subject: [PATCH] af_alg tests: Add another test. * tests/test-digest.h (test_digest_on_files): Also check a large file with a skipped header. * tests/test-md5.c: Include macros.h. * tests/test-sha1.c: Likewise. * tests/test-sha256.c: Likewise. * tests/test-sha512.c: Likewise. * modules/crypto/md5-tests (Files): Add tests/macros.h. * modules/crypto/sha1-tests (Files): Likewise. * modules/crypto/sha256-tests (Files): Likewise. * modules/crypto/sha512-tests (Files): Likewise. --- ChangeLog | 14 ++++++++++++++ modules/crypto/md5-tests | 1 + modules/crypto/sha1-tests | 1 + modules/crypto/sha256-tests | 1 + modules/crypto/sha512-tests | 1 + tests/test-digest.h | 17 +++++++++++------ tests/test-md5.c | 2 ++ tests/test-sha1.c | 2 ++ tests/test-sha256.c | 2 ++ tests/test-sha512.c | 2 ++ 10 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c1d3310b7..9db47aa0a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2018-06-24 Bruno Haible + + af_alg tests: Add another test. + * tests/test-digest.h (test_digest_on_files): Also check a large file + with a skipped header. + * tests/test-md5.c: Include macros.h. + * tests/test-sha1.c: Likewise. + * tests/test-sha256.c: Likewise. + * tests/test-sha512.c: Likewise. + * modules/crypto/md5-tests (Files): Add tests/macros.h. + * modules/crypto/sha1-tests (Files): Likewise. + * modules/crypto/sha256-tests (Files): Likewise. + * modules/crypto/sha512-tests (Files): Likewise. + 2018-06-24 Pádraig Brady maint: clarify comments about sticky EOF diff --git a/modules/crypto/md5-tests b/modules/crypto/md5-tests index 6e9c162145..177bd41231 100644 --- a/modules/crypto/md5-tests +++ b/modules/crypto/md5-tests @@ -3,6 +3,7 @@ tests/test-md5.c tests/test-digest.h tests/bench-md5.c tests/bench-digest.h +tests/macros.h Depends-on: getrusage diff --git a/modules/crypto/sha1-tests b/modules/crypto/sha1-tests index c0f68cfb9d..b30d7e55f3 100644 --- a/modules/crypto/sha1-tests +++ b/modules/crypto/sha1-tests @@ -3,6 +3,7 @@ tests/test-sha1.c tests/test-digest.h tests/bench-sha1.c tests/bench-digest.h +tests/macros.h Depends-on: getrusage diff --git a/modules/crypto/sha256-tests b/modules/crypto/sha256-tests index eecbee86d7..693b1bc0ff 100644 --- a/modules/crypto/sha256-tests +++ b/modules/crypto/sha256-tests @@ -4,6 +4,7 @@ tests/test-digest.h tests/bench-sha224.c tests/bench-sha256.c tests/bench-digest.h +tests/macros.h Depends-on: getrusage diff --git a/modules/crypto/sha512-tests b/modules/crypto/sha512-tests index 18f5f1c1a3..d448031c4f 100644 --- a/modules/crypto/sha512-tests +++ b/modules/crypto/sha512-tests @@ -4,6 +4,7 @@ tests/test-digest.h tests/bench-sha384.c tests/bench-sha512.c tests/bench-digest.h +tests/macros.h Depends-on: getrusage diff --git a/tests/test-digest.h b/tests/test-digest.h index e10f571fa5..369ef9f6a8 100644 --- a/tests/test-digest.h +++ b/tests/test-digest.h @@ -25,7 +25,7 @@ test_digest_on_files (int (*streamfunc) (FILE *, void *), int pass; unlink (TESTFILE); - for (pass = 0; pass < 4; pass++) + for (pass = 0; pass < 5; pass++) { { FILE *fp = fopen (TESTFILE, "wb"); @@ -39,14 +39,18 @@ test_digest_on_files (int (*streamfunc) (FILE *, void *), case 0: /* Nothing to do for the empty file. */ break; + case 2: + /* Fill the small file, with some header that will be skipped. */ + fputs ("ABCD", fp); + FALLTHROUGH; case 1: /* Fill the small file. */ fputs ("The quick brown fox jumps over the lazy dog.\n", fp); break; - case 2: - /* Fill the small file, with some header that will be skipped. */ - fputs ("ABCDThe quick brown fox jumps over the lazy dog.\n", fp); - break; + case 4: + /* Fill the large file, with some header that will be skipped. */ + fputs ("ABCD", fp); + FALLTHROUGH; case 3: /* Fill the large file (8 MiB). */ { @@ -80,7 +84,7 @@ test_digest_on_files (int (*streamfunc) (FILE *, void *), { case 0: expected = expected_for_empty_file; break; case 1: case 2: expected = expected_for_small_file; break; - case 3: expected = expected_for_large_file; break; + case 3: case 4: expected = expected_for_large_file; break; default: abort (); } @@ -93,6 +97,7 @@ test_digest_on_files (int (*streamfunc) (FILE *, void *), switch (pass) { case 2: + case 4: { char header[4]; if (fread (header, 1, sizeof (header), fp) != sizeof (header)) diff --git a/tests/test-md5.c b/tests/test-md5.c index 71093436c1..9e27be35bd 100644 --- a/tests/test-md5.c +++ b/tests/test-md5.c @@ -26,6 +26,8 @@ #include #include +#include "macros.h" + #define TESTFILE "test-md5.data" #include "test-digest.h" diff --git a/tests/test-sha1.c b/tests/test-sha1.c index 9b6cde32b4..dc056ae92f 100644 --- a/tests/test-sha1.c +++ b/tests/test-sha1.c @@ -24,6 +24,8 @@ #include #include +#include "macros.h" + #define TESTFILE "test-sha1.data" #include "test-digest.h" diff --git a/tests/test-sha256.c b/tests/test-sha256.c index 0a2667ae41..bc820ada3e 100644 --- a/tests/test-sha256.c +++ b/tests/test-sha256.c @@ -23,6 +23,8 @@ #include #include +#include "macros.h" + #define TESTFILE "test-sha256.data" #include "test-digest.h" diff --git a/tests/test-sha512.c b/tests/test-sha512.c index 577feb172d..72ff90c9f3 100644 --- a/tests/test-sha512.c +++ b/tests/test-sha512.c @@ -23,6 +23,8 @@ #include #include +#include "macros.h" + #define TESTFILE "test-sha512.data" #include "test-digest.h" -- 2.39.5