Sam Price created a merge request:
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1385
Project:Branches: TheSamPrice/rtems:fix/fatfs-mkfs-parm to rtems/rtos/rtems:main
Author: Sam Price
## Summary
testsuites/fstests: Include the FatFS headers in the FatFS tests
The three FatFS tests declared the disk I/O and f_mkfs() API by hand
instead of including <rtems/fatfs/rtems-fatfs.h>, which already declares
all of it. A hand-copied declaration can drift from the implementation,
and these had drifted in four ways:
* MKFS_PARM was redeclared with an unsigned long au_size. The member
is a DWORD in contrib/cpukit/fatfs/ff.h, which is a uint32_t. The
two layouts coincide on ILP32, so the tests work there by accident.
On LP64 the unsigned long is eight bytes with an eight byte
alignment, which pushes au_size from offset 12 to offset 16 and
grows the structure from 16 to 24 bytes.
fsfatfsformat01 fails outright as a result: f_mkfs() reads the
cluster size from the four bytes of padding the test never writes,
formats the volume with a garbage cluster size, and the block size
and block count assertions of test_disk_params() fail.
fsfatfssync01 and fatfs_support escape this only because their
MKFS_PARM objects are static const with a zero cluster size, so
f_mkfs() reads the padding of the wrong layout as zero and happens
to pick the automatic cluster size. An automatic object or a
non-zero cluster size would have failed the same way.
* FRESULT was redeclared as unsigned char, where ff.h makes it an
enum.
* f_mkfs() was declared as taking a const char * path, where ff.h uses
const TCHAR *.
* rtems-fatfs.h declares pdrv as uint8_t, not unsigned char. The two
agree on every RTEMS target today, so this one is only a latent
hazard. The extern on the prototypes was redundant as well: a
declaration of a function has external linkage without it.
Include <rtems/fatfs/rtems-fatfs.h> and delete the local FRESULT,
MKFS_PARM, FR_*, FM_* and prototype declarations, so that the tests
cannot drift from the implementation again. The header pulls in ff.h
and diskio.h itself. The local MKFS_PARM members were named num_fat and
auto_cluster_size, so the designated initializers become n_fat and
au_size.
contrib/cpukit/fatfs is added to the include path of fsfatfsformat01, of
fsfatfssync01, and of the testfatfs support library, which is how
spec/build/cpukit/objfatfs.yml reaches the same headers; the installed
layout puts ff.h, ffconf.h and diskio.h next to rtems-fatfs.h in
${BSP_INCLUDEDIR}/rtems/fatfs. testfatfs is a library target with its
own include list, so the eleven test programs that link it need no
change.
The lowercase mkfs_parm of fsfatfsformat01 is left alone: it is the
parameter descriptor of the test itself, which fatfs_format_disk()
converts into a MKFS_PARM member by member, not a copy of the FatFS
type.
The struct mismatch is architecture independent, so fsfatfsformat01
fails on every LP64 BSP.
Tested on riscv/mbv and riscv/mbv64 under QEMU amd-microblaze-v-generic:
the thirteen FatFS tests give 11 PASS and 2 XFAIL, and a sweep of all
110 fstests programs gives 86 PASS and 24 XFAIL with byte-identical
results on the two BSPs. Every XFAIL is a pre-existing
TEST_STATE_EXPECTED_FAIL from the fsrename*/fssymlink family, which
fails on every filesystem.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
## Generative AI
<!-- If you have used AI please use the "AI Contribution" template otherwise
leave this blank see our fulls statement at
https://www.rtems.org/generative-ai/-->
<!-- Default settings, if it is a dropdown it will set after submission -->
--
View it on GitLab:
https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1385
You're receiving this email because of your account on gitlab.rtems.org.
Unsubscribe from this thread:
https://gitlab.rtems.org/-/sent_notifications/4-9grmz3v2rguypxkbinjqvfu4l-1d/unsubscribe
| Manage all notifications: https://gitlab.rtems.org/-/profile/notifications |
Help: https://gitlab.rtems.org/help
_______________________________________________
bugs mailing list
[email protected]
http://lists.rtems.org/mailman/listinfo/bugs