1- {
2- makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix> ,
3- eval-config ? import <nixpkgs/nixos/lib/eval-config.nix> ,
4- qemu-common ? import <nixpkgs/nixos/lib/qemu-common.nix> ,
5- pkgs ? import <nixpkgs> { } ,
6- } :
7- let
8- lib = pkgs . lib ;
9- diskoLib = import ../lib {
10- inherit
11- lib
12- makeTest
13- eval-config
14- qemu-common
15- ;
16- } ;
17-
18- allTestFilenames = builtins . map ( lib . removeSuffix ".nix" ) (
19- builtins . filter ( x : lib . hasSuffix ".nix" x && x != "default.nix" ) (
20- lib . attrNames ( builtins . readDir ./. )
21- )
22- ) ;
23- incompatibleTests = lib . optionals pkgs . stdenv . buildPlatform . isRiscV64 [
24- "zfs"
25- "zfs-over-legacy"
26- "cli"
27- "module"
28- "complex"
29- ] ;
30- allCompatibleFilenames = lib . subtractLists incompatibleTests allTestFilenames ;
1+ # Main test runner for bcachefs TPM2 unlocking
2+ { pkgs , lib , ... } :
313
32- allTests = lib . genAttrs allCompatibleFilenames (
33- test : import ( ./. + "/ ${ test } .nix" ) { inherit diskoLib pkgs ; }
34- ) ;
4+ let
5+ # Import all test modules
6+ testModules = import ./bcachefs-tpm2-unlock.nix { inherit pkgs lib ; } ;
357in
36- allTests
8+ {
9+ # Run all tests as separate NixOS tests
10+ basicUnlock = testModules . basicUnlock ;
11+ tpmFailureFallback = testModules . tpmFailureFallback ;
12+ fido2Test = testModules . fido2Test ;
13+ performanceTest = testModules . performanceTest ;
14+
15+ # Combined test suite for CI
16+ testSuite = pkgs . symlinkJoin {
17+ name = "bcachefs-tpm2-test-suite" ;
18+ paths = [
19+ testModules . basicUnlock
20+ testModules . tpmFailureFallback
21+ testModules . fido2Test
22+ testModules . performanceTest
23+ ] ;
24+ } ;
25+
26+ # Test configuration for manual testing
27+ manualTestConfig = {
28+ imports = [ ./disko/module.nix ] ;
29+
30+ virtualisation . emptyDiskImages = [ 4096 ] ;
31+
32+ environment . systemPackages = with pkgs ; [
33+ clevis jose tpm2-tools bcachefs-tools libfido2
34+ util-linux time
35+ ] ;
36+
37+ disko . devices = {
38+ disk . main = {
39+ device = "/dev/vdb" ;
40+ type = "disk" ;
41+ content = {
42+ type = "gpt" ;
43+ partitions = {
44+ boot = {
45+ size = "1M" ;
46+ type = "EF02" ;
47+ } ;
48+ root = {
49+ size = "100%" ;
50+ content = {
51+ type = "bcachefs_filesystem" ;
52+ name = "nixos-main" ;
53+ mountpoint = "/" ;
54+ extraFormatArgs = [ "--encrypted" ] ;
55+
56+ unlock = {
57+ enable = true ;
58+ secretFiles = [
59+ ./test-secrets/tpm.jwe
60+ ./test-secrets/fido.jwe
61+ ./test-secrets/tang.jwe
62+ ] ;
63+ extraPackages = with pkgs ; [ libfido2 ] ;
64+ } ;
65+
66+ subvolumes = {
67+ "root" = { mountpoint = "/" ; } ;
68+ "home" = { mountpoint = "/home" ; } ;
69+ "nix" = { mountpoint = "/nix" ; } ;
70+ } ;
71+ } ;
72+ } ;
73+ } ;
74+ } ;
75+ } ;
76+ } ;
77+ } ;
78+ }
0 commit comments