blob: 17655bd6d9aab1400aac9ceb9980d81c6f066fc3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* Copyright (C) 2020 by Yann Sionneau <yann@sionneau.net> */
#include <stdio.h>
#include <mntent.h>
#include <stdlib.h>
#include <string.h>
static int
do_test (void)
{
char *res;
struct mntent m;
/* check that "ro" does not match "erROr" */
m.mnt_opts = "error";
res = hasmntopt (&m, MNTOPT_RO);
if (res != NULL) {
puts ("error: hasmntopt() picked up non existing option");
exit (1);
}
/* check that "ro" does not match "remount-ro" */
m.mnt_opts = "rw,relatime,errors=remount-ro";
res = hasmntopt (&m, MNTOPT_RO);
if (res != NULL) {
puts ("error: hasmntopt() picked up non existing option");
exit (1);
}
/* check that "ro" does match "ro" */
m.mnt_opts = "noatime,ro";
res = hasmntopt (&m, MNTOPT_RO);
if (res == NULL) {
puts ("error: hasmntopt() did not pick up an existing option");
exit (1);
}
if (strncmp(res, "ro", 2) != 0) {
puts ("error: hasmntopt() did not return a pointer to corresponding option");
exit (1);
}
return 0;
}
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
|