@@ -394,79 +394,117 @@ void test_parse_psm(void)
394
394
char * tau_ext ;
395
395
char * tau_legacy ;
396
396
};
397
- struct psm_strings disabled = {
397
+ struct psm_strings psm_disabled_tau_ext = {
398
398
.active_time = "11100000" ,
399
- .tau_ext = "11100000 " ,
399
+ .tau_ext = "00001000 " ,
400
400
.tau_legacy = "11100000" ,
401
401
};
402
+ struct psm_strings psm_disabled_tau_legacy = {
403
+ .active_time = "11100000" ,
404
+ .tau_ext = "11100000" ,
405
+ .tau_legacy = "01001010" ,
406
+ };
402
407
struct psm_strings tau_legacy = {
403
408
.active_time = "00001000" ,
404
409
.tau_ext = "11100000" ,
405
410
.tau_legacy = "00101010" ,
406
411
};
407
- struct psm_strings no_tau_legacy = {
412
+ struct psm_strings invalid_no_tau = {
408
413
.active_time = "00001000" ,
409
414
.tau_ext = "11100000" ,
415
+ .tau_legacy = "11100000" ,
410
416
};
411
417
struct psm_strings invalid_values = {
412
418
.active_time = "0001111111" ,
413
419
.tau_ext = "00001" ,
420
+ .tau_legacy = "111" ,
414
421
};
415
422
struct psm_strings valid_values_0 = {
416
423
.active_time = "01000001" ,
417
424
.tau_ext = "01000010" ,
425
+ .tau_legacy = "11100000" ,
418
426
};
419
427
struct psm_strings valid_values_1 = {
420
428
.active_time = "00100100" ,
421
429
.tau_ext = "00001000" ,
430
+ .tau_legacy = "11100000" ,
422
431
};
423
432
struct psm_strings valid_values_2 = {
424
433
.active_time = "00010000" ,
425
434
.tau_ext = "10111011" ,
435
+ .tau_legacy = "11100000" ,
426
436
};
427
437
428
- err = parse_psm (disabled .active_time , disabled .tau_ext , disabled .tau_legacy , & psm_cfg );
438
+ err = parse_psm (psm_disabled_tau_ext .active_time ,
439
+ psm_disabled_tau_ext .tau_ext ,
440
+ psm_disabled_tau_ext .tau_legacy ,
441
+ & psm_cfg );
429
442
TEST_ASSERT_EQUAL (0 , err );
430
- TEST_ASSERT_EQUAL (-1 , psm_cfg .tau );
443
+ TEST_ASSERT_EQUAL (4800 , psm_cfg .tau );
431
444
TEST_ASSERT_EQUAL (-1 , psm_cfg .active_time );
432
445
433
446
memset (& psm_cfg , 0 , sizeof (psm_cfg ));
434
447
435
- err = parse_psm (tau_legacy .active_time , tau_legacy .tau_ext , tau_legacy .tau_legacy ,
436
- & psm_cfg );
448
+ err = parse_psm (psm_disabled_tau_legacy .active_time ,
449
+ psm_disabled_tau_legacy .tau_ext ,
450
+ psm_disabled_tau_legacy .tau_legacy ,
451
+ & psm_cfg );
437
452
TEST_ASSERT_EQUAL (0 , err );
438
- TEST_ASSERT_EQUAL (600 , psm_cfg .tau );
439
- TEST_ASSERT_EQUAL (16 , psm_cfg .active_time );
453
+ TEST_ASSERT_EQUAL (3600 , psm_cfg .tau );
454
+ TEST_ASSERT_EQUAL (-1 , psm_cfg .active_time );
440
455
441
456
memset (& psm_cfg , 0 , sizeof (psm_cfg ));
442
457
443
- err = parse_psm (no_tau_legacy .active_time , no_tau_legacy .tau_ext , NULL , & psm_cfg );
458
+ err = parse_psm (tau_legacy .active_time ,
459
+ tau_legacy .tau_ext ,
460
+ tau_legacy .tau_legacy ,
461
+ & psm_cfg );
444
462
TEST_ASSERT_EQUAL (0 , err );
445
- TEST_ASSERT_EQUAL (-1 , psm_cfg .tau );
463
+ TEST_ASSERT_EQUAL (600 , psm_cfg .tau );
446
464
TEST_ASSERT_EQUAL (16 , psm_cfg .active_time );
447
465
448
466
memset (& psm_cfg , 0 , sizeof (psm_cfg ));
449
467
450
- err = parse_psm (invalid_values .active_time , invalid_values .tau_ext , NULL , & psm_cfg );
468
+ err = parse_psm (invalid_no_tau .active_time ,
469
+ invalid_no_tau .tau_ext ,
470
+ invalid_no_tau .tau_legacy ,
471
+ & psm_cfg );
472
+ TEST_ASSERT_EQUAL (- EINVAL , err );
473
+
474
+ memset (& psm_cfg , 0 , sizeof (psm_cfg ));
475
+
476
+ err = parse_psm (invalid_values .active_time ,
477
+ invalid_values .tau_ext ,
478
+ invalid_values .tau_legacy ,
479
+ & psm_cfg );
451
480
TEST_ASSERT_EQUAL (- EINVAL , err );
452
481
453
482
memset (& psm_cfg , 0 , sizeof (psm_cfg ));
454
483
455
- err = parse_psm (valid_values_0 .active_time , valid_values_0 .tau_ext , NULL , & psm_cfg );
484
+ err = parse_psm (valid_values_0 .active_time ,
485
+ valid_values_0 .tau_ext ,
486
+ valid_values_0 .tau_legacy ,
487
+ & psm_cfg );
456
488
TEST_ASSERT_EQUAL (0 , err );
457
489
TEST_ASSERT_EQUAL (72000 , psm_cfg .tau );
458
490
TEST_ASSERT_EQUAL (360 , psm_cfg .active_time );
459
491
460
492
memset (& psm_cfg , 0 , sizeof (psm_cfg ));
461
493
462
- err = parse_psm (valid_values_1 .active_time , valid_values_1 .tau_ext , NULL , & psm_cfg );
494
+ err = parse_psm (valid_values_1 .active_time ,
495
+ valid_values_1 .tau_ext ,
496
+ valid_values_1 .tau_legacy ,
497
+ & psm_cfg );
463
498
TEST_ASSERT_EQUAL (0 , err );
464
499
TEST_ASSERT_EQUAL (4800 , psm_cfg .tau );
465
500
TEST_ASSERT_EQUAL (240 , psm_cfg .active_time );
466
501
467
502
memset (& psm_cfg , 0 , sizeof (psm_cfg ));
468
503
469
- err = parse_psm (valid_values_2 .active_time , valid_values_2 .tau_ext , NULL , & psm_cfg );
504
+ err = parse_psm (valid_values_2 .active_time ,
505
+ valid_values_2 .tau_ext ,
506
+ valid_values_2 .tau_legacy ,
507
+ & psm_cfg );
470
508
TEST_ASSERT_EQUAL (0 , err );
471
509
TEST_ASSERT_EQUAL (1620 , psm_cfg .tau );
472
510
TEST_ASSERT_EQUAL (32 , psm_cfg .active_time );
0 commit comments