Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions slices/e2fsprogs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package: e2fsprogs

essential:
- e2fsprogs_copyright

slices:
standard:
essential:
- e2fsprogs_advanced
- e2fsprogs_attr
- e2fsprogs_debug
- e2fsprogs_fsck
- e2fsprogs_mkfs
- e2fsprogs_services
- e2fsprogs_tune

# Core filesystem checking and repair tools
fsck:
essential:
- libblkid1_libs
- libc6_libs
- libcom-err2_libs
- libext2fs2t64_libs
- libuuid1_libs
contents:
/usr/sbin/e2fsck:
/usr/sbin/fsck.ext2:
/usr/sbin/fsck.ext3:
/usr/sbin/fsck.ext4:
Comment on lines +27 to +29
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/usr/sbin/fsck.ext2:
/usr/sbin/fsck.ext3:
/usr/sbin/fsck.ext4:
/usr/sbin/fsck.ext2: # Symlink to e2fsck
/usr/sbin/fsck.ext3: # Symlink to e2fsck
/usr/sbin/fsck.ext4: # Symlink to e2fsck


# Filesystem creation tools
mkfs:
essential:
- e2fsprogs_config
- libblkid1_libs
- libc6_libs
- libcom-err2_libs
- libext2fs2t64_libs
- libuuid1_libs
contents:
/usr/sbin/mke2fs:
/usr/sbin/mkfs.ext2:
/usr/sbin/mkfs.ext3:
/usr/sbin/mkfs.ext4:
Comment on lines +42 to +44
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/usr/sbin/mkfs.ext2:
/usr/sbin/mkfs.ext3:
/usr/sbin/mkfs.ext4:
/usr/sbin/mkfs.ext2: # Symlink to mke2fs
/usr/sbin/mkfs.ext3: # Symlink to mke2fs
/usr/sbin/mkfs.ext4: # Symlink to mke2fs


# Filesystem tuning and maintenance
tune:
essential:
- libblkid1_libs
- libc6_libs
- libcom-err2_libs
- libext2fs2t64_libs
- libuuid1_libs
contents:
/usr/sbin/e2label:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/usr/sbin/e2label:
/usr/sbin/e2label: # Symlink to tune2fs

/usr/sbin/resize2fs:
/usr/sbin/tune2fs:

# Debugging and diagnostic tools
debug:
essential:
- libblkid1_libs
- libc6_libs
- libcom-err2_libs
- libext2fs2t64_libs
- libss2_libs
- libuuid1_libs
contents:
/usr/sbin/badblocks:
/usr/sbin/debugfs:
/usr/sbin/dumpe2fs:
/usr/sbin/e2freefrag:
/usr/sbin/e2image:
/usr/sbin/e2mmpstatus:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/usr/sbin/e2mmpstatus:
/usr/sbin/e2mmpstatus: # Symlink to dumpe2fs


# File attribute tools
attr:
essential:
- libc6_libs
- libcom-err2_libs
contents:
/usr/bin/chattr:
/usr/bin/lsattr:

# Advanced features
advanced:
essential:
- libc6_libs
- libext2fs2t64_libs
contents:
/usr/sbin/e2undo:
/usr/sbin/e4crypt:
/usr/sbin/e4defrag:
/usr/sbin/filefrag:
/usr/sbin/mklost+found:

# Scrubbing/integrity checking
scrub:
essential:
- e2fsprogs_config
- e2fsprogs_fsck
- systemd_services
contents:
/usr/libexec/e2fsprogs/e2scrub_all_cron:
/usr/libexec/e2fsprogs/e2scrub_fail:
/usr/sbin/e2scrub:
/usr/sbin/e2scrub_all:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e2scrub and e2scrub_all are bash scripts. they should be in a slice called scripts, and have a dependency on bash_bins, base-files_bin (due to the shebang) and a pile of utils. then, if you want a slice named after a function, you could do something like this:

scrub:
  essential:
    - e2fsprogs_scripts

scripts:
  ...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also these should be tested. it looks like they both have help if you supply some non-existent flag. you can then assert the return code is 2. this is a bit annoying to do with the -e flag (which i nonetheless recommend strongly. here is a small working example

#!/usr/bin/env -S bash -ex

function my_program {
  echo "doing something"
  return 33
}

status_file="$(mktemp)"
trap "rm -f $status_file" EXIT

out="$(
  set +e
  my_program
  echo "$?" >"$status_file"
)"
code="$(cat "$status_file")"

echo "code: $code"
echo "output: $out"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, i've done the analysis of e2scrub and e2scrub_all and they depend on the following binaries:

e2scrub:

