Skip to content

Commit 78d2c6a

Browse files
committed
test: pack_mapping: switch to xargs rather than find -exec
This decreases the test time by ~6 seconds and makes it more readable: % time ( sudo find "bundle/rootfs" -exec stat -c '%u:%g' {} \; >/dev/null ) ( sudo find "bundle/rootfs" -exec stat -c '%u:%g' {} \; > /dev/null; ) 0.07s user 0.37s system 12% cpu 3.492 total % time ( sudo find "bundle/rootfs" | sudo xargs stat -c '%u:%g' >/dev/null ) ( sudo find "bundle/rootfs" | sudo xargs stat -c '%u:%g' > /dev/null; ) 0.03s user 0.01s system 126% cpu 0.032 total Signed-off-by: Aleksa Sarai <[email protected]>
1 parent e7be525 commit 78d2c6a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/pack_mapping.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function teardown() {
4343
[ -f "$BUNDLE_A/config.json" ]
4444

4545
# Check that all of the files have a UID owner >=1337 and a GID owner >=8888.
46-
find "$BUNDLE_A/rootfs" -exec stat -c '%u:%g' {} \; | while read -r line; do
46+
find "$BUNDLE_A/rootfs" | xargs stat -c '%u:%g' | while read -r line; do
4747
uid=$(echo "$line" | cut -d: -f1)
4848
gid=$(echo "$line" | cut -d: -f2)
4949
[ "$uid" -ge 1337 ] && [ "$uid" -lt "$((1337 + 65535))" ]
@@ -59,7 +59,7 @@ function teardown() {
5959
[ -f "$BUNDLE_B/config.json" ]
6060

6161
# Check that all of the files have a UID owner >=8080 and a GID owner >=7777.
62-
find "$BUNDLE_B/rootfs" -exec stat -c '%u:%g' {} \; | while read -r line; do
62+
find "$BUNDLE_B/rootfs" | xargs stat -c '%u:%g' | while read -r line; do
6363
uid=$(echo "$line" | cut -d: -f1)
6464
gid=$(echo "$line" | cut -d: -f2)
6565
[ "$uid" -ge 8080 ] && [ "$uid" -lt "$((8080 + 65535))" ]

0 commit comments

Comments
 (0)