Skip to content

Commit

Permalink
nix: Test panicking both with and without opt
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Spinale <[email protected]>
  • Loading branch information
nspin committed Sep 25, 2024
1 parent 8748f75 commit c694055
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 31 deletions.
2 changes: 1 addition & 1 deletion crates/private/tests/root-task/panicking/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use sel4_root_task::{debug_println, panicking, root_task};

static F1_DROPPED: AtomicBool = AtomicBool::new(false);

#[root_task(stack_size = 4096 * 64, heap_size = 4096 * 16)] // TODO decrease stack size
#[root_task(heap_size = 4096 * 16)]
fn main(_: &sel4::BootInfoPtr) -> ! {
let _ = panicking::catch_unwind(|| {
f1();
Expand Down
76 changes: 46 additions & 30 deletions hacking/nix/scope/world/instances/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ in rec {
tests.root-task.config
tests.root-task.tls
tests.root-task.backtrace
tests.root-task.panicking.byConfig.abort.withAlloc
tests.root-task.panicking.byConfig.abort.withoutAlloc
tests.root-task.panicking.byConfig.unwind.withAlloc
tests.root-task.panicking.byConfig.unwind.withoutAlloc
# tests.root-task.panicking
tests.root-task.c
tests.root-task.verus
tests.root-task.dafny
Expand Down Expand Up @@ -179,41 +176,60 @@ in rec {
abort = null;
};

profile = {
release = true;
debug = false;
};

byConfig = lib.flip lib.mapAttrs panicStrategy
(panicStrategyName: _:
lib.flip lib.mapAttrs alloc
(_: allocFeatures: maybe (haveFullRuntime && haveUnwindingSupport) (mkInstance {
rootTask = mkTask {
rootCrate = crates.tests-root-task-panicking;
release = false;
features = allocFeatures ++ [ "panic-${panicStrategyName}" ];
extraProfile = {
panic = panicStrategyName;
};
};
extraPlatformArgs = lib.optionalAttrs canSimulate {
canAutomateSimply = panicStrategyName == "unwind";
};
})));

paths = [
[ "abort" "withAlloc" ]
[ "abort" "withoutAlloc" ]
[ "unwind" "withAlloc" ]
[ "unwind" "withoutAlloc" ]
];

automate = mkRunTests "run-all-panicking-tests" (lib.forEach paths (path: {
name = lib.concatStringsSep "." path;
value = (lib.attrByPath path (throw "x") byConfig).automate;
}));
(_: allocFeatures:
lib.flip lib.mapAttrs profile
(_: release:
maybe (haveFullRuntime && haveUnwindingSupport) (mkInstance {
rootTask = mkTask {
rootCrate = crates.tests-root-task-panicking;
inherit release;
features = allocFeatures ++ [ "panic-${panicStrategyName}" ];
extraProfile = {
panic = panicStrategyName;
};
};
extraPlatformArgs = lib.optionalAttrs canSimulate {
canAutomateSimply = panicStrategyName == "unwind";
};
}))));

paths = lib.mapCartesianProduct
({ panicStrategyName, allocName, profileName }: [ panicStrategyName allocName profileName ])
(lib.mapAttrs (lib.const lib.attrNames) {
panicStrategyName = panicStrategy;
allocName = alloc;
profileName = profile;
});

automate = mkRunTests "run-all-panicking-tests"
(lib.forEach
(lib.filter
(config: config != null)
(lib.forEach paths (path: lib.attrByPath path (throw "x") byConfig)))
(config: {
name = "test"; # TODO
value = config.automate;
}));

simulate = writeText "all-panicking-scripts" (toString (lib.forEach paths (path:
(lib.attrByPath path (throw "x") byConfig).simulate
)));

links = linkFarm "links" {
inherit simulate;
};

in {
inherit byConfig automate simulate;
inherit byConfig;
inherit links simulate automate;
};

c = maybe haveFullRuntime (callPackage ./c.nix {
Expand Down

0 comments on commit c694055

Please sign in to comment.