1 /* Test case by Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
2 and Ulrich Drepper <drepper@cygnus.com>. */
9 main (int argc
, char *argv
[])
13 struct mntent
*mnt
= &mef
;
17 mef
.mnt_fsname
= strdupa ("/dev/hda1");
18 mef
.mnt_dir
= strdupa ("/some dir");
19 mef
.mnt_type
= strdupa ("ext2");
20 mef
.mnt_opts
= strdupa ("defaults");
24 if (hasmntopt (mnt
, "defaults"))
28 printf ("Didn't find it\n");
33 fp
= fopen (name
, "w+");
36 printf ("Cannot open temporary file: %m\n");
43 /* Write the name entry. */
46 /* Prepare for reading. */
49 /* First, read it raw. */
50 if (fgets (buf
, sizeof (buf
), fp
) == NULL
)
52 printf ("Cannot read temporary file: %m");
56 if (strcmp (buf
, "/dev/hda1 /some\\040dir ext2 defaults 1 2\n") != 0)
58 puts ("Raw file data not correct");
62 /* Prepare for reading, part II. */
65 /* Now read it cooked. */
68 if (strcmp (mnt
->mnt_fsname
, "/dev/hda1") != 0
69 || strcmp (mnt
->mnt_dir
, "/some dir") != 0
70 || strcmp (mnt
->mnt_type
, "ext2") != 0
71 || strcmp (mnt
->mnt_opts
, "defaults") != 0
73 || mnt
->mnt_passno
!= 2)
75 puts ("Error while reading written entry back in");