+2018-05-06 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
af_alg: Add configure option to enable/disable use of Linux crypto API.
int pass;
unlink (TESTFILE);
- for (pass = 0; pass < 3; pass++)
+ for (pass = 0; pass < 4; pass++)
{
{
FILE *fp = fopen (TESTFILE, "wb");
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;
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 ();
}
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)
{