Commit b4326de2 authored by Lev Walkin's avatar Lev Walkin

diverging

parent 06230f79
......@@ -230,45 +230,23 @@ compare_with_data_out(const char *fname, char *buf, int size) {
char fbuf[1024];
size_t rd;
FILE *f;
char lastChar;
int mustfail, compare;
sprintf(outName, "../data-126/%s", fname);
strcpy(outName + strlen(outName) - 3, ".out");
fprintf(stderr, "Comparing PER output with [%s]\n", outName);
if(strstr(outName, "-06-P.out")) {
f = fopen(outName, "w");
fbuf[0] = 0x81;
fbuf[1] = 0x40;
fbuf[2] = 0x00;
fwrite(fbuf, 1, 3, f);
fclose(f);
}
if(strstr(outName, "-07-P.out")) {
f = fopen(outName, "w");
fbuf[0] = 0x81;
fbuf[1] = 0x40;
fbuf[2] = 0x40;
fwrite(fbuf, 1, 3, f);
fclose(f);
}
lastChar = outName[strlen(outName)-5];
mustfail = lastChar == 'P';
compare = lastChar != 'C';
if(strstr(outName, "-08-P.out")) {
f = fopen(outName, "w");
fbuf[0] = 0x81;
fbuf[1] = 0x40;
fbuf[2] = 0x80;
fwrite(fbuf, 1, 3, f);
fclose(f);
}
if(getenv("REGENERATE")) {
if(compare && getenv("REGENERATE")) {
f = fopen(outName, "w");
fwrite(buf, 1, size, f);
fclose(f);
} else {
int mustfail = outName[strlen(outName)-5] == 'P';
f = fopen(outName, "r");
assert(f);
rd = fread(fbuf, 1, sizeof(fbuf), f);
......@@ -279,9 +257,14 @@ compare_with_data_out(const char *fname, char *buf, int size) {
load_object_from(outName, fbuf, rd, AS_PER, mustfail);
if(mustfail) return;
assert(rd == (size_t)size);
assert(memcmp(fbuf, buf, rd) == 0);
fprintf(stderr, "XER->PER recoding .in->.out match.\n");
if(compare) {
assert(rd == (size_t)size);
assert(memcmp(fbuf, buf, rd) == 0);
fprintf(stderr, "XER->PER recoding .in->.out match.\n");
} else {
assert(rd != (size_t)size || memcmp(fbuf, buf, rd));
fprintf(stderr, "XER->PER recoding .in->.out diverge.\n");
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment