1
1
mirror of https://github.com/NixOS/mobile-nixos.git synced 2024-09-17 14:57:22 +03:00

examples: Add testing/crash-before-switch-root

Can be used as a single point of failure (hah!)
This commit is contained in:
Samuel Dionne-Riel 2020-11-08 16:49:34 -05:00
parent f335005132
commit bb7e9a3b7b
4 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,38 @@
`crash-before-switch-root`
==========================
What does this test?
--------------------
A simple known method to crash the system at boot.
This can be used to check changes to the errors handling.
Why is this scary?
------------------
Not scary at all. Only pretty useless in daily use!
How is success defined?
-----------------------
The boot process should proceed normally (splash, etc), but be
interrupted before switch root.
The crashing happens *after* mounting /mnt, but *before* switching root.
Running
-------
Assuming you are `cd`'d into the root of a Mobile NixOS checkout:
```
nix-build ./examples/testing/crash-before-switch-root && ./result
```
This will build for qemu-x86_64 by default.
As always, be mindful of your `NIX_PATH`.

View File

@ -0,0 +1,9 @@
{ config, lib, pkgs, ... }:
{
mobile.boot.stage-1.tasks = [ ./crash.rb ];
mobile.boot.stage-1.bootConfig = {
log.level = lib.mkForce "INFO";
};
}

View File

@ -0,0 +1,12 @@
class Tasks::Crash < SingletonTask
def initialize()
# Runs before SwitchRoot
Targets[:SwitchRoot].add_dependency(:Task, self)
# And after /mnt is available
add_dependency(:Mount, "/mnt")
end
def run()
raise "This is an exception from init!"
end
end

View File

@ -0,0 +1,11 @@
{ device ? "qemu-x86_64" }:
let
system-build = import ../../../. {
inherit device;
configuration = [ { imports = [
../../hello/configuration.nix
./configuration.nix
]; } ];
};
in
system-build.build.default