Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72a8ea3d authored by Mark Salyzyn's avatar Mark Salyzyn
Browse files

bootstat: test: fix Its_Just_So_Hard_reboot

Add the test injection to known list, and deal with an error
propagation issue.

Test: system/core/bootstat/boot_reason_test.sh Its_Just_So_Hard_reboot
Bug: 63736262
Change-Id: I4799956978a8884c69c830fcedd7febd143651fd
parent 972753e0
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -873,17 +873,30 @@ Its Just So Hard reboot test:
- NB: should report reboot,its_just_so_hard
- NB: expect log \"... I bootstat: Unknown boot reason: reboot,its_just_so_hard\"" ]
test_Its_Just_So_Hard_reboot() {
  if isDebuggable; then       # see below
    duration_test
  else
    duration_test `expr ${DURATION_DEFAULT} + ${DURATION_DEFAULT}`
  fi
  adb shell 'reboot "Its Just So Hard"'
  wait_for_screen
  EXPECT_PROPERTY sys.boot.reason reboot,its_just_so_hard
  EXPECT_PROPERTY persist.sys.boot.reason "reboot,Its Just So Hard"
  # Do not leave this test with an illegal value in persist.sys.boot.reason
  save_ret=${?}           # hold on to error code from above two lines
  if isDebuggable; then   # can do this easy, or we can do this hard.
    adb shell su root setprop persist.sys.boot.reason reboot,its_just_so_hard
  if checkDebugBuild; then
    flag=""
    ( exit ${save_ret} )  # because one can not just do ?=${save_ret}
  else
    flag="--allow_failure"
    report_bootstat_logs reboot,its_just_so_hard  # report what we have so far
    # user build mitigation
    adb shell reboot its_just_so_hard
    wait_for_screen
    ( exit ${save_ret} )  # because one can not just do ?=${save_ret}
    EXPECT_PROPERTY sys.boot.reason reboot,its_just_so_hard
  fi
  # Ensure persist.sys.boot.reason now valid, failure here acts as a signal
  # that we could choke up following tests.  For example test_properties.
  EXPECT_PROPERTY persist.sys.boot.reason reboot,its_just_so_hard ${flag}
  report_bootstat_logs reboot,its_just_so_hard
}
+2 −0
Original line number Diff line number Diff line
@@ -225,6 +225,8 @@ const std::map<std::string, int32_t> kBootReasonMap = {
    {"reboot,longkey", 85},
    {"reboot,2sec", 86},
    {"shutdown,thermal,battery", 87},
    {"reboot,its_just_so_hard", 88},  // produced by boot_reason_test
    {"reboot,Its Just So Hard", 89},  // produced by boot_reason_test
};

// Converts a string value representing the reason the system booted to an