monotone

monotone Mtn Source Tree

Root/restrictions.cc

1// Copyright (C) 2005 Derek Scherger <derek@echologic.com>
2//
3// This program is made available under the GNU GPL version 2.0 or
4// greater. See the accompanying file COPYING for details.
5//
6// This program is distributed WITHOUT ANY WARRANTY; without even the
7// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8// PURPOSE.
9
10#include "base.hh"
11#include <map>
12#include "vector.hh"
13
14#include "restrictions.hh"
15#include "revision.hh"
16#include "safe_map.hh"
17#include "transforms.hh"
18#include "app_state.hh"
19
20using std::make_pair;
21using std::map;
22using std::set;
23using std::vector;
24
25// TODO: add check for relevant rosters to be used by log
26//
27// i.e. as log goes back through older and older rosters it may hit one
28// that pre-dates any of the nodes in the restriction. the nodes that the
29// restriction includes or excludes may not have been born in a sufficiently
30// old roster. at this point log should stop because no earlier roster will
31// include these nodes.
32
33static void
34map_nodes(map<node_id, restricted_path::status> & node_map,
35 roster_t const & roster,
36 set<file_path> const & paths,
37 set<file_path> & known_paths,
38 restricted_path::status const status)
39{
40 for (set<file_path>::const_iterator i = paths.begin(); i != paths.end(); ++i)
41 {
42 if (roster.has_node(*i))
43 {
44 known_paths.insert(*i);
45 node_id nid = roster.get_node(*i)->self;
46
47 map<node_id, restricted_path::status>::iterator n
48 = node_map.find(nid);
49 if (n != node_map.end())
50 N(n->second == status,
51 F("conflicting include/exclude on path '%s'") % *i);
52 else
53 node_map.insert(make_pair(nid, status));
54 }
55 }
56}
57
58static void
59map_paths(map<file_path, restricted_path::status> & path_map,
60 set<file_path> const & paths,
61 restricted_path::status const status)
62{
63 for (set<file_path>::const_iterator i = paths.begin(); i != paths.end(); ++i)
64 {
65 map<file_path, restricted_path::status>::iterator p = path_map.find(*i);
66 if (p != path_map.end())
67 N(p->second == status,
68 F("conflicting include/exclude on path '%s'") % *i);
69 else
70 path_map.insert(make_pair(*i, status));
71 }
72}
73
74static void
75validate_roster_paths(set<file_path> const & included_paths,
76 set<file_path> const & excluded_paths,
77 set<file_path> const & known_paths,
78 app_state & app)
79{
80 int bad = 0;
81
82 for (set<file_path>::const_iterator i = included_paths.begin();
83 i != included_paths.end(); ++i)
84 {
85 // ignored paths are allowed into the restriction but are not
86 // considered invalid if they are found in none of the restriction's
87 // rosters
88 if (known_paths.find(*i) == known_paths.end())
89 {
90 if (!app.lua.hook_ignore_file(*i))
91 {
92 bad++;
93 W(F("restriction includes unknown path '%s'") % *i);
94 }
95 }
96 }
97
98 for (set<file_path>::const_iterator i = excluded_paths.begin();
99 i != excluded_paths.end(); ++i)
100 {
101 if (known_paths.find(*i) == known_paths.end())
102 {
103 bad++;
104 W(F("restriction excludes unknown path '%s'") % *i);
105 }
106 }
107
108 N(bad == 0, FP("%d unknown path", "%d unknown paths", bad) % bad);
109}
110
111void
112validate_workspace_paths(set<file_path> const & included_paths,
113 set<file_path> const & excluded_paths,
114 app_state & app)
115{
116 int bad = 0;
117
118 for (set<file_path>::const_iterator i = included_paths.begin();
119 i != included_paths.end(); ++i)
120 {
121 if (i->empty())
122 continue;
123
124 // ignored paths are allowed into the restriction but are not
125 // considered invalid if they are found in none of the restriction's
126 // rosters
127 if (!path_exists(*i) && !app.lua.hook_ignore_file(*i))
128 {
129 bad++;
130 W(F("restriction includes unknown path '%s'") % *i);
131 }
132 }
133
134 for (set<file_path>::const_iterator i = excluded_paths.begin();
135 i != excluded_paths.end(); ++i)
136 {
137 if (i->empty())
138 continue;
139
140 if (!path_exists(*i))
141 {
142 bad++;
143 W(F("restriction excludes unknown path '%s'") % *i);
144 }
145 }
146
147 N(bad == 0, FP("%d unknown path", "%d unknown paths", bad) % bad);
148}
149
150restriction::restriction(std::vector<file_path> const & includes,
151 std::vector<file_path> const & excludes,
152 long depth)
153 : included_paths(includes.begin(), includes.end()),
154 excluded_paths(excludes.begin(), excludes.end()),
155 depth(depth)
156{}
157
158node_restriction::node_restriction(std::vector<file_path> const & includes,
159 std::vector<file_path> const & excludes,
160 long depth,
161 roster_t const & roster,
162 app_state & a) :
163 restriction(includes, excludes, depth)
164{
165 map_nodes(node_map, roster, included_paths, known_paths,
166 restricted_path::included);
167 map_nodes(node_map, roster, excluded_paths, known_paths,
168 restricted_path::excluded);
169
170 validate_roster_paths(included_paths, excluded_paths, known_paths, a);
171}
172
173node_restriction::node_restriction(std::vector<file_path> const & includes,
174 std::vector<file_path> const & excludes,
175 long depth,
176 roster_t const & roster1,
177 roster_t const & roster2,
178 app_state & a) :
179 restriction(includes, excludes, depth)
180{
181 map_nodes(node_map, roster1, included_paths, known_paths,
182 restricted_path::included);
183 map_nodes(node_map, roster1, excluded_paths, known_paths,
184 restricted_path::excluded);
185
186 map_nodes(node_map, roster2, included_paths, known_paths,
187 restricted_path::included);
188 map_nodes(node_map, roster2, excluded_paths, known_paths,
189 restricted_path::excluded);
190
191 validate_roster_paths(included_paths, excluded_paths, known_paths, a);
192}
193
194node_restriction::node_restriction(std::vector<file_path> const & includes,
195 std::vector<file_path> const & excludes,
196 long depth,
197 parent_map const & rosters1,
198 roster_t const & roster2,
199 app_state & a) :
200 restriction(includes, excludes, depth)
201{
202 for (parent_map::const_iterator i = rosters1.begin();
203 i != rosters1.end();
204 i++)
205 {
206 map_nodes(node_map, parent_roster(i), included_paths, known_paths,
207 restricted_path::included);
208 map_nodes(node_map, parent_roster(i), excluded_paths, known_paths,
209 restricted_path::excluded);
210 }
211
212 map_nodes(node_map, roster2, included_paths, known_paths,
213 restricted_path::included);
214 map_nodes(node_map, roster2, excluded_paths, known_paths,
215 restricted_path::excluded);
216
217 validate_roster_paths(included_paths, excluded_paths, known_paths, a);
218}
219
220
221path_restriction::path_restriction(std::vector<file_path> const & includes,
222 std::vector<file_path> const & excludes,
223 long depth,
224 app_state & a,
225 validity_check vc) :
226 restriction(includes, excludes, depth)
227{
228 map_paths(path_map, included_paths, restricted_path::included);
229 map_paths(path_map, excluded_paths, restricted_path::excluded);
230
231 if (vc == check_paths)
232 {
233 validate_workspace_paths(included_paths, excluded_paths, a);
234 }
235}
236
237bool
238node_restriction::includes(roster_t const & roster, node_id nid) const
239{
240 MM(roster);
241 I(roster.has_node(nid));
242
243 file_path fp;
244 roster.get_name(nid, fp);
245
246 if (empty())
247 {
248 if (depth != -1)
249 {
250 int path_depth = fp.depth();
251 if (path_depth <= depth + 1)
252 {
253 L(FL("depth includes nid %d path '%s'") % nid % fp);
254 return true;
255 }
256 else
257 {
258 L(FL("depth excludes nid %d path '%s'") % nid % fp);
259 return false;
260 }
261 }
262 else
263 {
264 // don't log this, we end up using rather a bit of cpu time just
265 // in the logging code, for totally unrestricted operations.
266 return true;
267 }
268 }
269
270 node_id current = nid;
271 int path_depth = 0;
272
273 // FIXME: this uses depth+1 because the old semantics of depth=0 were
274 // something like "the current directory and its immediate children". it
275 // seems somewhat more reasonable here to use depth=0 to mean "exactly
276 // this directory" and depth=1 to mean "this directory and its immediate
277 // children"
278
279 while (!null_node(current) && (depth == -1 || path_depth <= depth + 1))
280 {
281 map<node_id, restricted_path::status>::const_iterator
282 r = node_map.find(current);
283
284 if (r != node_map.end())
285 {
286 switch (r->second)
287 {
288 case restricted_path::included:
289 L(FL("explicit include of nid %d path '%s'")
290 % current % fp);
291 return true;
292
293 case restricted_path::excluded:
294 L(FL("explicit exclude of nid %d path '%s'")
295 % current % fp);
296 return false;
297 }
298 }
299
300 node_t node = roster.get_node(current);
301 current = node->parent;
302 path_depth++;
303 }
304
305 if (included_paths.empty())
306 {
307 L(FL("default include of nid %d path '%s'")
308 % nid % fp);
309 return true;
310 }
311 else
312 {
313 if (global_sanity.debug_p())
314 {
315 // printing this slows down "log <file>".
316 L(FL("(debug) default exclude of nid %d path '%s'")
317 % nid % fp);
318 }
319 return false;
320 }
321}
322
323bool
324path_restriction::includes(file_path const & pth) const
325{
326 if (empty())
327 {
328 if (depth != -1)
329 {
330 int path_depth = pth.depth();
331 if (path_depth <= depth + 1)
332 {
333 L(FL("depth includes path '%s'") % pth);
334 return true;
335 }
336 else
337 {
338 L(FL("depth excludes path '%s'") % pth);
339 return false;
340 }
341 }
342 else
343 {
344 L(FL("empty include of path '%s'") % pth);
345 return true;
346 }
347 }
348
349 // FIXME: this uses depth+1 because the old semantics of depth=0 were
350 // something like "the current directory and its immediate children". it
351 // seems somewhat more reasonable here to use depth=0 to mean "exactly
352 // this directory" and depth=1 to mean "this directory and its immediate
353 // children"
354
355 int path_depth = 0;
356 file_path fp = pth;
357 while (depth == -1 || path_depth <= depth + 1)
358 {
359 map<file_path, restricted_path::status>::const_iterator
360 r = path_map.find(fp);
361
362 if (r != path_map.end())
363 {
364 switch (r->second)
365 {
366 case restricted_path::included:
367 L(FL("explicit include of path '%s'") % pth);
368 return true;
369
370 case restricted_path::excluded:
371 L(FL("explicit exclude of path '%s'") % pth);
372 return false;
373 }
374 }
375
376 if (fp.empty())
377 break;
378 fp = fp.dirname();
379 path_depth++;
380 }
381
382 if (included_paths.empty())
383 {
384 L(FL("default include of path '%s'") % pth);
385 return true;
386 }
387 else
388 {
389 L(FL("default exclude of path '%s'") % pth);
390 return false;
391 }
392}
393
394///////////////////////////////////////////////////////////////////////
395// tests
396///////////////////////////////////////////////////////////////////////
397
398#ifdef BUILD_UNIT_TESTS
399#include "app_state.hh"
400#include "unit_tests.hh"
401#include "roster.hh"
402#include "sanity.hh"
403
404using std::string;
405
406// f's and g's are files
407// x's and y's are directories
408// and this is rather painful
409
410#define fp_root file_path_internal("")
411#define fp_f file_path_internal("f")
412#define fp_g file_path_internal("g")
413
414#define fp_x file_path_internal("x")
415#define fp_xf file_path_internal("x/f")
416#define fp_xg file_path_internal("x/g")
417#define fp_xx file_path_internal("x/x")
418#define fp_xxf file_path_internal("x/x/f")
419#define fp_xxg file_path_internal("x/x/g")
420#define fp_xy file_path_internal("x/y")
421#define fp_xyf file_path_internal("x/y/f")
422#define fp_xyg file_path_internal("x/y/g")
423
424#define fp_y file_path_internal("y")
425#define fp_yf file_path_internal("y/f")
426#define fp_yg file_path_internal("y/g")
427#define fp_yx file_path_internal("y/x")
428#define fp_yxf file_path_internal("y/x/f")
429#define fp_yxg file_path_internal("y/x/g")
430#define fp_yy file_path_internal("y/y")
431#define fp_yyf file_path_internal("y/y/f")
432#define fp_yyg file_path_internal("y/y/g")
433
434node_id nid_root;
435node_id nid_f;
436node_id nid_g;
437
438node_id nid_x;
439node_id nid_xf;
440node_id nid_xg;
441node_id nid_xx;
442node_id nid_xxf;
443node_id nid_xxg;
444node_id nid_xy;
445node_id nid_xyf;
446node_id nid_xyg;
447
448node_id nid_y;
449node_id nid_yf;
450node_id nid_yg;
451node_id nid_yx;
452node_id nid_yxf;
453node_id nid_yxg;
454node_id nid_yy;
455node_id nid_yyf;
456node_id nid_yyg;
457
458file_id fid_f(string("1000000000000000000000000000000000000000"));
459file_id fid_g(string("2000000000000000000000000000000000000000"));
460
461file_id fid_xf(string("3000000000000000000000000000000000000000"));
462file_id fid_xg(string("4000000000000000000000000000000000000000"));
463file_id fid_xxf(string("5000000000000000000000000000000000000000"));
464file_id fid_xxg(string("6000000000000000000000000000000000000000"));
465file_id fid_xyf(string("7000000000000000000000000000000000000000"));
466file_id fid_xyg(string("8000000000000000000000000000000000000000"));
467
468file_id fid_yf(string("9000000000000000000000000000000000000000"));
469file_id fid_yg(string("a000000000000000000000000000000000000000"));
470file_id fid_yxf(string("b000000000000000000000000000000000000000"));
471file_id fid_yxg(string("c000000000000000000000000000000000000000"));
472file_id fid_yyf(string("d000000000000000000000000000000000000000"));
473file_id fid_yyg(string("e000000000000000000000000000000000000000"));
474
475static void setup(roster_t & roster)
476{
477 temp_node_id_source nis;
478
479 // these directories must exist for the path_restrictions to be valid. it
480 // is a bit lame to be creating directories arbitrarily like this. perhaps
481 // unit_tests should run in a unit_tests.dir or something.
482
483 mkdir_p(file_path_internal("x/x"));
484 mkdir_p(file_path_internal("x/y"));
485 mkdir_p(file_path_internal("y/x"));
486 mkdir_p(file_path_internal("y/y"));
487
488 nid_root = roster.create_dir_node(nis);
489 nid_f = roster.create_file_node(fid_f, nis);
490 nid_g = roster.create_file_node(fid_g, nis);
491
492 nid_x = roster.create_dir_node(nis);
493 nid_xf = roster.create_file_node(fid_xf, nis);
494 nid_xg = roster.create_file_node(fid_xg, nis);
495 nid_xx = roster.create_dir_node(nis);
496 nid_xxf = roster.create_file_node(fid_xxf, nis);
497 nid_xxg = roster.create_file_node(fid_xxg, nis);
498 nid_xy = roster.create_dir_node(nis);
499 nid_xyf = roster.create_file_node(fid_xxf, nis);
500 nid_xyg = roster.create_file_node(fid_xxg, nis);
501
502 nid_y = roster.create_dir_node(nis);
503 nid_yf = roster.create_file_node(fid_yf, nis);
504 nid_yg = roster.create_file_node(fid_yg, nis);
505 nid_yx = roster.create_dir_node(nis);
506 nid_yxf = roster.create_file_node(fid_yxf, nis);
507 nid_yxg = roster.create_file_node(fid_yxg, nis);
508 nid_yy = roster.create_dir_node(nis);
509 nid_yyf = roster.create_file_node(fid_yxf, nis);
510 nid_yyg = roster.create_file_node(fid_yxg, nis);
511
512 roster.attach_node(nid_root, fp_root);
513 roster.attach_node(nid_f, fp_f);
514 roster.attach_node(nid_g, fp_g);
515
516 roster.attach_node(nid_x, fp_x);
517 roster.attach_node(nid_xf, fp_xf);
518 roster.attach_node(nid_xg, fp_xg);
519 roster.attach_node(nid_xx, fp_xx);
520 roster.attach_node(nid_xxf, fp_xxf);
521 roster.attach_node(nid_xxg, fp_xxg);
522 roster.attach_node(nid_xy, fp_xy);
523 roster.attach_node(nid_xyf, fp_xyf);
524 roster.attach_node(nid_xyg, fp_xyg);
525
526 roster.attach_node(nid_y, fp_y);
527 roster.attach_node(nid_yf, fp_yf);
528 roster.attach_node(nid_yg, fp_yg);
529 roster.attach_node(nid_yx, fp_yx);
530 roster.attach_node(nid_yxf, fp_yxf);
531 roster.attach_node(nid_yxg, fp_yxg);
532 roster.attach_node(nid_yy, fp_yy);
533 roster.attach_node(nid_yyf, fp_yyf);
534 roster.attach_node(nid_yyg, fp_yyg);
535
536}
537
538UNIT_TEST(restrictions, empty_restriction)
539{
540 roster_t roster;
541 setup(roster);
542
543 // check restricted nodes
544
545 node_restriction nmask;
546
547 UNIT_TEST_CHECK(nmask.empty());
548
549 UNIT_TEST_CHECK(nmask.includes(roster, nid_root));
550 UNIT_TEST_CHECK(nmask.includes(roster, nid_f));
551 UNIT_TEST_CHECK(nmask.includes(roster, nid_g));
552
553 UNIT_TEST_CHECK(nmask.includes(roster, nid_x));
554 UNIT_TEST_CHECK(nmask.includes(roster, nid_xf));
555 UNIT_TEST_CHECK(nmask.includes(roster, nid_xg));
556 UNIT_TEST_CHECK(nmask.includes(roster, nid_xx));
557 UNIT_TEST_CHECK(nmask.includes(roster, nid_xxf));
558 UNIT_TEST_CHECK(nmask.includes(roster, nid_xxg));
559 UNIT_TEST_CHECK(nmask.includes(roster, nid_xy));
560 UNIT_TEST_CHECK(nmask.includes(roster, nid_xyf));
561 UNIT_TEST_CHECK(nmask.includes(roster, nid_xyg));
562
563 UNIT_TEST_CHECK(nmask.includes(roster, nid_y));
564 UNIT_TEST_CHECK(nmask.includes(roster, nid_yf));
565 UNIT_TEST_CHECK(nmask.includes(roster, nid_yg));
566 UNIT_TEST_CHECK(nmask.includes(roster, nid_yx));
567 UNIT_TEST_CHECK(nmask.includes(roster, nid_yxf));
568 UNIT_TEST_CHECK(nmask.includes(roster, nid_yxg));
569 UNIT_TEST_CHECK(nmask.includes(roster, nid_yy));
570 UNIT_TEST_CHECK(nmask.includes(roster, nid_yyf));
571 UNIT_TEST_CHECK(nmask.includes(roster, nid_yyg));
572
573 // check restricted paths
574
575 path_restriction pmask;
576
577 UNIT_TEST_CHECK(pmask.empty());
578
579 UNIT_TEST_CHECK(pmask.includes(fp_root));
580 UNIT_TEST_CHECK(pmask.includes(fp_f));
581 UNIT_TEST_CHECK(pmask.includes(fp_g));
582
583 UNIT_TEST_CHECK(pmask.includes(fp_x));
584 UNIT_TEST_CHECK(pmask.includes(fp_xf));
585 UNIT_TEST_CHECK(pmask.includes(fp_xg));
586 UNIT_TEST_CHECK(pmask.includes(fp_xx));
587 UNIT_TEST_CHECK(pmask.includes(fp_xxf));
588 UNIT_TEST_CHECK(pmask.includes(fp_xxg));
589 UNIT_TEST_CHECK(pmask.includes(fp_xy));
590 UNIT_TEST_CHECK(pmask.includes(fp_xyf));
591 UNIT_TEST_CHECK(pmask.includes(fp_xyg));
592
593 UNIT_TEST_CHECK(pmask.includes(fp_y));
594 UNIT_TEST_CHECK(pmask.includes(fp_yf));
595 UNIT_TEST_CHECK(pmask.includes(fp_yg));
596 UNIT_TEST_CHECK(pmask.includes(fp_yx));
597 UNIT_TEST_CHECK(pmask.includes(fp_yxf));
598 UNIT_TEST_CHECK(pmask.includes(fp_yxg));
599 UNIT_TEST_CHECK(pmask.includes(fp_yy));
600 UNIT_TEST_CHECK(pmask.includes(fp_yyf));
601 UNIT_TEST_CHECK(pmask.includes(fp_yyg));
602}
603
604UNIT_TEST(restrictions, simple_include)
605{
606 roster_t roster;
607 setup(roster);
608
609 vector<file_path> includes, excludes;
610 includes.push_back(file_path_internal("x/x"));
611 includes.push_back(file_path_internal("y/y"));
612
613 app_state app;
614
615 // check restricted nodes
616
617 node_restriction nmask(includes, excludes, -1, roster, app);
618
619 UNIT_TEST_CHECK(!nmask.empty());
620
621 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
622 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
623 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
624
625 UNIT_TEST_CHECK(!nmask.includes(roster, nid_x));
626 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xf));
627 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xg));
628 UNIT_TEST_CHECK( nmask.includes(roster, nid_xx));
629 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxf));
630 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxg));
631 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xy));
632 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyf));
633 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyg));
634
635 UNIT_TEST_CHECK(!nmask.includes(roster, nid_y));
636 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yf));
637 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yg));
638 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yx));
639 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxf));
640 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxg));
641 UNIT_TEST_CHECK( nmask.includes(roster, nid_yy));
642 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyf));
643 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyg));
644
645 // check restricted paths
646
647 path_restriction pmask(includes, excludes, -1, app);
648
649 UNIT_TEST_CHECK(!pmask.empty());
650
651 UNIT_TEST_CHECK(!pmask.includes(fp_root));
652 UNIT_TEST_CHECK(!pmask.includes(fp_f));
653 UNIT_TEST_CHECK(!pmask.includes(fp_g));
654
655 UNIT_TEST_CHECK(!pmask.includes(fp_x));
656 UNIT_TEST_CHECK(!pmask.includes(fp_xf));
657 UNIT_TEST_CHECK(!pmask.includes(fp_xg));
658 UNIT_TEST_CHECK( pmask.includes(fp_xx));
659 UNIT_TEST_CHECK( pmask.includes(fp_xxf));
660 UNIT_TEST_CHECK( pmask.includes(fp_xxg));
661 UNIT_TEST_CHECK(!pmask.includes(fp_xy));
662 UNIT_TEST_CHECK(!pmask.includes(fp_xyf));
663 UNIT_TEST_CHECK(!pmask.includes(fp_xyg));
664
665 UNIT_TEST_CHECK(!pmask.includes(fp_y));
666 UNIT_TEST_CHECK(!pmask.includes(fp_yf));
667 UNIT_TEST_CHECK(!pmask.includes(fp_yg));
668 UNIT_TEST_CHECK(!pmask.includes(fp_yx));
669 UNIT_TEST_CHECK(!pmask.includes(fp_yxf));
670 UNIT_TEST_CHECK(!pmask.includes(fp_yxg));
671 UNIT_TEST_CHECK( pmask.includes(fp_yy));
672 UNIT_TEST_CHECK( pmask.includes(fp_yyf));
673 UNIT_TEST_CHECK( pmask.includes(fp_yyg));
674}
675
676UNIT_TEST(restrictions, simple_exclude)
677{
678 roster_t roster;
679 setup(roster);
680
681 vector<file_path> includes, excludes;
682 excludes.push_back(file_path_internal("x/x"));
683 excludes.push_back(file_path_internal("y/y"));
684
685 app_state app;
686
687 // check restricted nodes
688
689 node_restriction nmask(includes, excludes, -1, roster, app);
690
691 UNIT_TEST_CHECK(!nmask.empty());
692
693 UNIT_TEST_CHECK( nmask.includes(roster, nid_root));
694 UNIT_TEST_CHECK( nmask.includes(roster, nid_f));
695 UNIT_TEST_CHECK( nmask.includes(roster, nid_g));
696
697 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
698 UNIT_TEST_CHECK( nmask.includes(roster, nid_xf));
699 UNIT_TEST_CHECK( nmask.includes(roster, nid_xg));
700 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xx));
701 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxf));
702 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxg));
703 UNIT_TEST_CHECK( nmask.includes(roster, nid_xy));
704 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyf));
705 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyg));
706
707 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
708 UNIT_TEST_CHECK( nmask.includes(roster, nid_yf));
709 UNIT_TEST_CHECK( nmask.includes(roster, nid_yg));
710 UNIT_TEST_CHECK( nmask.includes(roster, nid_yx));
711 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxf));
712 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxg));
713 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yy));
714 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyf));
715 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyg));
716
717 // check restricted paths
718
719 path_restriction pmask(includes, excludes, -1, app);
720
721 UNIT_TEST_CHECK(!pmask.empty());
722
723 UNIT_TEST_CHECK( pmask.includes(fp_root));
724 UNIT_TEST_CHECK( pmask.includes(fp_f));
725 UNIT_TEST_CHECK( pmask.includes(fp_g));
726
727 UNIT_TEST_CHECK( pmask.includes(fp_x));
728 UNIT_TEST_CHECK( pmask.includes(fp_xf));
729 UNIT_TEST_CHECK( pmask.includes(fp_xg));
730 UNIT_TEST_CHECK(!pmask.includes(fp_xx));
731 UNIT_TEST_CHECK(!pmask.includes(fp_xxf));
732 UNIT_TEST_CHECK(!pmask.includes(fp_xxg));
733 UNIT_TEST_CHECK( pmask.includes(fp_xy));
734 UNIT_TEST_CHECK( pmask.includes(fp_xyf));
735 UNIT_TEST_CHECK( pmask.includes(fp_xyg));
736
737 UNIT_TEST_CHECK( pmask.includes(fp_y));
738 UNIT_TEST_CHECK( pmask.includes(fp_yf));
739 UNIT_TEST_CHECK( pmask.includes(fp_yg));
740 UNIT_TEST_CHECK( pmask.includes(fp_yx));
741 UNIT_TEST_CHECK( pmask.includes(fp_yxf));
742 UNIT_TEST_CHECK( pmask.includes(fp_yxg));
743 UNIT_TEST_CHECK(!pmask.includes(fp_yy));
744 UNIT_TEST_CHECK(!pmask.includes(fp_yyf));
745 UNIT_TEST_CHECK(!pmask.includes(fp_yyg));
746}
747
748UNIT_TEST(restrictions, include_exclude)
749{
750 roster_t roster;
751 setup(roster);
752
753 vector<file_path> includes, excludes;
754 includes.push_back(file_path_internal("x"));
755 includes.push_back(file_path_internal("y"));
756 excludes.push_back(file_path_internal("x/x"));
757 excludes.push_back(file_path_internal("y/y"));
758
759 app_state app;
760
761 // check restricted nodes
762
763 node_restriction nmask(includes, excludes, -1, roster, app);
764
765 UNIT_TEST_CHECK(!nmask.empty());
766
767 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
768 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
769 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
770
771 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
772 UNIT_TEST_CHECK( nmask.includes(roster, nid_xf));
773 UNIT_TEST_CHECK( nmask.includes(roster, nid_xg));
774 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xx));
775 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxf));
776 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxg));
777 UNIT_TEST_CHECK( nmask.includes(roster, nid_xy));
778 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyf));
779 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyg));
780
781 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
782 UNIT_TEST_CHECK( nmask.includes(roster, nid_yf));
783 UNIT_TEST_CHECK( nmask.includes(roster, nid_yg));
784 UNIT_TEST_CHECK( nmask.includes(roster, nid_yx));
785 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxf));
786 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxg));
787 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yy));
788 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyf));
789 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyg));
790
791 // check restricted paths
792
793 path_restriction pmask(includes, excludes, -1, app);
794
795 UNIT_TEST_CHECK(!pmask.empty());
796
797 UNIT_TEST_CHECK(!pmask.includes(fp_root));
798 UNIT_TEST_CHECK(!pmask.includes(fp_f));
799 UNIT_TEST_CHECK(!pmask.includes(fp_g));
800
801 UNIT_TEST_CHECK( pmask.includes(fp_x));
802 UNIT_TEST_CHECK( pmask.includes(fp_xf));
803 UNIT_TEST_CHECK( pmask.includes(fp_xg));
804 UNIT_TEST_CHECK(!pmask.includes(fp_xx));
805 UNIT_TEST_CHECK(!pmask.includes(fp_xxf));
806 UNIT_TEST_CHECK(!pmask.includes(fp_xxg));
807 UNIT_TEST_CHECK( pmask.includes(fp_xy));
808 UNIT_TEST_CHECK( pmask.includes(fp_xyf));
809 UNIT_TEST_CHECK( pmask.includes(fp_xyg));
810
811 UNIT_TEST_CHECK( pmask.includes(fp_y));
812 UNIT_TEST_CHECK( pmask.includes(fp_yf));
813 UNIT_TEST_CHECK( pmask.includes(fp_yg));
814 UNIT_TEST_CHECK( pmask.includes(fp_yx));
815 UNIT_TEST_CHECK( pmask.includes(fp_yxf));
816 UNIT_TEST_CHECK( pmask.includes(fp_yxg));
817 UNIT_TEST_CHECK(!pmask.includes(fp_yy));
818 UNIT_TEST_CHECK(!pmask.includes(fp_yyf));
819 UNIT_TEST_CHECK(!pmask.includes(fp_yyg));
820}
821
822UNIT_TEST(restrictions, exclude_include)
823{
824 roster_t roster;
825 setup(roster);
826
827 vector<file_path> includes, excludes;
828 // note that excludes higher up the tree than the top
829 // include are rather pointless -- nothing above the
830 // top include is included anyway
831 excludes.push_back(file_path_internal("x"));
832 excludes.push_back(file_path_internal("y"));
833 includes.push_back(file_path_internal("x/x"));
834 includes.push_back(file_path_internal("y/y"));
835
836 app_state app;
837
838 // check restricted nodes
839
840 node_restriction nmask(includes, excludes, -1, roster, app);
841
842 UNIT_TEST_CHECK(!nmask.empty());
843
844 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
845 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
846 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
847
848 UNIT_TEST_CHECK(!nmask.includes(roster, nid_x));
849 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xf));
850 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xg));
851 UNIT_TEST_CHECK( nmask.includes(roster, nid_xx));
852 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxf));
853 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxg));
854 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xy));
855 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyf));
856 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyg));
857
858 UNIT_TEST_CHECK(!nmask.includes(roster, nid_y));
859 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yf));
860 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yg));
861 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yx));
862 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxf));
863 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxg));
864 UNIT_TEST_CHECK( nmask.includes(roster, nid_yy));
865 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyf));
866 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyg));
867
868 // check restricted paths
869
870 path_restriction pmask(includes, excludes, -1, app);
871
872 UNIT_TEST_CHECK(!pmask.empty());
873
874 UNIT_TEST_CHECK(!pmask.includes(fp_root));
875 UNIT_TEST_CHECK(!pmask.includes(fp_f));
876 UNIT_TEST_CHECK(!pmask.includes(fp_g));
877
878 UNIT_TEST_CHECK(!pmask.includes(fp_x));
879 UNIT_TEST_CHECK(!pmask.includes(fp_xf));
880 UNIT_TEST_CHECK(!pmask.includes(fp_xg));
881 UNIT_TEST_CHECK( pmask.includes(fp_xx));
882 UNIT_TEST_CHECK( pmask.includes(fp_xxf));
883 UNIT_TEST_CHECK( pmask.includes(fp_xxg));
884 UNIT_TEST_CHECK(!pmask.includes(fp_xy));
885 UNIT_TEST_CHECK(!pmask.includes(fp_xyf));
886 UNIT_TEST_CHECK(!pmask.includes(fp_xyg));
887
888 UNIT_TEST_CHECK(!pmask.includes(fp_y));
889 UNIT_TEST_CHECK(!pmask.includes(fp_yf));
890 UNIT_TEST_CHECK(!pmask.includes(fp_yg));
891 UNIT_TEST_CHECK(!pmask.includes(fp_yx));
892 UNIT_TEST_CHECK(!pmask.includes(fp_yxf));
893 UNIT_TEST_CHECK(!pmask.includes(fp_yxg));
894 UNIT_TEST_CHECK( pmask.includes(fp_yy));
895 UNIT_TEST_CHECK( pmask.includes(fp_yyf));
896 UNIT_TEST_CHECK( pmask.includes(fp_yyg));
897}
898
899UNIT_TEST(restrictions, invalid_roster_paths)
900{
901 roster_t roster;
902 setup(roster);
903
904 vector<file_path> includes, excludes;
905 includes.push_back(file_path_internal("foo"));
906 excludes.push_back(file_path_internal("bar"));
907
908 app_state app;
909 UNIT_TEST_CHECK_THROW(node_restriction(includes, excludes, -1, roster, app),
910 informative_failure);
911}
912
913UNIT_TEST(restrictions, invalid_workspace_paths)
914{
915 roster_t roster;
916 setup(roster);
917
918 vector<file_path> includes, excludes;
919 includes.push_back(file_path_internal("foo"));
920 excludes.push_back(file_path_internal("bar"));
921
922 app_state app;
923 UNIT_TEST_CHECK_THROW(path_restriction(includes, excludes, -1, app),
924 informative_failure);
925}
926
927UNIT_TEST(restrictions, ignored_invalid_workspace_paths)
928{
929 roster_t roster;
930 setup(roster);
931
932 vector<file_path> includes, excludes;
933 includes.push_back(file_path_internal("foo"));
934 excludes.push_back(file_path_internal("bar"));
935
936 app_state app;
937 path_restriction pmask(includes, excludes, -1, app, path_restriction::skip_check);
938
939 UNIT_TEST_CHECK( pmask.includes(file_path_internal("foo")));
940 UNIT_TEST_CHECK(!pmask.includes(file_path_internal("bar")));
941}
942
943UNIT_TEST(restrictions, include_depth_0)
944{
945 roster_t roster;
946 setup(roster);
947
948 vector<file_path> includes, excludes;
949 includes.push_back(file_path_internal("x"));
950 includes.push_back(file_path_internal("y"));
951
952 app_state app;
953 // FIXME: depth == 0 currently means directory + immediate children
954 // this should be changed to mean just the named directory but for
955 // compatibility with old restrictions this behaviour has been preserved
956 long depth = 0;
957
958 // check restricted nodes
959
960 node_restriction nmask(includes, excludes, depth, roster, app);
961
962 UNIT_TEST_CHECK(!nmask.empty());
963
964 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
965 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
966 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
967
968 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
969 UNIT_TEST_CHECK( nmask.includes(roster, nid_xf));
970 UNIT_TEST_CHECK( nmask.includes(roster, nid_xg));
971 UNIT_TEST_CHECK( nmask.includes(roster, nid_xx));
972 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxf));
973 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxg));
974 UNIT_TEST_CHECK( nmask.includes(roster, nid_xy));
975 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyf));
976 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyg));
977
978 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
979 UNIT_TEST_CHECK( nmask.includes(roster, nid_yf));
980 UNIT_TEST_CHECK( nmask.includes(roster, nid_yg));
981 UNIT_TEST_CHECK( nmask.includes(roster, nid_yx));
982 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxf));
983 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxg));
984 UNIT_TEST_CHECK( nmask.includes(roster, nid_yy));
985 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyf));
986 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyg));
987
988 // check restricted paths
989
990 path_restriction pmask(includes, excludes, depth, app);
991
992 UNIT_TEST_CHECK(!pmask.empty());
993
994 UNIT_TEST_CHECK(!pmask.includes(fp_root));
995 UNIT_TEST_CHECK(!pmask.includes(fp_f));
996 UNIT_TEST_CHECK(!pmask.includes(fp_g));
997
998 UNIT_TEST_CHECK( pmask.includes(fp_x));
999 UNIT_TEST_CHECK( pmask.includes(fp_xf));
1000 UNIT_TEST_CHECK( pmask.includes(fp_xg));
1001 UNIT_TEST_CHECK( pmask.includes(fp_xx));
1002 UNIT_TEST_CHECK(!pmask.includes(fp_xxf));
1003 UNIT_TEST_CHECK(!pmask.includes(fp_xxg));
1004 UNIT_TEST_CHECK( pmask.includes(fp_xy));
1005 UNIT_TEST_CHECK(!pmask.includes(fp_xyf));
1006 UNIT_TEST_CHECK(!pmask.includes(fp_xyg));
1007
1008 UNIT_TEST_CHECK( pmask.includes(fp_y));
1009 UNIT_TEST_CHECK( pmask.includes(fp_yf));
1010 UNIT_TEST_CHECK( pmask.includes(fp_yg));
1011 UNIT_TEST_CHECK( pmask.includes(fp_yx));
1012 UNIT_TEST_CHECK(!pmask.includes(fp_yxf));
1013 UNIT_TEST_CHECK(!pmask.includes(fp_yxg));
1014 UNIT_TEST_CHECK( pmask.includes(fp_yy));
1015 UNIT_TEST_CHECK(!pmask.includes(fp_yyf));
1016 UNIT_TEST_CHECK(!pmask.includes(fp_yyg));
1017}
1018
1019UNIT_TEST(restrictions, include_depth_0_empty_restriction)
1020{
1021 roster_t roster;
1022 setup(roster);
1023
1024 vector<file_path> includes, excludes;
1025
1026 app_state app;
1027 // FIXME: depth == 0 currently means directory + immediate children
1028 // this should be changed to mean just the named directory but for
1029 // compatibility with old restrictions this behaviour has been preserved
1030 long depth = 0;
1031
1032 // check restricted nodes
1033
1034 node_restriction nmask(includes, excludes, depth, roster, app);
1035
1036 UNIT_TEST_CHECK( nmask.empty());
1037
1038 UNIT_TEST_CHECK( nmask.includes(roster, nid_root));
1039 UNIT_TEST_CHECK( nmask.includes(roster, nid_f));
1040 UNIT_TEST_CHECK( nmask.includes(roster, nid_g));
1041
1042 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
1043 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xf));
1044 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xg));
1045 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xx));
1046 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxf));
1047 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxg));
1048 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xy));
1049 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyf));
1050 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyg));
1051
1052 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
1053 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yf));
1054 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yg));
1055 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yx));
1056 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxf));
1057 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxg));
1058 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yy));
1059 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyf));
1060 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyg));
1061
1062 // check restricted paths
1063
1064 path_restriction pmask(includes, excludes, depth, app);
1065
1066 UNIT_TEST_CHECK( pmask.empty());
1067
1068 UNIT_TEST_CHECK( pmask.includes(fp_root));
1069 UNIT_TEST_CHECK( pmask.includes(fp_f));
1070 UNIT_TEST_CHECK( pmask.includes(fp_g));
1071
1072 UNIT_TEST_CHECK( pmask.includes(fp_x));
1073 UNIT_TEST_CHECK(!pmask.includes(fp_xf));
1074 UNIT_TEST_CHECK(!pmask.includes(fp_xg));
1075 UNIT_TEST_CHECK(!pmask.includes(fp_xx));
1076 UNIT_TEST_CHECK(!pmask.includes(fp_xxf));
1077 UNIT_TEST_CHECK(!pmask.includes(fp_xxg));
1078 UNIT_TEST_CHECK(!pmask.includes(fp_xy));
1079 UNIT_TEST_CHECK(!pmask.includes(fp_xyf));
1080 UNIT_TEST_CHECK(!pmask.includes(fp_xyg));
1081
1082 UNIT_TEST_CHECK( pmask.includes(fp_y));
1083 UNIT_TEST_CHECK(!pmask.includes(fp_yf));
1084 UNIT_TEST_CHECK(!pmask.includes(fp_yg));
1085 UNIT_TEST_CHECK(!pmask.includes(fp_yx));
1086 UNIT_TEST_CHECK(!pmask.includes(fp_yxf));
1087 UNIT_TEST_CHECK(!pmask.includes(fp_yxg));
1088 UNIT_TEST_CHECK(!pmask.includes(fp_yy));
1089 UNIT_TEST_CHECK(!pmask.includes(fp_yyf));
1090 UNIT_TEST_CHECK(!pmask.includes(fp_yyg));
1091}
1092
1093UNIT_TEST(restrictions, include_depth_1)
1094{
1095 roster_t roster;
1096 setup(roster);
1097
1098 vector<file_path> includes, excludes;
1099 includes.push_back(file_path_internal("x"));
1100 includes.push_back(file_path_internal("y"));
1101
1102 app_state app;
1103 // FIXME: depth == 1 currently means directory + children + grand children
1104 // this should be changed to mean directory + immediate children but for
1105 // compatibility with old restrictions this behaviour has been preserved
1106 long depth = 1;
1107
1108 // check restricted nodes
1109
1110 node_restriction nmask(includes, excludes, depth, roster, app);
1111
1112 UNIT_TEST_CHECK(!nmask.empty());
1113
1114 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
1115 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
1116 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
1117
1118 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
1119 UNIT_TEST_CHECK( nmask.includes(roster, nid_xf));
1120 UNIT_TEST_CHECK( nmask.includes(roster, nid_xg));
1121 UNIT_TEST_CHECK( nmask.includes(roster, nid_xx));
1122 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxf));
1123 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxg));
1124 UNIT_TEST_CHECK( nmask.includes(roster, nid_xy));
1125 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyf));
1126 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyg));
1127
1128 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
1129 UNIT_TEST_CHECK( nmask.includes(roster, nid_yf));
1130 UNIT_TEST_CHECK( nmask.includes(roster, nid_yg));
1131 UNIT_TEST_CHECK( nmask.includes(roster, nid_yx));
1132 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxf));
1133 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxg));
1134 UNIT_TEST_CHECK( nmask.includes(roster, nid_yy));
1135 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyf));
1136 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyg));
1137
1138 // check restricted paths
1139
1140 path_restriction pmask(includes, excludes, depth, app);
1141
1142 UNIT_TEST_CHECK(!pmask.empty());
1143
1144 UNIT_TEST_CHECK(!pmask.includes(fp_root));
1145 UNIT_TEST_CHECK(!pmask.includes(fp_f));
1146 UNIT_TEST_CHECK(!pmask.includes(fp_g));
1147
1148 UNIT_TEST_CHECK( pmask.includes(fp_x));
1149 UNIT_TEST_CHECK( pmask.includes(fp_xf));
1150 UNIT_TEST_CHECK( pmask.includes(fp_xg));
1151 UNIT_TEST_CHECK( pmask.includes(fp_xx));
1152 UNIT_TEST_CHECK( pmask.includes(fp_xxf));
1153 UNIT_TEST_CHECK( pmask.includes(fp_xxg));
1154 UNIT_TEST_CHECK( pmask.includes(fp_xy));
1155 UNIT_TEST_CHECK( pmask.includes(fp_xyf));
1156 UNIT_TEST_CHECK( pmask.includes(fp_xyg));
1157
1158 UNIT_TEST_CHECK( pmask.includes(fp_y));
1159 UNIT_TEST_CHECK( pmask.includes(fp_yf));
1160 UNIT_TEST_CHECK( pmask.includes(fp_yg));
1161 UNIT_TEST_CHECK( pmask.includes(fp_yx));
1162 UNIT_TEST_CHECK( pmask.includes(fp_yxf));
1163 UNIT_TEST_CHECK( pmask.includes(fp_yxg));
1164 UNIT_TEST_CHECK( pmask.includes(fp_yy));
1165 UNIT_TEST_CHECK( pmask.includes(fp_yyf));
1166 UNIT_TEST_CHECK( pmask.includes(fp_yyg));
1167}
1168
1169#endif // BUILD_UNIT_TESTS
1170
1171// Local Variables:
1172// mode: C++
1173// fill-column: 76
1174// c-file-style: "gnu"
1175// indent-tabs-mode: nil
1176// End:
1177// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status