ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/radcompare.c
(Generate patch)

Comparing ray/src/util/radcompare.c (file contents):
Revision 2.3 by greg, Mon Oct 15 18:31:15 2018 UTC vs.
Revision 2.4 by greg, Mon Oct 15 21:47:52 2018 UTC

# Line 40 | Line 40 | const char     *file_type[] = {
40                          "ascii",
41                          COLRFMT,
42                          CIEFMT,
43 <                        "BINARY_float",
44 <                        "BINARY_double",
43 >                        "float",
44 >                        "double",
45                          "BSDF_RBFmesh",
46                          "Radiance_octree",
47                          "Radiance_tmesh",
# Line 85 | Line 85 | usage()
85   {
86          fputs("Usage: ", stderr);
87          fputs(progname, stderr);
88 <        fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] file1 file2\n",
88 >        fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n",
89                          stderr);
90          exit(1);
91   }
# Line 117 | Line 117 | real_check(double r1, double r2)
117          }
118          if (max_lim >= 0 && diff2 > max_lim*max_lim) {
119                  if (report != REP_QUIET)
120 <                        fprintf(stderr,
120 >                        printf(
121                          "%s: %sdifference between %.8g and %.8g exceeds epsilon\n",
122                                          progname,
123                                          (rel_min > 0) ? "relative " : "",
# Line 232 | Line 232 | setheadvar(char *val, void *p)
232                  if (!strcmp(key, hdr_ignkey[n]))
233                          return(0);
234          if (!(tep = lu_find(htp, key)))
235 <                return(-1);
235 >                return(-1);     /* memory allocation error */
236          if (!tep->key)
237                  tep->key = strcpy(malloc(kln+1), key);
238          if (tep->data)
# Line 248 | Line 248 | match_val(const LUENT *ep1, void *p2)
248          const LUENT     *ep2 = lu_find((LUTAB *)p2, ep1->key);
249          if (!ep2 || !ep2->data) {
250                  if (report != REP_QUIET)
251 <                        fprintf(stderr, "%s: Variable '%s' missing in '%s'\n",
251 >                        printf("%s: Variable '%s' missing in '%s'\n",
252                                          progname, ep1->key, f2name);
253                  return(-1);
254          }
255          if (!equiv_string((char *)ep1->data, (char *)ep2->data)) {
256 <                if (report != REP_QUIET)
257 <                        fprintf(stderr, "%s: Header variables '%s' have different values\n",
256 >                if (report != REP_QUIET) {
257 >                        printf("%s: Header variable '%s' has different values\n",
258                                          progname, ep1->key);
259 +                        if (report >= REP_VERBOSE) {
260 +                                printf("%s: %s=%s\n", f1name,
261 +                                                ep1->key, (char *)ep1->data);
262 +                                printf("%s: %s=%s\n", f2name,
263 +                                                ep2->key, (char *)ep2->data);
264 +                        }
265 +                }
266                  return(-1);
267          }
268          return(1);              /* good match */
# Line 268 | Line 275 | headers_match(LUTAB *hp1, LUTAB *hp2)
275          int     ne = lu_doall(hp1, match_val, hp2);
276          if (ne < 0)
277                  return(0);      /* something didn't match! */
278 <        ne = lu_doall(hp2, NULL, NULL) - ne;
279 <        if (ne) {
280 <                if (report != REP_QUIET)
274 <                        fprintf(stderr, "%s: '%s' has %d extra header variable(s)\n",
278 >                                /* non-fatal if second header has extra */
279 >        if (report >= REP_WARN && (ne = lu_doall(hp2, NULL, NULL) - ne))
280 >                printf("%s: '%s' has %d extra header setting(s)\n",
281                                          progname, f2name, ne);
276                return(0);
277        }
282          return(1);              /* good match */
283   }
284  
# Line 320 | Line 324 | identify_type(const char *name, FILE *fin, LUTAB *htp)
324                          goto badeof;
325                  adv_linecnt(htp);               /* for #?ID string */
326                  if (report >= REP_WARN && strncmp(sbuf, "RADIANCE", 8)) {
327 <                        fputs(name, stderr);
328 <                        fputs(": warning - unexpected header ID: ", stderr);
329 <                        fputs(sbuf, stderr);
327 >                        fputs(name, stdout);
328 >                        fputs(": warning - unexpected header ID: ", stdout);
329 >                        fputs(sbuf, stdout);
330                  }
331                  if (getheader(fin, setheadvar, htp) < 0) {
332                          fputs(name, stderr);
# Line 344 | Line 348 | identify_type(const char *name, FILE *fin, LUTAB *htp)
348          return(TYP_TEXT);
349   badeof:
350          if (report != REP_QUIET) {
351 <                fputs(name, stderr);
352 <                fputs(": Unexpected end-of-file\n", stderr);
351 >                fputs(name, stdout);
352 >                fputs(": Unexpected end-of-file\n", stdout);
353          }
354          return(-1);
355   }
# Line 358 | Line 362 | good_RMS()
362                  return(1);
363          if (diff2sum/(double)nsum > rms_lim*rms_lim) {
364                  if (report != REP_QUIET)
365 <                        fprintf(stderr,
365 >                        printf(
366          "%s: %sRMS difference between '%s' and '%s' of %.5g exceeds limit\n",
367                                          progname,
368                                          (rel_min > 0) ? "relative " : "",
# Line 367 | Line 371 | good_RMS()
371                  return(0);
372          }
373          if (report >= REP_VERBOSE)
374 <                fprintf(stderr,
371 <                        "%s: %sRMS difference of reals in '%s' and '%s' is %.5g\n",
374 >                printf("%s: %sRMS difference of reals in '%s' and '%s' is %.5g\n",
375                                  progname, (rel_min > 0) ? "relative " : "",
376                                  f1name, f2name, sqrt(diff2sum/(double)nsum));
377          return(1);
# Line 379 | Line 382 | static int
382   compare_binary()
383   {
384          if (report >= REP_VERBOSE) {
385 <                fputs(progname, stderr);
386 <                fputs(": comparing inputs as binary\n", stderr);
385 >                fputs(progname, stdout);
386 >                fputs(": comparing inputs as binary\n", stdout);
387          }
388          for ( ; ; ) {                           /* exact byte matching */
389                  int     c1 = getc(f1in);
# Line 389 | Line 392 | compare_binary()
392                          if (c2 == EOF)
393                                  return(1);      /* success! */
394                          if (report != REP_QUIET) {
395 <                                fputs(f1name, stderr);
396 <                                fputs(": Unexpected end-of-file\n", stderr);
395 >                                fputs(f1name, stdout);
396 >                                fputs(": Unexpected end-of-file\n", stdout);
397                          }
398                          return(0);
399                  }
400                  if (c2 == EOF) {
401                          if (report != REP_QUIET) {
402 <                                fputs(f2name, stderr);
403 <                                fputs(": Unexpected end-of-file\n", stderr);
402 >                                fputs(f2name, stdout);
403 >                                fputs(": Unexpected end-of-file\n", stdout);
404                          }
405                          return(0);
406                  }
# Line 406 | Line 409 | compare_binary()
409          }
410          if (report == REP_QUIET)
411                  return(0);
412 <        fprintf(stderr, "%s: binary files '%s' and '%s' differ at offset %ld|%ld\n",
412 >        printf("%s: binary files '%s' and '%s' differ at offset %ld|%ld\n",
413                          progname, f1name, f2name, ftell(f1in), ftell(f2in));
414          return(0);
415   }
# Line 418 | Line 421 | compare_text()
421          char    l1buf[4096], l2buf[4096];
422  
423          if (report >= REP_VERBOSE) {
424 <                fputs(progname, stderr);
425 <                fputs(": comparing inputs as ASCII text\n", stderr);
424 >                fputs(progname, stdout);
425 >                fputs(": comparing inputs as ASCII text\n", stdout);
426          }
427                                                  /* compare a line at a time */
428          while (fgets(l1buf, sizeof(l1buf), f1in)) {
# Line 433 | Line 436 | compare_text()
436                  }
437                  if (feof(f2in)) {
438                          if (report != REP_QUIET) {
439 <                                fputs(f2name, stderr);
440 <                                fputs(": Unexpected end-of-file\n", stderr);
439 >                                fputs(f2name, stdout);
440 >                                fputs(": Unexpected end-of-file\n", stdout);
441                          }
442                          return(0);
443                  }
444                                                  /* compare non-empty lines */
445                  if (!equiv_string(l1buf, l2buf)) {
446                          if (report != REP_QUIET) {
447 <                                fprintf(stderr, "%s: inputs '%s' and '%s' differ at line %d|%d\n",
447 >                                printf("%s: inputs '%s' and '%s' differ at line %d|%d\n",
448                                                  progname, f1name, f2name,
449                                                  lin1cnt, lin2cnt);
450                                  if (report >= REP_VERBOSE) {
451 <                                        fputs("------------- Mismatch -------------\n", stderr);
452 <                                        fprintf(stderr, "%s(%d):\t%s", f1name,
451 >                                        fputs("------------- Mismatch -------------\n", stdout);
452 >                                        printf("%s(%d):\t%s", f1name,
453                                                          lin1cnt, l1buf);
454 <                                        fprintf(stderr, "%s(%d):\t%s", f2name,
454 >                                        printf("%s(%d):\t%s", f2name,
455                                                          lin2cnt, l2buf);
456                                  }
457                          }
# Line 460 | Line 463 | compare_text()
463                  if (!*sskip2(l2buf,0))
464                          continue;
465                  if (report != REP_QUIET) {
466 <                        fputs(f1name, stderr);
467 <                        fputs(": Unexpected end-of-file\n", stderr);
466 >                        fputs(f1name, stdout);
467 >                        fputs(": Unexpected end-of-file\n", stdout);
468                  }
469                  return(0);
470          }
# Line 480 | Line 483 | compare_hdr()
483          fgetsresolu(&rs2, f2in);
484          if (rs1.rt != rs2.rt) {
485                  if (report != REP_QUIET)
486 <                        fprintf(stderr,
486 >                        printf(
487                          "%s: Images '%s' and '%s' have different pixel ordering\n",
488                                          progname, f1name, f2name);
489                  return(0);
490          }
491          if ((rs1.xr != rs2.xr) | (rs1.yr != rs2.yr)) {
492                  if (report != REP_QUIET)
493 <                        fprintf(stderr,
493 >                        printf(
494                          "%s: Images '%s' and '%s' are different sizes\n",
495                                          progname, f1name, f2name);
496                  return(0);
# Line 502 | Line 505 | compare_hdr()
505                  if ((freadscan(scan1, scanlen(&rs1), f1in) < 0) |
506                                  (freadscan(scan2, scanlen(&rs2), f2in) < 0)) {
507                          if (report != REP_QUIET)
508 <                                fprintf(stderr, "%s: Unexpected end-of-file\n",
508 >                                printf("%s: Unexpected end-of-file\n",
509                                                  progname);
510                          free(scan1);
511                          free(scan2);
# Line 517 | Line 520 | compare_hdr()
520                                                  colval(scan2[x],BLU)))
521                                  continue;
522                          if (report != REP_QUIET) {
523 <                                fprintf(stderr,
523 >                                printf(
524                                  "%s: pixels at scanline %d offset %d differ\n",
525                                          progname, y, x);
526                                  if (report >= REP_VERBOSE) {
527 <                                        fprintf(stderr, "%s: (R,G,B)=(%g,%g,%g)\n",
527 >                                        printf("%s: (R,G,B)=(%g,%g,%g)\n",
528                                                  f1name, colval(scan1[x],RED),
529                                                  colval(scan1[x],GRN),
530                                                  colval(scan1[x],BLU));
531 <                                        fprintf(stderr, "%s: (R,G,B)=(%g,%g,%g)\n",
531 >                                        printf("%s: (R,G,B)=(%g,%g,%g)\n",
532                                                  f2name, colval(scan2[x],RED),
533                                                  colval(scan2[x],GRN),
534                                                  colval(scan2[x],BLU));
# Line 559 | Line 562 | compare_float()
562                  if (real_check(f1, f2))
563                          continue;
564                  if (report != REP_QUIET)
565 <                        fprintf(stderr, "%s: %ld%s float values differ\n",
565 >                        printf("%s: %ld%s float values differ\n",
566                                          progname, nread, nsuffix[nread%10]);
567                  return(0);
568          }
# Line 567 | Line 570 | compare_float()
570                  return(good_RMS());             /* final check of RMS */
571   badeof:
572          if (report != REP_QUIET)
573 <                fprintf(stderr, "%s: Unexpected end-of-file\n", progname);
573 >                printf("%s: Unexpected end-of-file\n", progname);
574          return(0);
575   }
576  
# Line 585 | Line 588 | compare_double()
588                  if (real_check(f1, f2))
589                          continue;
590                  if (report != REP_QUIET)
591 <                        fprintf(stderr, "%s: %ld%s float values differ\n",
591 >                        printf("%s: %ld%s float values differ\n",
592                                          progname, nread, nsuffix[nread%10]);
593                  return(0);
594          }
# Line 593 | Line 596 | compare_double()
596                  return(good_RMS());             /* final check of RMS */
597   badeof:
598          if (report != REP_QUIET)
599 <                fprintf(stderr, "%s: Unexpected end-of-file\n", progname);
599 >                printf("%s: Unexpected end-of-file\n", progname);
600          return(0);
601   }
602  
# Line 647 | Line 650 | main(int argc, char *argv[])
650  
651          if (!strcmp(f1name, f2name)) {          /* inputs are same? */
652                  if (report >= REP_WARN)
653 <                        fprintf(stderr, "%s: warning - identical inputs given\n",
653 >                        printf("%s: warning - identical inputs given\n",
654                                          progname);
655                  return(0);
656          }
# Line 671 | Line 674 | main(int argc, char *argv[])
674                  return(1);
675          if (typ1 != typ2) {
676                  if (report != REP_QUIET)
677 <                        fprintf(stderr, "%s: '%s' is %s and '%s' is %s\n",
677 >                        printf("%s: '%s' is %s and '%s' is %s\n",
678                                          progname, f1name, file_type[typ1],
679                                          f2name, file_type[typ2]);
680                  return(1);
# Line 682 | Line 685 | main(int argc, char *argv[])
685          lu_done(&hdr1); lu_done(&hdr2);
686          if (!ign_header & (report >= REP_WARN)) {
687                  if (typ1 == TYP_UNKNOWN)
688 <                        fprintf(stderr, "%s: warning - unrecognized format, comparing as binary\n",
688 >                        printf("%s: warning - unrecognized format, comparing as binary\n",
689                                          progname);
690                  if (lin1cnt != lin2cnt)
691 <                        fprintf(stderr, "%s: warning - headers are different lengths\n",
691 >                        printf("%s: warning - headers are different lengths\n",
692                                          progname);
693          }
694          if (report >= REP_VERBOSE)
695 <                fprintf(stderr, "%s: input file type is %s\n",
695 >                printf("%s: input file type is %s\n",
696                                  progname, file_type[typ1]);
697  
698          switch (typ1) {                         /* compare based on type */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines