From cc5667cc2e786e79b35bfd893e14e4df4d901650 Mon Sep 17 00:00:00 2001 From: "David M. Syzdek" Date: Mon, 21 Mar 2022 22:28:31 -0800 Subject: tests: refactoring our_dict_initialize() --- tests/common-dict.c | 16 ++-------------- tests/common-dict.h | 3 +-- tests/test-dict-attrs.c | 6 ++++-- tests/test-dict-values.c | 6 ++++-- tests/test-dict-vendors.c | 6 ++++-- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/tests/common-dict.c b/tests/common-dict.c index 8a0ce8a..49c3f7f 100644 --- a/tests/common-dict.c +++ b/tests/common-dict.c @@ -304,6 +304,7 @@ our_dict_diag_vendor( int our_dict_initialize( unsigned opts, + unsigned tr_opts, TinyRadDict ** dictp ) { int rc; @@ -315,25 +316,12 @@ our_dict_initialize( errs = NULL; // initialize dictionary - if (tinyrad_dict_initialize(dictp, 0) != TRAD_SUCCESS) + if (tinyrad_dict_initialize(dictp, tr_opts) != TRAD_SUCCESS) { trutils_error(opts, NULL, "out of virtual memory"); return(1); }; - // load builtin/default dictionary objects - if ((opts & TEST_OPT_DFLT_DICT)) - { - trutils_verbose(opts, "loading default dictionary ..."); - if ((rc = tinyrad_dict_builtin(*dictp, &errs)) != TRAD_SUCCESS) - { - trutils_error(opts, errs, "tinyrad_dict_defaults(): %s", tinyrad_strerror(rc)); - tinyrad_strsfree(errs); - tinyrad_free(*dictp); - return(1); - }; - }; - // load test dictionary vendors trutils_verbose(opts, "adding test dictionary vendors ..."); if ((rc = tinyrad_dict_import(*dictp, test_dict_data_vendors, NULL, NULL, &errs)) != TRAD_SUCCESS) diff --git a/tests/common-dict.h b/tests/common-dict.h index 4b5ef17..84ae79c 100644 --- a/tests/common-dict.h +++ b/tests/common-dict.h @@ -49,8 +49,6 @@ /////////////////// #pragma mark - Definitions -#define TEST_OPT_DFLT_DICT 0x0040UL - ///////////////// // // @@ -94,6 +92,7 @@ our_dict_diag_vendor( int our_dict_initialize( unsigned opts, + unsigned tr_opts, TinyRadDict ** dictp ); diff --git a/tests/test-dict-attrs.c b/tests/test-dict-attrs.c index 6bf5970..6a334cb 100644 --- a/tests/test-dict-attrs.c +++ b/tests/test-dict-attrs.c @@ -101,6 +101,7 @@ main( int opt_index; size_t pos; unsigned opts; + unsigned tr_opts; TinyRadDict * dict; TinyRadDictAttr * attr; const TinyRadDictAttrDef * attr_def; @@ -120,7 +121,8 @@ main( trutils_initialize(PROGRAM_NAME); - opts = TEST_OPT_DFLT_DICT; + opts = 0; + tr_opts = TRAD_NOINIT | TRAD_BUILTIN_DICT; while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) { @@ -172,7 +174,7 @@ main( }; // initialize test dictionary - if ((our_dict_initialize(opts, &dict))) + if ((our_dict_initialize(opts, tr_opts, &dict))) return(1); trutils_verbose(opts, " %4s %9s %7s %s", "Type", "Vendor", "Vendor", "Name"); diff --git a/tests/test-dict-values.c b/tests/test-dict-values.c index ba32364..8337925 100644 --- a/tests/test-dict-values.c +++ b/tests/test-dict-values.c @@ -102,6 +102,7 @@ main( int opt_index; size_t pos; unsigned opts; + unsigned tr_opts; TinyRadDict * dict; TinyRadDictAttr * attr; TinyRadDictValue * value; @@ -122,7 +123,8 @@ main( trutils_initialize(PROGRAM_NAME); - opts = TEST_OPT_DFLT_DICT; + opts = 0; + tr_opts = TRAD_NOINIT | TRAD_BUILTIN_DICT; while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) { @@ -174,7 +176,7 @@ main( }; // initialize test dictionary - if ((our_dict_initialize(opts, &dict))) + if ((our_dict_initialize(opts, tr_opts, &dict))) return(1); trutils_verbose(opts, " %4s %9s %7s %s", "Type", "Vendor", "Vendor", "Name"); diff --git a/tests/test-dict-vendors.c b/tests/test-dict-vendors.c index 258a729..b183c0c 100644 --- a/tests/test-dict-vendors.c +++ b/tests/test-dict-vendors.c @@ -101,6 +101,7 @@ main( int opt_index; size_t pos; unsigned opts; + unsigned tr_opts; TinyRadDict * dict; TinyRadDictVendor * vendor; const TinyRadDictVendorDef * vendor_def; @@ -120,7 +121,8 @@ main( trutils_initialize(PROGRAM_NAME); - opts = TEST_OPT_DFLT_DICT; + opts = 0; + tr_opts = TRAD_NOINIT | TRAD_BUILTIN_DICT; while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) { @@ -172,7 +174,7 @@ main( }; // initialize test dictionary - if ((our_dict_initialize(opts, &dict))) + if ((our_dict_initialize(opts, tr_opts, &dict))) return(1); trutils_verbose(opts, "Vendor format: vendor id/name"); -- cgit v1.2.3