1#######################################################
2#
3# Test basename() without suffix
4#
5#######################################################
6
7body common control
8{
9      inputs => { "../../default.cf.sub" };
10      bundlesequence  => { default("$(this.promise_filename)") };
11      version => "1.0";
12}
13
14#######################################################
15
16bundle agent test
17{
18  vars:
19      # The tests starting with template will be tested with both types of
20      # directory separators on Windows.
21
22      "template_input[root]" string => "/";
23      "template_expected[root]" string => "/";
24
25      "template_input[simple]" string => "/foo/bar";
26      "template_expected[simple]" string => "bar";
27
28      "template_input[slash]" string => "/foo/bar/";
29      "template_expected[slash]" string => "bar";
30
31      "template_input[sub]" string => "/foo";
32      "template_expected[sub]" string => "foo";
33
34      "template_input[subslash]" string => "/foo/";
35      "template_expected[subslash]" string => "foo";
36
37      "template_input[dot]" string => "/foo/.";
38      "template_expected[dot]" string => ".";
39
40      "template_input[dot_subslash]" string => "/foo/./";
41      "template_expected[dot_subslash]" string => ".";
42
43      "template_input[multi]" string => "/foo/bar/baz";
44      "template_expected[multi]" string => "baz";
45
46      "template_input[multislash]" string => "/foo/bar/baz/";
47      "template_expected[multislash]" string => "baz";
48
49      "template_input[more]" string => "/a/b/c/d/e/f/g/h/i";
50      "template_expected[more]" string => "i";
51
52      "template_input[multislash]" string => "/a///b////c///";
53      "template_expected[multislash]" string => "c";
54
55      # Note: no template, because backslashes will be interpreted as UNC path on Windows.
56      "input[multislash_start]" string => "//a///b////c///";
57      "expected[multislash_start]" string => "c";
58
59      "template_input[rel_one]" string => "foo";
60      "template_expected[rel_one]" string => "foo";
61
62      "template_input[rel_more]" string => "foo/bar";
63      "template_expected[rel_more]" string => "bar";
64
65      "template_input[rel_one_subslash]" string => "foo/";
66      "template_expected[rel_one_subslash]" string => "foo";
67
68      "template_input[rel_more_subslash]" string => "foo/bar/";
69      "template_expected[rel_more_subslash]" string => "bar";
70
71      "template_input[rel_dot]" string => "foo/.";
72      "template_expected[rel_dot]" string => ".";
73
74      "template_input[rel_only_dot]" string => "./";
75      "template_expected[rel_only_dot]" string => ".";
76
77      "template_input[rel_multislash]" string => "a///b////c///";
78      "template_expected[rel_multislash]" string => "c";
79
80      "template_input[noop]" string => "";
81      "template_expected[noop]" string => "";
82
83      "template_keys" slist => getindices("template_input");
84
85    windows::
86      "template_input[full_root]" string => "C:/";
87      "template_expected[full_root]" string => "/";
88
89      "template_input[full_root_file]" string => "C:/foo";
90      "template_expected[full_root_file]" string => "foo";
91
92      "template_input[full_root_file_subslash]" string => "C:/foo/";
93      "template_expected[full_root_file_subslash]" string => "foo";
94
95      "template_input[full_file]" string => "C:/foo/bar";
96      "template_expected[full_file]" string => "bar";
97
98      "template_input[full_file_subslash]" string => "C:/foo/bar/";
99      "template_expected[full_file_subslash]" string => "bar";
100
101      "template_input[dir]" string => "C:foo";
102      "template_expected[dir]" string => "foo";
103
104      "template_input[two_dirs]" string => "C:foo/bar";
105      "template_expected[two_dirs]" string => "bar";
106
107      "template_input[dir_subslash]" string => "C:foo/";
108      "template_expected[dir_subslash]" string => "foo";
109
110      "template_input[two_dirs_subslash]" string => "C:foo/bar/";
111      "template_expected[two_dirs_subslash]" string => "bar";
112
113      # UNC paths don't have forward slash equivalents.
114      "input[native_unc_one]" string => "\\\\foo";
115      "expected[native_unc_one]" string => "foo";
116
117      "input[native_unc_two]" string => "\\\\foo\\bar";
118      "expected[native_unc_two]" string => "bar";
119
120      "input[native_unc_three]" string => "\\\\foo\\bar\\charlie\\";
121      "expected[native_unc_three]" string => "charlie";
122
123    any::
124      "input[native_$(template_keys)]" string => "$(template_input[$(template_keys)])";
125      "expected[native_$(template_keys)]" string => "$(template_expected[$(template_keys)])";
126
127      "keys" slist => getindices("input");
128
129      "actual[$(keys)]" string => basename("$(input[$(keys)])");
130}
131
132#######################################################
133
134bundle agent check
135{
136  vars:
137      "keys" slist => { @(test.keys) };
138
139  classes:
140      "failed_cmp_$(keys)" not => strcmp(basename("$(test.input[$(keys)])"), "$(test.expected[$(keys)])");
141      "ok" not => classmatch("failed_cmp_.*");
142
143  reports:
144    DEBUG::
145      "'basename($(test.input[$(keys)]))' = '$(test.actual[$(keys)])' != '$(test.expected[$(keys)])'"
146        if => "failed_cmp_$(keys)";
147
148    ok::
149      "$(this.promise_filename) Pass";
150    !ok::
151      "$(this.promise_filename) FAIL";
152}
153