genimage/test
Rasmus Villemoes ec5fb97d94 util.c: add fsync_close() helper, use where appropriate
Using genimage directly on an eMMC on target, I'm seeing that the
BLKRRPART ioctl fails with EBUSY, presumably because there's still
lots of data in flight, and then subsequent parts of my bootstrap
procedure fail because the expected partitions can't be found.

Whenever we've written some data, we really should ensure that all
data has hit the disk before proceeding, and close() itself is not
synchronous.

Add a fsync_close() helper that does exactly what it says on the
tin. Use that wherever we close an fd that has been open for writing
and actually written to (i.e., no point in doing that in the
reload_partitions() function).

Currently, the return value of these close() calls are ignored, so at
least for now continue to do that, but at least we do see an error
message in case something went wrong.

A test case is updated to reflect the new, and more accurate, disk
usage. It turns out that the lack of this fsync'ing has really created
images which later (long after genimage is done and the test framework
has accepted them) would increase in disk usage, i.e. once the kernel
gets around to write out any buffered data. With current master, one
can observe this:

  $ mkdir images input tmp
  $ dd if=/dev/zero of=input/part1.img bs=512 count=7 && dd if=/dev/zero of=input/part2.img bs=512 count=11 && touch input/part3.img
  $ ./genimage --outputpath=images --inputpath=input --rootpath=/no/such/dir --tmppath=tmp --config test/hdimage.config
  $ date ; du -B 1 images/test.hdimage-2
  Fri Nov  1 08:20:39 PM CET 2024
  61440   images/test.hdimage-2
  # Let time pass...
  $ date ; du -B 1 images/test.hdimage-2
  Fri Nov  1 08:21:10 PM CET 2024
  65536   images/test.hdimage-2

Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
2024-11-01 20:32:47 +01:00
..
include test: add tests for --includepath 2021-06-04 22:10:42 +02:00
rauc-openssl-ca test: add rauc test 2020-01-31 12:53:13 +01:00
btrfs.config btrfs: Implement extraargs 2024-08-08 11:58:05 +02:00
cpio.config add basic test suite 2017-11-12 10:02:59 +01:00
cramfs.config add basic test suite 2017-11-12 10:02:59 +01:00
exec-check.sh make rootpath optional 2022-03-25 16:43:36 +01:00
exec-fail.config test: add tests to check exec-* commands 2020-08-28 16:37:38 +02:00
exec.config test: add tests to check exec-* commands 2020-08-28 16:37:38 +02:00
ext2.config image-ext2: default to mke2fs 2024-03-22 09:16:25 +01:00
ext2percent.config image-ext2: default to mke2fs 2024-03-22 09:16:25 +01:00
ext2test-percent.0.dump test: handle new genext2fs and e2fsprogs versions 2021-05-01 18:30:29 +02:00
ext2test-percent.1.dump test: handle new genext2fs and e2fsprogs versions 2021-05-01 18:30:29 +02:00
ext2test-percent.2.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
ext2test.0.dump test: handle new genext2fs and e2fsprogs versions 2021-05-01 18:30:29 +02:00
ext2test.1.dump test: handle new genext2fs and e2fsprogs versions 2021-05-01 18:30:29 +02:00
ext2test.2.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
ext3.config image-ext2: default to mke2fs 2024-03-22 09:16:25 +01:00
ext3test.0.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
ext3test.1.dump test: handle new genext2fs and e2fsprogs versions 2021-05-01 18:30:29 +02:00
ext3test.2.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
ext4.config image-ext2: default to mke2fs 2024-03-22 09:16:25 +01:00
ext4test.0.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
ext4test.1.dump test: handle new genext2fs and e2fsprogs versions 2021-05-01 18:30:29 +02:00
ext4test.2.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
ext.test tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
f2fs.config Initial F2FS support 2022-03-25 15:53:00 +01:00
filesystem.test btrfs: Implement extraargs 2024-08-08 11:58:05 +02:00
fip.config Add Firmware Image Package (FIP) support 2022-04-22 09:51:45 +02:00
fit.config Add FIT image support 2018-03-19 15:53:26 +01:00
fit.its Add FIT image support 2018-03-19 15:53:26 +01:00
flash-types.config add basic test suite 2017-11-12 10:02:59 +01:00
flash.config add basic test suite 2017-11-12 10:02:59 +01:00
flash.md5 test: use partitions with actual content 2018-12-16 00:10:18 +01:00
flash.test test: remove leftover debugging 2022-12-08 16:09:16 +01:00
genimage.test test: remove leftover debugging 2022-12-08 16:09:16 +01:00
gpt-invalid-partition-type1.config image-hd: support long GPT partition type shortcuts 2023-03-28 09:46:50 +02:00
gpt-invalid-partition-type2.config image-hd: support long GPT partition type shortcuts 2023-03-28 09:46:50 +02:00
gpt-overlap1.config Use "partition-table-type" instead deprecated "gpt" option 2022-09-02 15:01:20 +01:00
gpt-overlap2.config Use "partition-table-type" instead deprecated "gpt" option 2022-09-02 15:01:20 +01:00
gpt-overlap3.config Use "partition-table-type" instead deprecated "gpt" option 2022-09-02 15:01:20 +01:00
gpt-partition-types.config image-hd: add shortcuts from the Discoverable Partitions Specification 2023-03-28 09:46:50 +02:00
gpt-partition-types.fdisk image-hd: add shortcuts from the Discoverable Partitions Specification 2023-03-28 09:46:50 +02:00
hdimage2.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage4.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage4.fdisk hdimage: Add GPT support 2019-02-12 09:29:54 +01:00
hdimage5.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage5.fdisk test: add test for gpt-no-backup 2020-12-04 15:41:14 +01:00
hdimage6.config image-hd.c: fix extended partition with offset 2021-04-09 16:04:12 +02:00
hdimage6.fdisk test: factor out some test data generation 2021-04-09 16:04:14 +02:00
hdimage7.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage7.fdisk add test for partitions out of order 2021-04-21 14:23:51 +02:00
hdimage-fail1.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-fail2.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-fail3.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-fail4.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-fail5.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-fail6.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-fail7.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-fail8.config image-hd: add forced-primary flag for higher MBR layout flexibility 2024-06-21 17:38:05 +02:00
hdimage-fail9.config image-hd: add forced-primary flag for higher MBR layout flexibility 2024-06-21 17:38:05 +02:00
hdimage-fail10.config image-hd: add forced-primary flag for higher MBR layout flexibility 2024-06-21 17:38:05 +02:00
hdimage-fail11.config image-hd: add forced-primary flag for higher MBR layout flexibility 2024-06-21 17:38:05 +02:00
hdimage-forced-primary.config image-hd: add forced-primary flag for higher MBR layout flexibility 2024-06-21 17:38:05 +02:00
hdimage-forced-primary.fdisk image-hd: add forced-primary flag for higher MBR layout flexibility 2024-06-21 17:38:05 +02:00
hdimage-hybrid.config image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-hybrid.fdisk image-hd: stricter option handling 2021-04-25 17:15:38 +02:00
hdimage-nopart.config image-hd: improve offset handling for images without partition table 2022-06-17 11:34:47 +02:00
hdimage-nopart.hexdump image-hd: improve offset handling for images without partition table 2022-06-17 11:34:47 +02:00
hdimage.config test: hdimage: use one empty partiton file 2020-11-27 11:19:24 +01:00
hdimage.fdisk test: fix check for older versions of the tools 2017-11-19 12:43:33 +01:00
hdimage.fdisk-2 test: add test for extended-partition attribute 2017-12-18 16:19:58 -05:00
hdimage.test util.c: add fsync_close() helper, use where appropriate 2024-11-01 20:32:47 +01:00
hole.config Use "partition-table-type" instead deprecated "gpt" option 2022-09-02 15:01:20 +01:00
include-aaa.fdisk test: add tests for --includepath 2021-06-04 22:10:42 +02:00
include-bbb.fdisk test: add tests for --includepath 2021-06-04 22:10:42 +02:00
include-ccc.fdisk test: add tests for --includepath 2021-06-04 22:10:42 +02:00
include-test.config test: add tests for --includepath 2021-06-04 22:10:42 +02:00
include.config test: add tests for --includepath 2021-06-04 22:10:42 +02:00
iso.config add basic test suite 2017-11-12 10:02:59 +01:00
jffs2.config add basic test suite 2017-11-12 10:02:59 +01:00
jffs2.md5 test: add some simple checks to verify if the images are generated correctly 2017-11-19 10:34:38 +01:00
misc.test test: handle more rauc versions 2024-07-04 15:12:25 +02:00
mke2fs.0.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
mke2fs.1.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
mke2fs.2.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
mke2fs.3.dump tests: ext: use different output files to compare to instead of trying to patch the output 2024-06-28 09:25:34 +02:00
mke2fs.conf test: add simple test for an image created with mke2fs 2018-03-28 23:45:39 +02:00
mke2fs.config test: mke2fs: fully disable quota in the test 2022-12-08 16:53:54 +01:00
qemu.config add qemu handler 2018-03-19 21:55:28 +01:00
qemu.qcow.gz test: use partitions with actual content 2018-12-16 00:10:18 +01:00
rauc.config image-rauc: allow to specify an offset to skip input bytes 2024-03-22 19:26:49 +01:00
sharness.sh add basic test suite 2017-11-12 10:02:59 +01:00
sparse.config test: add more sparse checks 2023-10-11 08:53:58 +02:00
squashfs.config add basic test suite 2017-11-12 10:02:59 +01:00
tar.config add basic test suite 2017-11-12 10:02:59 +01:00
test2.raucb.info.1 test: handle more rauc versions 2024-07-04 15:12:25 +02:00
test2.raucb.info.2 test: handle more rauc versions 2024-07-04 15:12:25 +02:00
test2.raucb.info.3 test: handle more rauc versions 2024-07-04 15:12:25 +02:00
test2.raucb.info.4 test: handle more rauc versions 2024-07-04 15:12:25 +02:00
test-setup.sh run_genimage_impl: abort for missing config file 2024-06-21 16:27:00 +02:00
test.raucb.info.1 test: handle more rauc versions 2024-07-04 15:12:25 +02:00
test.raucb.info.2 test: handle more rauc versions 2024-07-04 15:12:25 +02:00
test.raucb.info.3 test: handle more rauc versions 2024-07-04 15:12:25 +02:00
test.raucb.info.4 test: handle more rauc versions 2024-07-04 15:12:25 +02:00
ubi.config add basic test suite 2017-11-12 10:02:59 +01:00
ubifs.config add basic test suite 2017-11-12 10:02:59 +01:00
vfat.config test/vfat.config: check non-multiple-of-1MB filesystem size 2018-05-05 11:12:42 +02:00