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:
parent
f335005132
commit
bb7e9a3b7b
38
examples/testing/crash-before-switch-root/README.md
Normal file
38
examples/testing/crash-before-switch-root/README.md
Normal 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`.
|
@ -0,0 +1,9 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
mobile.boot.stage-1.tasks = [ ./crash.rb ];
|
||||
|
||||
mobile.boot.stage-1.bootConfig = {
|
||||
log.level = lib.mkForce "INFO";
|
||||
};
|
||||
}
|
12
examples/testing/crash-before-switch-root/crash.rb
Normal file
12
examples/testing/crash-before-switch-root/crash.rb
Normal 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
|
11
examples/testing/crash-before-switch-root/default.nix
Normal file
11
examples/testing/crash-before-switch-root/default.nix
Normal 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
|
Loading…
Reference in New Issue
Block a user