| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
m> |
| 21 |
|
| 22 |
|
| 23 |
#ifdef HAVE_CONFIG_H |
| 24 |
#include <config.h> |
| 25 |
#endif |
| 26 |
|
| 27 |
#include <stdio.h> |
| 28 |
#include <string.h> |
| 29 |
#include "fsdev.h" |
| 30 |
#include "fsdev.c" |
| 31 |
|
| 32 |
#if defined(OS_LINUX) || defined(OS_AIX) |
| 33 |
#include <mntent.h> |
| 34 |
|
| 35 |
static int test_single_call() |
| 36 |
{ |
| 37 |
struct mntent ment = {0}; |
| 38 |
ment.mnt_type = "autofs"; |
| 39 |
int ret = is_local_fs(&ment); |
| 40 |
|
| 41 |
return (ret == 0); |
| 42 |
} |
| 43 |
|
| 44 |
static int test_multiple_calls(const char *fake_mtab) |
| 45 |
{ |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
FILE *f = setmntent(fake_mtab, "r"); |
| 51 |
if (f == NULL) { |
| 52 |
fprintf(stderr, "fake_mtab could not be open\n"); |
| 53 |
return 0; |
| 54 |
} |
| 55 |
struct mntent *ment; |
| 56 |
unsigned int locals = 0; |
| 57 |
while ((ment = getmntent(f)) != NULL) { |
| 58 |
if (is_local_fs(ment)) { |
| 59 |
locals++; |
| 60 |
} |
| 61 |
} |
| 62 |
endmntent(f); |
| 63 |
return (locals == 3); |
| 64 |
} |
| 65 |
|
| 66 |
int main(int argc, char *argv[]) |
| 67 |
{ |
| 68 |
if (!test_single_call()) { |
| 69 |
fprintf(stderr, "test_single_call has failed\n"); |
| 70 |
return 1; |
| 71 |
} |
| 72 |
if (!test_multiple_calls(argv[1])) { |
| 73 |
fprintf(stderr, "test_multiple_calls has failed\n"); |
| 74 |
return 1; |
| 75 |
} |
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
#else |
| 80 |
|
| 81 |
int main(int argc, char *argv[]) |
| 82 |
{ |
| 83 |
fprintf(stderr, "is_local is only defined and used by Linux and AIX\n"); |
| 84 |
return 0; |
| 85 |
} |
| 86 |
|
| 87 |
#endif |