MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / doTest

Function doTest

util/bmptest.c:85–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83
84
85static int doTest(const char *ext, int width, int align, int height, PF *pf,
86 enum BMPORN orientation)
87{
88 char filename[80], *md5sum, md5buf[65];
89 int pitch = BMPPAD(width * pf->size, align), loadWidth = 0, loadHeight = 0,
90 retval = 0;
91 unsigned char *buf = NULL;
92 char *md5ref = !stricmp(ext, "ppm") ? "c0c9f772b464d1896326883a5c79c545" :
93 "b03eec1eaaad38fed9cab5082bf37e52";
94
95 if((buf = (unsigned char *)malloc(pitch * height)) == NULL)
96 THROW("Could not allocate memory");
97 initBuf(buf, width, pitch, height, pf, orientation);
98
99 snprintf(filename, 80, "bmptest_%s_%d_%s.%s", pf->name, align,
100 orientation == BMPORN_TOPDOWN ? "td" : "bu", ext);
101 if(bmp_save(filename, buf, width, pitch, height, pf->id, orientation) == -1)
102 THROW(bmp_geterr());
103 md5sum = MD5File(filename, md5buf);
104 if(stricmp(md5sum, md5ref))
105 THROW_MD5(filename, md5sum, md5ref);
106
107 free(buf); buf = NULL;
108 if(bmp_load(filename, &buf, &loadWidth, align, &loadHeight, pf->id,
109 orientation) == -1)
110 THROW(bmp_geterr());
111 if(width != loadWidth || height != loadHeight)
112 {
113 printf("\n Image dimensions of %s are bogus\n", filename);
114 retval = -1; goto bailout;
115 }
116 if(!cmpBuf(buf, width, pitch, height, pf, orientation))
117 {
118 printf("\n Pixel data in %s is bogus\n", filename);
119 retval = -1; goto bailout;
120 }
121 unlink(filename);
122
123 bailout:
124 free(buf);
125 return retval;
126}
127
128
129int main(void)

Callers 1

mainFunction · 0.70

Calls 6

bmp_saveFunction · 0.85
bmp_geterrFunction · 0.85
MD5FileFunction · 0.85
bmp_loadFunction · 0.85
initBufFunction · 0.70
cmpBufFunction · 0.70

Tested by

no test coverage detected