From 5fd7ff9cddc8da79f6a1e8e518e6c5afe769db0d Mon Sep 17 00:00:00 2001 From: Cedric Hombourger Date: Mon, 14 Aug 2023 12:32:10 +0200 Subject: [PATCH] tests: storage: add storage write test for bmap images Signed-off-by: Cedric Hombourger --- .github/workflows/main.yml | 1 + scripts/test-using-docker | 19 ++++++++++++++++--- tests/test_storage.py | 10 ++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 46c0c048..773aebe1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,7 @@ jobs: uses: actions/checkout@v3 - name: tox run: | + sudo apt-get install -y bmap-tools pip3 install --user tox tox -s mtda-nanopi-images: diff --git a/scripts/test-using-docker b/scripts/test-using-docker index fe88bc46..5cfed0a2 100644 --- a/scripts/test-using-docker +++ b/scripts/test-using-docker @@ -52,11 +52,23 @@ sed -i -e 's,command=bash,command=sh,g' ${tmp_dir}/docker.ini cd ${tmp_dir} -echo "# getting various docker images" +# Create a docker image with a file filled with zeroes in order to +# get holes in the resulting .tar image +cat << EOF > Dockerfile +FROM rockylinux:9 +RUN dd if=/dev/zero of=/EMPTY bs=1M count=8 +EOF + +docker build -t rockylinux . +rm -f Dockerfile + docker stop mtda-docker >/dev/null 2>&1 || true -for image in alpine debian ubuntu archlinux almalinux +for image in alpine debian ubuntu archlinux almalinux rockylinux do - docker pull ${image} >/dev/null || exit ${?} + if [ "${image}" != "rockylinux" ]; then + echo "# getting docker image '${image}' ..." + docker pull ${image} >/dev/null || exit ${?} + fi docker rm mtda-docker >/dev/null 2>&1 || true docker create --name=mtda-docker ${image} sh >/dev/null docker export mtda-docker > ${image}.tar || exit ${?} @@ -67,6 +79,7 @@ gzip -f debian.tar || exit ${?} zstd --rm -f ubuntu.tar || exit ${?} bzip2 -f archlinux.tar || exit ${?} xz -f almalinux.tar || exit ${?} +bmaptool create rockylinux.tar > rockylinux.tar.bmap || exit ${?} du -sh *.tar* echo "# starting mtda in the background" diff --git a/tests/test_storage.py b/tests/test_storage.py index 4cc9675a..3b643453 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -29,6 +29,16 @@ def test_write_raw(powered_off): assert Console.wait_for("Alpine") is not None +def test_write_bmap(powered_off): + assert Storage.to_host() is True + Storage.write("rockylinux.tar") + assert Storage.to_target() is True + + assert Target.on() is True + Console.send("cat /etc/os-release\r") + assert Console.wait_for("Rocky Linux") is not None + + def test_write_bz2(powered_off): assert Storage.to_host() is True Storage.write("archlinux.tar.bz2")