1 | #include <mntent.h> |
2 | #include <stdio.h> |
3 | #include <string.h> |
4 | |
5 | |
6 | static int |
7 | do_test (void) |
8 | { |
9 | int result = 0; |
10 | struct mntent mef; |
11 | |
12 | mef.mnt_fsname = strdupa ("/dev/sdf6" ); |
13 | mef.mnt_dir = strdupa ("/some dir" ); |
14 | mef.mnt_type = strdupa ("ext3" ); |
15 | mef.mnt_opts = strdupa ("opt1,opt2,noopt=6,rw,norw,brw" ); |
16 | mef.mnt_freq = 1; |
17 | mef.mnt_passno = 2; |
18 | |
19 | #define TEST(opt, found) \ |
20 | if ((!!hasmntopt (&mef, (opt))) != (found)) \ |
21 | { \ |
22 | printf ("Option %s was %sfound\n", (opt), (found) ? "not " : ""); \ |
23 | result = 1; \ |
24 | } |
25 | |
26 | TEST ("opt1" , 1) |
27 | TEST ("opt2" , 1) |
28 | TEST ("noopt" , 1) |
29 | TEST ("rw" , 1) |
30 | TEST ("norw" , 1) |
31 | TEST ("brw" , 1) |
32 | TEST ("opt" , 0) |
33 | TEST ("oopt" , 0) |
34 | TEST ("w" , 0) |
35 | TEST ("r" , 0) |
36 | TEST ("br" , 0) |
37 | TEST ("nor" , 0) |
38 | TEST ("or" , 0) |
39 | |
40 | return result; |
41 | } |
42 | |
43 | #define TEST_FUNCTION do_test () |
44 | #include "../test-skeleton.c" |
45 | |