|
30 | 30 | #include <stdlib.h> |
31 | 31 | #include <string.h> |
32 | 32 | #include <stdint.h> |
| 33 | +#include <errno.h> |
33 | 34 | #include <avro.h> |
34 | 35 |
|
35 | 36 | /* |
@@ -118,20 +119,21 @@ static int test_array_int64min(void) |
118 | 119 | return 1; |
119 | 120 | } |
120 | 121 |
|
121 | | - /* This MUST fail gracefully (return error) rather than looping |
122 | | - * unboundedly or triggering undefined behavior. */ |
| 122 | + /* This MUST fail with EINVAL rather than looping unboundedly or |
| 123 | + * triggering undefined behavior from negating INT64_MIN. */ |
123 | 124 | rc = avro_value_read(reader, &value); |
124 | | - if (rc == 0) { |
| 125 | + if (rc != EINVAL) { |
125 | 126 | fprintf(stderr, |
126 | | - "FAIL: INT64_MIN array block count was not rejected\n"); |
| 127 | + "FAIL: INT64_MIN array block count: expected EINVAL, " |
| 128 | + "got rc=%d (%s)\n", rc, avro_strerror()); |
127 | 129 | avro_reader_free(reader); |
128 | 130 | avro_value_decref(&value); |
129 | 131 | avro_value_iface_decref(iface); |
130 | 132 | avro_schema_decref(schema); |
131 | 133 | return 1; |
132 | 134 | } |
133 | 135 |
|
134 | | - printf("PASS: INT64_MIN array block count rejected: %s\n", |
| 136 | + printf("PASS: INT64_MIN array block count rejected with EINVAL: %s\n", |
135 | 137 | avro_strerror()); |
136 | 138 |
|
137 | 139 | avro_reader_free(reader); |
@@ -183,19 +185,21 @@ static int test_map_int64min(void) |
183 | 185 | return 1; |
184 | 186 | } |
185 | 187 |
|
186 | | - /* This MUST fail gracefully. */ |
| 188 | + /* This MUST fail with EINVAL rather than looping unboundedly or |
| 189 | + * triggering undefined behavior from negating INT64_MIN. */ |
187 | 190 | rc = avro_value_read(reader, &value); |
188 | | - if (rc == 0) { |
| 191 | + if (rc != EINVAL) { |
189 | 192 | fprintf(stderr, |
190 | | - "FAIL: INT64_MIN map block count was not rejected\n"); |
| 193 | + "FAIL: INT64_MIN map block count: expected EINVAL, " |
| 194 | + "got rc=%d (%s)\n", rc, avro_strerror()); |
191 | 195 | avro_reader_free(reader); |
192 | 196 | avro_value_decref(&value); |
193 | 197 | avro_value_iface_decref(iface); |
194 | 198 | avro_schema_decref(schema); |
195 | 199 | return 1; |
196 | 200 | } |
197 | 201 |
|
198 | | - printf("PASS: INT64_MIN map block count rejected: %s\n", |
| 202 | + printf("PASS: INT64_MIN map block count rejected with EINVAL: %s\n", |
199 | 203 | avro_strerror()); |
200 | 204 |
|
201 | 205 | avro_reader_free(reader); |
|
0 commit comments