|
Message-Id: <20210821085420.474615-3-hi@alyssa.is> Date: Sat, 21 Aug 2021 08:54:19 +0000 From: Alyssa Ross <hi@...ssa.is> To: musl@...ts.openwall.com Cc: Alyssa Ross <hi@...ssa.is> Subject: [PATCH libc-test 2/3] functional: add mntent test for single-field line Glibc only requires a single field to be present in an fstab line to parse it, and will initialize all other string fields to the empty string. This test checks for that behaviour. --- I'm providing this test as a seperate patch to make it easy to pass on this test while still accepting the rest, because I'm not sure whether it's a good thing or not for Musl to allow fstab lines like this, even though Glibc does. src/functional/mntent.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/functional/mntent.c b/src/functional/mntent.c index 59d816a..caa7d33 100644 --- a/src/functional/mntent.c +++ b/src/functional/mntent.c @@ -31,6 +31,18 @@ void test_getmntent_empty(void) ASSERT(endmntent(f) == 1); } +void test_getmntent_short(void) +{ + char fstab[] = "1\n"; + FILE *f = fmemopen((void *)fstab, sizeof fstab - 1, "r"); + if (!f) ERR("fmemopen"); + struct mntent *m = getmntent(f); + ASSERT(m); + ASSERT(!strcmp(m->mnt_fsname, "1")); + ASSERT(!*m->mnt_dir); + ASSERT(endmntent(f) == 1); +} + void test_getmntent(void) { // Checks that the fifth and sixth fields default to 0. @@ -71,6 +83,7 @@ void test_getmntent_r(void) int main(void) { test_getmntent_empty(); + test_getmntent_short(); test_getmntent(); test_getmntent_r(); } -- 2.32.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.