nixos/tests/systemd-repart: make sizeDiff configurable
The +32M is not sufficient to create additional partitions. Make it configurable.
This commit is contained in:
@@ -9,30 +9,37 @@ with pkgs.lib;
|
|||||||
|
|
||||||
let
|
let
|
||||||
# A testScript fragment that prepares a disk with some empty, unpartitioned
|
# A testScript fragment that prepares a disk with some empty, unpartitioned
|
||||||
# space. and uses it to boot the test with. Takes a single argument `machine`
|
# space. and uses it to boot the test with.
|
||||||
# from which the diskImage is extracted.
|
# Takes two arguments, `machine` from which the diskImage is extracted,
|
||||||
useDiskImage = machine: ''
|
# as well an optional `sizeDiff` (defaulting to +32M), describing how should
|
||||||
import os
|
# be resized.
|
||||||
import shutil
|
useDiskImage =
|
||||||
import subprocess
|
{
|
||||||
import tempfile
|
machine,
|
||||||
|
sizeDiff ? "+32M",
|
||||||
|
}:
|
||||||
|
''
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
|
||||||
tmp_disk_image = tempfile.NamedTemporaryFile()
|
tmp_disk_image = tempfile.NamedTemporaryFile()
|
||||||
|
|
||||||
shutil.copyfile("${machine.system.build.diskImage}/nixos.img", tmp_disk_image.name)
|
shutil.copyfile("${machine.system.build.diskImage}/nixos.img", tmp_disk_image.name)
|
||||||
|
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
"${machine.virtualisation.qemu.package}/bin/qemu-img",
|
"${machine.virtualisation.qemu.package}/bin/qemu-img",
|
||||||
"resize",
|
"resize",
|
||||||
"-f",
|
"-f",
|
||||||
"raw",
|
"raw",
|
||||||
tmp_disk_image.name,
|
tmp_disk_image.name,
|
||||||
"+32M",
|
"${sizeDiff}",
|
||||||
])
|
])
|
||||||
|
|
||||||
# Set NIX_DISK_IMAGE so that the qemu script finds the right disk image.
|
# Set NIX_DISK_IMAGE so that the qemu script finds the right disk image.
|
||||||
os.environ['NIX_DISK_IMAGE'] = tmp_disk_image.name
|
os.environ['NIX_DISK_IMAGE'] = tmp_disk_image.name
|
||||||
'';
|
'';
|
||||||
|
|
||||||
common =
|
common =
|
||||||
{
|
{
|
||||||
@@ -98,7 +105,7 @@ in
|
|||||||
testScript =
|
testScript =
|
||||||
{ nodes, ... }:
|
{ nodes, ... }:
|
||||||
''
|
''
|
||||||
${useDiskImage nodes.machine}
|
${useDiskImage { inherit (nodes) machine; }}
|
||||||
|
|
||||||
machine.start()
|
machine.start()
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
@@ -128,7 +135,7 @@ in
|
|||||||
testScript =
|
testScript =
|
||||||
{ nodes, ... }:
|
{ nodes, ... }:
|
||||||
''
|
''
|
||||||
${useDiskImage nodes.machine}
|
${useDiskImage { inherit (nodes) machine; }}
|
||||||
|
|
||||||
machine.start()
|
machine.start()
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
@@ -196,7 +203,7 @@ in
|
|||||||
testScript =
|
testScript =
|
||||||
{ nodes, ... }:
|
{ nodes, ... }:
|
||||||
''
|
''
|
||||||
${useDiskImage nodes.machine}
|
${useDiskImage { inherit (nodes) machine; }}
|
||||||
|
|
||||||
machine.start()
|
machine.start()
|
||||||
machine.wait_for_unit("multi-user.target")
|
machine.wait_for_unit("multi-user.target")
|
||||||
|
|||||||
Reference in New Issue
Block a user