#include <fuse.h>
#include <stdlib.h>
#include <string.h>
static int
test_null_args(void)
{
if (fuse_parse_cmdline(NULL, NULL, NULL, NULL) == 0)
exit(__LINE__);
return (0);
}
static int
test_all_args(char **dir, int *multithreaded, int *foreground)
{
char *argv[] = {
"progname",
"-odebug",
"-d",
"-f",
"/mnt",
"-s"
};
struct fuse_args args = FUSE_ARGS_INIT(6, argv);
if (dir != NULL)
*dir = NULL;
if (multithreaded != NULL)
*multithreaded = 0;
if (foreground != NULL)
*foreground = 0;
if (fuse_parse_cmdline(&args, dir, multithreaded, foreground) != 0)
exit (__LINE__);
if (dir != NULL && strcmp(*dir, "/mnt") != 0)
exit(__LINE__);
if (multithreaded != NULL && *multithreaded == 1)
exit(__LINE__);
if (foreground != NULL && *foreground == 0)
exit(__LINE__);
if (args.argc != 1)
exit(__LINE__);
if (strcmp(args.argv[0], "progname") != 0)
exit(__LINE__);
return (0);
}
int
main(void)
{
char *dir;
int multithreaded, foreground;
test_null_args();
test_all_args(NULL, NULL, NULL);
test_all_args(&dir, NULL, NULL);
test_all_args(&dir, &multithreaded, NULL);
test_all_args(&dir, &multithreaded, &foreground);
return (0);
}