echo
awk
date
dumpe2fs
fstrim
grep
lsblk
lvs
realpath
sleep

e2scrub_all:

echo
dumpe2fs
grep
lsblk
lvs
readlink
sed
systemd-escape

i think you can skip the systemd part since the script accounts for it possibly not being there, but do add a comment saying that systemd-escape is needed for full systemd functionality


config:
contents:
/etc/e2scrub.conf:
/etc/mke2fs.conf:

services:
essential:
- e2fsprogs_scrub
- logsave_bins
contents:
/etc/cron.d/e2scrub_all:
/usr/lib/systemd/system/e2scrub@.service:
/usr/lib/systemd/system/e2scrub_all.service:
/usr/lib/systemd/system/e2scrub_all.timer:
/usr/lib/systemd/system/e2scrub_fail@.service:
/usr/lib/systemd/system/e2scrub_reap.service:
/usr/lib/udev/rules.d/64-ext4.rules:
/usr/lib/udev/rules.d/96-e2scrub.rules:

copyright:
contents:
/usr/share/doc/e2fsprogs/copyright:
16 changes: 16 additions & 0 deletions slices/libext2fs2t64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package: libext2fs2t64

essential:
- libext2fs2t64_copyright

slices:
libs:
essential:
- libc6_libs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- libc6_libs
- libc6_libs
- libcom-err2_libs

libcom-err2_libs requires libcom_err.so.2 from libcom-err2. here's ldd output:

	linux-vdso.so.1 (0x0000ffff8084c000)
	libcom_err.so.2 => /usr/lib/aarch64-linux-gnu/libcom_err.so.2 (0x0000ffff80740000)
	libc.so.6 => /usr/lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff80540000)
	/lib/ld-linux-aarch64.so.1 (0x0000ffff80810000)

contents:
/usr/lib/*-linux-*/libe2p.so.2*:
/usr/lib/*-linux-*/libext2fs.so.2*:

copyright:
contents:
/usr/share/doc/libext2fs2t64/copyright:
16 changes: 16 additions & 0 deletions slices/libss2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package: libss2

essential:
- libss2_copyright

slices:
libs:
essential:
- libc6_libs
- libcom-err2_libs
contents:
/usr/lib/*-linux-*/libss.so.*:

copyright:
contents:
/usr/share/doc/libss2/copyright:
79 changes: 79 additions & 0 deletions tests/spread/integration/e2fsprogs/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
summary: Integration tests for e2fsprogs

execute: |
rootfs="$(install-slices e2fsprogs_standard)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that standard contains everything, but we should test each of the slices separately to guarantee that they can work standalone.

For a better coverage I'd suggest to just run some smoke tests for the standard slice (just run -v and -h for the binaries) and move the functionality testing to a test for each individual slice.

Use variant and separated sh scripts for each variant (anticipating @lczyk's comment :p ) - For reference: example

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. seconded ☝️ :) makes for a muuuch cleaner code imo (bash linting + syntax highlight of the test files) + spread runs all the bits as separate tests, so if one breaks it does not take the whole test down


cleanup() {
umount -l "${rootfs}/dev" 2>/dev/null || true
rm -f "${rootfs}/tmp/ext2.img" "${rootfs}/tmp/ext3.img" "${rootfs}/tmp/ext4.img" "${rootfs}/tmp/ext4.e2i" "${rootfs}/tmp/testfile" 2>/dev/null || true
rm -rf "${rootfs}/tmp/mklostfound" 2>/dev/null || true
}
trap cleanup EXIT

mkdir -p "${rootfs}/dev" "${rootfs}/tmp"
mount --bind /dev "${rootfs}/dev"

# Basic smoke: versions/help
chroot "${rootfs}" /usr/sbin/e2fsck -V >/dev/null
chroot "${rootfs}" /usr/sbin/mke2fs -V >/dev/null
chroot "${rootfs}" /usr/sbin/debugfs -V >/dev/null

# Create tiny filesystem images on the host (no real devices touched)
dd if=/dev/zero of="${rootfs}/tmp/ext2.img" bs=1M count=16
dd if=/dev/zero of="${rootfs}/tmp/ext3.img" bs=1M count=16
dd if=/dev/zero of="${rootfs}/tmp/ext4.img" bs=1M count=16

# mkfs.* and fsck.*: do something real but safe (-n for fsck)
chroot "${rootfs}" /usr/sbin/mkfs.ext2 -F /tmp/ext2.img >/dev/null
chroot "${rootfs}" /usr/sbin/fsck.ext2 -n /tmp/ext2.img >/dev/null

