@@ -511,19 +511,27 @@ BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
511
511
/**
512
512
* prep_mmc_bootdev() - Set up an mmc bootdev so we can access other distros
513
513
*
514
+ * After calling this function, set std->bootdev_order to *@old_orderp to
515
+ * restore normal operation of bootstd (i.e. with the original bootdev order)
516
+ *
514
517
* @uts: Unit test state
515
- * @mmc_dev: MMC device to use, e.g. "mmc4"
518
+ * @mmc_dev: MMC device to use, e.g. "mmc4". Note that this must remain valid
519
+ * in the caller until
520
+ * @bind_cros: true to bind the ChromiumOS bootmeth
521
+ * @old_orderp: Returns the original bootdev order, which must be restored
516
522
* Returns 0 on success, -ve on failure
517
523
*/
518
524
static int prep_mmc_bootdev (struct unit_test_state * uts , const char * mmc_dev ,
519
- bool bind_cros )
525
+ bool bind_cros , const char * * * old_orderp )
520
526
{
521
- const char * order [] = {"mmc2" , "mmc1" , mmc_dev , NULL };
527
+ static const char * order [] = {"mmc2" , "mmc1" , NULL , NULL };
522
528
struct udevice * dev , * bootstd ;
523
529
struct bootstd_priv * std ;
524
530
const char * * old_order ;
525
531
ofnode root , node ;
526
532
533
+ order [2 ] = mmc_dev ;
534
+
527
535
/* Enable the mmc4 node since we need a second bootflow */
528
536
root = oftree_root (oftree_default ());
529
537
node = ofnode_find_subnode (root , mmc_dev );
@@ -546,26 +554,49 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev,
546
554
std = dev_get_priv (bootstd );
547
555
old_order = std -> bootdev_order ;
548
556
std -> bootdev_order = order ;
557
+ * old_orderp = old_order ;
558
+
559
+ return 0 ;
560
+ }
561
+
562
+ /**
563
+ * scan_mmc_bootdev() - Set up an mmc bootdev so we can access other distros
564
+ *
565
+ * @uts: Unit test state
566
+ * @mmc_dev: MMC device to use, e.g. "mmc4"
567
+ * @bind_cros: true to bind the ChromiumOS bootmeth
568
+ * Returns 0 on success, -ve on failure
569
+ */
570
+ static int scan_mmc_bootdev (struct unit_test_state * uts , const char * mmc_dev ,
571
+ bool bind_cros )
572
+ {
573
+ struct bootstd_priv * std ;
574
+ struct udevice * bootstd ;
575
+ const char * * old_order ;
576
+
577
+ ut_assertok (prep_mmc_bootdev (uts , mmc_dev , bind_cros , & old_order ));
549
578
550
579
console_record_reset_enable ();
551
580
ut_assertok (run_command ("bootflow scan" , 0 ));
552
581
ut_assert_console_end ();
553
582
554
583
/* Restore the order used by the device tree */
584
+ ut_assertok (uclass_first_device_err (UCLASS_BOOTSTD , & bootstd ));
585
+ std = dev_get_priv (bootstd );
555
586
std -> bootdev_order = old_order ;
556
587
557
588
return 0 ;
558
589
}
559
590
560
591
/**
561
- * prep_mmc4_bootdev () - Set up the mmc4 bootdev so we can access a fake Armbian
592
+ * scan_mmc4_bootdev () - Set up the mmc4 bootdev so we can access a fake Armbian
562
593
*
563
594
* @uts: Unit test state
564
595
* Returns 0 on success, -ve on failure
565
596
*/
566
- static int prep_mmc4_bootdev (struct unit_test_state * uts )
597
+ static int scan_mmc4_bootdev (struct unit_test_state * uts )
567
598
{
568
- ut_assertok (prep_mmc_bootdev (uts , "mmc4" , false));
599
+ ut_assertok (scan_mmc_bootdev (uts , "mmc4" , false));
569
600
570
601
return 0 ;
571
602
}
@@ -575,7 +606,7 @@ static int bootflow_cmd_menu(struct unit_test_state *uts)
575
606
{
576
607
char prev [3 ];
577
608
578
- ut_assertok (prep_mmc4_bootdev (uts ));
609
+ ut_assertok (scan_mmc4_bootdev (uts ));
579
610
580
611
/* Add keypresses to move to and select the second one in the list */
581
612
prev [0 ] = CTL_CH ('n' );
@@ -681,7 +712,7 @@ static int bootflow_menu_theme(struct unit_test_state *uts)
681
712
ofnode node ;
682
713
int i ;
683
714
684
- ut_assertok (prep_mmc4_bootdev (uts ));
715
+ ut_assertok (scan_mmc4_bootdev (uts ));
685
716
686
717
ut_assertok (bootflow_menu_new (& exp ));
687
718
node = ofnode_path ("/bootstd/theme" );
@@ -996,7 +1027,7 @@ BOOTSTD_TEST(bootflow_cmdline_special, 0);
996
1027
/* Test ChromiumOS bootmeth */
997
1028
static int bootflow_cros (struct unit_test_state * uts )
998
1029
{
999
- ut_assertok (prep_mmc_bootdev (uts , "mmc5" , true));
1030
+ ut_assertok (scan_mmc_bootdev (uts , "mmc5" , true));
1000
1031
ut_assertok (run_command ("bootflow list" , 0 ));
1001
1032
1002
1033
ut_assert_nextlinen ("Showing all" );
0 commit comments