diff options
| author | David M. Syzdek <david@syzdek.net> | 2022-03-08 17:22:25 -0900 |
|---|---|---|
| committer | David M. Syzdek <david@syzdek.net> | 2022-03-08 17:22:25 -0900 |
| commit | 8a9bbec87523b98af1da3ed43ed03436b0ef04b1 (patch) | |
| tree | cf1b7504bcaac44b5fd63a4ddb6fa95e4a523b32 /tests | |
| parent | cc98d826f549fb77b9f4a90afdea726cf15a39f3 (diff) | |
| download | tinyrad-8a9bbec87523b98af1da3ed43ed03436b0ef04b1.tar.gz tinyrad-8a9bbec87523b98af1da3ed43ed03436b0ef04b1.tar.bz2 tinyrad-8a9bbec87523b98af1da3ed43ed03436b0ef04b1.tar.xz tinyrad-8a9bbec87523b98af1da3ed43ed03436b0ef04b1.zip | |
tests: replacing our_error() with trutils_error()
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/common.c | 27 | ||||
| -rw-r--r-- | tests/common.h | 8 | ||||
| -rw-r--r-- | tests/dict-data.c | 10 | ||||
| -rw-r--r-- | tests/test-array-queue.c | 14 | ||||
| -rw-r--r-- | tests/test-array-sorted.c | 60 | ||||
| -rw-r--r-- | tests/test-array-stack.c | 14 | ||||
| -rw-r--r-- | tests/test-dict-attrs.c | 12 | ||||
| -rw-r--r-- | tests/test-dict-values.c | 22 | ||||
| -rw-r--r-- | tests/test-dict-vendors.c | 8 | ||||
| -rw-r--r-- | tests/test-oid-str.c | 18 | ||||
| -rw-r--r-- | tests/test-options.c | 108 | ||||
| -rw-r--r-- | tests/test-pckt-byte-order.c | 6 |
12 files changed, 136 insertions, 171 deletions
diff --git a/tests/common.c b/tests/common.c index b028a48..ba1b046 100644 --- a/tests/common.c +++ b/tests/common.c | |||
| @@ -486,33 +486,6 @@ int our_urldesc_test_good(const char * url, unsigned opts) | |||
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | 488 | ||
| 489 | //---------------// | ||
| 490 | // log functions // | ||
| 491 | //---------------// | ||
| 492 | #pragma mark log functions | ||
| 493 | |||
| 494 | int our_error(unsigned opts, char ** errs, const char * fmt, ...) | ||
| 495 | { | ||
| 496 | int pos; | ||
| 497 | va_list args; | ||
| 498 | |||
| 499 | if ( ((opts & TRUTILS_OPT_QUIET)) && ((opts & TRUTILS_OPT_VERBOSE)) ) | ||
| 500 | return(1); | ||
| 501 | |||
| 502 | if ((errs)) | ||
| 503 | for(pos = 0; ((errs[pos])); pos++) | ||
| 504 | fprintf(stderr, "%s: %s\n", program_name, errs[pos]); | ||
| 505 | |||
| 506 | fprintf(stderr, "%s: ", program_name); | ||
| 507 | va_start(args, fmt); | ||
| 508 | vfprintf(stderr, fmt, args); | ||
| 509 | va_end(args); | ||
| 510 | fprintf(stderr, "\n"); | ||
| 511 | |||
| 512 | return(1); | ||
| 513 | } | ||
| 514 | |||
| 515 | |||
| 516 | //----------------// | 489 | //----------------// |
| 517 | // misc functions // | 490 | // misc functions // |
| 518 | //----------------// | 491 | //----------------// |
diff --git a/tests/common.h b/tests/common.h index b792059..de71cf9 100644 --- a/tests/common.h +++ b/tests/common.h | |||
| @@ -94,14 +94,6 @@ int our_urldesc_test_bad(const char * url, unsigned opts); | |||
| 94 | int our_urldesc_test_good(const char * url, unsigned opts); | 94 | int our_urldesc_test_good(const char * url, unsigned opts); |
| 95 | 95 | ||
| 96 | 96 | ||
| 97 | //---------------// | ||
| 98 | // log functions // | ||
| 99 | //---------------// | ||
| 100 | #pragma mark log functions | ||
| 101 | |||
| 102 | int our_error(unsigned opts, char ** errs, const char * fmt, ...); | ||
| 103 | |||
| 104 | |||
| 105 | //----------------// | 97 | //----------------// |
| 106 | // misc functions // | 98 | // misc functions // |
| 107 | //----------------// | 99 | //----------------// |
diff --git a/tests/dict-data.c b/tests/dict-data.c index f42bdca..e3124c1 100644 --- a/tests/dict-data.c +++ b/tests/dict-data.c | |||
| @@ -319,7 +319,7 @@ our_dict_initialize( | |||
| 319 | // initialize dictionary | 319 | // initialize dictionary |
| 320 | if (tinyrad_dict_initialize(dictp, 0) != TRAD_SUCCESS) | 320 | if (tinyrad_dict_initialize(dictp, 0) != TRAD_SUCCESS) |
| 321 | { | 321 | { |
| 322 | our_error(opts, NULL, "out of virtual memory"); | 322 | trutils_error(opts, NULL, "out of virtual memory"); |
| 323 | return(1); | 323 | return(1); |
| 324 | }; | 324 | }; |
| 325 | 325 | ||
| @@ -329,7 +329,7 @@ our_dict_initialize( | |||
| 329 | trutils_verbose(opts, "loading default dictionary ..."); | 329 | trutils_verbose(opts, "loading default dictionary ..."); |
| 330 | if ((rc = tinyrad_dict_defaults(*dictp, &errs, 0)) != TRAD_SUCCESS) | 330 | if ((rc = tinyrad_dict_defaults(*dictp, &errs, 0)) != TRAD_SUCCESS) |
| 331 | { | 331 | { |
| 332 | our_error(opts, errs, "tinyrad_dict_defaults(): %s", tinyrad_strerror(rc)); | 332 | trutils_error(opts, errs, "tinyrad_dict_defaults(): %s", tinyrad_strerror(rc)); |
| 333 | tinyrad_strsfree(errs); | 333 | tinyrad_strsfree(errs); |
| 334 | tinyrad_free(*dictp); | 334 | tinyrad_free(*dictp); |
| 335 | return(1); | 335 | return(1); |
| @@ -340,7 +340,7 @@ our_dict_initialize( | |||
| 340 | trutils_verbose(opts, "adding test dictionary vendors ..."); | 340 | trutils_verbose(opts, "adding test dictionary vendors ..."); |
| 341 | if ((rc = tinyrad_dict_import(*dictp, test_dict_data_vendors, NULL, NULL, &errs, 0)) != TRAD_SUCCESS) | 341 | if ((rc = tinyrad_dict_import(*dictp, test_dict_data_vendors, NULL, NULL, &errs, 0)) != TRAD_SUCCESS) |
| 342 | { | 342 | { |
| 343 | our_error(opts, errs, "tinyrad_dict_import(vendors): %s", tinyrad_strerror(rc)); | 343 | trutils_error(opts, errs, "tinyrad_dict_import(vendors): %s", tinyrad_strerror(rc)); |
| 344 | tinyrad_strsfree(errs); | 344 | tinyrad_strsfree(errs); |
| 345 | tinyrad_free(*dictp); | 345 | tinyrad_free(*dictp); |
| 346 | return(1); | 346 | return(1); |
| @@ -350,7 +350,7 @@ our_dict_initialize( | |||
| 350 | trutils_verbose(opts, "adding test dictionary attributes ..."); | 350 | trutils_verbose(opts, "adding test dictionary attributes ..."); |
| 351 | if ((rc = tinyrad_dict_import(*dictp, NULL, test_dict_data_attrs, NULL, &errs, 0)) != TRAD_SUCCESS) | 351 | if ((rc = tinyrad_dict_import(*dictp, NULL, test_dict_data_attrs, NULL, &errs, 0)) != TRAD_SUCCESS) |
| 352 | { | 352 | { |
| 353 | our_error(opts, errs, "tinyrad_dict_import(attributes): %s", tinyrad_strerror(rc)); | 353 | trutils_error(opts, errs, "tinyrad_dict_import(attributes): %s", tinyrad_strerror(rc)); |
| 354 | tinyrad_strsfree(errs); | 354 | tinyrad_strsfree(errs); |
| 355 | tinyrad_free(*dictp); | 355 | tinyrad_free(*dictp); |
| 356 | return(1); | 356 | return(1); |
| @@ -360,7 +360,7 @@ our_dict_initialize( | |||
| 360 | trutils_verbose(opts, "adding test dictionary values ..."); | 360 | trutils_verbose(opts, "adding test dictionary values ..."); |
| 361 | if ((rc = tinyrad_dict_import(*dictp, NULL, NULL, test_dict_data_values, &errs, 0)) != TRAD_SUCCESS) | 361 | if ((rc = tinyrad_dict_import(*dictp, NULL, NULL, test_dict_data_values, &errs, 0)) != TRAD_SUCCESS) |
| 362 | { | 362 | { |
| 363 | our_error(opts, errs, "tinyrad_dict_import(values): %s", tinyrad_strerror(rc)); | 363 | trutils_error(opts, errs, "tinyrad_dict_import(values): %s", tinyrad_strerror(rc)); |
| 364 | tinyrad_strsfree(errs); | 364 | tinyrad_strsfree(errs); |
| 365 | tinyrad_free(*dictp); | 365 | tinyrad_free(*dictp); |
| 366 | return(1); | 366 | return(1); |
diff --git a/tests/test-array-queue.c b/tests/test-array-queue.c index e5b979f..25575ea 100644 --- a/tests/test-array-queue.c +++ b/tests/test-array-queue.c | |||
| @@ -222,7 +222,7 @@ int main( int argc, char * argv[] ) | |||
| 222 | { | 222 | { |
| 223 | for(; (pos > 0); pos--) | 223 | for(; (pos > 0); pos--) |
| 224 | free(data[pos-1].name); | 224 | free(data[pos-1].name); |
| 225 | return(our_error(opts, NULL, "out of virtual memory")); | 225 | return(trutils_error(opts, NULL, "out of virtual memory")); |
| 226 | }; | 226 | }; |
| 227 | }; | 227 | }; |
| 228 | 228 | ||
| @@ -242,26 +242,26 @@ int main( int argc, char * argv[] ) | |||
| 242 | if ((x % 4) == 3) | 242 | if ((x % 4) == 3) |
| 243 | { | 243 | { |
| 244 | if ((objp = tinyrad_array_dequeue(list, &list_len, sizeof(MyData *))) == NULL) | 244 | if ((objp = tinyrad_array_dequeue(list, &list_len, sizeof(MyData *))) == NULL) |
| 245 | return(our_error(opts, NULL, "unable to dequeue from queue")); | 245 | return(trutils_error(opts, NULL, "unable to dequeue from queue")); |
| 246 | if ((strcasecmp(src[x/4]->name, (*objp)->name))) | 246 | if ((strcasecmp(src[x/4]->name, (*objp)->name))) |
| 247 | return(our_error(opts, NULL, "str of dequeued object is incorrect")); | 247 | return(trutils_error(opts, NULL, "str of dequeued object is incorrect")); |
| 248 | }; | 248 | }; |
| 249 | 249 | ||
| 250 | // adds objects to queue | 250 | // adds objects to queue |
| 251 | if (tinyrad_array_enqueue((void **)&list, &list_len, sizeof(MyData *), &src[x], &realloc) == -1) | 251 | if (tinyrad_array_enqueue((void **)&list, &list_len, sizeof(MyData *), &src[x], &realloc) == -1) |
| 252 | return(our_error(opts, NULL, "failed to enqueue object to queue")); | 252 | return(trutils_error(opts, NULL, "failed to enqueue object to queue")); |
| 253 | }; | 253 | }; |
| 254 | 254 | ||
| 255 | 255 | ||
| 256 | // loop through queue and verify data | 256 | // loop through queue and verify data |
| 257 | trutils_verbose(opts, "verifing queue ..."); | 257 | trutils_verbose(opts, "verifing queue ..."); |
| 258 | if (list_len != ((MY_LIST_LEN / 4) * 3)) | 258 | if (list_len != ((MY_LIST_LEN / 4) * 3)) |
| 259 | return(our_error(opts, NULL, "queue length is incorrect")); | 259 | return(trutils_error(opts, NULL, "queue length is incorrect")); |
| 260 | delta = MY_LIST_LEN - list_len; | 260 | delta = MY_LIST_LEN - list_len; |
| 261 | for(x = delta; (x < MY_LIST_LEN); x++) | 261 | for(x = delta; (x < MY_LIST_LEN); x++) |
| 262 | { | 262 | { |
| 263 | if ((strcmp(src[x]->name, list[list_len-x+delta-1]->name))) | 263 | if ((strcmp(src[x]->name, list[list_len-x+delta-1]->name))) |
| 264 | return(our_error(opts, NULL, "queue data does not match test data")); | 264 | return(trutils_error(opts, NULL, "queue data does not match test data")); |
| 265 | }; | 265 | }; |
| 266 | 266 | ||
| 267 | 267 | ||
| @@ -269,7 +269,7 @@ int main( int argc, char * argv[] ) | |||
| 269 | trutils_verbose(opts, "dequeueing from queue ..."); | 269 | trutils_verbose(opts, "dequeueing from queue ..."); |
| 270 | while (list_len > 0) | 270 | while (list_len > 0) |
| 271 | if (tinyrad_array_dequeue(list, &list_len, sizeof(MyData *)) == NULL) | 271 | if (tinyrad_array_dequeue(list, &list_len, sizeof(MyData *)) == NULL) |
| 272 | return(our_error(opts, NULL, "unable to dequeue from queue")); | 272 | return(trutils_error(opts, NULL, "unable to dequeue from queue")); |
| 273 | 273 | ||
| 274 | return(0); | 274 | return(0); |
| 275 | } | 275 | } |
diff --git a/tests/test-array-sorted.c b/tests/test-array-sorted.c index 8901c8b..4b51eaa 100644 --- a/tests/test-array-sorted.c +++ b/tests/test-array-sorted.c | |||
| @@ -292,7 +292,7 @@ int main( int argc, char * argv[] ) | |||
| 292 | { | 292 | { |
| 293 | for(; (pos > 0); pos--) | 293 | for(; (pos > 0); pos--) |
| 294 | free(data[pos-1].name); | 294 | free(data[pos-1].name); |
| 295 | return(our_error(opts, NULL, "out of virtual memory")); | 295 | return(trutils_error(opts, NULL, "out of virtual memory")); |
| 296 | }; | 296 | }; |
| 297 | }; | 297 | }; |
| 298 | 298 | ||
| @@ -335,7 +335,7 @@ int main( int argc, char * argv[] ) | |||
| 335 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) | 335 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) |
| 336 | return(1); | 336 | return(1); |
| 337 | if ((list_len)) | 337 | if ((list_len)) |
| 338 | return(our_error(opts, NULL, "list still has elements")); | 338 | return(trutils_error(opts, NULL, "list still has elements")); |
| 339 | free(list); | 339 | free(list); |
| 340 | 340 | ||
| 341 | 341 | ||
| @@ -350,7 +350,7 @@ int main( int argc, char * argv[] ) | |||
| 350 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) | 350 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) |
| 351 | return(1); | 351 | return(1); |
| 352 | if ((list_len)) | 352 | if ((list_len)) |
| 353 | return(our_error(opts, NULL, "list still has elements")); | 353 | return(trutils_error(opts, NULL, "list still has elements")); |
| 354 | free(list); | 354 | free(list); |
| 355 | 355 | ||
| 356 | 356 | ||
| @@ -373,7 +373,7 @@ int main( int argc, char * argv[] ) | |||
| 373 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) | 373 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) |
| 374 | return(1); | 374 | return(1); |
| 375 | if ((list_len)) | 375 | if ((list_len)) |
| 376 | return(our_error(opts, NULL, "list still has elements")); | 376 | return(trutils_error(opts, NULL, "list still has elements")); |
| 377 | free(list); | 377 | free(list); |
| 378 | 378 | ||
| 379 | 379 | ||
| @@ -396,7 +396,7 @@ int main( int argc, char * argv[] ) | |||
| 396 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) | 396 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) |
| 397 | return(1); | 397 | return(1); |
| 398 | if ((list_len)) | 398 | if ((list_len)) |
| 399 | return(our_error(opts, NULL, "list still has elements")); | 399 | return(trutils_error(opts, NULL, "list still has elements")); |
| 400 | free(list); | 400 | free(list); |
| 401 | 401 | ||
| 402 | 402 | ||
| @@ -419,7 +419,7 @@ int main( int argc, char * argv[] ) | |||
| 419 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) | 419 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) |
| 420 | return(1); | 420 | return(1); |
| 421 | if ((list_len)) | 421 | if ((list_len)) |
| 422 | return(our_error(opts, NULL, "list still has elements")); | 422 | return(trutils_error(opts, NULL, "list still has elements")); |
| 423 | free(list); | 423 | free(list); |
| 424 | 424 | ||
| 425 | 425 | ||
| @@ -447,7 +447,7 @@ int main( int argc, char * argv[] ) | |||
| 447 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) | 447 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) |
| 448 | return(1); | 448 | return(1); |
| 449 | if ((list_len)) | 449 | if ((list_len)) |
| 450 | return(our_error(opts, NULL, "list still has elements")); | 450 | return(trutils_error(opts, NULL, "list still has elements")); |
| 451 | free(list); | 451 | free(list); |
| 452 | 452 | ||
| 453 | 453 | ||
| @@ -470,7 +470,7 @@ int main( int argc, char * argv[] ) | |||
| 470 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) | 470 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) |
| 471 | return(1); | 471 | return(1); |
| 472 | if ((list_len)) | 472 | if ((list_len)) |
| 473 | return(our_error(opts, NULL, "list still has elements")); | 473 | return(trutils_error(opts, NULL, "list still has elements")); |
| 474 | free(list); | 474 | free(list); |
| 475 | 475 | ||
| 476 | 476 | ||
| @@ -493,7 +493,7 @@ int main( int argc, char * argv[] ) | |||
| 493 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) | 493 | if ((my_test_remove(opts, list, &list_len, src, test, MY_LIST_LEN, merge))) |
| 494 | return(1); | 494 | return(1); |
| 495 | if ((list_len)) | 495 | if ((list_len)) |
| 496 | return(our_error(opts, NULL, "list still has elements")); | 496 | return(trutils_error(opts, NULL, "list still has elements")); |
| 497 | free(list); | 497 | free(list); |
| 498 | 498 | ||
| 499 | return(0); | 499 | return(0); |
| @@ -616,7 +616,7 @@ my_test_insert( | |||
| 616 | case TINYRAD_ARRAY_REPLACE: action_name = "REPLACE"; break; | 616 | case TINYRAD_ARRAY_REPLACE: action_name = "REPLACE"; break; |
| 617 | case 0: action_name = "DEFAULT"; break; | 617 | case 0: action_name = "DEFAULT"; break; |
| 618 | default: | 618 | default: |
| 619 | return(our_error(opts, NULL, "unknown insert action")); | 619 | return(trutils_error(opts, NULL, "unknown insert action")); |
| 620 | }; | 620 | }; |
| 621 | switch(mergeopt) | 621 | switch(mergeopt) |
| 622 | { | 622 | { |
| @@ -625,19 +625,19 @@ my_test_insert( | |||
| 625 | case TINYRAD_ARRAY_ANYDUP: merge_type = "ANY"; break; | 625 | case TINYRAD_ARRAY_ANYDUP: merge_type = "ANY"; break; |
| 626 | case 0: merge_type = "DEFAULT"; break; | 626 | case 0: merge_type = "DEFAULT"; break; |
| 627 | default: | 627 | default: |
| 628 | return(our_error(opts, NULL, "unknown dup action")); | 628 | return(trutils_error(opts, NULL, "unknown dup action")); |
| 629 | }; | 629 | }; |
| 630 | 630 | ||
| 631 | trutils_verbose(opts, "testing tinyrad_array_add( %7s, %9s, %s ) [%s] ...", action_name, merge_type, compar_name, (((iteration)) ? "duplicate" : "unique")); | 631 | trutils_verbose(opts, "testing tinyrad_array_add( %7s, %9s, %s ) [%s] ...", action_name, merge_type, compar_name, (((iteration)) ? "duplicate" : "unique")); |
| 632 | for(x = 0; (x < dat_len); x++) | 632 | for(x = 0; (x < dat_len); x++) |
| 633 | { | 633 | { |
| 634 | if (tinyrad_array_add((void **)listp, list_lenp, sizeof(MyData *), &src[x], arrayopt, compar, NULL, &realloc) == -1) | 634 | if (tinyrad_array_add((void **)listp, list_lenp, sizeof(MyData *), &src[x], arrayopt, compar, NULL, &realloc) == -1) |
| 635 | return(our_error(opts, NULL, "tinyrad_array_add(%s): returned error", action_name)); | 635 | return(trutils_error(opts, NULL, "tinyrad_array_add(%s): returned error", action_name)); |
| 636 | len = (iteration*dat_len) + x + 1; | 636 | len = (iteration*dat_len) + x + 1; |
| 637 | if ( ((iteration)) && (!(arrayopt & TINYRAD_ARRAY_MERGE)) ) | 637 | if ( ((iteration)) && (!(arrayopt & TINYRAD_ARRAY_MERGE)) ) |
| 638 | len = dat_len; | 638 | len = dat_len; |
| 639 | if (*list_lenp != len) | 639 | if (*list_lenp != len) |
| 640 | return(our_error(opts, NULL, "tinyrad_array_add(%s): did not increment length", action_name)); | 640 | return(trutils_error(opts, NULL, "tinyrad_array_add(%s): did not increment length", action_name)); |
| 641 | }; | 641 | }; |
| 642 | 642 | ||
| 643 | list = *listp; | 643 | list = *listp; |
| @@ -651,19 +651,19 @@ my_test_insert( | |||
| 651 | { | 651 | { |
| 652 | pos = x/iteration; | 652 | pos = x/iteration; |
| 653 | if ((strcasecmp(test[pos]->name, list[x]->name))) | 653 | if ((strcasecmp(test[pos]->name, list[x]->name))) |
| 654 | return(our_error(opts, NULL, "tinyrad_array_add(%s): misordered the list", action_name)); | 654 | return(trutils_error(opts, NULL, "tinyrad_array_add(%s): misordered the list", action_name)); |
| 655 | switch(mergeopt) | 655 | switch(mergeopt) |
| 656 | { | 656 | { |
| 657 | case TINYRAD_ARRAY_LASTDUP: | 657 | case TINYRAD_ARRAY_LASTDUP: |
| 658 | if ( (x < ((dat_len*iteration)-1)) && ((x % iteration) == (iteration-1)) ) | 658 | if ( (x < ((dat_len*iteration)-1)) && ((x % iteration) == (iteration-1)) ) |
| 659 | if (!(strcasecmp(list[x]->name, list[x+1]->name))) | 659 | if (!(strcasecmp(list[x]->name, list[x+1]->name))) |
| 660 | return(our_error(opts, NULL, "tinyrad_array_add(%s): first match not returned", action_name)); | 660 | return(trutils_error(opts, NULL, "tinyrad_array_add(%s): first match not returned", action_name)); |
| 661 | break; | 661 | break; |
| 662 | 662 | ||
| 663 | case TINYRAD_ARRAY_FIRSTDUP: | 663 | case TINYRAD_ARRAY_FIRSTDUP: |
| 664 | if ( (x > 0) && (!(x % iteration)) ) | 664 | if ( (x > 0) && (!(x % iteration)) ) |
| 665 | if (!(strcasecmp(list[x]->name, list[x-1]->name))) | 665 | if (!(strcasecmp(list[x]->name, list[x-1]->name))) |
| 666 | return(our_error(opts, NULL, "tinyrad_array_add(%s): first match not returned", action_name)); | 666 | return(trutils_error(opts, NULL, "tinyrad_array_add(%s): first match not returned", action_name)); |
| 667 | break; | 667 | break; |
| 668 | 668 | ||
| 669 | case TINYRAD_ARRAY_ANYDUP: | 669 | case TINYRAD_ARRAY_ANYDUP: |
| @@ -712,7 +712,7 @@ my_test_remove( | |||
| 712 | case TINYRAD_ARRAY_REPLACE: action_name = "REPLACE"; break; | 712 | case TINYRAD_ARRAY_REPLACE: action_name = "REPLACE"; break; |
| 713 | case 0: action_name = "DEFAULT"; break; | 713 | case 0: action_name = "DEFAULT"; break; |
| 714 | default: | 714 | default: |
| 715 | return(our_error(opts, NULL, "unknown insert action")); | 715 | return(trutils_error(opts, NULL, "unknown insert action")); |
| 716 | }; | 716 | }; |
| 717 | switch(mergeopt) | 717 | switch(mergeopt) |
| 718 | { | 718 | { |
| @@ -721,19 +721,19 @@ my_test_remove( | |||
| 721 | case TINYRAD_ARRAY_ANYDUP: merge_type = "ANY"; break; | 721 | case TINYRAD_ARRAY_ANYDUP: merge_type = "ANY"; break; |
| 722 | case 0: merge_type = "DEFAULT"; break; | 722 | case 0: merge_type = "DEFAULT"; break; |
| 723 | default: | 723 | default: |
| 724 | return(our_error(opts, NULL, "unknown dup action")); | 724 | return(trutils_error(opts, NULL, "unknown dup action")); |
| 725 | }; | 725 | }; |
| 726 | 726 | ||
| 727 | trutils_verbose(opts, "testing tinyrad_array_remove( %7s, %9s, %s ) [%s] ...", action_name, merge_type, compar_name, (((iteration)) ? "duplicate" : "unique")); | 727 | trutils_verbose(opts, "testing tinyrad_array_remove( %7s, %9s, %s ) [%s] ...", action_name, merge_type, compar_name, (((iteration)) ? "duplicate" : "unique")); |
| 728 | for(x = 0; (x < dat_len); x++) | 728 | for(x = 0; (x < dat_len); x++) |
| 729 | { | 729 | { |
| 730 | if (tinyrad_array_remove(list, list_lenp, sizeof(MyData *), &src[x], arrayopt, compar, NULL) == -1) | 730 | if (tinyrad_array_remove(list, list_lenp, sizeof(MyData *), &src[x], arrayopt, compar, NULL) == -1) |
| 731 | return(our_error(opts, NULL, "tinyrad_array_remove(%s): returned error", action_name)); | 731 | return(trutils_error(opts, NULL, "tinyrad_array_remove(%s): returned error", action_name)); |
| 732 | len = ((iteration+1)*dat_len) - x - 1; | 732 | len = ((iteration+1)*dat_len) - x - 1; |
| 733 | if ( ((iteration)) && (!(arrayopt & TINYRAD_ARRAY_MERGE)) ) | 733 | if ( ((iteration)) && (!(arrayopt & TINYRAD_ARRAY_MERGE)) ) |
| 734 | len = dat_len; | 734 | len = dat_len; |
| 735 | if (*list_lenp != len) | 735 | if (*list_lenp != len) |
| 736 | return(our_error(opts, NULL, "tinyrad_array_remove(%s): did not decrement length", action_name)); | 736 | return(trutils_error(opts, NULL, "tinyrad_array_remove(%s): did not decrement length", action_name)); |
| 737 | }; | 737 | }; |
| 738 | 738 | ||
| 739 | if (!(arrayopt & TINYRAD_ARRAY_MERGE)) | 739 | if (!(arrayopt & TINYRAD_ARRAY_MERGE)) |
| @@ -744,19 +744,19 @@ my_test_remove( | |||
| 744 | { | 744 | { |
| 745 | pos = x/iteration; | 745 | pos = x/iteration; |
| 746 | if ((strcasecmp(test[pos]->name, list[x]->name))) | 746 | if ((strcasecmp(test[pos]->name, list[x]->name))) |
| 747 | return(our_error(opts, NULL, "tinyrad_array_remove(%s): misordered the list", action_name)); | 747 | return(trutils_error(opts, NULL, "tinyrad_array_remove(%s): misordered the list", action_name)); |
| 748 | switch(mergeopt) | 748 | switch(mergeopt) |
| 749 | { | 749 | { |
| 750 | case TINYRAD_ARRAY_LASTDUP: | 750 | case TINYRAD_ARRAY_LASTDUP: |
| 751 | if ( (x < ((dat_len*iteration)-1)) && ((x % iteration) == (iteration-1)) ) | 751 | if ( (x < ((dat_len*iteration)-1)) && ((x % iteration) == (iteration-1)) ) |
| 752 | if (!(strcasecmp(list[x]->name, list[x+1]->name))) | 752 | if (!(strcasecmp(list[x]->name, list[x+1]->name))) |
| 753 | return(our_error(opts, NULL, "tinyrad_array_remove(%s): first match not returned", action_name)); | 753 | return(trutils_error(opts, NULL, "tinyrad_array_remove(%s): first match not returned", action_name)); |
| 754 | break; | 754 | break; |
| 755 | 755 | ||
| 756 | case TINYRAD_ARRAY_FIRSTDUP: | 756 | case TINYRAD_ARRAY_FIRSTDUP: |
| 757 | if ( (x > 0) && (!(x % iteration)) ) | 757 | if ( (x > 0) && (!(x % iteration)) ) |
| 758 | if (!(strcasecmp(list[x]->name, list[x-1]->name))) | 758 | if (!(strcasecmp(list[x]->name, list[x-1]->name))) |
| 759 | return(our_error(opts, NULL, "tinyrad_array_remove(%s): first match not returned", action_name)); | 759 | return(trutils_error(opts, NULL, "tinyrad_array_remove(%s): first match not returned", action_name)); |
| 760 | break; | 760 | break; |
| 761 | 761 | ||
| 762 | case TINYRAD_ARRAY_ANYDUP: | 762 | case TINYRAD_ARRAY_ANYDUP: |
| @@ -799,12 +799,12 @@ my_test_search( | |||
| 799 | case MY_KEY_NAME: ptr = list[y]->name; break; | 799 | case MY_KEY_NAME: ptr = list[y]->name; break; |
| 800 | case MY_KEY_VALUE: ptr = &list[y]->value; break; | 800 | case MY_KEY_VALUE: ptr = &list[y]->value; break; |
| 801 | default: | 801 | default: |
| 802 | return(our_error(opts, NULL, "unknown key")); | 802 | return(trutils_error(opts, NULL, "unknown key")); |
| 803 | }; | 803 | }; |
| 804 | if ((idx = tinyrad_array_search(list, x, sizeof(MyData *), ptr, TINYRAD_ARRAY_FIRSTDUP, NULL, compar)) == -1) | 804 | if ((idx = tinyrad_array_search(list, x, sizeof(MyData *), ptr, TINYRAD_ARRAY_FIRSTDUP, NULL, compar)) == -1) |
| 805 | return(our_error(opts, NULL, "tinyrad_array_search(); size: %zu; func: %s; idx: %zu; search error", x, compar_name, y)); | 805 | return(trutils_error(opts, NULL, "tinyrad_array_search(); size: %zu; func: %s; idx: %zu; search error", x, compar_name, y)); |
| 806 | if ((size_t)idx != y) | 806 | if ((size_t)idx != y) |
| 807 | return(our_error(opts, NULL, "tinyrad_array_search(); size: %zu; func: %s; idx: %zu; index mismatch", x, compar_name, y)); | 807 | return(trutils_error(opts, NULL, "tinyrad_array_search(); size: %zu; func: %s; idx: %zu; index mismatch", x, compar_name, y)); |
| 808 | }; | 808 | }; |
| 809 | }; | 809 | }; |
| 810 | 810 | ||
| @@ -820,14 +820,14 @@ my_test_search( | |||
| 820 | case MY_KEY_NAME: ptr = list[y]->name; break; | 820 | case MY_KEY_NAME: ptr = list[y]->name; break; |
| 821 | case MY_KEY_VALUE: ptr = &list[y]->value; break; | 821 | case MY_KEY_VALUE: ptr = &list[y]->value; break; |
| 822 | default: | 822 | default: |
| 823 | return(our_error(opts, NULL, "unknown key")); | 823 | return(trutils_error(opts, NULL, "unknown key")); |
| 824 | }; | 824 | }; |
| 825 | if ((res = tinyrad_array_get(list, x, sizeof(MyData *), ptr, TINYRAD_ARRAY_FIRSTDUP, compar)) == NULL) | 825 | if ((res = tinyrad_array_get(list, x, sizeof(MyData *), ptr, TINYRAD_ARRAY_FIRSTDUP, compar)) == NULL) |
| 826 | return(our_error(opts, NULL, "tinyrad_array_get(); size: %zu; func: %s; idx: %zu; search error", x, compar_name, y)); | 826 | return(trutils_error(opts, NULL, "tinyrad_array_get(); size: %zu; func: %s; idx: %zu; search error", x, compar_name, y)); |
| 827 | if ((strcasecmp((*res)->name, list[y]->name))) | 827 | if ((strcasecmp((*res)->name, list[y]->name))) |
| 828 | return(our_error(opts, NULL, "tinyrad_array_get(); size: %zu; func: %s; idx: %zu; result name does not match", x, compar_name, y)); | 828 | return(trutils_error(opts, NULL, "tinyrad_array_get(); size: %zu; func: %s; idx: %zu; result name does not match", x, compar_name, y)); |
| 829 | if ((*res)->value != list[y]->value) | 829 | if ((*res)->value != list[y]->value) |
| 830 | return(our_error(opts, NULL, "tinyrad_array_get(); size: %zu; func: %s; idx: %zu; result value does not match", x, compar_name, y)); | 830 | return(trutils_error(opts, NULL, "tinyrad_array_get(); size: %zu; func: %s; idx: %zu; result value does not match", x, compar_name, y)); |
| 831 | }; | 831 | }; |
| 832 | }; | 832 | }; |
| 833 | 833 | ||
diff --git a/tests/test-array-stack.c b/tests/test-array-stack.c index de1971e..9bb1929 100644 --- a/tests/test-array-stack.c +++ b/tests/test-array-stack.c | |||
| @@ -222,7 +222,7 @@ int main( int argc, char * argv[] ) | |||
| 222 | { | 222 | { |
| 223 | for(; (pos > 0); pos--) | 223 | for(; (pos > 0); pos--) |
| 224 | free(data[pos-1].name); | 224 | free(data[pos-1].name); |
| 225 | return(our_error(opts, NULL, "out of virtual memory")); | 225 | return(trutils_error(opts, NULL, "out of virtual memory")); |
| 226 | }; | 226 | }; |
| 227 | }; | 227 | }; |
| 228 | 228 | ||
| @@ -242,27 +242,27 @@ int main( int argc, char * argv[] ) | |||
| 242 | if ((x % 4) == 3) | 242 | if ((x % 4) == 3) |
| 243 | { | 243 | { |
| 244 | if ((objp = tinyrad_array_pop(list, &list_len, sizeof(MyData *))) == NULL) | 244 | if ((objp = tinyrad_array_pop(list, &list_len, sizeof(MyData *))) == NULL) |
| 245 | return(our_error(opts, NULL, "unable to pop from stack")); | 245 | return(trutils_error(opts, NULL, "unable to pop from stack")); |
| 246 | if ((strcasecmp(src[x-1]->name, (*objp)->name))) | 246 | if ((strcasecmp(src[x-1]->name, (*objp)->name))) |
| 247 | return(our_error(opts, NULL, "str of pop object is incorrect")); | 247 | return(trutils_error(opts, NULL, "str of pop object is incorrect")); |
| 248 | }; | 248 | }; |
| 249 | 249 | ||
| 250 | // adds objects to stack | 250 | // adds objects to stack |
| 251 | if (tinyrad_array_push((void **)&list, &list_len, sizeof(MyData *), &src[x], &realloc) == -1) | 251 | if (tinyrad_array_push((void **)&list, &list_len, sizeof(MyData *), &src[x], &realloc) == -1) |
| 252 | return(our_error(opts, NULL, "failed to push object to stack")); | 252 | return(trutils_error(opts, NULL, "failed to push object to stack")); |
| 253 | }; | 253 | }; |
| 254 | 254 | ||
| 255 | 255 | ||
| 256 | // loop through stack and verify data | 256 | // loop through stack and verify data |
| 257 | trutils_verbose(opts, "verifing stack ..."); | 257 | trutils_verbose(opts, "verifing stack ..."); |
| 258 | if (list_len != ((MY_LIST_LEN / 4) * 3)) | 258 | if (list_len != ((MY_LIST_LEN / 4) * 3)) |
| 259 | return(our_error(opts, NULL, "stack length is incorrect")); | 259 | return(trutils_error(opts, NULL, "stack length is incorrect")); |
| 260 | for(x = 0, y = 0; (x < MY_LIST_LEN); x++) | 260 | for(x = 0, y = 0; (x < MY_LIST_LEN); x++) |
| 261 | { | 261 | { |
| 262 | if ((x % 4) == 2) | 262 | if ((x % 4) == 2) |
| 263 | continue; | 263 | continue; |
| 264 | if ((strcmp(src[x]->name, list[y]->name))) | 264 | if ((strcmp(src[x]->name, list[y]->name))) |
| 265 | return(our_error(opts, NULL, "stack data does not match test data")); | 265 | return(trutils_error(opts, NULL, "stack data does not match test data")); |
| 266 | y++; | 266 | y++; |
| 267 | }; | 267 | }; |
| 268 | 268 | ||
| @@ -271,7 +271,7 @@ int main( int argc, char * argv[] ) | |||
| 271 | trutils_verbose(opts, "popping from stack ..."); | 271 | trutils_verbose(opts, "popping from stack ..."); |
| 272 | while (list_len > 0) | 272 | while (list_len > 0) |
| 273 | if (tinyrad_array_pop(list, &list_len, sizeof(MyData *)) == NULL) | 273 | if (tinyrad_array_pop(list, &list_len, sizeof(MyData *)) == NULL) |
| 274 | return(our_error(opts, NULL, "unable to pop from stack")); | 274 | return(trutils_error(opts, NULL, "unable to pop from stack")); |
| 275 | 275 | ||
| 276 | return(0); | 276 | return(0); |
| 277 | } | 277 | } |
diff --git a/tests/test-dict-attrs.c b/tests/test-dict-attrs.c index 41e3280..ebbe44c 100644 --- a/tests/test-dict-attrs.c +++ b/tests/test-dict-attrs.c | |||
| @@ -283,7 +283,7 @@ my_verify_attr( | |||
| 283 | if (!(attr)) | 283 | if (!(attr)) |
| 284 | { | 284 | { |
| 285 | our_dict_diag_attr(opts, attr_def, attr); | 285 | our_dict_diag_attr(opts, attr_def, attr); |
| 286 | return(our_error(opts, NULL, "attribute was not found")); | 286 | return(trutils_error(opts, NULL, "attribute was not found")); |
| 287 | }; | 287 | }; |
| 288 | 288 | ||
| 289 | // compare data types | 289 | // compare data types |
| @@ -291,7 +291,7 @@ my_verify_attr( | |||
| 291 | if (attr_def->data_type != u32) | 291 | if (attr_def->data_type != u32) |
| 292 | { | 292 | { |
| 293 | our_dict_diag_attr(opts, attr_def, attr); | 293 | our_dict_diag_attr(opts, attr_def, attr); |
| 294 | return(our_error(opts, NULL, "attribute data types do not match")); | 294 | return(trutils_error(opts, NULL, "attribute data types do not match")); |
| 295 | }; | 295 | }; |
| 296 | 296 | ||
| 297 | // compare types | 297 | // compare types |
| @@ -299,7 +299,7 @@ my_verify_attr( | |||
| 299 | if (attr_def->type != u8) | 299 | if (attr_def->type != u8) |
| 300 | { | 300 | { |
| 301 | our_dict_diag_attr(opts, attr_def, attr); | 301 | our_dict_diag_attr(opts, attr_def, attr); |
| 302 | return(our_error(opts, NULL, "attribute types do not match")); | 302 | return(trutils_error(opts, NULL, "attribute types do not match")); |
| 303 | }; | 303 | }; |
| 304 | 304 | ||
| 305 | // compare vendor ID | 305 | // compare vendor ID |
| @@ -307,7 +307,7 @@ my_verify_attr( | |||
| 307 | if (attr_def->vendor_id != u32) | 307 | if (attr_def->vendor_id != u32) |
| 308 | { | 308 | { |
| 309 | our_dict_diag_attr(opts, attr_def, attr); | 309 | our_dict_diag_attr(opts, attr_def, attr); |
| 310 | return(our_error(opts, NULL, "attribute vendor ID do not match")); | 310 | return(trutils_error(opts, NULL, "attribute vendor ID do not match")); |
| 311 | }; | 311 | }; |
| 312 | 312 | ||
| 313 | // compare vendor types | 313 | // compare vendor types |
| @@ -315,7 +315,7 @@ my_verify_attr( | |||
| 315 | if (attr_def->vendor_type != u32) | 315 | if (attr_def->vendor_type != u32) |
| 316 | { | 316 | { |
| 317 | our_dict_diag_attr(opts, attr_def, attr); | 317 | our_dict_diag_attr(opts, attr_def, attr); |
| 318 | return(our_error(opts, NULL, "attribute vendor types do not match")); | 318 | return(trutils_error(opts, NULL, "attribute vendor types do not match")); |
| 319 | }; | 319 | }; |
| 320 | 320 | ||
| 321 | // compare flags | 321 | // compare flags |
| @@ -323,7 +323,7 @@ my_verify_attr( | |||
| 323 | if (attr_def->flags != u32) | 323 | if (attr_def->flags != u32) |
| 324 | { | 324 | { |
| 325 | our_dict_diag_attr(opts, attr_def, attr); | 325 | our_dict_diag_attr(opts, attr_def, attr); |
| 326 | return(our_error(opts, NULL, "attribute flags do not match")); | 326 | return(trutils_error(opts, NULL, "attribute flags do not match")); |
| 327 | }; | 327 | }; |
| 328 | 328 | ||
| 329 | return(0); | 329 | return(0); |
diff --git a/tests/test-dict-values.c b/tests/test-dict-values.c index 8fece04..e324345 100644 --- a/tests/test-dict-values.c +++ b/tests/test-dict-values.c | |||
| @@ -193,7 +193,7 @@ main( | |||
| 193 | ); | 193 | ); |
| 194 | if ((attr = tinyrad_dict_attr_get(dict, value_def->attr_name, 0, NULL, 0, 0)) == NULL) | 194 | if ((attr = tinyrad_dict_attr_get(dict, value_def->attr_name, 0, NULL, 0, 0)) == NULL) |
| 195 | { | 195 | { |
| 196 | our_error(opts, NULL, "%s: %s: unable to retrieve attribute", value_def->attr_name, value_def->value_name); | 196 | trutils_error(opts, NULL, "%s: %s: unable to retrieve attribute", value_def->attr_name, value_def->value_name); |
| 197 | tinyrad_free(attr); | 197 | tinyrad_free(attr); |
| 198 | tinyrad_free(dict); | 198 | tinyrad_free(dict); |
| 199 | return(1); | 199 | return(1); |
| @@ -223,7 +223,7 @@ main( | |||
| 223 | ); | 223 | ); |
| 224 | if ((attr = tinyrad_dict_attr_get(dict, value_def->attr_name, 0, NULL, 0, 0)) == NULL) | 224 | if ((attr = tinyrad_dict_attr_get(dict, value_def->attr_name, 0, NULL, 0, 0)) == NULL) |
| 225 | { | 225 | { |
| 226 | our_error(opts, NULL, "%s: %s: unable to retrieve attribute", value_def->attr_name, value_def->value_name); | 226 | trutils_error(opts, NULL, "%s: %s: unable to retrieve attribute", value_def->attr_name, value_def->value_name); |
| 227 | tinyrad_free(attr); | 227 | tinyrad_free(attr); |
| 228 | tinyrad_free(dict); | 228 | tinyrad_free(dict); |
| 229 | return(1); | 229 | return(1); |
| @@ -253,7 +253,7 @@ main( | |||
| 253 | ); | 253 | ); |
| 254 | if ((attr = tinyrad_dict_attr_get(dict, value_def->attr_name, 0, NULL, 0, 0)) == NULL) | 254 | if ((attr = tinyrad_dict_attr_get(dict, value_def->attr_name, 0, NULL, 0, 0)) == NULL) |
| 255 | { | 255 | { |
| 256 | our_error(opts, NULL, "%s: %s: unable to retrieve attribute", value_def->attr_name, value_def->value_name); | 256 | trutils_error(opts, NULL, "%s: %s: unable to retrieve attribute", value_def->attr_name, value_def->value_name); |
| 257 | tinyrad_free(attr); | 257 | tinyrad_free(attr); |
| 258 | tinyrad_free(dict); | 258 | tinyrad_free(dict); |
| 259 | return(1); | 259 | return(1); |
| @@ -283,7 +283,7 @@ main( | |||
| 283 | ); | 283 | ); |
| 284 | if ((attr = tinyrad_dict_attr_get(dict, value_def->attr_name, 0, NULL, 0, 0)) == NULL) | 284 | if ((attr = tinyrad_dict_attr_get(dict, value_def->attr_name, 0, NULL, 0, 0)) == NULL) |
| 285 | { | 285 | { |
| 286 | our_error(opts, NULL, "%s: %s: unable to retrieve attribute", value_def->attr_name, value_def->value_name); | 286 | trutils_error(opts, NULL, "%s: %s: unable to retrieve attribute", value_def->attr_name, value_def->value_name); |
| 287 | tinyrad_free(attr); | 287 | tinyrad_free(attr); |
| 288 | tinyrad_free(dict); | 288 | tinyrad_free(dict); |
| 289 | return(1); | 289 | return(1); |
| @@ -327,7 +327,7 @@ my_verify_value( | |||
| 327 | if (!(value)) | 327 | if (!(value)) |
| 328 | { | 328 | { |
| 329 | our_dict_diag_value(opts, value_def, value); | 329 | our_dict_diag_value(opts, value_def, value); |
| 330 | return(our_error(opts, NULL, "value was not found")); | 330 | return(trutils_error(opts, NULL, "value was not found")); |
| 331 | }; | 331 | }; |
| 332 | 332 | ||
| 333 | //// compare value names | 333 | //// compare value names |
| @@ -336,7 +336,7 @@ my_verify_value( | |||
| 336 | //{ | 336 | //{ |
| 337 | // tinyrad_free(str); | 337 | // tinyrad_free(str); |
| 338 | // our_dict_diag_value(opts, def, value); | 338 | // our_dict_diag_value(opts, def, value); |
| 339 | // return(our_error(opts, NULL, "value names do not match")); | 339 | // return(trutils_error(opts, NULL, "value names do not match")); |
| 340 | //}; | 340 | //}; |
| 341 | //tinyrad_free(str); | 341 | //tinyrad_free(str); |
| 342 | 342 | ||
| @@ -346,7 +346,7 @@ my_verify_value( | |||
| 346 | //{ | 346 | //{ |
| 347 | // tinyrad_free(str); | 347 | // tinyrad_free(str); |
| 348 | // our_dict_diag_value(opts, def, value); | 348 | // our_dict_diag_value(opts, def, value); |
| 349 | // return(our_error(opts, NULL, "value names do not match")); | 349 | // return(trutils_error(opts, NULL, "value names do not match")); |
| 350 | //}; | 350 | //}; |
| 351 | //tinyrad_free(str); | 351 | //tinyrad_free(str); |
| 352 | 352 | ||
| @@ -356,7 +356,7 @@ my_verify_value( | |||
| 356 | if (a_u8 != v_u8) | 356 | if (a_u8 != v_u8) |
| 357 | { | 357 | { |
| 358 | our_dict_diag_value(opts, value_def, value); | 358 | our_dict_diag_value(opts, value_def, value); |
| 359 | return(our_error(opts, NULL, "attribute type does not match")); | 359 | return(trutils_error(opts, NULL, "attribute type does not match")); |
| 360 | }; | 360 | }; |
| 361 | 361 | ||
| 362 | // compare attribute vendor ID | 362 | // compare attribute vendor ID |
| @@ -365,7 +365,7 @@ my_verify_value( | |||
| 365 | if (a_u32 != v_u32) | 365 | if (a_u32 != v_u32) |
| 366 | { | 366 | { |
| 367 | our_dict_diag_value(opts, value_def, value); | 367 | our_dict_diag_value(opts, value_def, value); |
| 368 | return(our_error(opts, NULL, "attribute vendor id does not match")); | 368 | return(trutils_error(opts, NULL, "attribute vendor id does not match")); |
| 369 | }; | 369 | }; |
| 370 | 370 | ||
| 371 | // compare attribute vendor type | 371 | // compare attribute vendor type |
| @@ -374,7 +374,7 @@ my_verify_value( | |||
| 374 | if (a_u32 != v_u32) | 374 | if (a_u32 != v_u32) |
| 375 | { | 375 | { |
| 376 | our_dict_diag_value(opts, value_def, value); | 376 | our_dict_diag_value(opts, value_def, value); |
| 377 | return(our_error(opts, NULL, "attribute vendor type does not match")); | 377 | return(trutils_error(opts, NULL, "attribute vendor type does not match")); |
| 378 | }; | 378 | }; |
| 379 | 379 | ||
| 380 | // compare value data | 380 | // compare value data |
| @@ -382,7 +382,7 @@ my_verify_value( | |||
| 382 | if (value_def->data != u64) | 382 | if (value_def->data != u64) |
| 383 | { | 383 | { |
| 384 | our_dict_diag_value(opts, value_def, value); | 384 | our_dict_diag_value(opts, value_def, value); |
| 385 | return(our_error(opts, NULL, "value data does not match")); | 385 | return(trutils_error(opts, NULL, "value data does not match")); |
| 386 | }; | 386 | }; |
| 387 | 387 | ||
| 388 | return(0); | 388 | return(0); |
diff --git a/tests/test-dict-vendors.c b/tests/test-dict-vendors.c index af7f0e3..fba49f6 100644 --- a/tests/test-dict-vendors.c +++ b/tests/test-dict-vendors.c | |||
| @@ -254,7 +254,7 @@ my_verify_vendor( | |||
| 254 | if (!(vendor)) | 254 | if (!(vendor)) |
| 255 | { | 255 | { |
| 256 | our_dict_diag_vendor(opts, vendor_def, NULL); | 256 | our_dict_diag_vendor(opts, vendor_def, NULL); |
| 257 | return(our_error(opts, NULL, "vendor was not found")); | 257 | return(trutils_error(opts, NULL, "vendor was not found")); |
| 258 | }; | 258 | }; |
| 259 | 259 | ||
| 260 | // compare vendor ID | 260 | // compare vendor ID |
| @@ -262,7 +262,7 @@ my_verify_vendor( | |||
| 262 | if (vendor_def->vendor_id != u32) | 262 | if (vendor_def->vendor_id != u32) |
| 263 | { | 263 | { |
| 264 | our_dict_diag_vendor(opts, vendor_def, vendor); | 264 | our_dict_diag_vendor(opts, vendor_def, vendor); |
| 265 | return(our_error(opts, NULL, "vendor ID do not match")); | 265 | return(trutils_error(opts, NULL, "vendor ID do not match")); |
| 266 | }; | 266 | }; |
| 267 | 267 | ||
| 268 | // compare vendor type octets | 268 | // compare vendor type octets |
| @@ -270,7 +270,7 @@ my_verify_vendor( | |||
| 270 | if (vendor_def->vendor_type_octs != u8) | 270 | if (vendor_def->vendor_type_octs != u8) |
| 271 | { | 271 | { |
| 272 | our_dict_diag_vendor(opts, vendor_def, vendor); | 272 | our_dict_diag_vendor(opts, vendor_def, vendor); |
| 273 | return(our_error(opts, NULL, "attribute type octets do not match")); | 273 | return(trutils_error(opts, NULL, "attribute type octets do not match")); |
| 274 | }; | 274 | }; |
| 275 | 275 | ||
| 276 | // compare vendor len octets | 276 | // compare vendor len octets |
| @@ -278,7 +278,7 @@ my_verify_vendor( | |||
| 278 | if (vendor_def->vendor_len_octs != u8) | 278 | if (vendor_def->vendor_len_octs != u8) |
| 279 | { | 279 | { |
| 280 | our_dict_diag_vendor(opts, vendor_def, vendor); | 280 | our_dict_diag_vendor(opts, vendor_def, vendor); |
| 281 | return(our_error(opts, NULL, "attribute len octets do not match")); | 281 | return(trutils_error(opts, NULL, "attribute len octets do not match")); |
| 282 | }; | 282 | }; |
| 283 | 283 | ||
| 284 | return(0); | 284 | return(0); |
diff --git a/tests/test-oid-str.c b/tests/test-oid-str.c index 76b93d3..9e79ebb 100644 --- a/tests/test-oid-str.c +++ b/tests/test-oid-str.c | |||
| @@ -215,7 +215,7 @@ int main(int argc, char * argv[]) | |||
| 215 | trutils_verbose(opts, " Initializing OID from values ..."); | 215 | trutils_verbose(opts, " Initializing OID from values ..."); |
| 216 | if ((oid = tinyrad_oid_init(test_vals[x].vals, y)) == NULL) | 216 | if ((oid = tinyrad_oid_init(test_vals[x].vals, y)) == NULL) |
| 217 | { | 217 | { |
| 218 | our_error(opts, NULL, "out of virtual memory"); | 218 | trutils_error(opts, NULL, "out of virtual memory"); |
| 219 | errs++; | 219 | errs++; |
| 220 | continue; | 220 | continue; |
| 221 | }; | 221 | }; |
| @@ -223,14 +223,14 @@ int main(int argc, char * argv[]) | |||
| 223 | trutils_verbose(opts, " Testing values of OID ..."); | 223 | trutils_verbose(opts, " Testing values of OID ..."); |
| 224 | if ((rc = tinyrad_oid_values(oid, &vals, &len)) != TRAD_SUCCESS) | 224 | if ((rc = tinyrad_oid_values(oid, &vals, &len)) != TRAD_SUCCESS) |
| 225 | { | 225 | { |
| 226 | our_error(opts, NULL, "tinyrad_oid_values(): %s", tinyrad_strerror(rc)); | 226 | trutils_error(opts, NULL, "tinyrad_oid_values(): %s", tinyrad_strerror(rc)); |
| 227 | errs++; | 227 | errs++; |
| 228 | tinyrad_free(oid); | 228 | tinyrad_free(oid); |
| 229 | continue; | 229 | continue; |
| 230 | }; | 230 | }; |
| 231 | if (len != y) | 231 | if (len != y) |
| 232 | { | 232 | { |
| 233 | our_error(opts, NULL, "OID length does not match reference"); | 233 | trutils_error(opts, NULL, "OID length does not match reference"); |
| 234 | errs++; | 234 | errs++; |
| 235 | tinyrad_free(oid); | 235 | tinyrad_free(oid); |
| 236 | continue; | 236 | continue; |
| @@ -239,7 +239,7 @@ int main(int argc, char * argv[]) | |||
| 239 | { | 239 | { |
| 240 | if (test_vals[x].vals[pos] != vals[pos]) | 240 | if (test_vals[x].vals[pos] != vals[pos]) |
| 241 | { | 241 | { |
| 242 | our_error(opts, NULL, "OID values do not match reference"); | 242 | trutils_error(opts, NULL, "OID values do not match reference"); |
| 243 | errs++; | 243 | errs++; |
| 244 | pos = y; | 244 | pos = y; |
| 245 | }; | 245 | }; |
| @@ -311,7 +311,7 @@ my_oid_test( | |||
| 311 | trutils_verbose(opts, " Generating %s ...", title); | 311 | trutils_verbose(opts, " Generating %s ...", title); |
| 312 | if ((str = tinyrad_oid2str(oldoid, type)) == NULL) | 312 | if ((str = tinyrad_oid2str(oldoid, type)) == NULL) |
| 313 | { | 313 | { |
| 314 | our_error(opts, NULL, "out of virtual memory"); | 314 | trutils_error(opts, NULL, "out of virtual memory"); |
| 315 | return(1); | 315 | return(1); |
| 316 | }; | 316 | }; |
| 317 | trutils_verbose(opts, " %s: %s", title, str); | 317 | trutils_verbose(opts, " %s: %s", title, str); |
| @@ -319,7 +319,7 @@ my_oid_test( | |||
| 319 | trutils_verbose(opts, " Generating OID from %s ...", title); | 319 | trutils_verbose(opts, " Generating OID from %s ...", title); |
| 320 | if ((newoid = tinyrad_str2oid(str)) == NULL) | 320 | if ((newoid = tinyrad_str2oid(str)) == NULL) |
| 321 | { | 321 | { |
| 322 | our_error(opts, NULL, "error generating OID from %s", title); | 322 | trutils_error(opts, NULL, "error generating OID from %s", title); |
| 323 | tinyrad_free(str); | 323 | tinyrad_free(str); |
| 324 | return(1); | 324 | return(1); |
| 325 | }; | 325 | }; |
| @@ -331,7 +331,7 @@ my_oid_test( | |||
| 331 | trutils_verbose(opts, " Generated OID: %s", my_oidstr(newvals, newlen)); | 331 | trutils_verbose(opts, " Generated OID: %s", my_oidstr(newvals, newlen)); |
| 332 | if (newlen != oldlen) | 332 | if (newlen != oldlen) |
| 333 | { | 333 | { |
| 334 | our_error(opts, NULL, "old and new OID lengths do not match"); | 334 | trutils_error(opts, NULL, "old and new OID lengths do not match"); |
| 335 | tinyrad_free(newoid); | 335 | tinyrad_free(newoid); |
| 336 | tinyrad_free(newvals); | 336 | tinyrad_free(newvals); |
| 337 | tinyrad_free(oldvals); | 337 | tinyrad_free(oldvals); |
| @@ -341,7 +341,7 @@ my_oid_test( | |||
| 341 | { | 341 | { |
| 342 | if (newvals[pos] != oldvals[pos]) | 342 | if (newvals[pos] != oldvals[pos]) |
| 343 | { | 343 | { |
| 344 | our_error(opts, NULL, "old and new OID values do not match"); | 344 | trutils_error(opts, NULL, "old and new OID values do not match"); |
| 345 | tinyrad_free(newoid); | 345 | tinyrad_free(newoid); |
| 346 | tinyrad_free(newvals); | 346 | tinyrad_free(newvals); |
| 347 | tinyrad_free(oldvals); | 347 | tinyrad_free(oldvals); |
| @@ -353,7 +353,7 @@ my_oid_test( | |||
| 353 | if ((tinyrad_oid_cmp(&oldoid, &newoid))) | 353 | if ((tinyrad_oid_cmp(&oldoid, &newoid))) |
| 354 | { | 354 | { |
| 355 | tinyrad_free(newoid); | 355 | tinyrad_free(newoid); |
| 356 | our_error(opts, NULL, "old OID does not match new OID"); | 356 | trutils_error(opts, NULL, "old OID does not match new OID"); |
| 357 | return(1); | 357 | return(1); |
| 358 | }; | 358 | }; |
| 359 | 359 | ||
diff --git a/tests/test-options.c b/tests/test-options.c index 5545905..8ad7cfc 100644 --- a/tests/test-options.c +++ b/tests/test-options.c | |||
| @@ -160,50 +160,50 @@ int main( int argc, char * argv[] ) | |||
| 160 | // TRAD_OPT_DEBUG_SYSLOG | 160 | // TRAD_OPT_DEBUG_SYSLOG |
| 161 | opt = TRAD_ON; | 161 | opt = TRAD_ON; |
| 162 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_SYSLOG, &opt)) != TRAD_SUCCESS) | 162 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_SYSLOG, &opt)) != TRAD_SUCCESS) |
| 163 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_SYSLOG, TRAD_ON): %s", tinyrad_strerror(rc))); | 163 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_SYSLOG, TRAD_ON): %s", tinyrad_strerror(rc))); |
| 164 | opt = ~TRAD_ON; | 164 | opt = ~TRAD_ON; |
| 165 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_SYSLOG, &opt)) != TRAD_SUCCESS) | 165 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_SYSLOG, &opt)) != TRAD_SUCCESS) |
| 166 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_SYSLOG, &opt): %s", tinyrad_strerror(rc))); | 166 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_SYSLOG, &opt): %s", tinyrad_strerror(rc))); |
| 167 | if (opt != TRAD_ON) | 167 | if (opt != TRAD_ON) |
| 168 | return(our_error(opts, NULL, "value for TRAD_OPT_DEBUG_SYSLOG does not match")); | 168 | return(trutils_error(opts, NULL, "value for TRAD_OPT_DEBUG_SYSLOG does not match")); |
| 169 | opt = TRAD_OFF; | 169 | opt = TRAD_OFF; |
| 170 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_SYSLOG, &opt)) != TRAD_SUCCESS) | 170 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_SYSLOG, &opt)) != TRAD_SUCCESS) |
| 171 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_SYSLOG, TRAD_ON): %s", tinyrad_strerror(rc))); | 171 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_SYSLOG, TRAD_ON): %s", tinyrad_strerror(rc))); |
| 172 | opt = ~TRAD_OFF; | 172 | opt = ~TRAD_OFF; |
| 173 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_SYSLOG, &opt)) != TRAD_SUCCESS) | 173 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_SYSLOG, &opt)) != TRAD_SUCCESS) |
| 174 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_SYSLOG, &opt): %s", tinyrad_strerror(rc))); | 174 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_SYSLOG, &opt): %s", tinyrad_strerror(rc))); |
| 175 | if (opt != TRAD_OFF) | 175 | if (opt != TRAD_OFF) |
| 176 | return(our_error(opts, NULL, "value for TRAD_OPT_DEBUG_SYSLOG does not match")); | 176 | return(trutils_error(opts, NULL, "value for TRAD_OPT_DEBUG_SYSLOG does not match")); |
| 177 | 177 | ||
| 178 | // TRAD_OPT_DEBUG_IDENT | 178 | // TRAD_OPT_DEBUG_IDENT |
| 179 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_IDENT, PROGRAM_NAME)) != TRAD_SUCCESS) | 179 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_IDENT, PROGRAM_NAME)) != TRAD_SUCCESS) |
| 180 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_IDENT, PROGRAM_NAME): %s", tinyrad_strerror(rc))); | 180 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_IDENT, PROGRAM_NAME): %s", tinyrad_strerror(rc))); |
| 181 | str = NULL; | 181 | str = NULL; |
| 182 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_IDENT, &str)) != TRAD_SUCCESS) | 182 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_IDENT, &str)) != TRAD_SUCCESS) |
| 183 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_IDENT, &str): %s", tinyrad_strerror(rc))); | 183 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_IDENT, &str): %s", tinyrad_strerror(rc))); |
| 184 | if (!(str)) | 184 | if (!(str)) |
| 185 | return(our_error(opts, NULL, "value for TRAD_OPT_DEBUG_IDENT is NULL")); | 185 | return(trutils_error(opts, NULL, "value for TRAD_OPT_DEBUG_IDENT is NULL")); |
| 186 | if ((strcmp(PROGRAM_NAME, str))) | 186 | if ((strcmp(PROGRAM_NAME, str))) |
| 187 | return(our_error(opts, NULL, "value for TRAD_OPT_DEBUG_IDENT does not match")); | 187 | return(trutils_error(opts, NULL, "value for TRAD_OPT_DEBUG_IDENT does not match")); |
| 188 | free(str); | 188 | free(str); |
| 189 | 189 | ||
| 190 | // TRAD_OPT_DEBUG_LEVEL | 190 | // TRAD_OPT_DEBUG_LEVEL |
| 191 | opt = TRAD_DEBUG_PACKETS; | 191 | opt = TRAD_DEBUG_PACKETS; |
| 192 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_LEVEL, &opt)) != TRAD_SUCCESS) | 192 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_LEVEL, &opt)) != TRAD_SUCCESS) |
| 193 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_LEVEL, TRAD_DEBUG_PACKETS): %s", tinyrad_strerror(rc))); | 193 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_LEVEL, TRAD_DEBUG_PACKETS): %s", tinyrad_strerror(rc))); |
| 194 | opt = ~TRAD_DEBUG_PACKETS; | 194 | opt = ~TRAD_DEBUG_PACKETS; |
| 195 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_LEVEL, &opt)) != TRAD_SUCCESS) | 195 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_LEVEL, &opt)) != TRAD_SUCCESS) |
| 196 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_LEVEL, &opt): %s", tinyrad_strerror(rc))); | 196 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_LEVEL, &opt): %s", tinyrad_strerror(rc))); |
| 197 | if (opt != TRAD_DEBUG_PACKETS) | 197 | if (opt != TRAD_DEBUG_PACKETS) |
| 198 | return(our_error(opts, NULL, "value for TRAD_OPT_DEBUG_LEVEL does not match")); | 198 | return(trutils_error(opts, NULL, "value for TRAD_OPT_DEBUG_LEVEL does not match")); |
| 199 | opt = TRAD_DEBUG_NONE; | 199 | opt = TRAD_DEBUG_NONE; |
| 200 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_LEVEL, &opt)) != TRAD_SUCCESS) | 200 | if ((rc = tinyrad_set_option(NULL, TRAD_OPT_DEBUG_LEVEL, &opt)) != TRAD_SUCCESS) |
| 201 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_LEVEL, TRAD_DEBUG_NONE): %s", tinyrad_strerror(rc))); | 201 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DEBUG_LEVEL, TRAD_DEBUG_NONE): %s", tinyrad_strerror(rc))); |
| 202 | opt = ~TRAD_DEBUG_NONE; | 202 | opt = ~TRAD_DEBUG_NONE; |
| 203 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_LEVEL, &opt)) != TRAD_SUCCESS) | 203 | if ((rc = tinyrad_get_option(NULL, TRAD_OPT_DEBUG_LEVEL, &opt)) != TRAD_SUCCESS) |
| 204 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_LEVEL, &opt): %s", tinyrad_strerror(rc))); | 204 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DEBUG_LEVEL, &opt): %s", tinyrad_strerror(rc))); |
| 205 | if (opt != TRAD_DEBUG_NONE) | 205 | if (opt != TRAD_DEBUG_NONE) |
| 206 | return(our_error(opts, NULL, "value for TRAD_OPT_DEBUG_LEVEL does not match")); | 206 | return(trutils_error(opts, NULL, "value for TRAD_OPT_DEBUG_LEVEL does not match")); |
| 207 | 207 | ||
| 208 | // enable debug | 208 | // enable debug |
| 209 | if ((debug)) | 209 | if ((debug)) |
| @@ -211,118 +211,118 @@ int main( int argc, char * argv[] ) | |||
| 211 | 211 | ||
| 212 | // initialize tinyrad | 212 | // initialize tinyrad |
| 213 | if ((rc = tinyrad_initialize(&tr, NULL, "radius://localhost/secret", 0)) != TRAD_SUCCESS) | 213 | if ((rc = tinyrad_initialize(&tr, NULL, "radius://localhost/secret", 0)) != TRAD_SUCCESS) |
| 214 | return(our_error(opts, NULL, "tinyrad_initialize(tr, \"radius://localhost/secret\", 0): %s", tinyrad_strerror(rc))); | 214 | return(trutils_error(opts, NULL, "tinyrad_initialize(tr, \"radius://localhost/secret\", 0): %s", tinyrad_strerror(rc))); |
| 215 | 215 | ||
| 216 | // TRAD_OPT_DESC | 216 | // TRAD_OPT_DESC |
| 217 | opt = 53; | 217 | opt = 53; |
| 218 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_DESC, &opt)) == TRAD_SUCCESS) | 218 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_DESC, &opt)) == TRAD_SUCCESS) |
| 219 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DESC, 53): was able to set file descriptor", tinyrad_strerror(rc))); | 219 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_DESC, 53): was able to set file descriptor", tinyrad_strerror(rc))); |
| 220 | opt = ~0x00; | 220 | opt = ~0x00; |
| 221 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_DESC, &opt)) != TRAD_SUCCESS) | 221 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_DESC, &opt)) != TRAD_SUCCESS) |
| 222 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DESC, &opt): %s", tinyrad_strerror(rc))); | 222 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_DESC, &opt): %s", tinyrad_strerror(rc))); |
| 223 | 223 | ||
| 224 | // TRAD_OPT_IPV4 | 224 | // TRAD_OPT_IPV4 |
| 225 | //opt = TRAD_ON; | 225 | //opt = TRAD_ON; |
| 226 | //if ((rc = tinyrad_set_option(tr, TRAD_OPT_IPV4, &opt)) != TRAD_SUCCESS) | 226 | //if ((rc = tinyrad_set_option(tr, TRAD_OPT_IPV4, &opt)) != TRAD_SUCCESS) |
| 227 | // return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_IPV4, TRAD_ON): %s", tinyrad_strerror(rc))); | 227 | // return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_IPV4, TRAD_ON): %s", tinyrad_strerror(rc))); |
| 228 | //opt = (int)~0x00; | 228 | //opt = (int)~0x00; |
| 229 | //if ((rc = tinyrad_get_option(tr, TRAD_OPT_IPV4, &opt)) != TRAD_SUCCESS) | 229 | //if ((rc = tinyrad_get_option(tr, TRAD_OPT_IPV4, &opt)) != TRAD_SUCCESS) |
| 230 | // return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_IPV4, &opt): %s", tinyrad_strerror(rc))); | 230 | // return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_IPV4, &opt): %s", tinyrad_strerror(rc))); |
| 231 | //if (opt != TRAD_ON) | 231 | //if (opt != TRAD_ON) |
| 232 | // return(our_error(opts, NULL, "value for TRAD_OPT_IPV4 does not match")); | 232 | // return(trutils_error(opts, NULL, "value for TRAD_OPT_IPV4 does not match")); |
| 233 | //opt = TRAD_OFF; | 233 | //opt = TRAD_OFF; |
| 234 | //if ((rc = tinyrad_set_option(tr, TRAD_OPT_IPV4, &opt)) != TRAD_SUCCESS) | 234 | //if ((rc = tinyrad_set_option(tr, TRAD_OPT_IPV4, &opt)) != TRAD_SUCCESS) |
| 235 | // return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_IPV4, TRAD_ON): %s", tinyrad_strerror(rc))); | 235 | // return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_IPV4, TRAD_ON): %s", tinyrad_strerror(rc))); |
| 236 | //opt = ~TRAD_OFF; | 236 | //opt = ~TRAD_OFF; |
| 237 | //if ((rc = tinyrad_get_option(tr, TRAD_OPT_IPV4, &opt)) != TRAD_SUCCESS) | 237 | //if ((rc = tinyrad_get_option(tr, TRAD_OPT_IPV4, &opt)) != TRAD_SUCCESS) |
| 238 | // return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_IPV4, &opt): %s", tinyrad_strerror(rc))); | 238 | // return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_IPV4, &opt): %s", tinyrad_strerror(rc))); |
| 239 | //if (opt != TRAD_OFF) | 239 | //if (opt != TRAD_OFF) |
| 240 | // return(our_error(opts, NULL, "value for TRAD_OPT_IPV4 does not match")); | 240 | // return(trutils_error(opts, NULL, "value for TRAD_OPT_IPV4 does not match")); |
| 241 | 241 | ||
| 242 | // TRAD_OPT_IPV6 | 242 | // TRAD_OPT_IPV6 |
| 243 | //opt = TRAD_ON; | 243 | //opt = TRAD_ON; |
| 244 | //if ((rc = tinyrad_set_option(tr, TRAD_OPT_IPV6, &opt)) != TRAD_SUCCESS) | 244 | //if ((rc = tinyrad_set_option(tr, TRAD_OPT_IPV6, &opt)) != TRAD_SUCCESS) |
| 245 | // return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_IPV6, TRAD_ON): %s", tinyrad_strerror(rc))); | 245 | // return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_IPV6, TRAD_ON): %s", tinyrad_strerror(rc))); |
| 246 | //opt = (int)~0x00; | 246 | //opt = (int)~0x00; |
| 247 | //if ((rc = tinyrad_get_option(tr, TRAD_OPT_IPV6, &opt)) != TRAD_SUCCESS) | 247 | //if ((rc = tinyrad_get_option(tr, TRAD_OPT_IPV6, &opt)) != TRAD_SUCCESS) |
| 248 | // return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_IPV6, &opt): %s", tinyrad_strerror(rc))); | 248 | // return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_IPV6, &opt): %s", tinyrad_strerror(rc))); |
| 249 | //if (opt != TRAD_ON) | 249 | //if (opt != TRAD_ON) |
| 250 | // return(our_error(opts, NULL, "value for TRAD_OPT_IPV6 does not match")); | 250 | // return(trutils_error(opts, NULL, "value for TRAD_OPT_IPV6 does not match")); |
| 251 | //opt = TRAD_OFF; | 251 | //opt = TRAD_OFF; |
| 252 | //if ((rc = tinyrad_set_option(tr, TRAD_OPT_IPV6, &opt)) != TRAD_SUCCESS) | 252 | //if ((rc = tinyrad_set_option(tr, TRAD_OPT_IPV6, &opt)) != TRAD_SUCCESS) |
| 253 | // return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_IPV6, TRAD_ON): %s", tinyrad_strerror(rc))); | 253 | // return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_IPV6, TRAD_ON): %s", tinyrad_strerror(rc))); |
| 254 | //opt = ~TRAD_OFF; | 254 | //opt = ~TRAD_OFF; |
| 255 | //if ((rc = tinyrad_get_option(tr, TRAD_OPT_IPV6, &opt)) != TRAD_SUCCESS) | 255 | //if ((rc = tinyrad_get_option(tr, TRAD_OPT_IPV6, &opt)) != TRAD_SUCCESS) |
| 256 | // return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_IPV6, &opt): %s", tinyrad_strerror(rc))); | 256 | // return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_IPV6, &opt): %s", tinyrad_strerror(rc))); |
| 257 | //if (opt != TRAD_OFF) | 257 | //if (opt != TRAD_OFF) |
| 258 | // return(our_error(opts, NULL, "value for TRAD_OPT_IPV6 does not match")); | 258 | // return(trutils_error(opts, NULL, "value for TRAD_OPT_IPV6 does not match")); |
| 259 | 259 | ||
| 260 | // TRAD_OPT_NETWORK_TIMEOUT | 260 | // TRAD_OPT_NETWORK_TIMEOUT |
| 261 | tv.tv_sec = 200; | 261 | tv.tv_sec = 200; |
| 262 | tv.tv_usec = 111; | 262 | tv.tv_usec = 111; |
| 263 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_NETWORK_TIMEOUT, &tv)) != TRAD_SUCCESS) | 263 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_NETWORK_TIMEOUT, &tv)) != TRAD_SUCCESS) |
| 264 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_NETWORK_TIMEOUT, &tv): %s", tinyrad_strerror(rc))); | 264 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_NETWORK_TIMEOUT, &tv): %s", tinyrad_strerror(rc))); |
| 265 | tv.tv_sec = ~0x00; | 265 | tv.tv_sec = ~0x00; |
| 266 | tv.tv_usec = ~0x00; | 266 | tv.tv_usec = ~0x00; |
| 267 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_NETWORK_TIMEOUT, &tv)) != TRAD_SUCCESS) | 267 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_NETWORK_TIMEOUT, &tv)) != TRAD_SUCCESS) |
| 268 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_NETWORK_TIMEOUT, &tv): %s", tinyrad_strerror(rc))); | 268 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_NETWORK_TIMEOUT, &tv): %s", tinyrad_strerror(rc))); |
| 269 | if (tv.tv_sec != 200) | 269 | if (tv.tv_sec != 200) |
| 270 | return(our_error(opts, NULL, "tv_sec for TRAD_OPT_NETWORK_TIMEOUT does not match")); | 270 | return(trutils_error(opts, NULL, "tv_sec for TRAD_OPT_NETWORK_TIMEOUT does not match")); |
| 271 | if (tv.tv_usec != 111) | 271 | if (tv.tv_usec != 111) |
| 272 | return(our_error(opts, NULL, "tv_usec for TRAD_OPT_NETWORK_TIMEOUT does not match")); | 272 | return(trutils_error(opts, NULL, "tv_usec for TRAD_OPT_NETWORK_TIMEOUT does not match")); |
| 273 | 273 | ||
| 274 | // TRAD_OPT_TIMEOUT | 274 | // TRAD_OPT_TIMEOUT |
| 275 | opt = 53; | 275 | opt = 53; |
| 276 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_TIMEOUT, &opt)) != TRAD_SUCCESS) | 276 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_TIMEOUT, &opt)) != TRAD_SUCCESS) |
| 277 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_TIMEOUT, TRAD_ON): %s", tinyrad_strerror(rc))); | 277 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_TIMEOUT, TRAD_ON): %s", tinyrad_strerror(rc))); |
| 278 | opt = ~0x00; | 278 | opt = ~0x00; |
| 279 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_TIMEOUT, &opt)) != TRAD_SUCCESS) | 279 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_TIMEOUT, &opt)) != TRAD_SUCCESS) |
| 280 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_TIMEOUT, &opt): %s", tinyrad_strerror(rc))); | 280 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_TIMEOUT, &opt): %s", tinyrad_strerror(rc))); |
| 281 | if (opt != 53) | 281 | if (opt != 53) |
| 282 | return(our_error(opts, NULL, "value for TRAD_OPT_TIMEOUT does not match")); | 282 | return(trutils_error(opts, NULL, "value for TRAD_OPT_TIMEOUT does not match")); |
| 283 | 283 | ||
| 284 | // TRAD_OPT_SOCKET_BIND_ADDRESSES | 284 | // TRAD_OPT_SOCKET_BIND_ADDRESSES |
| 285 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, "127.0.0.1")) != TRAD_SUCCESS) | 285 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, "127.0.0.1")) != TRAD_SUCCESS) |
| 286 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, \"127.0.0.1\"): %s", tinyrad_strerror(rc))); | 286 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, \"127.0.0.1\"): %s", tinyrad_strerror(rc))); |
| 287 | str = NULL; | 287 | str = NULL; |
| 288 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str)) != TRAD_SUCCESS) | 288 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str)) != TRAD_SUCCESS) |
| 289 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str): %s", tinyrad_strerror(rc))); | 289 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str): %s", tinyrad_strerror(rc))); |
| 290 | if (!(str)) | 290 | if (!(str)) |
| 291 | return(our_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES is NULL")); | 291 | return(trutils_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES is NULL")); |
| 292 | if ((strcmp(str, "127.0.0.1 ::"))) | 292 | if ((strcmp(str, "127.0.0.1 ::"))) |
| 293 | return(our_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES does not match")); | 293 | return(trutils_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES does not match")); |
| 294 | free(str); | 294 | free(str); |
| 295 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, "::1")) != TRAD_SUCCESS) | 295 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, "::1")) != TRAD_SUCCESS) |
| 296 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, \"127.0.0.1\"): %s", tinyrad_strerror(rc))); | 296 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, \"127.0.0.1\"): %s", tinyrad_strerror(rc))); |
| 297 | str = NULL; | 297 | str = NULL; |
| 298 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str)) != TRAD_SUCCESS) | 298 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str)) != TRAD_SUCCESS) |
| 299 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str): %s", tinyrad_strerror(rc))); | 299 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str): %s", tinyrad_strerror(rc))); |
| 300 | if (!(str)) | 300 | if (!(str)) |
| 301 | return(our_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES is NULL")); | 301 | return(trutils_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES is NULL")); |
| 302 | if ((strcmp(str, "0.0.0.0 ::1"))) | 302 | if ((strcmp(str, "0.0.0.0 ::1"))) |
| 303 | return(our_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES does not match")); | 303 | return(trutils_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES does not match")); |
| 304 | free(str); | 304 | free(str); |
| 305 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, "::1 127.0.0.1")) != TRAD_SUCCESS) | 305 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, "::1 127.0.0.1")) != TRAD_SUCCESS) |
| 306 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, \"127.0.0.1\"): %s", tinyrad_strerror(rc))); | 306 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, \"127.0.0.1\"): %s", tinyrad_strerror(rc))); |
| 307 | str = NULL; | 307 | str = NULL; |
| 308 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str)) != TRAD_SUCCESS) | 308 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str)) != TRAD_SUCCESS) |
| 309 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str): %s", tinyrad_strerror(rc))); | 309 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_SOCKET_BIND_ADDRESSES, &str): %s", tinyrad_strerror(rc))); |
| 310 | if (!(str)) | 310 | if (!(str)) |
| 311 | return(our_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES is NULL")); | 311 | return(trutils_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES is NULL")); |
| 312 | if ((strcmp(str, "127.0.0.1 ::1"))) | 312 | if ((strcmp(str, "127.0.0.1 ::1"))) |
| 313 | return(our_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES does not match")); | 313 | return(trutils_error(opts, NULL, "value for TRAD_OPT_SOCKET_BIND_ADDRESSES does not match")); |
| 314 | free(str); | 314 | free(str); |
| 315 | 315 | ||
| 316 | // TRAD_OPT_URI | 316 | // TRAD_OPT_URI |
| 317 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_URI, "radius://localhost/radiussecret")) != TRAD_SUCCESS) | 317 | if ((rc = tinyrad_set_option(tr, TRAD_OPT_URI, "radius://localhost/radiussecret")) != TRAD_SUCCESS) |
| 318 | return(our_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_URI, \"radius://localhost/radiussecret\"): %s", tinyrad_strerror(rc))); | 318 | return(trutils_error(opts, NULL, "tinyrad_set_option(tr, TRAD_OPT_URI, \"radius://localhost/radiussecret\"): %s", tinyrad_strerror(rc))); |
| 319 | str = NULL; | 319 | str = NULL; |
| 320 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_URI, &str)) != TRAD_SUCCESS) | 320 | if ((rc = tinyrad_get_option(tr, TRAD_OPT_URI, &str)) != TRAD_SUCCESS) |
| 321 | return(our_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_URI, &str): %s", tinyrad_strerror(rc))); | 321 | return(trutils_error(opts, NULL, "tinyrad_get_option(tr, TRAD_OPT_URI, &str): %s", tinyrad_strerror(rc))); |
| 322 | if (!(str)) | 322 | if (!(str)) |
| 323 | return(our_error(opts, NULL, "value for TRAD_OPT_URI is NULL")); | 323 | return(trutils_error(opts, NULL, "value for TRAD_OPT_URI is NULL")); |
| 324 | if ((strcmp(str, "radius://localhost/radiussecret"))) | 324 | if ((strcmp(str, "radius://localhost/radiussecret"))) |
| 325 | return(our_error(opts, NULL, "value for TRAD_OPT_URI does not match")); | 325 | return(trutils_error(opts, NULL, "value for TRAD_OPT_URI does not match")); |
| 326 | free(str); | 326 | free(str); |
| 327 | 327 | ||
| 328 | return(0); | 328 | return(0); |
diff --git a/tests/test-pckt-byte-order.c b/tests/test-pckt-byte-order.c index edef3b6..85b3ad5 100644 --- a/tests/test-pckt-byte-order.c +++ b/tests/test-pckt-byte-order.c | |||
| @@ -302,7 +302,7 @@ my_test_value( | |||
| 302 | 302 | ||
| 303 | if ( value != ptoh) | 303 | if ( value != ptoh) |
| 304 | { | 304 | { |
| 305 | our_error(opts, NULL, "value parsed from buffer does not match original"); | 305 | trutils_error(opts, NULL, "value parsed from buffer does not match original"); |
| 306 | return(1); | 306 | return(1); |
| 307 | }; | 307 | }; |
| 308 | 308 | ||
| @@ -313,13 +313,13 @@ my_test_value( | |||
| 313 | byte = ((offset+width-pos) << 4) | ((offset+width-pos) << 0); | 313 | byte = ((offset+width-pos) << 4) | ((offset+width-pos) << 0); |
| 314 | if (buff[pos] != byte) | 314 | if (buff[pos] != byte) |
| 315 | { | 315 | { |
| 316 | our_error(opts, NULL, "unexpected byte in buffer at offset %zu", pos); | 316 | trutils_error(opts, NULL, "unexpected byte in buffer at offset %zu", pos); |
| 317 | return(1); | 317 | return(1); |
| 318 | }; | 318 | }; |
| 319 | } else { | 319 | } else { |
| 320 | if (buff[pos] != 0xff) | 320 | if (buff[pos] != 0xff) |
| 321 | { | 321 | { |
| 322 | our_error(opts, NULL, "unexpected byte in buffer at offset %zu", pos); | 322 | trutils_error(opts, NULL, "unexpected byte in buffer at offset %zu", pos); |
| 323 | return(1); | 323 | return(1); |
| 324 | }; | 324 | }; |
| 325 | }; | 325 | }; |
