Bundle libseccomp 2.3.1
[linux-seccomp.git] / libseccomp / tests / 12-sim-basic_masked_ops.py
1 #!/usr/bin/env python
2
3 #
4 # Seccomp Library test program
5 #
6 # Copyright (c) 2012 Red Hat <pmoore@redhat.com>
7 # Author: Paul Moore <paul@paul-moore.com>
8 #
9
10 #
11 # This library is free software; you can redistribute it and/or modify it
12 # under the terms of version 2.1 of the GNU Lesser General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This library is distributed in the hope that it will be useful, but WITHOUT
16 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
18 # for more details.
19 #
20 # You should have received a copy of the GNU Lesser General Public License
21 # along with this library; if not, see <http://www.gnu.org/licenses>.
22 #
23
24 import argparse
25 import sys
26
27 import util
28
29 from seccomp import *
30
31 def test(args):
32 f = SyscallFilter(KILL)
33 # the syscall and argument numbers are all fake to make the test simpler
34 f.add_rule_exactly(ALLOW, 1000,
35 Arg(0, EQ, 0),
36 Arg(1, EQ, 1),
37 Arg(2, EQ, 2))
38 f.add_rule_exactly(ALLOW, 1000,
39 Arg(0, EQ, 0),
40 Arg(1, MASKED_EQ, 0x00ff, 1),
41 Arg(2, EQ, 2))
42 f.add_rule_exactly(ALLOW, 1000,
43 Arg(0, EQ, 0),
44 Arg(1, MASKED_EQ, 0xffff, 11),
45 Arg(2, EQ, 2))
46 f.add_rule_exactly(ALLOW, 1000,
47 Arg(0, EQ, 0),
48 Arg(1, MASKED_EQ, 0xffff, 111),
49 Arg(2, EQ, 2))
50 f.add_rule_exactly(ALLOW, 1000,
51 Arg(0, EQ, 0),
52 Arg(1, MASKED_EQ, 0xff00, 1000),
53 Arg(2, EQ, 2))
54 return f
55
56 args = util.get_opt()
57 ctx = test(args)
58 util.filter_output(args, ctx)
59
60 # kate: syntax python;
61 # kate: indent-mode python; space-indent on; indent-width 4; mixedindent off;
This page took 0.021677 seconds and 4 git commands to generate.