MCPcopy Index your code
hub / github.com/GJDuck/e9patch / test_fread

Function test_fread

test/regtest/patch.cpp:726–756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

724}
725
726void test_fread(void)
727{
728 size_t size = 2 * BUFSIZ;
729 FILE *stream = fopen("test.tmp", "w");
730 for (size_t i = 0; i < size; i++)
731 fputc(0xFF, stream);
732 fclose(stream);
733 stream = fopen("test.tmp", "r");
734 uint8_t *buf = (uint8_t *)malloc(size);
735 memset(buf, 0xAA, size);
736 for (size_t i = 0; i < size; )
737 {
738 size_t r = fread(buf+i, 1, size-i, stream);
739 if (r == 0)
740 {
741 fprintf(stderr, "fread() failed\n");
742 abort();
743 }
744 i += r;
745 }
746 fclose(stream);
747 unlink("test.tmp");
748 for (size_t i = 0; i < size; i++)
749 {
750 if (buf[i] != 0xFF)
751 {
752 fprintf(stderr, "buf[%zu] = 0x%.2X?\n", i, buf[i]);
753 break;
754 }
755 }
756}
757
758void test_stdio(intptr_t arg)
759{

Callers

nothing calls this directly

Calls 9

fopenFunction · 0.85
fputcFunction · 0.85
fcloseFunction · 0.85
mallocFunction · 0.85
memsetFunction · 0.85
freadFunction · 0.85
abortFunction · 0.85
unlinkFunction · 0.85
fprintfFunction · 0.50

Tested by

no test coverage detected