Index | Thread | Search

From:
Kenjiro Nakayama <nakayamakenjiro@gmail.com>
Subject:
[patch] libressl: add more logs for asn1_time_compare_test
To:
tech@openbsd.org
Date:
Sun, 21 Jul 2024 19:10:01 +0900

Download raw body.

Thread
When one of the asn1_time_compare_test fails, it is difficult to
determine which test failed.

For example, currently it just outputs:

```
$ ./tests/asn1time 
  ... (snip)...
ASN1_TIME_compare tests...
140524144512Z vs. 150923032700Z: want -1, got 0
Time overflow tests...
```

Therefore, this patch adds some logs to make debugging easier.


diff --git src/regress/lib/libcrypto/asn1/asn1time.c src/regress/lib/libcrypto/asn1/asn1time.c
index b11a89230..8a5dac320 100644
--- src/regress/lib/libcrypto/asn1/asn1time.c
+++ src/regress/lib/libcrypto/asn1/asn1time.c
@@ -581,15 +581,15 @@ asn1_time_compare_families(const struct asn1_time_test *fam1, size_t fam1_size,
 			asn1_cmp = ASN1_TIME_compare(t1, t2);
 
 			if (time_cmp != asn1_cmp) {
-				fprintf(stderr, "%s vs. %s: want %d, got %d\n",
-				    att1->str, att2->str, time_cmp, asn1_cmp);
+				fprintf(stderr, "test %d (ASN1_TIME_compare) - %s vs. %s: want %d, got %d\n",
+				    i, att1->str, att2->str, time_cmp, asn1_cmp);
 				comparison_failure |= 1;
 			}
 
 			time_cmp = ASN1_TIME_cmp_time_t(t1, att2->time);
 			if (time_cmp != asn1_cmp) {
-				fprintf(stderr, "%s vs. %lld: want %d, got %d\n",
-				    att1->str, (long long)att2->time,
+				fprintf(stderr, "test %d (ASN1_TIME_cmp_time_t) - %s vs. %lld: want %d, got %d\n",
+				    i, att1->str, (long long)att2->time,
 				    asn1_cmp, time_cmp);
 				comparison_failure |= 1;
 			}
@@ -598,8 +598,8 @@ asn1_time_compare_families(const struct asn1_time_test *fam1, size_t fam1_size,
 			if (t1->type != V_ASN1_UTCTIME)
 				asn1_cmp = -2;
 			if (time_cmp != asn1_cmp) {
-				fprintf(stderr, "%s vs. %lld: want %d, got %d\n",
-				    att1->str, (long long)att2->time,
+				fprintf(stderr, "test %d (ASN1_UTCTIME_cmp_time_t) - %s vs. %lld: want %d, got %d\n",
+				    i, att1->str, (long long)att2->time,
 				    asn1_cmp, time_cmp);
 				comparison_failure |= 1;
 			}
@@ -624,9 +624,13 @@ asn1_time_compare_test(void)
 	size_t utc_size = N_UTCTIME_TESTS;
 	int failed = 0;
 
+	fprintf(stderr, "Time compare tests (gen, gen)...\n");
 	failed |= asn1_time_compare_families(gen, gen_size, gen, gen_size);
+	fprintf(stderr, "Time compare tests (gen, utc)...\n");
 	failed |= asn1_time_compare_families(gen, gen_size, utc, utc_size);
+	fprintf(stderr, "Time compare tests (utc, gen)...\n");
 	failed |= asn1_time_compare_families(utc, utc_size, gen, gen_size);
+	fprintf(stderr, "Time compare tests (utc, utc)...\n");
 	failed |= asn1_time_compare_families(utc, utc_size, utc, utc_size);
 
 	return failed;