fix: yield the console once the display manager starts
Since the boot only counted as complete when the default target was reached, bootvine kept taking its terminal back from a display manager that started while another unit still held graphical.target. The StartupFinished signal was never parsed either, so nothing else ended the watch.
This commit is contained in:
1 parent
58bef783cc
commit
631315ffe1
5 files changed
+128
-29
No files matched your search
@@ -293,7 +293,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_manager_activation_does_not_hand_the_console_over() {
|
||||
fn display_manager_activation_does_not_complete_the_boot() {
|
||||
let mut state = sample();
|
||||
queue_unit(&mut state, 20, waiting(HANDOFF_UNIT, &[]), 500 * MS);
|
||||
assert!(!state.display_manager_started());
|
||||
|
||||
@@ -147,16 +147,20 @@ impl<Desk: ConsoleDesk> WatchScreen<Desk> {
|
||||
{
|
||||
self.origin = origin;
|
||||
}
|
||||
if !self.state.is_complete() {
|
||||
return ControlFlow::Continue(());
|
||||
if self.state.display_manager_started() {
|
||||
let display_manager = self
|
||||
.state
|
||||
.handoff_unit
|
||||
.as_deref()
|
||||
.unwrap_or("display manager");
|
||||
self.desk
|
||||
.begin_handover(display_manager, now + self.timing.wait_for_display_manager);
|
||||
} else if self.state.is_complete() {
|
||||
self.desk.begin_handover(
|
||||
self.state.root.unit().unwrap_or("boot"),
|
||||
now + self.timing.keep_final_frame_for,
|
||||
);
|
||||
}
|
||||
let hold_for = if self.state.display_manager_started() {
|
||||
self.timing.wait_for_display_manager
|
||||
} else {
|
||||
self.timing.keep_final_frame_for
|
||||
};
|
||||
self.desk
|
||||
.begin_handover(self.state.root.unit().unwrap_or("boot"), now + hold_for);
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
@@ -261,3 +265,84 @@ fn drop_bold(frame: &mut Buffer) {
|
||||
.iter_mut()
|
||||
.for_each(|cell| cell.modifier.remove(Modifier::BOLD));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
boot_model::{ActiveState, Activity, HANDOFF_UNIT},
|
||||
demo_script::boot_test_fixtures::{MS, nested_boot_sample, queue_unit, waiting},
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
struct HandoverRecorder {
|
||||
glyphs: Glyphs,
|
||||
handovers: Vec<String>,
|
||||
}
|
||||
|
||||
impl ConsoleDesk for HandoverRecorder {
|
||||
fn glyphs(&self) -> &Glyphs {
|
||||
&self.glyphs
|
||||
}
|
||||
|
||||
fn drops_bold(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn prompt(&self, _now: Duration) -> Option<PasswordPrompt<'_>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn press_key(&mut self, _event: &Event, _now: Duration) -> ControlFlow<WatchEnding> {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
fn frame_passed(
|
||||
&mut self,
|
||||
_state: &mut BootState,
|
||||
_now: Duration,
|
||||
) -> ControlFlow<WatchEnding> {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
||||
fn begin_handover(&mut self, reached: &str, _deadline: Duration) {
|
||||
self.handovers.push(reached.to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
fn screen_watching(state: BootState) -> WatchScreen<HandoverRecorder> {
|
||||
let origin = BootOrigin {
|
||||
host: "test".to_owned(),
|
||||
system: None,
|
||||
generation: None,
|
||||
kernel: "Linux".to_owned(),
|
||||
};
|
||||
WatchScreen::new(
|
||||
state,
|
||||
HandoverRecorder::default(),
|
||||
origin,
|
||||
Colors::default(),
|
||||
Timing::default(),
|
||||
Duration::ZERO,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_manager_start_hands_over_before_the_boot_completes() {
|
||||
let mut state = nested_boot_sample();
|
||||
queue_unit(&mut state, 20, waiting(HANDOFF_UNIT, &[]), 500 * MS);
|
||||
let mut screen = screen_watching(state);
|
||||
let _ = screen.apply_boot_changes(Vec::new(), 1000 * MS);
|
||||
assert!(screen.desk.handovers.is_empty());
|
||||
let started = BootChange::UpdateActivity {
|
||||
unit: HANDOFF_UNIT.to_owned(),
|
||||
activity: Activity {
|
||||
state: Some(ActiveState::Active),
|
||||
..Activity::default()
|
||||
},
|
||||
};
|
||||
let _ = screen.apply_boot_changes(vec![started], 6000 * MS);
|
||||
assert!(!screen.state.is_complete());
|
||||
assert_eq!(screen.desk.handovers, [HANDOFF_UNIT]);
|
||||
}
|
||||
}
|
||||
@@ -389,7 +389,7 @@ fn parse_signal(message: &Message) -> Option<Signal> {
|
||||
let member = message.member()?;
|
||||
match (&*interface, &*member) {
|
||||
(MANAGER_INTERFACE, "JobNew" | "JobRemoved") => parse_job_signal(message, &member),
|
||||
(MANAGER_INTERFACE, "PropertiesChanged") => parse_manager_change(message),
|
||||
(MANAGER_INTERFACE, "StartupFinished") => Some(Signal::BootFinished),
|
||||
(PROPERTIES_INTERFACE, "PropertiesChanged") => parse_unit_change(message),
|
||||
_ => None,
|
||||
}
|
||||
@@ -425,24 +425,6 @@ fn parse_unit_change(message: &Message) -> Option<Signal> {
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_manager_change(message: &Message) -> Option<Signal> {
|
||||
let (changed_interface, changed, _invalidated): (String, PropMap, Vec<String>) =
|
||||
message.read3().ok()?;
|
||||
if changed_interface != MANAGER_INTERFACE {
|
||||
return None;
|
||||
}
|
||||
finish_timestamp(&changed)
|
||||
.is_some()
|
||||
.then_some(Signal::BootFinished)
|
||||
}
|
||||
|
||||
fn finish_timestamp(properties: &PropMap) -> Option<u64> {
|
||||
properties
|
||||
.get("FinishTimestampMonotonic")
|
||||
.and_then(|value| value.0.as_u64())
|
||||
.filter(|micros| *micros != 0)
|
||||
}
|
||||
|
||||
fn activity_from(properties: &PropMap) -> Activity {
|
||||
let monotonic = |property: &str| {
|
||||
properties
|
||||
@@ -461,3 +443,23 @@ fn activity_from(properties: &PropMap) -> Activity {
|
||||
active_exit: monotonic("ActiveExitTimestampMonotonic"),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn startup_finished_signal_marks_the_boot_finished() {
|
||||
let startup_finished = Message::signal(
|
||||
&Path::from(MANAGER_PATH),
|
||||
&MANAGER_INTERFACE.into(),
|
||||
&"StartupFinished".into(),
|
||||
)
|
||||
.append3(0_u64, 0_u64, 0_u64)
|
||||
.append3(0_u64, 0_u64, 0_u64);
|
||||
assert!(matches!(
|
||||
parse_signal(&startup_finished),
|
||||
Some(Signal::BootFinished)
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,14 @@
|
||||
settings.Manager.ShowStatus = lib.mkForce true;
|
||||
services.demo-db.serviceConfig.ExecStop = lib.mkForce (waitFor "release-demo-db");
|
||||
services.backdoor.before = [ "demo-db.service" ];
|
||||
services.demo-late-sensor = {
|
||||
wantedBy = [ "graphical.target" ];
|
||||
after = [ "greetd.service" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = waitFor "release-late-sensor";
|
||||
};
|
||||
};
|
||||
};
|
||||
virtualisation = {
|
||||
memorySize = 2048;
|
||||
|
||||
@@ -23,6 +23,10 @@ assert console_level() == "1", f"stage 2 sysctl reopened the kernel console: {co
|
||||
|
||||
machine.wait_for_unit("greetd.service")
|
||||
retry(lambda _: unit_state("bootvine") == "inactive", timeout_seconds=60)
|
||||
assert unit_state("demo-late-sensor") == "activating", "the boot finished before the display manager took over"
|
||||
assert foreground_terminal() != f"tty{BOOTVINE_TERMINAL}", "bootvine took the console back from the display manager"
|
||||
machine.succeed("touch /run/release-late-sensor")
|
||||
machine.wait_for_unit("graphical.target")
|
||||
|
||||
journal = bootvine_journal()
|
||||
print(journal)
|
||||
|
||||
Reference in new issue
Block a user