summaryrefslogtreecommitdiffstats
path: root/lib/tests/test_opts.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-03-30 14:02:13 (GMT)
committerThomas Guyot-Sionnest <dermoth@users.sourceforge.net>2008-03-30 14:02:13 (GMT)
commit8aa5ec317af49d811b1c4b65c905cca81f845321 (patch)
tree8dbf98859c71ae6c056bf23901f0e63482d99144 /lib/tests/test_opts.c
parentdf93abdbaf6fe9efdf41cfa822c4d3a816830ddb (diff)
downloadmonitoring-plugins-8aa5ec317af49d811b1c4b65c905cca81f845321.tar.gz
- Remove the last argument of np_extra_opts
- Code cleanups and comments git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1967 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib/tests/test_opts.c')
-rw-r--r--lib/tests/test_opts.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/lib/tests/test_opts.c b/lib/tests/test_opts.c
index 769a2df..7c173f3 100644
--- a/lib/tests/test_opts.c
+++ b/lib/tests/test_opts.c
@@ -57,7 +57,7 @@ int
57main (int argc, char **argv) 57main (int argc, char **argv)
58{ 58{
59 char **argv_test=NULL, **argv_known=NULL; 59 char **argv_test=NULL, **argv_known=NULL;
60 int i, argc_test, argc_new; 60 int i, argc_test;
61 61
62 plan_tests(11); 62 plan_tests(11);
63 63
@@ -68,9 +68,9 @@ main (int argc, char **argv)
68 argv_known=(char **)realloc(argv_known, 2*sizeof(char **)); 68 argv_known=(char **)realloc(argv_known, 2*sizeof(char **));
69 argv_known[0] = "prog_name"; 69 argv_known[0] = "prog_name";
70 argv_known[1] = NULL; 70 argv_known[1] = NULL;
71 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new); 71 argv_test=np_extra_opts(&argc_test, argv_test, "check_disk");
72 ok(array_diff(argc_new, argv_test, 1, argv_known), "No opts, returns correct argv/argc"); 72 ok(array_diff(argc_test, argv_test, 1, argv_known), "No opts, returns correct argv/argc");
73 my_free(&argc_new, argv_test); 73 my_free(&argc_test, argv_test);
74 74
75 argv_test=(char **)malloc(6*sizeof(char **)); 75 argv_test=(char **)malloc(6*sizeof(char **));
76 argv_test[0] = "prog_name"; 76 argv_test[0] = "prog_name";
@@ -87,9 +87,9 @@ main (int argc, char **argv)
87 argv_known[3] = "--arg3"; 87 argv_known[3] = "--arg3";
88 argv_known[4] = "val2"; 88 argv_known[4] = "val2";
89 argv_known[5] = NULL; 89 argv_known[5] = NULL;
90 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new); 90 argv_test=np_extra_opts(&argc_test, argv_test, "check_disk");
91 ok(array_diff(argc_new, argv_test, 5, argv_known), "No extra opts, verbatim copy of argv"); 91 ok(array_diff(argc_test, argv_test, 5, argv_known), "No extra opts, verbatim copy of argv");
92 my_free(&argc_new,argv_test); 92 my_free(&argc_test,argv_test);
93 93
94 argv_test=(char **)malloc(3*sizeof(char **)); 94 argv_test=(char **)malloc(3*sizeof(char **));
95 argv_test[0] = "prog_name"; 95 argv_test[0] = "prog_name";
@@ -102,9 +102,9 @@ main (int argc, char **argv)
102 argv_known[2] = "--this=Your Mother!"; 102 argv_known[2] = "--this=Your Mother!";
103 argv_known[3] = "--blank"; 103 argv_known[3] = "--blank";
104 argv_known[4] = NULL; 104 argv_known[4] = NULL;
105 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new); 105 argv_test=np_extra_opts(&argc_test, argv_test, "check_disk");
106 ok(array_diff(argc_new, argv_test, 4, argv_known), "Only extra opts using default section"); 106 ok(array_diff(argc_test, argv_test, 4, argv_known), "Only extra opts using default section");
107 my_free(&argc_new,argv_test); 107 my_free(&argc_test,argv_test);
108 108
109 argv_test=(char **)malloc(5*sizeof(char **)); 109 argv_test=(char **)malloc(5*sizeof(char **));
110 argv_test[0] = "prog_name"; 110 argv_test[0] = "prog_name";
@@ -119,9 +119,9 @@ main (int argc, char **argv)
119 argv_known[2] = "--something else=oops"; 119 argv_known[2] = "--something else=oops";
120 argv_known[3] = "--this=that"; 120 argv_known[3] = "--this=that";
121 argv_known[4] = NULL; 121 argv_known[4] = NULL;
122 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new); 122 argv_test=np_extra_opts(argc_test, argv_test, "check_disk");
123 ok(array_diff(argc_new, argv_test, 4, argv_known), "Only extra opts specified twice"); 123 ok(array_diff(argc_test, argv_test, 4, argv_known), "Only extra opts specified twice");
124 my_free(&argc_new,argv_test); 124 my_free(&argc_test,argv_test);
125 125
126 argv_test=(char **)malloc(7*sizeof(char **)); 126 argv_test=(char **)malloc(7*sizeof(char **));
127 argv_test[0] = "prog_name"; 127 argv_test[0] = "prog_name";
@@ -141,9 +141,9 @@ main (int argc, char **argv)
141 argv_known[5] = "--arg1=val1"; 141 argv_known[5] = "--arg1=val1";
142 argv_known[6] = "--arg2"; 142 argv_known[6] = "--arg2";
143 argv_known[7] = NULL; 143 argv_known[7] = NULL;
144 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new); 144 argv_test=np_extra_opts(argc_test, argv_test, "check_disk");
145 ok(array_diff(argc_new, argv_test, 7, argv_known), "twice extra opts using two sections"); 145 ok(array_diff(argc_test, argv_test, 7, argv_known), "twice extra opts using two sections");
146 my_free(&argc_new,argv_test); 146 my_free(&argc_test,argv_test);
147 147
148 /* Next three checks should die according to N::P - for now they're useful 148 /* Next three checks should die according to N::P - for now they're useful
149 * to test code is working properly (i.e. no srash or unexpected behavior) 149 * to test code is working properly (i.e. no srash or unexpected behavior)
@@ -162,9 +162,9 @@ main (int argc, char **argv)
162 argv_known[2] = "--arg3"; 162 argv_known[2] = "--arg3";
163 argv_known[3] = "val2"; 163 argv_known[3] = "val2";
164 argv_known[4] = NULL; 164 argv_known[4] = NULL;
165 argv_test=np_extra_opts(argc_test, argv_test, "check_missing", &argc_new); 165 argv_test=np_extra_opts(argc_test, argv_test, "check_missing");
166 ok(array_diff(argc_new, argv_test, 4, argv_known), "Missing section 1"); 166 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 1");
167 my_free(&argc_new,argv_test); 167 my_free(&argc_test,argv_test);
168 168
169 argv_test=(char **)malloc(7*sizeof(char **)); 169 argv_test=(char **)malloc(7*sizeof(char **));
170 argv_test[0] = "prog_name"; 170 argv_test[0] = "prog_name";
@@ -181,9 +181,9 @@ main (int argc, char **argv)
181 argv_known[2] = "--arg3"; 181 argv_known[2] = "--arg3";
182 argv_known[3] = "val2"; 182 argv_known[3] = "val2";
183 argv_known[4] = NULL; 183 argv_known[4] = NULL;
184 argv_test=np_extra_opts(argc_test, argv_test, "check_missing", &argc_new); 184 argv_test=np_extra_opts(argc_test, argv_test, "check_missing");
185 ok(array_diff(argc_new, argv_test, 4, argv_known), "Missing section 2"); 185 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 2");
186 my_free(&argc_new,argv_test); 186 my_free(&argc_test,argv_test);
187 187
188 argv_test=(char **)malloc(6*sizeof(char **)); 188 argv_test=(char **)malloc(6*sizeof(char **));
189 argv_test[0] = "prog_name"; 189 argv_test[0] = "prog_name";
@@ -199,9 +199,9 @@ main (int argc, char **argv)
199 argv_known[2] = "--arg3"; 199 argv_known[2] = "--arg3";
200 argv_known[3] = "val2"; 200 argv_known[3] = "val2";
201 argv_known[4] = NULL; 201 argv_known[4] = NULL;
202 argv_test=np_extra_opts(argc_test, argv_test, "check_missing", &argc_new); 202 argv_test=np_extra_opts(argc_test, argv_test, "check_missing");
203 ok(array_diff(argc_new, argv_test, 4, argv_known), "Missing section 3"); 203 ok(array_diff(argc_test, argv_test, 4, argv_known), "Missing section 3");
204 my_free(&argc_new,argv_test); 204 my_free(&argc_test,argv_test);
205 205
206 setenv("NAGIOS_CONFIG_PATH", ".", 1); 206 setenv("NAGIOS_CONFIG_PATH", ".", 1);
207 argv_test=(char **)malloc(6*sizeof(char **)); 207 argv_test=(char **)malloc(6*sizeof(char **));
@@ -219,9 +219,9 @@ main (int argc, char **argv)
219 argv_known[3] = "--arg3"; 219 argv_known[3] = "--arg3";
220 argv_known[4] = "val2"; 220 argv_known[4] = "val2";
221 argv_known[5] = NULL; 221 argv_known[5] = NULL;
222 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new); 222 argv_test=np_extra_opts(argc_test, argv_test, "check_disk");
223 ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 1"); 223 ok(array_diff(argc_test, argv_test, 5, argv_known), "Default section 1");
224 my_free(&argc_new,argv_test); 224 my_free(&argc_test,argv_test);
225 225
226 argv_test=(char **)malloc(6*sizeof(char **)); 226 argv_test=(char **)malloc(6*sizeof(char **));
227 argv_test[0] = "prog_name"; 227 argv_test[0] = "prog_name";
@@ -238,9 +238,9 @@ main (int argc, char **argv)
238 argv_known[3] = "--arg3"; 238 argv_known[3] = "--arg3";
239 argv_known[4] = "val2"; 239 argv_known[4] = "val2";
240 argv_known[5] = NULL; 240 argv_known[5] = NULL;
241 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new); 241 argv_test=np_extra_opts(argc_test, argv_test, "check_disk");
242 ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 2"); 242 ok(array_diff(argc_test, argv_test, 5, argv_known), "Default section 2");
243 my_free(&argc_new,argv_test); 243 my_free(&argc_test,argv_test);
244 244
245 argv_test=(char **)malloc(6*sizeof(char **)); 245 argv_test=(char **)malloc(6*sizeof(char **));
246 argv_test[0] = "prog_name"; 246 argv_test[0] = "prog_name";
@@ -257,9 +257,9 @@ main (int argc, char **argv)
257 argv_known[3] = "--arg3"; 257 argv_known[3] = "--arg3";
258 argv_known[4] = "val2"; 258 argv_known[4] = "val2";
259 argv_known[5] = NULL; 259 argv_known[5] = NULL;
260 argv_test=np_extra_opts(argc_test, argv_test, "check_disk", &argc_new); 260 argv_test=np_extra_opts(argc_test, argv_test, "check_disk");
261 ok(array_diff(argc_new, argv_test, 5, argv_known), "Default section 3"); 261 ok(array_diff(argc_test, argv_test, 5, argv_known), "Default section 3");
262 my_free(&argc_new,argv_test); 262 my_free(&argc_test,argv_test);
263 263
264 return exit_status(); 264 return exit_status();
265} 265}