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>
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 restriction(includes, excludes, depth)
226{
227 map_paths(path_map, included_paths, restricted_path::included);
228 map_paths(path_map, excluded_paths, restricted_path::excluded);
229
230 validate_workspace_paths(included_paths, excluded_paths, a);
231}
232
233bool
234node_restriction::includes(roster_t const & roster, node_id nid) const
235{
236 MM(roster);
237 I(roster.has_node(nid));
238
239 file_path fp;
240 roster.get_name(nid, fp);
241
242 if (empty())
243 {
244 if (depth != -1)
245 {
246 int path_depth = fp.depth();
247 if (path_depth <= depth + 1)
248 {
249 L(FL("depth includes nid %d path '%s'") % nid % fp);
250 return true;
251 }
252 else
253 {
254 L(FL("depth excludes nid %d path '%s'") % nid % fp);
255 return false;
256 }
257 }
258 else
259 {
260 // don't log this, we end up using rather a bit of cpu time just
261 // in the logging code, for totally unrestricted operations.
262 return true;
263 }
264 }
265
266 node_id current = nid;
267 int path_depth = 0;
268
269 // FIXME: this uses depth+1 because the old semantics of depth=0 were
270 // something like "the current directory and its immediate children". it
271 // seems somewhat more reasonable here to use depth=0 to mean "exactly
272 // this directory" and depth=1 to mean "this directory and its immediate
273 // children"
274
275 while (!null_node(current) && (depth == -1 || path_depth <= depth + 1))
276 {
277 map<node_id, restricted_path::status>::const_iterator
278 r = node_map.find(current);
279
280 if (r != node_map.end())
281 {
282 switch (r->second)
283 {
284 case restricted_path::included:
285 L(FL("explicit include of nid %d path '%s'")
286 % current % fp);
287 return true;
288
289 case restricted_path::excluded:
290 L(FL("explicit exclude of nid %d path '%s'")
291 % current % fp);
292 return false;
293 }
294 }
295
296 node_t node = roster.get_node(current);
297 current = node->parent;
298 path_depth++;
299 }
300
301 if (included_paths.empty())
302 {
303 L(FL("default include of nid %d path '%s'")
304 % nid % fp);
305 return true;
306 }
307 else
308 {
309 if (global_sanity.debug)
310 {
311 // printing this slows down "log <file>".
312 L(FL("(debug) default exclude of nid %d path '%s'")
313 % nid % fp);
314 }
315 return false;
316 }
317}
318
319bool
320path_restriction::includes(file_path const & pth) const
321{
322 if (empty())
323 {
324 if (depth != -1)
325 {
326 int path_depth = pth.depth();
327 if (path_depth <= depth + 1)
328 {
329 L(FL("depth includes path '%s'") % pth);
330 return true;
331 }
332 else
333 {
334 L(FL("depth excludes path '%s'") % pth);
335 return false;
336 }
337 }
338 else
339 {
340 L(FL("empty include of path '%s'") % pth);
341 return true;
342 }
343 }
344
345 // FIXME: this uses depth+1 because the old semantics of depth=0 were
346 // something like "the current directory and its immediate children". it
347 // seems somewhat more reasonable here to use depth=0 to mean "exactly
348 // this directory" and depth=1 to mean "this directory and its immediate
349 // children"
350
351 int path_depth = 0;
352 file_path fp = pth;
353 while (depth == -1 || path_depth <= depth + 1)
354 {
355 map<file_path, restricted_path::status>::const_iterator
356 r = path_map.find(fp);
357
358 if (r != path_map.end())
359 {
360 switch (r->second)
361 {
362 case restricted_path::included:
363 L(FL("explicit include of path '%s'") % pth);
364 return true;
365
366 case restricted_path::excluded:
367 L(FL("explicit exclude of path '%s'") % pth);
368 return false;
369 }
370 }
371
372 if (fp.empty())
373 break;
374 fp = fp.dirname();
375 path_depth++;
376 }
377
378 if (included_paths.empty())
379 {
380 L(FL("default include of path '%s'") % pth);
381 return true;
382 }
383 else
384 {
385 L(FL("default exclude of path '%s'") % pth);
386 return false;
387 }
388}
389
390///////////////////////////////////////////////////////////////////////
391// tests
392///////////////////////////////////////////////////////////////////////
393
394#ifdef BUILD_UNIT_TESTS
395#include "app_state.hh"
396#include "unit_tests.hh"
397#include "roster.hh"
398#include "sanity.hh"
399
400using std::string;
401
402// f's and g's are files
403// x's and y's are directories
404// and this is rather painful
405
406file_path fp_root = file_path_internal("");
407file_path fp_f = file_path_internal("f");
408file_path fp_g = file_path_internal("g");
409
410file_path fp_x = file_path_internal("x");
411file_path fp_xf = file_path_internal("x/f");
412file_path fp_xg = file_path_internal("x/g");
413file_path fp_xx = file_path_internal("x/x");
414file_path fp_xxf = file_path_internal("x/x/f");
415file_path fp_xxg = file_path_internal("x/x/g");
416file_path fp_xy = file_path_internal("x/y");
417file_path fp_xyf = file_path_internal("x/y/f");
418file_path fp_xyg = file_path_internal("x/y/g");
419
420file_path fp_y = file_path_internal("y");
421file_path fp_yf = file_path_internal("y/f");
422file_path fp_yg = file_path_internal("y/g");
423file_path fp_yx = file_path_internal("y/x");
424file_path fp_yxf = file_path_internal("y/x/f");
425file_path fp_yxg = file_path_internal("y/x/g");
426file_path fp_yy = file_path_internal("y/y");
427file_path fp_yyf = file_path_internal("y/y/f");
428file_path fp_yyg = file_path_internal("y/y/g");
429
430node_id nid_root;
431node_id nid_f;
432node_id nid_g;
433
434node_id nid_x;
435node_id nid_xf;
436node_id nid_xg;
437node_id nid_xx;
438node_id nid_xxf;
439node_id nid_xxg;
440node_id nid_xy;
441node_id nid_xyf;
442node_id nid_xyg;
443
444node_id nid_y;
445node_id nid_yf;
446node_id nid_yg;
447node_id nid_yx;
448node_id nid_yxf;
449node_id nid_yxg;
450node_id nid_yy;
451node_id nid_yyf;
452node_id nid_yyg;
453
454file_id fid_f(string("1000000000000000000000000000000000000000"));
455file_id fid_g(string("2000000000000000000000000000000000000000"));
456
457file_id fid_xf(string("3000000000000000000000000000000000000000"));
458file_id fid_xg(string("4000000000000000000000000000000000000000"));
459file_id fid_xxf(string("5000000000000000000000000000000000000000"));
460file_id fid_xxg(string("6000000000000000000000000000000000000000"));
461file_id fid_xyf(string("7000000000000000000000000000000000000000"));
462file_id fid_xyg(string("8000000000000000000000000000000000000000"));
463
464file_id fid_yf(string("9000000000000000000000000000000000000000"));
465file_id fid_yg(string("a000000000000000000000000000000000000000"));
466file_id fid_yxf(string("b000000000000000000000000000000000000000"));
467file_id fid_yxg(string("c000000000000000000000000000000000000000"));
468file_id fid_yyf(string("d000000000000000000000000000000000000000"));
469file_id fid_yyg(string("e000000000000000000000000000000000000000"));
470
471static void setup(roster_t & roster)
472{
473 temp_node_id_source nis;
474
475 // these directories must exist for the path_restrictions to be valid. it
476 // is a bit lame to be creating directories arbitrarily like this. perhaps
477 // unit_tests should run in a unit_tests.dir or something.
478
479 mkdir_p(file_path_internal("x/x"));
480 mkdir_p(file_path_internal("x/y"));
481 mkdir_p(file_path_internal("y/x"));
482 mkdir_p(file_path_internal("y/y"));
483
484 nid_root = roster.create_dir_node(nis);
485 nid_f = roster.create_file_node(fid_f, nis);
486 nid_g = roster.create_file_node(fid_g, nis);
487
488 nid_x = roster.create_dir_node(nis);
489 nid_xf = roster.create_file_node(fid_xf, nis);
490 nid_xg = roster.create_file_node(fid_xg, nis);
491 nid_xx = roster.create_dir_node(nis);
492 nid_xxf = roster.create_file_node(fid_xxf, nis);
493 nid_xxg = roster.create_file_node(fid_xxg, nis);
494 nid_xy = roster.create_dir_node(nis);
495 nid_xyf = roster.create_file_node(fid_xxf, nis);
496 nid_xyg = roster.create_file_node(fid_xxg, nis);
497
498 nid_y = roster.create_dir_node(nis);
499 nid_yf = roster.create_file_node(fid_yf, nis);
500 nid_yg = roster.create_file_node(fid_yg, nis);
501 nid_yx = roster.create_dir_node(nis);
502 nid_yxf = roster.create_file_node(fid_yxf, nis);
503 nid_yxg = roster.create_file_node(fid_yxg, nis);
504 nid_yy = roster.create_dir_node(nis);
505 nid_yyf = roster.create_file_node(fid_yxf, nis);
506 nid_yyg = roster.create_file_node(fid_yxg, nis);
507
508 roster.attach_node(nid_root, fp_root);
509 roster.attach_node(nid_f, fp_f);
510 roster.attach_node(nid_g, fp_g);
511
512 roster.attach_node(nid_x, fp_x);
513 roster.attach_node(nid_xf, fp_xf);
514 roster.attach_node(nid_xg, fp_xg);
515 roster.attach_node(nid_xx, fp_xx);
516 roster.attach_node(nid_xxf, fp_xxf);
517 roster.attach_node(nid_xxg, fp_xxg);
518 roster.attach_node(nid_xy, fp_xy);
519 roster.attach_node(nid_xyf, fp_xyf);
520 roster.attach_node(nid_xyg, fp_xyg);
521
522 roster.attach_node(nid_y, fp_y);
523 roster.attach_node(nid_yf, fp_yf);
524 roster.attach_node(nid_yg, fp_yg);
525 roster.attach_node(nid_yx, fp_yx);
526 roster.attach_node(nid_yxf, fp_yxf);
527 roster.attach_node(nid_yxg, fp_yxg);
528 roster.attach_node(nid_yy, fp_yy);
529 roster.attach_node(nid_yyf, fp_yyf);
530 roster.attach_node(nid_yyg, fp_yyg);
531
532}
533
534UNIT_TEST(restrictions, empty_restriction)
535{
536 roster_t roster;
537 setup(roster);
538
539 // check restricted nodes
540
541 node_restriction nmask;
542
543 UNIT_TEST_CHECK(nmask.empty());
544
545 UNIT_TEST_CHECK(nmask.includes(roster, nid_root));
546 UNIT_TEST_CHECK(nmask.includes(roster, nid_f));
547 UNIT_TEST_CHECK(nmask.includes(roster, nid_g));
548
549 UNIT_TEST_CHECK(nmask.includes(roster, nid_x));
550 UNIT_TEST_CHECK(nmask.includes(roster, nid_xf));
551 UNIT_TEST_CHECK(nmask.includes(roster, nid_xg));
552 UNIT_TEST_CHECK(nmask.includes(roster, nid_xx));
553 UNIT_TEST_CHECK(nmask.includes(roster, nid_xxf));
554 UNIT_TEST_CHECK(nmask.includes(roster, nid_xxg));
555 UNIT_TEST_CHECK(nmask.includes(roster, nid_xy));
556 UNIT_TEST_CHECK(nmask.includes(roster, nid_xyf));
557 UNIT_TEST_CHECK(nmask.includes(roster, nid_xyg));
558
559 UNIT_TEST_CHECK(nmask.includes(roster, nid_y));
560 UNIT_TEST_CHECK(nmask.includes(roster, nid_yf));
561 UNIT_TEST_CHECK(nmask.includes(roster, nid_yg));
562 UNIT_TEST_CHECK(nmask.includes(roster, nid_yx));
563 UNIT_TEST_CHECK(nmask.includes(roster, nid_yxf));
564 UNIT_TEST_CHECK(nmask.includes(roster, nid_yxg));
565 UNIT_TEST_CHECK(nmask.includes(roster, nid_yy));
566 UNIT_TEST_CHECK(nmask.includes(roster, nid_yyf));
567 UNIT_TEST_CHECK(nmask.includes(roster, nid_yyg));
568
569 // check restricted paths
570
571 path_restriction pmask;
572
573 UNIT_TEST_CHECK(pmask.empty());
574
575 UNIT_TEST_CHECK(pmask.includes(fp_root));
576 UNIT_TEST_CHECK(pmask.includes(fp_f));
577 UNIT_TEST_CHECK(pmask.includes(fp_g));
578
579 UNIT_TEST_CHECK(pmask.includes(fp_x));
580 UNIT_TEST_CHECK(pmask.includes(fp_xf));
581 UNIT_TEST_CHECK(pmask.includes(fp_xg));
582 UNIT_TEST_CHECK(pmask.includes(fp_xx));
583 UNIT_TEST_CHECK(pmask.includes(fp_xxf));
584 UNIT_TEST_CHECK(pmask.includes(fp_xxg));
585 UNIT_TEST_CHECK(pmask.includes(fp_xy));
586 UNIT_TEST_CHECK(pmask.includes(fp_xyf));
587 UNIT_TEST_CHECK(pmask.includes(fp_xyg));
588
589 UNIT_TEST_CHECK(pmask.includes(fp_y));
590 UNIT_TEST_CHECK(pmask.includes(fp_yf));
591 UNIT_TEST_CHECK(pmask.includes(fp_yg));
592 UNIT_TEST_CHECK(pmask.includes(fp_yx));
593 UNIT_TEST_CHECK(pmask.includes(fp_yxf));
594 UNIT_TEST_CHECK(pmask.includes(fp_yxg));
595 UNIT_TEST_CHECK(pmask.includes(fp_yy));
596 UNIT_TEST_CHECK(pmask.includes(fp_yyf));
597 UNIT_TEST_CHECK(pmask.includes(fp_yyg));
598}
599
600UNIT_TEST(restrictions, simple_include)
601{
602 roster_t roster;
603 setup(roster);
604
605 vector<file_path> includes, excludes;
606 includes.push_back(file_path_internal("x/x"));
607 includes.push_back(file_path_internal("y/y"));
608
609 app_state app;
610
611 // check restricted nodes
612
613 node_restriction nmask(includes, excludes, -1, roster, app);
614
615 UNIT_TEST_CHECK(!nmask.empty());
616
617 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
618 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
619 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
620
621 UNIT_TEST_CHECK(!nmask.includes(roster, nid_x));
622 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xf));
623 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xg));
624 UNIT_TEST_CHECK( nmask.includes(roster, nid_xx));
625 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxf));
626 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxg));
627 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xy));
628 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyf));
629 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyg));
630
631 UNIT_TEST_CHECK(!nmask.includes(roster, nid_y));
632 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yf));
633 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yg));
634 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yx));
635 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxf));
636 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxg));
637 UNIT_TEST_CHECK( nmask.includes(roster, nid_yy));
638 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyf));
639 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyg));
640
641 // check restricted paths
642
643 path_restriction pmask(includes, excludes, -1, app);
644
645 UNIT_TEST_CHECK(!pmask.empty());
646
647 UNIT_TEST_CHECK(!pmask.includes(fp_root));
648 UNIT_TEST_CHECK(!pmask.includes(fp_f));
649 UNIT_TEST_CHECK(!pmask.includes(fp_g));
650
651 UNIT_TEST_CHECK(!pmask.includes(fp_x));
652 UNIT_TEST_CHECK(!pmask.includes(fp_xf));
653 UNIT_TEST_CHECK(!pmask.includes(fp_xg));
654 UNIT_TEST_CHECK( pmask.includes(fp_xx));
655 UNIT_TEST_CHECK( pmask.includes(fp_xxf));
656 UNIT_TEST_CHECK( pmask.includes(fp_xxg));
657 UNIT_TEST_CHECK(!pmask.includes(fp_xy));
658 UNIT_TEST_CHECK(!pmask.includes(fp_xyf));
659 UNIT_TEST_CHECK(!pmask.includes(fp_xyg));
660
661 UNIT_TEST_CHECK(!pmask.includes(fp_y));
662 UNIT_TEST_CHECK(!pmask.includes(fp_yf));
663 UNIT_TEST_CHECK(!pmask.includes(fp_yg));
664 UNIT_TEST_CHECK(!pmask.includes(fp_yx));
665 UNIT_TEST_CHECK(!pmask.includes(fp_yxf));
666 UNIT_TEST_CHECK(!pmask.includes(fp_yxg));
667 UNIT_TEST_CHECK( pmask.includes(fp_yy));
668 UNIT_TEST_CHECK( pmask.includes(fp_yyf));
669 UNIT_TEST_CHECK( pmask.includes(fp_yyg));
670}
671
672UNIT_TEST(restrictions, simple_exclude)
673{
674 roster_t roster;
675 setup(roster);
676
677 vector<file_path> includes, excludes;
678 excludes.push_back(file_path_internal("x/x"));
679 excludes.push_back(file_path_internal("y/y"));
680
681 app_state app;
682
683 // check restricted nodes
684
685 node_restriction nmask(includes, excludes, -1, roster, app);
686
687 UNIT_TEST_CHECK(!nmask.empty());
688
689 UNIT_TEST_CHECK( nmask.includes(roster, nid_root));
690 UNIT_TEST_CHECK( nmask.includes(roster, nid_f));
691 UNIT_TEST_CHECK( nmask.includes(roster, nid_g));
692
693 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
694 UNIT_TEST_CHECK( nmask.includes(roster, nid_xf));
695 UNIT_TEST_CHECK( nmask.includes(roster, nid_xg));
696 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xx));
697 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxf));
698 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxg));
699 UNIT_TEST_CHECK( nmask.includes(roster, nid_xy));
700 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyf));
701 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyg));
702
703 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
704 UNIT_TEST_CHECK( nmask.includes(roster, nid_yf));
705 UNIT_TEST_CHECK( nmask.includes(roster, nid_yg));
706 UNIT_TEST_CHECK( nmask.includes(roster, nid_yx));
707 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxf));
708 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxg));
709 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yy));
710 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyf));
711 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyg));
712
713 // check restricted paths
714
715 path_restriction pmask(includes, excludes, -1, app);
716
717 UNIT_TEST_CHECK(!pmask.empty());
718
719 UNIT_TEST_CHECK( pmask.includes(fp_root));
720 UNIT_TEST_CHECK( pmask.includes(fp_f));
721 UNIT_TEST_CHECK( pmask.includes(fp_g));
722
723 UNIT_TEST_CHECK( pmask.includes(fp_x));
724 UNIT_TEST_CHECK( pmask.includes(fp_xf));
725 UNIT_TEST_CHECK( pmask.includes(fp_xg));
726 UNIT_TEST_CHECK(!pmask.includes(fp_xx));
727 UNIT_TEST_CHECK(!pmask.includes(fp_xxf));
728 UNIT_TEST_CHECK(!pmask.includes(fp_xxg));
729 UNIT_TEST_CHECK( pmask.includes(fp_xy));
730 UNIT_TEST_CHECK( pmask.includes(fp_xyf));
731 UNIT_TEST_CHECK( pmask.includes(fp_xyg));
732
733 UNIT_TEST_CHECK( pmask.includes(fp_y));
734 UNIT_TEST_CHECK( pmask.includes(fp_yf));
735 UNIT_TEST_CHECK( pmask.includes(fp_yg));
736 UNIT_TEST_CHECK( pmask.includes(fp_yx));
737 UNIT_TEST_CHECK( pmask.includes(fp_yxf));
738 UNIT_TEST_CHECK( pmask.includes(fp_yxg));
739 UNIT_TEST_CHECK(!pmask.includes(fp_yy));
740 UNIT_TEST_CHECK(!pmask.includes(fp_yyf));
741 UNIT_TEST_CHECK(!pmask.includes(fp_yyg));
742}
743
744UNIT_TEST(restrictions, include_exclude)
745{
746 roster_t roster;
747 setup(roster);
748
749 vector<file_path> includes, excludes;
750 includes.push_back(file_path_internal("x"));
751 includes.push_back(file_path_internal("y"));
752 excludes.push_back(file_path_internal("x/x"));
753 excludes.push_back(file_path_internal("y/y"));
754
755 app_state app;
756
757 // check restricted nodes
758
759 node_restriction nmask(includes, excludes, -1, roster, app);
760
761 UNIT_TEST_CHECK(!nmask.empty());
762
763 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
764 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
765 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
766
767 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
768 UNIT_TEST_CHECK( nmask.includes(roster, nid_xf));
769 UNIT_TEST_CHECK( nmask.includes(roster, nid_xg));
770 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xx));
771 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxf));
772 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxg));
773 UNIT_TEST_CHECK( nmask.includes(roster, nid_xy));
774 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyf));
775 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyg));
776
777 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
778 UNIT_TEST_CHECK( nmask.includes(roster, nid_yf));
779 UNIT_TEST_CHECK( nmask.includes(roster, nid_yg));
780 UNIT_TEST_CHECK( nmask.includes(roster, nid_yx));
781 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxf));
782 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxg));
783 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yy));
784 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyf));
785 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyg));
786
787 // check restricted paths
788
789 path_restriction pmask(includes, excludes, -1, app);
790
791 UNIT_TEST_CHECK(!pmask.empty());
792
793 UNIT_TEST_CHECK(!pmask.includes(fp_root));
794 UNIT_TEST_CHECK(!pmask.includes(fp_f));
795 UNIT_TEST_CHECK(!pmask.includes(fp_g));
796
797 UNIT_TEST_CHECK( pmask.includes(fp_x));
798 UNIT_TEST_CHECK( pmask.includes(fp_xf));
799 UNIT_TEST_CHECK( pmask.includes(fp_xg));
800 UNIT_TEST_CHECK(!pmask.includes(fp_xx));
801 UNIT_TEST_CHECK(!pmask.includes(fp_xxf));
802 UNIT_TEST_CHECK(!pmask.includes(fp_xxg));
803 UNIT_TEST_CHECK( pmask.includes(fp_xy));
804 UNIT_TEST_CHECK( pmask.includes(fp_xyf));
805 UNIT_TEST_CHECK( pmask.includes(fp_xyg));
806
807 UNIT_TEST_CHECK( pmask.includes(fp_y));
808 UNIT_TEST_CHECK( pmask.includes(fp_yf));
809 UNIT_TEST_CHECK( pmask.includes(fp_yg));
810 UNIT_TEST_CHECK( pmask.includes(fp_yx));
811 UNIT_TEST_CHECK( pmask.includes(fp_yxf));
812 UNIT_TEST_CHECK( pmask.includes(fp_yxg));
813 UNIT_TEST_CHECK(!pmask.includes(fp_yy));
814 UNIT_TEST_CHECK(!pmask.includes(fp_yyf));
815 UNIT_TEST_CHECK(!pmask.includes(fp_yyg));
816}
817
818UNIT_TEST(restrictions, exclude_include)
819{
820 roster_t roster;
821 setup(roster);
822
823 vector<file_path> includes, excludes;
824 // note that excludes higher up the tree than the top
825 // include are rather pointless -- nothing above the
826 // top include is included anyway
827 excludes.push_back(file_path_internal("x"));
828 excludes.push_back(file_path_internal("y"));
829 includes.push_back(file_path_internal("x/x"));
830 includes.push_back(file_path_internal("y/y"));
831
832 app_state app;
833
834 // check restricted nodes
835
836 node_restriction nmask(includes, excludes, -1, roster, app);
837
838 UNIT_TEST_CHECK(!nmask.empty());
839
840 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
841 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
842 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
843
844 UNIT_TEST_CHECK(!nmask.includes(roster, nid_x));
845 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xf));
846 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xg));
847 UNIT_TEST_CHECK( nmask.includes(roster, nid_xx));
848 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxf));
849 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxg));
850 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xy));
851 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyf));
852 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyg));
853
854 UNIT_TEST_CHECK(!nmask.includes(roster, nid_y));
855 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yf));
856 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yg));
857 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yx));
858 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxf));
859 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxg));
860 UNIT_TEST_CHECK( nmask.includes(roster, nid_yy));
861 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyf));
862 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyg));
863
864 // check restricted paths
865
866 path_restriction pmask(includes, excludes, -1, app);
867
868 UNIT_TEST_CHECK(!pmask.empty());
869
870 UNIT_TEST_CHECK(!pmask.includes(fp_root));
871 UNIT_TEST_CHECK(!pmask.includes(fp_f));
872 UNIT_TEST_CHECK(!pmask.includes(fp_g));
873
874 UNIT_TEST_CHECK(!pmask.includes(fp_x));
875 UNIT_TEST_CHECK(!pmask.includes(fp_xf));
876 UNIT_TEST_CHECK(!pmask.includes(fp_xg));
877 UNIT_TEST_CHECK( pmask.includes(fp_xx));
878 UNIT_TEST_CHECK( pmask.includes(fp_xxf));
879 UNIT_TEST_CHECK( pmask.includes(fp_xxg));
880 UNIT_TEST_CHECK(!pmask.includes(fp_xy));
881 UNIT_TEST_CHECK(!pmask.includes(fp_xyf));
882 UNIT_TEST_CHECK(!pmask.includes(fp_xyg));
883
884 UNIT_TEST_CHECK(!pmask.includes(fp_y));
885 UNIT_TEST_CHECK(!pmask.includes(fp_yf));
886 UNIT_TEST_CHECK(!pmask.includes(fp_yg));
887 UNIT_TEST_CHECK(!pmask.includes(fp_yx));
888 UNIT_TEST_CHECK(!pmask.includes(fp_yxf));
889 UNIT_TEST_CHECK(!pmask.includes(fp_yxg));
890 UNIT_TEST_CHECK( pmask.includes(fp_yy));
891 UNIT_TEST_CHECK( pmask.includes(fp_yyf));
892 UNIT_TEST_CHECK( pmask.includes(fp_yyg));
893}
894
895UNIT_TEST(restrictions, invalid_roster_paths)
896{
897 roster_t roster;
898 setup(roster);
899
900 vector<file_path> includes, excludes;
901 includes.push_back(file_path_internal("foo"));
902 excludes.push_back(file_path_internal("bar"));
903
904 app_state app;
905 UNIT_TEST_CHECK_THROW(node_restriction(includes, excludes, -1, roster, app),
906 informative_failure);
907}
908
909UNIT_TEST(restrictions, invalid_workspace_paths)
910{
911 roster_t roster;
912 setup(roster);
913
914 vector<file_path> includes, excludes;
915 includes.push_back(file_path_internal("foo"));
916 excludes.push_back(file_path_internal("bar"));
917
918 app_state app;
919 UNIT_TEST_CHECK_THROW(path_restriction(includes, excludes, -1, app),
920 informative_failure);
921}
922
923UNIT_TEST(restrictions, include_depth_0)
924{
925 roster_t roster;
926 setup(roster);
927
928 vector<file_path> includes, excludes;
929 includes.push_back(file_path_internal("x"));
930 includes.push_back(file_path_internal("y"));
931
932 app_state app;
933 // FIXME: depth == 0 currently means directory + immediate children
934 // this should be changed to mean just the named directory but for
935 // compatibility with old restrictions this behaviour has been preserved
936 long depth = 0;
937
938 // check restricted nodes
939
940 node_restriction nmask(includes, excludes, depth, roster, app);
941
942 UNIT_TEST_CHECK(!nmask.empty());
943
944 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
945 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
946 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
947
948 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
949 UNIT_TEST_CHECK( nmask.includes(roster, nid_xf));
950 UNIT_TEST_CHECK( nmask.includes(roster, nid_xg));
951 UNIT_TEST_CHECK( nmask.includes(roster, nid_xx));
952 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxf));
953 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxg));
954 UNIT_TEST_CHECK( nmask.includes(roster, nid_xy));
955 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyf));
956 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyg));
957
958 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
959 UNIT_TEST_CHECK( nmask.includes(roster, nid_yf));
960 UNIT_TEST_CHECK( nmask.includes(roster, nid_yg));
961 UNIT_TEST_CHECK( nmask.includes(roster, nid_yx));
962 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxf));
963 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxg));
964 UNIT_TEST_CHECK( nmask.includes(roster, nid_yy));
965 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyf));
966 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyg));
967
968 // check restricted paths
969
970 path_restriction pmask(includes, excludes, depth, app);
971
972 UNIT_TEST_CHECK(!pmask.empty());
973
974 UNIT_TEST_CHECK(!pmask.includes(fp_root));
975 UNIT_TEST_CHECK(!pmask.includes(fp_f));
976 UNIT_TEST_CHECK(!pmask.includes(fp_g));
977
978 UNIT_TEST_CHECK( pmask.includes(fp_x));
979 UNIT_TEST_CHECK( pmask.includes(fp_xf));
980 UNIT_TEST_CHECK( pmask.includes(fp_xg));
981 UNIT_TEST_CHECK( pmask.includes(fp_xx));
982 UNIT_TEST_CHECK(!pmask.includes(fp_xxf));
983 UNIT_TEST_CHECK(!pmask.includes(fp_xxg));
984 UNIT_TEST_CHECK( pmask.includes(fp_xy));
985 UNIT_TEST_CHECK(!pmask.includes(fp_xyf));
986 UNIT_TEST_CHECK(!pmask.includes(fp_xyg));
987
988 UNIT_TEST_CHECK( pmask.includes(fp_y));
989 UNIT_TEST_CHECK( pmask.includes(fp_yf));
990 UNIT_TEST_CHECK( pmask.includes(fp_yg));
991 UNIT_TEST_CHECK( pmask.includes(fp_yx));
992 UNIT_TEST_CHECK(!pmask.includes(fp_yxf));
993 UNIT_TEST_CHECK(!pmask.includes(fp_yxg));
994 UNIT_TEST_CHECK( pmask.includes(fp_yy));
995 UNIT_TEST_CHECK(!pmask.includes(fp_yyf));
996 UNIT_TEST_CHECK(!pmask.includes(fp_yyg));
997}
998
999UNIT_TEST(restrictions, include_depth_0_empty_restriction)
1000{
1001 roster_t roster;
1002 setup(roster);
1003
1004 vector<file_path> includes, excludes;
1005
1006 app_state app;
1007 // FIXME: depth == 0 currently means directory + immediate children
1008 // this should be changed to mean just the named directory but for
1009 // compatibility with old restrictions this behaviour has been preserved
1010 long depth = 0;
1011
1012 // check restricted nodes
1013
1014 node_restriction nmask(includes, excludes, depth, roster, app);
1015
1016 UNIT_TEST_CHECK( nmask.empty());
1017
1018 UNIT_TEST_CHECK( nmask.includes(roster, nid_root));
1019 UNIT_TEST_CHECK( nmask.includes(roster, nid_f));
1020 UNIT_TEST_CHECK( nmask.includes(roster, nid_g));
1021
1022 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
1023 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xf));
1024 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xg));
1025 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xx));
1026 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxf));
1027 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xxg));
1028 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xy));
1029 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyf));
1030 UNIT_TEST_CHECK(!nmask.includes(roster, nid_xyg));
1031
1032 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
1033 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yf));
1034 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yg));
1035 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yx));
1036 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxf));
1037 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yxg));
1038 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yy));
1039 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyf));
1040 UNIT_TEST_CHECK(!nmask.includes(roster, nid_yyg));
1041
1042 // check restricted paths
1043
1044 path_restriction pmask(includes, excludes, depth, app);
1045
1046 UNIT_TEST_CHECK( pmask.empty());
1047
1048 UNIT_TEST_CHECK( pmask.includes(fp_root));
1049 UNIT_TEST_CHECK( pmask.includes(fp_f));
1050 UNIT_TEST_CHECK( pmask.includes(fp_g));
1051
1052 UNIT_TEST_CHECK( pmask.includes(fp_x));
1053 UNIT_TEST_CHECK(!pmask.includes(fp_xf));
1054 UNIT_TEST_CHECK(!pmask.includes(fp_xg));
1055 UNIT_TEST_CHECK(!pmask.includes(fp_xx));
1056 UNIT_TEST_CHECK(!pmask.includes(fp_xxf));
1057 UNIT_TEST_CHECK(!pmask.includes(fp_xxg));
1058 UNIT_TEST_CHECK(!pmask.includes(fp_xy));
1059 UNIT_TEST_CHECK(!pmask.includes(fp_xyf));
1060 UNIT_TEST_CHECK(!pmask.includes(fp_xyg));
1061
1062 UNIT_TEST_CHECK( pmask.includes(fp_y));
1063 UNIT_TEST_CHECK(!pmask.includes(fp_yf));
1064 UNIT_TEST_CHECK(!pmask.includes(fp_yg));
1065 UNIT_TEST_CHECK(!pmask.includes(fp_yx));
1066 UNIT_TEST_CHECK(!pmask.includes(fp_yxf));
1067 UNIT_TEST_CHECK(!pmask.includes(fp_yxg));
1068 UNIT_TEST_CHECK(!pmask.includes(fp_yy));
1069 UNIT_TEST_CHECK(!pmask.includes(fp_yyf));
1070 UNIT_TEST_CHECK(!pmask.includes(fp_yyg));
1071}
1072
1073UNIT_TEST(restrictions, include_depth_1)
1074{
1075 roster_t roster;
1076 setup(roster);
1077
1078 vector<file_path> includes, excludes;
1079 includes.push_back(file_path_internal("x"));
1080 includes.push_back(file_path_internal("y"));
1081
1082 app_state app;
1083 // FIXME: depth == 1 currently means directory + children + grand children
1084 // this should be changed to mean directory + immediate children but for
1085 // compatibility with old restrictions this behaviour has been preserved
1086 long depth = 1;
1087
1088 // check restricted nodes
1089
1090 node_restriction nmask(includes, excludes, depth, roster, app);
1091
1092 UNIT_TEST_CHECK(!nmask.empty());
1093
1094 UNIT_TEST_CHECK(!nmask.includes(roster, nid_root));
1095 UNIT_TEST_CHECK(!nmask.includes(roster, nid_f));
1096 UNIT_TEST_CHECK(!nmask.includes(roster, nid_g));
1097
1098 UNIT_TEST_CHECK( nmask.includes(roster, nid_x));
1099 UNIT_TEST_CHECK( nmask.includes(roster, nid_xf));
1100 UNIT_TEST_CHECK( nmask.includes(roster, nid_xg));
1101 UNIT_TEST_CHECK( nmask.includes(roster, nid_xx));
1102 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxf));
1103 UNIT_TEST_CHECK( nmask.includes(roster, nid_xxg));
1104 UNIT_TEST_CHECK( nmask.includes(roster, nid_xy));
1105 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyf));
1106 UNIT_TEST_CHECK( nmask.includes(roster, nid_xyg));
1107
1108 UNIT_TEST_CHECK( nmask.includes(roster, nid_y));
1109 UNIT_TEST_CHECK( nmask.includes(roster, nid_yf));
1110 UNIT_TEST_CHECK( nmask.includes(roster, nid_yg));
1111 UNIT_TEST_CHECK( nmask.includes(roster, nid_yx));
1112 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxf));
1113 UNIT_TEST_CHECK( nmask.includes(roster, nid_yxg));
1114 UNIT_TEST_CHECK( nmask.includes(roster, nid_yy));
1115 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyf));
1116 UNIT_TEST_CHECK( nmask.includes(roster, nid_yyg));
1117
1118 // check restricted paths
1119
1120 path_restriction pmask(includes, excludes, depth, app);
1121
1122 UNIT_TEST_CHECK(!pmask.empty());
1123
1124 UNIT_TEST_CHECK(!pmask.includes(fp_root));
1125 UNIT_TEST_CHECK(!pmask.includes(fp_f));
1126 UNIT_TEST_CHECK(!pmask.includes(fp_g));
1127
1128 UNIT_TEST_CHECK( pmask.includes(fp_x));
1129 UNIT_TEST_CHECK( pmask.includes(fp_xf));
1130 UNIT_TEST_CHECK( pmask.includes(fp_xg));
1131 UNIT_TEST_CHECK( pmask.includes(fp_xx));
1132 UNIT_TEST_CHECK( pmask.includes(fp_xxf));
1133 UNIT_TEST_CHECK( pmask.includes(fp_xxg));
1134 UNIT_TEST_CHECK( pmask.includes(fp_xy));
1135 UNIT_TEST_CHECK( pmask.includes(fp_xyf));
1136 UNIT_TEST_CHECK( pmask.includes(fp_xyg));
1137
1138 UNIT_TEST_CHECK( pmask.includes(fp_y));
1139 UNIT_TEST_CHECK( pmask.includes(fp_yf));
1140 UNIT_TEST_CHECK( pmask.includes(fp_yg));
1141 UNIT_TEST_CHECK( pmask.includes(fp_yx));
1142 UNIT_TEST_CHECK( pmask.includes(fp_yxf));
1143 UNIT_TEST_CHECK( pmask.includes(fp_yxg));
1144 UNIT_TEST_CHECK( pmask.includes(fp_yy));
1145 UNIT_TEST_CHECK( pmask.includes(fp_yyf));
1146 UNIT_TEST_CHECK( pmask.includes(fp_yyg));
1147}
1148
1149#endif // BUILD_UNIT_TESTS
1150
1151// Local Variables:
1152// mode: C++
1153// fill-column: 76
1154// c-file-style: "gnu"
1155// indent-tabs-mode: nil
1156// End:
1157// 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