MCPcopy Create free account
hub / github.com/RsyncProject/rsync / run_test

Function run_test

wildtest.c:54–108  ·  view source on GitHub ↗

match just at the start of string (anchored tests) */

Source from the content-addressed store, hash-verified

52
53/* match just at the start of string (anchored tests) */
54static void
55run_test(int line, bool matches,
56#ifdef COMPARE_WITH_FNMATCH
57 bool same_as_fnmatch,
58#endif
59 const char *text, const char *pattern)
60{
61 bool matched;
62#ifdef COMPARE_WITH_FNMATCH
63 bool fn_matched;
64 int flags = strstr(pattern, "**")? 0 : FNM_PATHNAME;
65#endif
66
67 if (explode_mod) {
68 char buf[MAXPATHLEN*2], *texts[MAXPATHLEN];
69 int pos = 0, cnt = 0, ndx = 0, len = strlen(text);
70
71 if (empty_at_start)
72 texts[ndx++] = "";
73 /* An empty string must turn into at least one empty array item. */
74 while (1) {
75 texts[ndx] = buf + ndx * (explode_mod + 1);
76 strlcpy(texts[ndx++], text + pos, explode_mod + 1);
77 if (pos + explode_mod >= len)
78 break;
79 pos += explode_mod;
80 if (!(++cnt % empties_mod))
81 texts[ndx++] = "";
82 }
83 if (empty_at_end)
84 texts[ndx++] = "";
85 texts[ndx] = NULL;
86 matched = wildmatch_array(pattern, (const char**)texts, 0);
87 } else
88 matched = wildmatch(pattern, text);
89#ifdef COMPARE_WITH_FNMATCH
90 fn_matched = !fnmatch(pattern, text, flags);
91#endif
92 if (matched != matches) {
93 printf("wildmatch failure on line %d:\n %s\n %s\n expected %s match\n",
94 line, text, pattern, matches? "a" : "NO");
95 wildmatch_errors++;
96 }
97#ifdef COMPARE_WITH_FNMATCH
98 if (fn_matched != (matches ^ !same_as_fnmatch)) {
99 printf("fnmatch disagreement on line %d:\n %s\n %s\n expected %s match\n",
100 line, text, pattern, matches ^ !same_as_fnmatch? "a" : "NO");
101 fnmatch_errors++;
102 }
103#endif
104 if (output_iterations) {
105 printf("%d: \"%s\" iterations = %d\n", line, pattern,
106 wildmatch_iteration_count);
107 }
108}
109
110int
111main(int argc, char **argv)

Callers 1

mainFunction · 0.85

Calls 3

strlcpyFunction · 0.85
wildmatch_arrayFunction · 0.85
wildmatchFunction · 0.85

Tested by

no test coverage detected