test/system: speed up podman cp dir from host to container

It makes the test a bit uglier but I cannot see a good way to sped this
up otherwise. I chnaged the created test to only start/stop the
contianer once instead of every test case iteration. This makes it about
2s faster locally.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2024-06-03 15:23:31 +02:00
parent 8d3f65b026
commit 8852614792
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
1 changed files with 12 additions and 6 deletions

View File

@ -360,20 +360,26 @@ load helpers
while read src dest dest_fullname description; do
run_podman cp $srcdir/$src destrunning:$dest
run_podman exec destrunning cat $dest_fullname/hostfile0 $dest_fullname/hostfile1
is "$(echo $output)" "${randomcontent[*]}" "$description (cp -> ctr:$dest - RUNNING)"
is "${lines[*]}" "${randomcontent[*]}" "$description (cp -> ctr:$dest - RUNNING)"
done < <(parse_table "$tests")
run_podman rm -t 0 -f destrunning
# CREATED container
run_podman create --name destcreated --workdir=/srv $cpimage sleep infinity
while read src dest dest_fullname description; do
run_podman create --name destcreated --workdir=/srv $cpimage sleep infinity
run_podman cp $srcdir/$src destcreated:$dest
run_podman start destcreated
run_podman exec destcreated cat $dest_fullname/hostfile0 $dest_fullname/hostfile1
is "$(echo $output)" "${randomcontent[*]}" "$description (cp -> ctr:$dest - CREATED)"
run_podman rm -t 0 -f destcreated
# tests checks are done below
done < <(parse_table "$tests")
# Now do the test checks, it is a bit ugly that we do this over two loops but this
# makes the test faster as we do not have to start/stop the container on every iteration.
run_podman start destcreated
while read src dest dest_fullname description; do
run_podman exec destcreated cat $dest_fullname/hostfile0 $dest_fullname/hostfile1
is "${lines[*]}" "${randomcontent[*]}" "$description (cp -> ctr:$dest - CREATED)"
done < <(parse_table "$tests")
run_podman rm -t 0 -f destcreated
run_podman create --name destnotdir --workdir=/srv $cpimage sleep infinity
run_podman 125 cp $srcdir destnotdir:/etc/os-release
is "$output" "Error: destination must be a directory when copying a directory" "cannot copy directory to file"