diff options
Diffstat (limited to 'cmd/sharefs/test')
| -rw-r--r-- | cmd/sharefs/test/configuration.nix | 39 | ||||
| -rw-r--r-- | cmd/sharefs/test/default.nix | 44 | ||||
| -rw-r--r-- | cmd/sharefs/test/test.py | 14 |
3 files changed, 97 insertions, 0 deletions
diff --git a/cmd/sharefs/test/configuration.nix b/cmd/sharefs/test/configuration.nix new file mode 100644 index 00000000..d9c011bc --- /dev/null +++ b/cmd/sharefs/test/configuration.nix @@ -0,0 +1,39 @@ +{ pkgs, ... }: +{ + users.users = { + alice = { + isNormalUser = true; + description = "Alice Foobar"; + password = "foobar"; + uid = 1000; + }; + }; + + home-manager.users.alice.home.stateVersion = "24.11"; + + # Automatically login on tty1 as a normal user: + services.getty.autologinUser = "alice"; + + # For benchmarking sharefs: + environment.systemPackages = [ pkgs.fsmark ]; + + virtualisation = { + diskSize = 6 * 1024; + + qemu.options = [ + # Increase test performance: + "-smp 8" + ]; + }; + + environment.hakurei = rec { + enable = true; + stateDir = "/var/lib/hakurei"; + sharefs.source = "${stateDir}/sdcard"; + users.alice = 0; + + extraHomeConfig = { + home.stateVersion = "23.05"; + }; + }; +} diff --git a/cmd/sharefs/test/default.nix b/cmd/sharefs/test/default.nix new file mode 100644 index 00000000..53ab8fc2 --- /dev/null +++ b/cmd/sharefs/test/default.nix @@ -0,0 +1,44 @@ +{ + testers, + + system, + self, +}: +testers.nixosTest { + name = "sharefs"; + nodes.machine = + { options, pkgs, ... }: + let + fhs = + let + hakurei = options.environment.hakurei.package.default; + in + pkgs.buildFHSEnv { + pname = "hakurei-fhs"; + inherit (hakurei) version; + targetPkgs = _: hakurei.targetPkgs; + extraOutputsToInstall = [ "dev" ]; + profile = '' + export PKG_CONFIG_PATH="/usr/share/pkgconfig:$PKG_CONFIG_PATH" + ''; + }; + in + { + environment.systemPackages = [ + # For go tests: + (pkgs.writeShellScriptBin "sharefs-workload-hakurei-tests" '' + cp -r "${self.packages.${system}.hakurei.src}" "/sdcard/hakurei" && cd "/sdcard/hakurei" + ${fhs}/bin/hakurei-fhs -c 'CC="clang -O3 -Werror" go test ./...' + '') + ]; + + imports = [ + ./configuration.nix + + self.nixosModules.hakurei + self.inputs.home-manager.nixosModules.home-manager + ]; + }; + + testScript = builtins.readFile ./test.py; +} diff --git a/cmd/sharefs/test/test.py b/cmd/sharefs/test/test.py new file mode 100644 index 00000000..58062e02 --- /dev/null +++ b/cmd/sharefs/test/test.py @@ -0,0 +1,14 @@ +start_all() +machine.wait_for_unit("multi-user.target") + +# Benchmark sharefs: +machine.succeed("fs_mark -v -d /sdcard/fs_mark -l /tmp/fs_log.txt") +machine.copy_from_vm("/tmp/fs_log.txt", "") + +# Check permissions: +machine.succeed("ls /var/lib/hakurei/sdcard/fs_mark") +machine.succeed("sudo -u alice rm -rf /sdcard/fs_mark") +machine.fail("ls /var/lib/hakurei/sdcard/fs_mark") + +# Run hakurei tests on sharefs: +machine.succeed("sudo -u alice sharefs-workload-hakurei-tests") |
