summaryrefslogtreecommitdiffstats
path: root/test/parser/test-grub2-test-file-ops.c
blob: b614fc1924b69bf5c3810aef783c03dfd2a8a7db (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

#include "parser-test.h"

#if 0 /* PARSER_EMBEDDED_CONFIG */
status=success

if [ -f /file_that_does_not_exist -a $status = success ]
then status=fail_f_1
fi
if [ -f /dir -a $status = success ]
then status=fail_f_2
fi
if [ ! -f /empty_file -a $status = success ]
then status=fail_f_3
fi

if [ -s /file_that_does_not_exist -a $status = success ]
then status=fail_s_1
fi
if [ ! -s /dir -a $status = success ]
then status=fail_s_2
fi
if [ -s /empty_file -a $status = success ]
then status=fail_s_3
fi
if [ ! -s /non_empty_file -a $status = success ]
then status=fail_s_4
fi

if [ -d /file_that_does_not_exist -a $status = success ]
then status=fail_d_1
fi
if [ ! -d /dir -a $status = success ]
then status=fail_d_2
fi
if [ -d /empty_file -a $status = success ]
then status=fail_d_3
fi

menuentry $status {
  linux /vmlinux
}
#endif

void run_test(struct parser_test *test)
{
	struct discover_boot_option *opt;
	struct discover_context *ctx;

	ctx = test->ctx;

	test_read_conf_embedded(test, "/grub2/grub.cfg");
	test_add_file_data(test, ctx->device, "/empty_file", "", 0);
	test_add_file_data(test, ctx->device, "/non_empty_file", "1", 1);
	test_add_dir(test, ctx->device, "/dir");

	test_run_parser(test, "grub2");

	check_boot_option_count(ctx, 1);
	opt = get_boot_option(ctx, 0);

	check_name(opt, "success");
}
OpenPOWER on IntegriCloud