Lines Matching refs:g
61 static void InstallFake(glob_t* g) { in InstallFake() argument
62 g->gl_closedir = fake_closedir; in InstallFake()
63 g->gl_readdir = fake_readdir; in InstallFake()
64 g->gl_opendir = fake_opendir; in InstallFake()
65 g->gl_lstat = fake_lstat; in InstallFake()
66 g->gl_stat = fake_stat; in InstallFake()
70 glob_t g = {}; in TEST() local
71 ASSERT_EQ(GLOB_NOMATCH, glob("/will/match/nothing", 0, nullptr, &g)); in TEST()
72 ASSERT_EQ(0U, g.gl_pathc); in TEST()
73 ASSERT_MATCH_COUNT(0U, g); in TEST()
77 glob_t g = {}; in TEST() local
78 ASSERT_EQ(0, glob("/proc/version", 0, nullptr, &g)); in TEST()
79 ASSERT_EQ(1U, g.gl_pathc); in TEST()
80 ASSERT_MATCH_COUNT(1U, g); in TEST()
81 ASSERT_STREQ("/proc/version", g.gl_pathv[0]); in TEST()
82 ASSERT_EQ(nullptr, g.gl_pathv[1]); in TEST()
83 ASSERT_EQ(0, glob("/proc/version", GLOB_APPEND, nullptr, &g)); in TEST()
84 ASSERT_EQ(2U, g.gl_pathc); in TEST()
85 ASSERT_MATCH_COUNT(1U, g); in TEST()
86 ASSERT_STREQ("/proc/version", g.gl_pathv[0]); in TEST()
87 ASSERT_STREQ("/proc/version", g.gl_pathv[1]); in TEST()
88 ASSERT_EQ(nullptr, g.gl_pathv[2]); in TEST()
89 globfree(&g); in TEST()
93 glob_t g = {}; in TEST() local
94 g.gl_offs = 2; in TEST()
95 ASSERT_EQ(0, glob("/proc/version", GLOB_DOOFFS, nullptr, &g)); in TEST()
96 ASSERT_EQ(1U, g.gl_pathc); in TEST()
97 ASSERT_MATCH_COUNT(1U, g); in TEST()
98 ASSERT_EQ(nullptr, g.gl_pathv[0]); in TEST()
99 ASSERT_EQ(nullptr, g.gl_pathv[1]); in TEST()
100 ASSERT_STREQ("/proc/version", g.gl_pathv[2]); in TEST()
101 ASSERT_EQ(nullptr, g.gl_pathv[3]); in TEST()
102 globfree(&g); in TEST()
115 glob_t g = {}; in TEST() local
116 InstallFake(&g); in TEST()
120 ASSERT_EQ(GLOB_NOMATCH, glob("/opendir-fail/x*", GLOB_ALTDIRFUNC, test_error_callback, &g)); in TEST()
126 ASSERT_EQ(GLOB_ABORTED, glob("/opendir-fail/x*", GLOB_ALTDIRFUNC, test_error_callback, &g)); in TEST()
132 glob_t g = {}; in TEST() local
133 InstallFake(&g); in TEST()
135 ASSERT_EQ(GLOB_NOMATCH, glob("/opendir-fail/x*", GLOB_ALTDIRFUNC, nullptr, &g)); in TEST()
137 ASSERT_EQ(GLOB_ABORTED, glob("/opendir-fail/x*", GLOB_ALTDIRFUNC | GLOB_ERR, nullptr, &g)); in TEST()
145 glob_t g = {}; in TEST() local
147 ASSERT_EQ(0, glob(td.path, GLOB_MARK, nullptr, &g)); in TEST()
148 ASSERT_EQ(1U, g.gl_pathc); in TEST()
149 ASSERT_MATCH_COUNT(1U, g); in TEST()
150 ASSERT_EQ(std::string(td.path) + "/", g.gl_pathv[0]); in TEST()
151 ASSERT_EQ(nullptr, g.gl_pathv[1]); in TEST()
155 ASSERT_EQ(0, glob(tf.path, GLOB_MARK, nullptr, &g)); in TEST()
156 ASSERT_EQ(1U, g.gl_pathc); in TEST()
157 ASSERT_MATCH_COUNT(1U, g); in TEST()
158 ASSERT_STREQ(tf.path, g.gl_pathv[0]); in TEST()
159 ASSERT_EQ(nullptr, g.gl_pathv[1]); in TEST()
161 globfree(&g); in TEST()
165 glob_t g = {}; in TEST() local
166 ASSERT_EQ(0, glob("/will/match/nothing", GLOB_NOCHECK, nullptr, &g)); in TEST()
167 ASSERT_EQ(1U, g.gl_pathc); in TEST()
168 ASSERT_MATCH_COUNT(0U, g); in TEST()
169 ASSERT_STREQ("/will/match/nothing", g.gl_pathv[0]); in TEST()
170 ASSERT_EQ(nullptr, g.gl_pathv[1]); in TEST()
171 globfree(&g); in TEST()
177 glob_t g = {}; in TEST() local
178 InstallFake(&g); in TEST()
180 ASSERT_EQ(0, glob("*", GLOB_ALTDIRFUNC, nullptr, &g)); in TEST()
181 ASSERT_EQ(4U, g.gl_pathc); in TEST()
182 ASSERT_MATCH_COUNT(4U, g); in TEST()
183 ASSERT_STREQ("a", g.gl_pathv[0]); in TEST()
184 ASSERT_STREQ("b", g.gl_pathv[1]); in TEST()
185 ASSERT_STREQ("c", g.gl_pathv[2]); in TEST()
186 ASSERT_STREQ("d", g.gl_pathv[3]); in TEST()
187 ASSERT_EQ(nullptr, g.gl_pathv[4]); in TEST()
189 ASSERT_EQ(0, glob("*", GLOB_ALTDIRFUNC | GLOB_NOSORT, nullptr, &g)); in TEST()
190 ASSERT_EQ(4U, g.gl_pathc); in TEST()
191 ASSERT_MATCH_COUNT(4U, g); in TEST()
192 ASSERT_STREQ("c", g.gl_pathv[0]); in TEST()
193 ASSERT_STREQ("a", g.gl_pathv[1]); in TEST()
194 ASSERT_STREQ("d", g.gl_pathv[2]); in TEST()
195 ASSERT_STREQ("b", g.gl_pathv[3]); in TEST()
196 ASSERT_EQ(nullptr, g.gl_pathv[4]); in TEST()
200 glob_t g = {}; in TEST() local
201 ASSERT_EQ(GLOB_NOMATCH, glob("/does-not-exist", 0, nullptr, &g)); in TEST()
202 ASSERT_TRUE((g.gl_flags & GLOB_MAGCHAR) == 0); in TEST()
203 ASSERT_EQ(GLOB_NOMATCH, glob("/does-not-exist*", 0, nullptr, &g)); in TEST()
204 ASSERT_TRUE((g.gl_flags & GLOB_MAGCHAR) != 0); in TEST()
207 ASSERT_EQ(GLOB_NOMATCH, glob("/does-not-exist", GLOB_MAGCHAR, nullptr, &g)); in TEST()
208 ASSERT_TRUE((g.gl_flags & GLOB_MAGCHAR) == 0); in TEST()
212 glob_t g = {}; in CheckGlob() local
213 InstallFake(&g); in CheckGlob()
216 ASSERT_EQ(expected_result, glob(pattern, GLOB_ALTDIRFUNC, nullptr, &g)) << pattern; in CheckGlob()
217 ASSERT_EQ(expected_matches.size(), g.gl_pathc); in CheckGlob()
218 ASSERT_MATCH_COUNT(expected_matches.size(), g); in CheckGlob()
220 ASSERT_EQ(expected_matches[i], g.gl_pathv[i]); in CheckGlob()
223 ASSERT_EQ(nullptr, g.gl_pathv[expected_matches.size()]); in CheckGlob()
225 globfree(&g); in CheckGlob()