aboutsummaryrefslogtreecommitdiffstats
path: root/test/suite_dfilter/group_integer.py
blob: 1a6425e4cec678a3f57ac8cf108cfe82dc4d5c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
#
# SPDX-License-Identifier: GPL-2.0-or-later

import unittest
import fixtures
from suite_dfilter.dfiltertest import *


@fixtures.uses_fixtures
class case_integer(unittest.TestCase):
    trace_file = "ntp.pcap"

    def test_eq_1(self, checkDFilterCount):
        dfilter = "ip.version == 4"
        checkDFilterCount(dfilter, 1)

    def test_eq_2(self, checkDFilterCount):
        dfilter = "ip.version == 6"
        checkDFilterCount(dfilter, 0)

    def test_eq_3(self, checkDFilterFail):
        # Invalid filter (only one equals sign)
        dfilter = "ip.version = 4"
        checkDFilterFail(dfilter)

    def test_eq_4(self, checkDFilterFail):
        # Invalid filter
        dfilter = "ip.version == the quick brown fox jumps over the lazy dog"
        checkDFilterFail(dfilter)

    def test_eq_5(self, checkDFilterFail):
        # Invalid filter
        dfilter = "ip.version == 4 the quick brown fox jumps over the lazy dog"
        checkDFilterFail(dfilter)

    def test_ne_1(self, checkDFilterCount):
        dfilter = "ip.version != 0"
        checkDFilterCount(dfilter, 1)

    def test_ne_2(self, checkDFilterCount):
        dfilter = "ip.version != 4"
        checkDFilterCount(dfilter, 0)

    def test_u_gt_1(self, checkDFilterCount):
        dfilter = "ip.version > 3"
        checkDFilterCount(dfilter, 1)

    def test_u_gt_2(self, checkDFilterCount):
        dfilter = "ip.version > 4"
        checkDFilterCount(dfilter, 0)

    def test_u_gt_3(self, checkDFilterCount):
        dfilter = "ip.version > 5"
        checkDFilterCount(dfilter, 0)

    def test_u_ge_1(self, checkDFilterCount):
        dfilter = "ip.version >= 3"
        checkDFilterCount(dfilter, 1)

    def test_u_ge_2(self, checkDFilterCount):
        dfilter = "ip.version >= 4"
        checkDFilterCount(dfilter, 1)

    def test_u_ge_3(self, checkDFilterCount):
        dfilter = "ip.version >= 5"
        checkDFilterCount(dfilter, 0)

    def test_u_lt_1(self, checkDFilterCount):
        dfilter = "ip.version < 3"
        checkDFilterCount(dfilter, 0)

    def test_u_lt_2(self, checkDFilterCount):
        dfilter = "ip.version < 4"
        checkDFilterCount(dfilter, 0)

    def test_u_lt_3(self, checkDFilterCount):
        dfilter = "ip.version < 5"
        checkDFilterCount(dfilter, 1)

    def test_u_le_1(self, checkDFilterCount):
        dfilter = "ip.version <= 3"
        checkDFilterCount(dfilter, 0)

    def test_u_le_2(self, checkDFilterCount):
        dfilter = "ip.version <= 4"
        checkDFilterCount(dfilter, 1)

    def test_u_le_3(self, checkDFilterCount):
        dfilter = "ip.version <= 5"
        checkDFilterCount(dfilter, 1)

    def test_s_gt_1(self, checkDFilterCount):
        dfilter = "ntp.precision > 244"
        checkDFilterCount(dfilter, 1)

    def test_s_gt_2(self, checkDFilterCount):
        dfilter = "ntp.precision > 245"
        checkDFilterCount(dfilter, 0)

    def test_s_gt_3(self, checkDFilterCount):
        dfilter = "ntp.precision > 246"
        checkDFilterCount(dfilter, 0)

    def test_s_ge_1(self, checkDFilterCount):
        dfilter = "ntp.precision >= 244"
        checkDFilterCount(dfilter, 1)

    def test_s_ge_2(self, checkDFilterCount):
        dfilter = "ntp.precision >= 245"
        checkDFilterCount(dfilter, 1)

    def test_s_ge_3(self, checkDFilterCount):
        dfilter = "ntp.precision >= 246"
        checkDFilterCount(dfilter, 0)

    def test_s_lt_1(self, checkDFilterCount):
        dfilter = "ntp.precision < 244"
        checkDFilterCount(dfilter, 0)

    def test_s_lt_2(self, checkDFilterCount):
        dfilter = "ntp.precision < 245"
        checkDFilterCount(dfilter, 0)

    def test_s_lt_3(self, checkDFilterCount):
        dfilter = "ntp.precision < 246"
        checkDFilterCount(dfilter, 1)

    def test_s_le_1(self, checkDFilterCount):
        dfilter = "ntp.precision <= 244"
        checkDFilterCount(dfilter, 0)

    def test_s_le_2(self, checkDFilterCount):
        dfilter = "ntp.precision <= 245"
        checkDFilterCount(dfilter, 1)

    def test_s_le_3(self, checkDFilterCount):
        dfilter = "ntp.precision <= 246"
        checkDFilterCount(dfilter, 1)

    def test_bool_eq_1(self, checkDFilterCount):
        dfilter = "ip.flags.df == 0"
        checkDFilterCount(dfilter, 1)

    def test_bool_eq_2(self, checkDFilterCount):
        dfilter = "ip.flags.df == 1"
        checkDFilterCount(dfilter, 0)

    def test_bool_ne_1(self, checkDFilterCount):
        dfilter = "ip.flags.df != 1"
        checkDFilterCount(dfilter, 1)

    def test_bool_ne_2(self, checkDFilterCount):
        dfilter = "ip.flags.df != 0"
        checkDFilterCount(dfilter, 0)