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 os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
class TestCase(unittest.TestCase):
|
||||
def run_osbuild(self, pipeline, store):
|
||||
osbuild_cmd = ["python3", "-m", "osbuild", "--json", "--store", store, "--libdir", ".", pipeline]
|
||||
def setUp(self):
|
||||
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)
|
||||
if build_pipeline:
|
||||
|
|
|
|||
|
|
@ -1,31 +1,29 @@
|
|||
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from . import osbuildtest
|
||||
|
||||
|
||||
class TestBoot(osbuildtest.TestCase):
|
||||
def test_boot(self):
|
||||
with tempfile.TemporaryDirectory(dir="/var/tmp") as store:
|
||||
_, output_id = self.run_osbuild("test/pipelines/f30-boot.json", store=store)
|
||||
_, output_id = self.run_osbuild("test/pipelines/f30-boot.json")
|
||||
|
||||
r = subprocess.run(["qemu-system-x86_64",
|
||||
"-snapshot",
|
||||
"-m", "1024",
|
||||
"-accel", "kvm:hvf:tcg",
|
||||
r = subprocess.run(["qemu-system-x86_64",
|
||||
"-snapshot",
|
||||
"-m", "1024",
|
||||
"-accel", "kvm:hvf:tcg",
|
||||
|
||||
# be silent
|
||||
"-nographic",
|
||||
"-monitor", "none",
|
||||
"-serial", "none",
|
||||
# be silent
|
||||
"-nographic",
|
||||
"-monitor", "none",
|
||||
"-serial", "none",
|
||||
|
||||
# create /dev/vport0p1
|
||||
"-chardev", "stdio,id=stdio",
|
||||
"-device", "virtio-serial",
|
||||
"-device", "virtserialport,chardev=stdio",
|
||||
# create /dev/vport0p1
|
||||
"-chardev", "stdio,id=stdio",
|
||||
"-device", "virtio-serial",
|
||||
"-device", "virtserialport,chardev=stdio",
|
||||
|
||||
f"{store}/refs/{output_id}/f30-boot.qcow2"
|
||||
], encoding="utf-8", capture_output=True, check=True)
|
||||
f"{self.store}/refs/{output_id}/f30-boot.qcow2"
|
||||
], 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