Skip to content

Commit

Permalink
tests: Use mke2fs for sysimage creation
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Gladkov <[email protected]>
  • Loading branch information
legionus committed Feb 11, 2022
1 parent 80ec242 commit d9a39a5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 109 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,7 @@ jobs:
if: steps.last-status.outputs.status != 'passed'
run: |
sudo apt-get -qq -y update
sudo apt-get -qq -y install git e2fsprogs genext2fs expect qemu-kvm
- name: "Checkout genext2fs"
if: steps.last-status.outputs.status != 'passed'
uses: actions/checkout@v2
with:
repository: bestouff/genext2fs

- name: "Build genext2fs"
if: steps.last-status.outputs.status != 'passed'
run: |
./autogen.sh
./configure
make
sudo cp -vaf ./genext2fs /usr/bin/genext2fs
sudo apt-get -qq -y install git expect qemu-kvm
- name: "Checkout Repository"
if: steps.last-status.outputs.status != 'passed'
Expand Down
29 changes: 0 additions & 29 deletions testing/sh-functions
Original file line number Diff line number Diff line change
Expand Up @@ -116,33 +116,4 @@ prepare_testsuite()
> "$workdir/qemu-stdout"
}

convert_sysimage_ext3()
{
local sysimage_tar="$1"; shift
local sysimage_img="$1"; shift

sz_block=4096
n_blocks=$(( $(stat -c %s "$sysimage_tar") / $sz_block ))
n_inodes=$(tar -tf "$sysimage_tar" | wc -l)

blocks=$(( $n_blocks + ( ( $n_blocks * 30 ) / 100 ) ))

(
flock -e 0

run genext2fs -z -N $n_inodes -B $sz_block -b $blocks \
-L SYSIMAGE -a "$sysimage_tar" \
"$sysimage_img"

run /sbin/tune2fs \
-O dir_index,has_journal,uninit_bg \
"$sysimage_img"
) < "$0"

qemu_args \
-blockdev "driver=file,node-name=sysimage,filename=$sysimage_img" \
-device "virtio-blk,drive=sysimage" \
> "$top_workdir/qemu-sysimage"
}

trap 'exit_handler $?' EXIT HUP INT QUIT TERM
32 changes: 32 additions & 0 deletions testing/sh-pack-sysimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash -efu

gh_group_start "packing sysimage"

cat_exec "$top_workdir/run.sh" <<-EOF
#!/bin/bash -efux
bytes=\$(du -sb /image |cut -f1)
bytes=\$(( \$bytes + ( ( \$bytes * 30 ) / 100 ) ))
dd count=1 bs=\$bytes if=/dev/zero of=/host/$workdir/sysimage.img
/sbin/mke2fs -t ext3 -L SYSIMAGE -d /image /host/$workdir/sysimage.img
EOF

run podman run --rm -ti \
--mount="type=image,src=localhost/mi-$VENDOR:sysimage,dst=/image" \
--mount="type=tmpfs,destination=/image$builddir" \
--mount="type=bind,src=$topdir/.build/dest,dst=/image$builddir/.build/dest" \
--mount="type=bind,src=$topdir/data,dst=/image$builddir/data" \
--mount="type=bind,src=$topdir/features,dst=/image$builddir/features" \
--mount="type=bind,src=$topdir/guess,dst=/image$builddir/guess" \
--mount="type=bind,src=$topdir/kmodule.deps.d,dst=/image$builddir/kmodule.deps.d" \
--mount="type=bind,src=$topdir/tools,dst=/image$builddir/tools" \
--volume="$topdir:/host" \
"localhost/mi-$VENDOR:sysimage" "/host/$workdir/run.sh"

qemu_args \
-blockdev "driver=file,node-name=sysimage,filename=$top_workdir/sysimage.img" \
-device "virtio-blk,drive=sysimage" \
> "$top_workdir/qemu-sysimage"

gh_group_end
4 changes: 2 additions & 2 deletions testing/sh-run-kickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ for (( i=1; i <= KICKSTART_DISKS; i++ )); do

fn="$top_workdir/disk-$i.qcow2"
[ -f "$fn" ] ||
qemu-img create -q -f qcow2 "$fn" 3G
qemu-img create -q -f qcow2 -o preallocation=falloc,lazy_refcounts=on "$fn" 3G

qemu_args \
-blockdev "driver=qcow2,node-name=disk$i,file.driver=file,file.node-name=file$i,file.filename=$fn" \
-blockdev "driver=qcow2,node-name=disk$i,file.locking=off,file.driver=file,file.node-name=file$i,file.filename=$fn,cache.direct=on,cache.no-flush=on,discard=unmap,detect-zeroes=unmap" \
-device "virtio-blk,drive=disk$i,id=virtio$i"
done > "$top_workdir/qemu-disks"

