]> git.scottworley.com Git - nixos-qemu-vm-isolation/commitdiff
Reduce repetition in test script
authorScott Worley <scottworley@scottworley.com>
Fri, 21 Jul 2023 08:09:58 +0000 (01:09 -0700)
committerScott Worley <scottworley@scottworley.com>
Fri, 21 Jul 2023 09:49:17 +0000 (02:49 -0700)
checks/mount-grep.nix

index 33478ea687c2229ababb3b7faa4568e479a47b71..f7eb3a327a367e2ec4d16dee8cf271f0308b0e03 100644 (file)
@@ -18,16 +18,14 @@ pkgs: {
 
   testScript = ''
     start_all()
-    shared.wait_for_unit("multi-user.target")
-    private.wait_for_unit("multi-user.target")
-    useNixStoreImage.wait_for_unit("multi-user.target")
+    for machine in [shared, private, useNixStoreImage]:
+      machine.wait_for_unit("multi-user.target")
 
     shared.succeed("[[ $(mount | grep -c virt) -gt 0 ]]")
-    private.succeed("[[ $(mount | grep -c virt) -eq 0 ]]")
-    useNixStoreImage.succeed("[[ $(mount | grep -c virt) -eq 0 ]]")
-
     shared.succeed("[[ -e ${pkgs.pv} ]]")
-    private.fail("[[ -e ${pkgs.pv} ]]")
-    useNixStoreImage.fail("[[ -e ${pkgs.pv} ]]")
+
+    for machine in [private, useNixStoreImage]:
+      machine.succeed("[[ $(mount | grep -c virt) -eq 0 ]]")
+      machine.fail("[[ -e ${pkgs.pv} ]]")
   '';
 }