chroot "${rootfs}" /usr/sbin/mkfs.ext3 -F /tmp/ext3.img >/dev/null
chroot "${rootfs}" /usr/sbin/fsck.ext3 -n /tmp/ext3.img >/dev/null

chroot "${rootfs}" /usr/sbin/mkfs.ext4 -F /tmp/ext4.img >/dev/null
chroot "${rootfs}" /usr/sbin/fsck.ext4 -n /tmp/ext4.img >/dev/null

# e2fsck should also be able to check the image directly
chroot "${rootfs}" /usr/sbin/e2fsck -fn /tmp/ext4.img >/dev/null

# Label/tune/dump/debug/resize against the ext4 image
chroot "${rootfs}" /usr/sbin/e2label /tmp/ext4.img TESTIMG
chroot "${rootfs}" /usr/sbin/e2label /tmp/ext4.img | grep -F TESTIMG >/dev/null

chroot "${rootfs}" /usr/sbin/tune2fs -l /tmp/ext4.img | grep -E '^Filesystem volume name:[[:space:]]*TESTIMG$' >/dev/null
chroot "${rootfs}" /usr/sbin/dumpe2fs -h /tmp/ext4.img | grep -E '^Filesystem volume name:[[:space:]]*TESTIMG$' >/dev/null
chroot "${rootfs}" /usr/sbin/resize2fs -P /tmp/ext4.img >/dev/null
chroot "${rootfs}" /usr/sbin/debugfs -R 'stats' /tmp/ext4.img | grep -E '^Block size:' >/dev/null

# Other diagnostic tools
chroot "${rootfs}" /usr/sbin/filefrag -v /tmp/ext4.img >/dev/null
chroot "${rootfs}" /usr/sbin/badblocks -sv /tmp/ext4.img >/dev/null

# e2image: generate a raw metadata image and ensure it was created
chroot "${rootfs}" /usr/sbin/e2image -r /tmp/ext4.img /tmp/ext4.e2i >/dev/null
test -s "${rootfs}/tmp/ext4.e2i"

# Attributes: best-effort functional smoke on a regular file
echo "hello" > "${rootfs}/tmp/testfile"
chroot "${rootfs}" /usr/bin/lsattr /tmp/testfile >/dev/null || true
chroot "${rootfs}" /usr/bin/chattr --help 2>&1 | grep -i 'Usage' >/dev/null

# Advanced tools: cover binaries without requiring a mounted ext4 filesystem
chroot "${rootfs}" /usr/sbin/e4crypt help 2>&1 | grep -i 'Usage\|Commands\|help' >/dev/null
chroot "${rootfs}" /usr/sbin/e4defrag --help >/dev/null
chroot "${rootfs}" /usr/sbin/e2undo --help >/dev/null

mkdir -p "${rootfs}/tmp/mklostfound"
chroot "${rootfs}" /usr/sbin/mklost+found /tmp/mklostfound >/dev/null
test -d "${rootfs}/tmp/mklostfound/lost+found"

# Scrub tooling (scripts/services): just verify the entrypoints respond
chroot "${rootfs}" /usr/sbin/e2scrub --help >/dev/null || true
chroot "${rootfs}" /usr/sbin/e2scrub_all --help >/dev/null || true
chroot "${rootfs}" /usr/libexec/e2fsprogs/e2scrub_fail --help >/dev/null || true

# MMP status may require a real block device; ensure it at least runs
chroot "${rootfs}" /usr/sbin/e2mmpstatus --help >/dev/null || true

# e2freefrag expects a mounted ext filesystem; smoke-test help only
chroot "${rootfs}" /usr/sbin/e2freefrag --help >/dev/null
9 changes: 9 additions & 0 deletions tests/spread/integration/libext2fs2t64/task.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a PR specific comment.

@lczyk @cjdcordeiro we have a bunch of tests for libraries like this one, but some other libraries are not tested - should we put a convention in place to always do a simple existence check for the files?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think lots of lower hanging fruit and i'm not convinced that simple existence test is really testing anything that installability tests are not testing already. honestly, i'd even say to remove this and libss2 tests

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
summary: Integration tests for libext2fs2t64

execute: |
rootfs="$(install-slices libext2fs2t64_libs)"

arch=$(uname -m)-linux-gnu

test -f ${rootfs}/usr/lib/${arch}/libe2p.so.2
test -f ${rootfs}/usr/lib/${arch}/libext2fs.so.2
8 changes: 8 additions & 0 deletions tests/spread/integration/libss2/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
summary: Integration tests for libss2

execute: |
rootfs="$(install-slices libss2_libs)"

arch=$(uname -m)-linux-gnu

test -f ${rootfs}/usr/lib/${arch}/libss.so.*
Loading