more debug

This commit is contained in:
Lev Walkin 2017-10-20 23:09:45 -07:00
parent 1418d985cb
commit ba2c5727d0
1 changed files with 11 additions and 2 deletions

View File

@ -227,6 +227,13 @@ check_random_roundtrip(enum asn_transfer_syntax syntax, size_t max_random_value_
} }
assert(structure != 0); assert(structure != 0);
if(debug) {
fprintf(stderr, "Random structure %s:\n",
sizeof(ASN1_STR) > 60 ? "T" : ASN1_STR);
asn_fprint(stderr, &asn_DEF_T, structure);
xer_fprint(stderr, &asn_DEF_T, structure);
}
asn_enc_rval_t er; asn_enc_rval_t er;
for(;;) { for(;;) {
er = asn_encode_to_buffer( er = asn_encode_to_buffer(
@ -270,6 +277,8 @@ check_random_roundtrip(enum asn_transfer_syntax syntax, size_t max_random_value_
er.encoded, rval.consumed); er.encoded, rval.consumed);
fprintf(stderr, "Original random structure:\n"); fprintf(stderr, "Original random structure:\n");
asn_fprint(stderr, &asn_DEF_T, structure); asn_fprint(stderr, &asn_DEF_T, structure);
fprintf(stderr, "Partially decoded %s value:\n", ASN1_STR);
asn_fprint(stderr, &asn_DEF_T, decoded_structure);
assert((ssize_t)rval.consumed == er.encoded); assert((ssize_t)rval.consumed == er.encoded);
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
} }
@ -288,7 +297,7 @@ check_random_roundtrip(enum asn_transfer_syntax syntax, size_t max_random_value_
*/ */
int cmp = asn_DEF_T.op->compare_struct(&asn_DEF_T, structure, int cmp = asn_DEF_T.op->compare_struct(&asn_DEF_T, structure,
decoded_structure); decoded_structure);
if(cmp != 0) { if(cmp != 0 || debug) {
fprintf(stderr, "Random %s value:\n", ASN1_STR); fprintf(stderr, "Random %s value:\n", ASN1_STR);
asn_fprint(stderr, &asn_DEF_T, structure); asn_fprint(stderr, &asn_DEF_T, structure);
xer_fprint(stderr, &asn_DEF_T, structure); xer_fprint(stderr, &asn_DEF_T, structure);
@ -335,7 +344,7 @@ int main(int argc, char **argv) {
mode = MODE_CHECK_RANDOM_ROUNDTRIP; mode = MODE_CHECK_RANDOM_ROUNDTRIP;
break; break;
case 'd': case 'd':
debug = 1; debug++;
break; break;
case 'e': case 'e':
enabled_encodings |= 1 << lookup_syntax(optarg); enabled_encodings |= 1 << lookup_syntax(optarg);