aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2022-03-21 22:28:31 -0800
committerDavid M. Syzdek <david@syzdek.net>2022-03-21 22:28:31 -0800
commitcc5667cc2e786e79b35bfd893e14e4df4d901650 (patch)
tree645362b012c6794ee65e7ec82fb4d02eb7f40e0b /tests
parent2a88719cd1b45d4e74f9c225f315ef46799de18e (diff)
downloadtinyrad-cc5667cc2e786e79b35bfd893e14e4df4d901650.tar.gz
tinyrad-cc5667cc2e786e79b35bfd893e14e4df4d901650.tar.bz2
tinyrad-cc5667cc2e786e79b35bfd893e14e4df4d901650.tar.xz
tinyrad-cc5667cc2e786e79b35bfd893e14e4df4d901650.zip
tests: refactoring our_dict_initialize()
Diffstat (limited to 'tests')
-rw-r--r--tests/common-dict.c16
-rw-r--r--tests/common-dict.h3
-rw-r--r--tests/test-dict-attrs.c6
-rw-r--r--tests/test-dict-values.c6
-rw-r--r--tests/test-dict-vendors.c6
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(
304int 304int
305our_dict_initialize( 305our_dict_initialize(
306 unsigned opts, 306 unsigned opts,
307 unsigned tr_opts,
307 TinyRadDict ** dictp ) 308 TinyRadDict ** dictp )
308{ 309{
309 int rc; 310 int rc;
@@ -315,25 +316,12 @@ our_dict_initialize(
315 errs = NULL; 316 errs = NULL;
316 317
317 // initialize dictionary 318 // initialize dictionary
318 if (tinyrad_dict_initialize(dictp, 0) != TRAD_SUCCESS) 319 if (tinyrad_dict_initialize(dictp, tr_opts) != TRAD_SUCCESS)
319 { 320 {
320 trutils_error(opts, NULL, "out of virtual memory"); 321 trutils_error(opts, NULL, "out of virtual memory");
321 return(1); 322 return(1);
322 }; 323 };
323 324
324 // load builtin/default dictionary objects
325 if ((opts & TEST_OPT_DFLT_DICT))
326 {
327 trutils_verbose(opts, "loading default dictionary ...");
328 if ((rc = tinyrad_dict_builtin(*dictp, &errs)) != TRAD_SUCCESS)
329 {
330 trutils_error(opts, errs, "tinyrad_dict_defaults(): %s", tinyrad_strerror(rc));
331 tinyrad_strsfree(errs);
332 tinyrad_free(*dictp);
333 return(1);
334 };
335 };
336
337 // load test dictionary vendors 325 // load test dictionary vendors
338 trutils_verbose(opts, "adding test dictionary vendors ..."); 326 trutils_verbose(opts, "adding test dictionary vendors ...");
339 if ((rc = tinyrad_dict_import(*dictp, test_dict_data_vendors, NULL, NULL, &errs)) != TRAD_SUCCESS) 327 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 @@
49/////////////////// 49///////////////////
50#pragma mark - Definitions 50#pragma mark - Definitions
51 51
52#define TEST_OPT_DFLT_DICT 0x0040UL
53
54 52
55///////////////// 53/////////////////
56// // 54// //
@@ -94,6 +92,7 @@ our_dict_diag_vendor(
94int 92int
95our_dict_initialize( 93our_dict_initialize(
96 unsigned opts, 94 unsigned opts,
95 unsigned tr_opts,
97 TinyRadDict ** dictp ); 96 TinyRadDict ** dictp );
98 97
99 98
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(
101 int opt_index; 101 int opt_index;
102 size_t pos; 102 size_t pos;
103 unsigned opts; 103 unsigned opts;
104 unsigned tr_opts;
104 TinyRadDict * dict; 105 TinyRadDict * dict;
105 TinyRadDictAttr * attr; 106 TinyRadDictAttr * attr;
106 const TinyRadDictAttrDef * attr_def; 107 const TinyRadDictAttrDef * attr_def;
@@ -120,7 +121,8 @@ main(
120 121
121 trutils_initialize(PROGRAM_NAME); 122 trutils_initialize(PROGRAM_NAME);
122 123
123 opts = TEST_OPT_DFLT_DICT; 124 opts = 0;
125 tr_opts = TRAD_NOINIT | TRAD_BUILTIN_DICT;
124 126
125 while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) 127 while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1)
126 { 128 {
@@ -172,7 +174,7 @@ main(
172 }; 174 };
173 175
174 // initialize test dictionary 176 // initialize test dictionary
175 if ((our_dict_initialize(opts, &dict))) 177 if ((our_dict_initialize(opts, tr_opts, &dict)))
176 return(1); 178 return(1);
177 179
178 trutils_verbose(opts, " %4s %9s %7s %s", "Type", "Vendor", "Vendor", "Name"); 180 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(
102 int opt_index; 102 int opt_index;
103 size_t pos; 103 size_t pos;
104 unsigned opts; 104 unsigned opts;
105 unsigned tr_opts;
105 TinyRadDict * dict; 106 TinyRadDict * dict;
106 TinyRadDictAttr * attr; 107 TinyRadDictAttr * attr;
107 TinyRadDictValue * value; 108 TinyRadDictValue * value;
@@ -122,7 +123,8 @@ main(
122 123
123 trutils_initialize(PROGRAM_NAME); 124 trutils_initialize(PROGRAM_NAME);
124 125
125 opts = TEST_OPT_DFLT_DICT; 126 opts = 0;
127 tr_opts = TRAD_NOINIT | TRAD_BUILTIN_DICT;
126 128
127 while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) 129 while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1)
128 { 130 {
@@ -174,7 +176,7 @@ main(
174 }; 176 };
175 177
176 // initialize test dictionary 178 // initialize test dictionary
177 if ((our_dict_initialize(opts, &dict))) 179 if ((our_dict_initialize(opts, tr_opts, &dict)))
178 return(1); 180 return(1);
179 181
180 trutils_verbose(opts, " %4s %9s %7s %s", "Type", "Vendor", "Vendor", "Name"); 182 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(
101 int opt_index; 101 int opt_index;
102 size_t pos; 102 size_t pos;
103 unsigned opts; 103 unsigned opts;
104 unsigned tr_opts;
104 TinyRadDict * dict; 105 TinyRadDict * dict;
105 TinyRadDictVendor * vendor; 106 TinyRadDictVendor * vendor;
106 const TinyRadDictVendorDef * vendor_def; 107 const TinyRadDictVendorDef * vendor_def;
@@ -120,7 +121,8 @@ main(
120 121
121 trutils_initialize(PROGRAM_NAME); 122 trutils_initialize(PROGRAM_NAME);
122 123
123 opts = TEST_OPT_DFLT_DICT; 124 opts = 0;
125 tr_opts = TRAD_NOINIT | TRAD_BUILTIN_DICT;
124 126
125 while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1) 127 while((c = getopt_long(argc, argv, short_opt, long_opt, &opt_index)) != -1)
126 { 128 {
@@ -172,7 +174,7 @@ main(
172 }; 174 };
173 175
174 // initialize test dictionary 176 // initialize test dictionary
175 if ((our_dict_initialize(opts, &dict))) 177 if ((our_dict_initialize(opts, tr_opts, &dict)))
176 return(1); 178 return(1);
177 179
178 trutils_verbose(opts, "Vendor format: vendor id/name"); 180 trutils_verbose(opts, "Vendor format: vendor id/name");