# HG changeset patch # User Bruno Haible # Date 1525605066 -7200 # Node ID fd1939030d58fd9c7ec8cbf38f70222a43981908 # Parent a3877e074b79cbfe910d4273724e758977dc48a9 crypto/{md5,sha1,sha256,sha512} tests: Enhance test. * tests/test-digest.h (test_digest_on_files): Add a test with a FILE stream that is not positioned at the beginning. diff -r a3877e074b79 -r fd1939030d58 ChangeLog --- a/ChangeLog Sun May 06 12:23:55 2018 +0200 +++ b/ChangeLog Sun May 06 13:11:06 2018 +0200 @@ -1,3 +1,9 @@ +2018-05-06 Bruno Haible + + crypto/{md5,sha1,sha256,sha512} tests: Enhance test. + * tests/test-digest.h (test_digest_on_files): Add a test with a FILE + stream that is not positioned at the beginning. + 2018-05-06 Bruno Haible af_alg: Add configure option to enable/disable use of Linux crypto API. diff -r a3877e074b79 -r fd1939030d58 tests/test-digest.h --- a/tests/test-digest.h Sun May 06 12:23:55 2018 +0200 +++ b/tests/test-digest.h Sun May 06 13:11:06 2018 +0200 @@ -25,7 +25,7 @@ int pass; unlink (TESTFILE); - for (pass = 0; pass < 3; pass++) + for (pass = 0; pass < 4; pass++) { { FILE *fp = fopen (TESTFILE, "wb"); @@ -44,6 +44,10 @@ 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 3: /* Fill the large file (8 MiB). */ { unsigned int i; @@ -74,9 +78,9 @@ switch (pass) { - case 0: expected = expected_for_empty_file; break; - case 1: expected = expected_for_small_file; break; - case 2: expected = expected_for_large_file; break; + 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; default: abort (); } @@ -86,6 +90,20 @@ fprintf (stderr, "Could not open file %s.\n", TESTFILE); exit (1); } + switch (pass) + { + case 2: + { + char header[4]; + if (fread (header, 1, sizeof (header), fp) != sizeof (header)) + { + fprintf (stderr, "Could not read the header of %s.\n", + TESTFILE); + exit (1); + } + } + break; + } ret = streamfunc (fp, digest); if (ret) {