Expand Down
22 changes: 1 addition & 21 deletions testing/testing-altlinux
Original file line number Diff line number Diff line change
Expand Up @@ -131,27 +131,7 @@ for step in "$@"; do
gh_group_end
fi

gh_group_start "adding make-initrd binaries"

run podman run --rm -ti \
--mount="type=image,src=localhost/mi-$VENDOR:sysimage,dst=/image" \
--mount="type=tmpfs,destination=/image$builddir" \
--mount="type=bind,src=$topdir/.build/dest,dst=/image$builddir/.build/dest" \
--mount="type=bind,src=$topdir/data,dst=/image$builddir/data" \
--mount="type=bind,src=$topdir/features,dst=/image$builddir/features" \
--mount="type=bind,src=$topdir/guess,dst=/image$builddir/guess" \
--mount="type=bind,src=$topdir/kmodule.deps.d,dst=/image$builddir/kmodule.deps.d" \
--mount="type=bind,src=$topdir/tools,dst=/image$builddir/tools" \
--volume="$topdir:/host" \
"$IMAGE" tar -C /image -cf /host/$workdir/sysimage.tar .

convert_sysimage_ext3 \
"$top_workdir/sysimage.tar" \
"$top_workdir/sysimage.img"

rm -f -- "$top_workdir/sysimage.tar"

gh_group_end
. "$topdir/testing/sh-pack-sysimage.sh"
;;
build-kickstart)
gh_group_start "creating kickstart image"
Expand Down
22 changes: 1 addition & 21 deletions testing/testing-fedora
Original file line number Diff line number Diff line change
Expand Up @@ -124,27 +124,7 @@ for step in "$@"; do
gh_group_end
fi

gh_group_start "adding make-initrd binaries"

run podman run --rm -ti \
--mount="type=image,src=localhost/mi-$VENDOR:sysimage,dst=/image" \
--mount="type=tmpfs,destination=/image$builddir" \
--mount="type=bind,src=$topdir/.build/dest,dst=/image$builddir/.build/dest" \
--mount="type=bind,src=$topdir/data,dst=/image$builddir/data" \
--mount="type=bind,src=$topdir/features,dst=/image$builddir/features" \
--mount="type=bind,src=$topdir/guess,dst=/image$builddir/guess" \
--mount="type=bind,src=$topdir/kmodule.deps.d,dst=/image$builddir/kmodule.deps.d" \
--mount="type=bind,src=$topdir/tools,dst=/image$builddir/tools" \
--volume="$topdir:/host" \
"$IMAGE" tar -C /image -cf /host/$workdir/sysimage.tar .

convert_sysimage_ext3 \
"$top_workdir/sysimage.tar" \
"$top_workdir/sysimage.img"

rm -f -- "$top_workdir/sysimage.tar"

gh_group_end
. "$topdir/testing/sh-pack-sysimage.sh"
;;
build-kickstart)
gh_group_start "creating kickstart image"
Expand Down
22 changes: 1 addition & 21 deletions testing/testing-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,7 @@ for step in "$@"; do
gh_group_end
fi

gh_group_start "adding make-initrd binaries"

run podman run --rm -ti \
--mount="type=image,src=localhost/mi-$VENDOR:sysimage,dst=/image" \
--mount="type=tmpfs,destination=/image$builddir" \
--mount="type=bind,src=$topdir/.build/dest,dst=/image$builddir/.build/dest" \
--mount="type=bind,src=$topdir/data,dst=/image$builddir/data" \
--mount="type=bind,src=$topdir/features,dst=/image$builddir/features" \
--mount="type=bind,src=$topdir/guess,dst=/image$builddir/guess" \
--mount="type=bind,src=$topdir/kmodule.deps.d,dst=/image$builddir/kmodule.deps.d" \
--mount="type=bind,src=$topdir/tools,dst=/image$builddir/tools" \
--volume="$topdir:/host" \
"$IMAGE" tar -C /image -cf /host/$workdir/sysimage.tar .

convert_sysimage_ext3 \
"$top_workdir/sysimage.tar" \
"$top_workdir/sysimage.img"

rm -f -- "$top_workdir/sysimage.tar"

gh_group_end
. "$topdir/testing/sh-pack-sysimage.sh"
;;
build-kickstart)
gh_group_start "creating kickstart image"
Expand Down

0 comments on commit d9a39a5

Please sign in to comment.