test: move temporary store to osbuildtest.TestCase
All tests will need a store. There's no need for each to create a temporary directory.
This commit is contained in:
parent
34098bf6c6
commit
2205e972d3
2 changed files with 26 additions and 20 deletions
|
|
@ -1,14 +1,22 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
class TestCase(unittest.TestCase):
|
class TestCase(unittest.TestCase):
|
||||||
def run_osbuild(self, pipeline, store):
|
def setUp(self):
|
||||||
osbuild_cmd = ["python3", "-m", "osbuild", "--json", "--store", store, "--libdir", ".", pipeline]
|
self.store = tempfile.mkdtemp(dir="/var/tmp")
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
shutil.rmtree(self.store)
|
||||||
|
|
||||||
|
def run_osbuild(self, pipeline):
|
||||||
|
osbuild_cmd = ["python3", "-m", "osbuild", "--json", "--store", self.store, "--libdir", ".", pipeline]
|
||||||
|
|
||||||
build_pipeline = os.getenv("OSBUILD_TEST_BUILD_PIPELINE", None)
|
build_pipeline = os.getenv("OSBUILD_TEST_BUILD_PIPELINE", None)
|
||||||
if build_pipeline:
|
if build_pipeline:
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,29 @@
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
|
||||||
import unittest
|
import unittest
|
||||||
from . import osbuildtest
|
from . import osbuildtest
|
||||||
|
|
||||||
|
|
||||||
class TestBoot(osbuildtest.TestCase):
|
class TestBoot(osbuildtest.TestCase):
|
||||||
def test_boot(self):
|
def test_boot(self):
|
||||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as store:
|
_, output_id = self.run_osbuild("test/pipelines/f30-boot.json")
|
||||||
_, output_id = self.run_osbuild("test/pipelines/f30-boot.json", store=store)
|
|
||||||
|
|
||||||
r = subprocess.run(["qemu-system-x86_64",
|
r = subprocess.run(["qemu-system-x86_64",
|
||||||
"-snapshot",
|
"-snapshot",
|
||||||
"-m", "1024",
|
"-m", "1024",
|
||||||
"-accel", "kvm:hvf:tcg",
|
"-accel", "kvm:hvf:tcg",
|
||||||
|
|
||||||
# be silent
|
# be silent
|
||||||
"-nographic",
|
"-nographic",
|
||||||
"-monitor", "none",
|
"-monitor", "none",
|
||||||
"-serial", "none",
|
"-serial", "none",
|
||||||
|
|
||||||
# create /dev/vport0p1
|
# create /dev/vport0p1
|
||||||
"-chardev", "stdio,id=stdio",
|
"-chardev", "stdio,id=stdio",
|
||||||
"-device", "virtio-serial",
|
"-device", "virtio-serial",
|
||||||
"-device", "virtserialport,chardev=stdio",
|
"-device", "virtserialport,chardev=stdio",
|
||||||
|
|
||||||
f"{store}/refs/{output_id}/f30-boot.qcow2"
|
f"{self.store}/refs/{output_id}/f30-boot.qcow2"
|
||||||
], encoding="utf-8", capture_output=True, check=True)
|
], encoding="utf-8", capture_output=True, check=True)
|
||||||
|
|
||||||
self.assertEqual(r.stdout.strip(), "running")
|
self.assertEqual(r.stdout.strip(), "running")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue