@@ -45,6 +45,8 @@ int config_option_letters_test()
45
45
return ret ;
46
46
}
47
47
48
+ const uint8_t null_key [16 ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
49
+
48
50
static picoquic_quic_config_t param1 = {
49
51
1024 , /*uint32_t nb_connections; */
50
52
"/data/github/picoquic" , /* char const* solution_dir; */
@@ -78,7 +80,7 @@ static picoquic_quic_config_t param1 = {
78
80
"/data/www/" , /* char const* www_dir; */
79
81
{ 0x01 , 0x23 , 0x45 , 0x67 , 0x89 , 0xab , 0xcd , 0xef ,
80
82
0xFE , 0xDC , 0xBA , 0x98 , 0x76 , 0x54 , 0x32 , 0x10 }, /* uint8_t reset_seed[16]; */
81
- { 0 } , /* const uint8_t* ticket_encryption_key; */
83
+ null_key , /* const uint8_t* ticket_encryption_key; */
82
84
0 , /* size_t ticket_encryption_key_length; */
83
85
/* Server flags */
84
86
1 , /* unsigned int do_retry : 1; */
@@ -210,33 +212,34 @@ static config_error_test_t config_errors[] = {
210
212
{ 1 , { "-c" }},
211
213
{ 1 , { "-k" }},
212
214
{ 1 , { "-x" }},
213
- { 2 , { "-x" , "-1024 " }},
215
+ { 2 , { "-x" , "nb_cnx " }},
214
216
{ 1 , { "-l" }},
215
217
{ 1 , { "-b" }},
216
218
{ 1 , { "-q" }},
217
- { 2 , { "-p" , "-443 " }},
219
+ { 2 , { "-p" , "port " }},
218
220
{ 1 , { "-p" }},
219
221
{ 1 , { "-e" , }},
220
222
{ 2 , { "-e" , "a" }},
221
223
{ 1 , { "-m" }},
222
224
{ 1 , { "-m" , "-1" }},
223
225
{ 2 , { "-m" , "15360" }},
224
- { 2 , { "-P" , "-3 " }},
225
- { 2 , { "-O" , "-2 " }},
226
+ { 2 , { "-P" , "33 " }},
227
+ { 2 , { "-O" , "22 " }},
226
228
{ 2 , { "-M" , "5" }},
227
229
{ 2 , { "-R" , "17" }},
228
230
{ 1 , { "-w" }},
229
231
{ 2 , { "-s" , "0123456789abcdexyedcba9876543210" }},
230
232
{ 2 , { "-s" , "0123456789abcdeffedcba987654321" }},
231
233
{ 2 , { "-s" , "0123456789abcdeffedcba98765432" }},
232
- { 2 , { "-B" , "-1 " }},
234
+ { 2 , { "-B" , "buffer " }},
233
235
{ 1 , { "-F" }},
234
236
{ 2 , { "-j" , "3" }},
235
237
{ 1 , { "-i" }},
236
238
{ 2 , { "-I" , "-1" }},
237
239
{ 2 , { "-I" , "255" }},
238
240
{ 2 , { "-U" , "XY000002" }},
239
- { 2 , { "-W" , "-1" }}
241
+ { 2 , { "-W" , "cwin" }},
242
+ { 2 , { "-d" , "idle" }}
240
243
};
241
244
242
245
static size_t nb_config_errors = sizeof (config_errors ) / sizeof (config_error_test_t );
@@ -368,17 +371,23 @@ static int config_parse_command_line(picoquic_quic_config_t* actual, const char*
368
371
ret = -1 ;
369
372
break ;
370
373
}
371
- opt = x [1 ];
372
- opt_ind ++ ;
373
374
if (opt_ind < argc ) {
374
- optval = argv [opt_ind ];
375
- if (optval [0 ] == '-' ) {
376
- optval = NULL ;
377
- }
378
- else {
379
- opt_ind ++ ;
375
+ opt = x [1 ];
376
+ opt_ind ++ ;
377
+ if (opt_ind < argc ) {
378
+ optval = argv [opt_ind ];
379
+ if (optval [0 ] == '-' ) {
380
+ optval = NULL ;
381
+ }
382
+ else {
383
+ opt_ind ++ ;
384
+ }
380
385
}
381
386
}
387
+ else {
388
+ optval = NULL ;
389
+ }
390
+
382
391
ret = picoquic_config_command_line (opt , & opt_ind , argc , argv , optval , actual );
383
392
if (ret != 0 ) {
384
393
if (!expect_error ) {
@@ -394,49 +403,9 @@ static int config_parse_command_line(picoquic_quic_config_t* actual, const char*
394
403
static int config_parse_command_line_test (const picoquic_quic_config_t * expected , const char * * argv , int argc )
395
404
{
396
405
int ret = 0 ;
397
- int opt_ind = 0 ;
398
406
picoquic_quic_config_t actual ;
399
407
400
- #if 1
401
408
ret = config_parse_command_line (& actual , argv , argc , 0 );
402
- #else
403
-
404
-
405
- picoquic_config_init (& actual );
406
-
407
- while (opt_ind < argc && ret == 0 ) {
408
- const char * x = argv [opt_ind ];
409
- const char * optval = NULL ;
410
- int opt ;
411
- if (x == NULL ) {
412
- /* could not parse to the end! */
413
- DBG_PRINTF ("Unexpected stop after %d arguments, expected %d" , opt_ind , argc );
414
- ret = -1 ;
415
- break ;
416
- }
417
- else if (x [0 ] != '-' || x [1 ] == 0 || x [2 ] != 0 ) {
418
- /* could not parse to the end! */
419
- DBG_PRINTF ("Unexpected argument: %s" , x );
420
- ret = -1 ;
421
- break ;
422
- }
423
- opt = x [1 ];
424
- opt_ind ++ ;
425
- if (opt_ind < argc ) {
426
- optval = argv [opt_ind ];
427
- if (optval [0 ] == '-' ) {
428
- optval = NULL ;
429
- }
430
- else {
431
- opt_ind ++ ;
432
- }
433
- }
434
- ret = picoquic_config_command_line (opt , & opt_ind , argc , argv , optval , & actual );
435
- if (ret != 0 ) {
436
- DBG_PRINTF ("Could not parse opt -%c" , opt );
437
- }
438
- }
439
- #endif
440
409
441
410
if (ret == 0 ) {
442
411
ret = config_test_compare (expected , & actual );
0 commit comments