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
|
# Copyright (c) 2013 by Gilbert Ramirez <gram@alumni.rice.edu>
#
# SPDX-License-Identifier: GPL-2.0-or-later
import pytest
from suite_dfilter.dfiltertest import *
class TestDfilterTime:
trace_file = "http.pcap"
def test_eq_1(self, checkDFilterCount):
dfilter = 'frame.time == "Dec 31, 2002 13:55:31.3"'
checkDFilterCount(dfilter, 1)
def test_eq_2(self, checkDFilterCount):
dfilter = 'frame.time == "Jan 31, 2002 13:55:31.3"'
checkDFilterCount(dfilter, 0)
def test_eq_3(self, checkDFilterCount):
dfilter = 'frame.time == "2002-12-31 13:55:31.3"'
checkDFilterCount(dfilter, 1)
def test_eq_4(self, checkDFilterCount):
dfilter = 'frame.time == 1041342931.3'
checkDFilterCount(dfilter, 1)
def test_ne_1(self, checkDFilterCount):
dfilter = 'frame.time != "Dec 31, 2002 13:55:31.3"'
checkDFilterCount(dfilter, 0)
def test_ne_2(self, checkDFilterCount):
dfilter = 'frame.time != "Jan 31, 2002 13:55:31.3"'
checkDFilterCount(dfilter, 1)
def test_gt_1(self, checkDFilterCount):
dfilter = 'frame.time > "Dec 31, 2002 13:54:31.3"'
checkDFilterCount(dfilter, 1)
def test_gt_2(self, checkDFilterCount):
dfilter = 'frame.time > "Dec 31, 2002 13:55:31.3"'
checkDFilterCount(dfilter, 0)
def test_gt_3(self, checkDFilterCount):
dfilter = 'frame.time > "Dec 31, 2002 13:56:31.3"'
checkDFilterCount(dfilter, 0)
def test_ge_1(self, checkDFilterCount):
dfilter = 'frame.time >= "Dec 31, 2002 13:54:31.3"'
checkDFilterCount(dfilter, 1)
def test_ge_2(self, checkDFilterCount):
dfilter = 'frame.time >= "Dec 31, 2002 13:55:31.3"'
checkDFilterCount(dfilter, 1)
def test_ge_3(self, checkDFilterCount):
dfilter = 'frame.time >= "Dec 31, 2002 13:56:31.3"'
checkDFilterCount(dfilter, 0)
def test_lt_1(self, checkDFilterCount):
dfilter = 'frame.time < "Dec 31, 2002 13:54:31.3"'
checkDFilterCount(dfilter, 0)
def test_lt_2(self, checkDFilterCount):
dfilter = 'frame.time < "Dec 31, 2002 13:55:31.3"'
checkDFilterCount(dfilter, 0)
def test_lt_3(self, checkDFilterCount):
dfilter = 'frame.time < "Dec 31, 2002 13:56:31.3"'
checkDFilterCount(dfilter, 1)
def test_le_1(self, checkDFilterCount):
dfilter = 'frame.time <= "Dec 31, 2002 13:54:31.3"'
checkDFilterCount(dfilter, 0)
def test_le_2(self, checkDFilterCount):
dfilter = 'frame.time <= "Dec 31, 2002 13:55:31.3"'
checkDFilterCount(dfilter, 1)
def test_le_3(self, checkDFilterCount):
dfilter = 'frame.time <= "Dec 31, 2002 13:56:31.3"'
checkDFilterCount(dfilter, 1)
def test_utc_time_1(self, checkDFilterCount):
dfilter = 'frame.time == "Dec 31, 2002 13:55:31.3 UTC"'
checkDFilterCount(dfilter, 1)
def test_utc_time_2(self, checkDFilterCount):
dfilter = 'frame.time == "2002-12-31 13:55:31.3 UTC"'
checkDFilterCount(dfilter, 1)
def test_bad_time_2(self, checkDFilterFail):
# Miliseconds can only occur after seconds.
dfilter = 'frame.time == "2002-12-31 13:55.3"'
error = 'requires a seconds field'
checkDFilterFail(dfilter, error)
def test_bad_time_3(self, checkDFilterFail):
# Reject months in a different locale (mrt is March in nl_NL.UTF-8).
dfilter = 'frame.time == "mrt 1, 2000 00:00:00"'
error = '"mrt 1, 2000 00:00:00" is not a valid absolute time. Example: "Nov 12, 1999 08:55:44.123" or "2011-07-04 12:34:56"'
checkDFilterFail(dfilter, error)
class TestDfilterTimeRelative:
trace_file = "nfs.pcap"
def test_relative_time_1(self, checkDFilterCount):
dfilter = "frame.time_delta == 0.7"
checkDFilterCount(dfilter, 1)
def test_relative_time_2(self, checkDFilterCount):
dfilter = "frame.time_delta > 0.7"
checkDFilterCount(dfilter, 0)
def test_relative_time_3(self, checkDFilterCount):
dfilter = "frame.time_delta < 0.7"
checkDFilterCount(dfilter, 1)
class TestDfilterTimezone:
trace_file = "http.pcap"
# These are all the same value expressed in different
# ways and timezones
def test_time_1(self, checkDFilterCount):
dfilter = 'frame.time == "2002-12-31 13:55:31.3"'
checkDFilterCount(dfilter, 1)
def test_time_2(self, checkDFilterCount):
dfilter = 'frame.time == "2002-12-31 13:55:31.3Z"'
checkDFilterCount(dfilter, 1)
def test_time_3(self, checkDFilterCount):
dfilter = 'frame.time == "2002-12-31 15:55:31.3 +02:00"'
checkDFilterCount(dfilter, 1)
def test_time_4(self, checkDFilterCount):
# Foxtrot time zone
dfilter = 'frame.time == "2002-12-31 19:55:31.3 F"'
checkDFilterCount(dfilter, 1)
def test_time_5(self, checkDFilterCount):
dfilter = 'frame.time == "2002-12-31 05:55:31.3 PST"'
checkDFilterCount(dfilter, 1)
def test_time_6(self, checkDFilterCount):
dfilter = 'frame.time == "2002-12-31 07:55:31.3 CST"'
checkDFilterCount(dfilter, 1)
|