MCPcopy Create free account
hub / github.com/OpenPrinting/cups / random_tests

Function random_tests

cups/testfile.c:357–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355 */
356
357static int /* O - Status */
358random_tests(void)
359{
360 int status, /* Status of tests */
361 pass, /* Current pass */
362 count, /* Number of records read */
363 record, /* Current record */
364 num_records; /* Number of records */
365 off_t pos; /* Position in file */
366 ssize_t expected; /* Expected position in file */
367 cups_file_t *fp; /* File */
368 char buffer[512]; /* Data buffer */
369
370
371 /*
372 * Run 4 passes, each time appending to a data file and then reopening the
373 * file for reading to validate random records in the file.
374 */
375
376 for (status = 0, pass = 0; pass < 4; pass ++)
377 {
378 /*
379 * cupsFileOpen(append)
380 */
381
382 printf("\ncupsFileOpen(append %d): ", pass);
383
384 if ((fp = cupsFileOpen("testfile.dat", "a")) == NULL)
385 {
386 printf("FAIL (%s)\n", strerror(errno));
387 status ++;
388 break;
389 }
390 else
391 puts("PASS");
392
393 /*
394 * cupsFileTell()
395 */
396
397 expected = 256 * (ssize_t)sizeof(buffer) * pass;
398
399 fputs("cupsFileTell(): ", stdout);
400 if ((pos = cupsFileTell(fp)) != (off_t)expected)
401 {
402 printf("FAIL (" CUPS_LLFMT " instead of " CUPS_LLFMT ")\n",
403 CUPS_LLCAST pos, CUPS_LLCAST expected);
404 status ++;
405 break;
406 }
407 else
408 puts("PASS");
409
410 /*
411 * cupsFileWrite()
412 */
413
414 fputs("cupsFileWrite(256 512-byte records): ", stdout);

Callers 1

mainFunction · 0.85

Calls 6

cupsFileOpenFunction · 0.85
cupsFileTellFunction · 0.85
cupsFileWriteFunction · 0.85
cupsFileCloseFunction · 0.85
cupsFileSeekFunction · 0.85
cupsFileReadFunction · 0.85

Tested by

no test coverage detected