Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
c5e1b99e
Commit
c5e1b99e
authored
7 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
Python 3: tests fixes
parent
2060322f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/linux.uts
+7
-4
7 additions, 4 deletions
test/linux.uts
with
7 additions
and
4 deletions
test/linux.uts
+
7
−
4
View file @
c5e1b99e
...
@@ -12,10 +12,13 @@
...
@@ -12,10 +12,13 @@
~ automaton netaccess linux needs_root
~ automaton netaccess linux needs_root
* This test retries on failure because it often fails
* This test retries on failure because it often fails
from __future__ import print_function
import os
import os
import time
import time
import signal
import signal
from scapy.modules.six.moves import range
def handler(signum, stack_frame):
def handler(signum, stack_frame):
raise Exception("Timer expired !")
raise Exception("Timer expired !")
...
@@ -28,12 +31,12 @@ IPTABLE_RULE = "iptables -%c INPUT -s %s -p tcp --sport 80 -j DROP"
...
@@ -28,12 +31,12 @@ IPTABLE_RULE = "iptables -%c INPUT -s %s -p tcp --sport 80 -j DROP"
assert(os.system(IPTABLE_RULE % ('A', SECDEV_IP4)) == 0)
assert(os.system(IPTABLE_RULE % ('A', SECDEV_IP4)) == 0)
success = False
success = False
for i in
x
range(10):
for i in range(10):
tmp = signal.alarm(5)
tmp = signal.alarm(5)
try:
try:
r, w = os.pipe()
r, w = os.pipe()
t = TCP_client(SECDEV_IP4, 80, external_fd={ "tcp": (r,w) })
t = TCP_client(SECDEV_IP4, 80, external_fd={ "tcp": (r,w) })
tmp = os.write(w, "HEAD / HTTP/1.0\r\n\r\n")
tmp = os.write(w,
b
"HEAD / HTTP/1.0\r\n\r\n")
t.runbg()
t.runbg()
time.sleep(0.5)
time.sleep(0.5)
response = os.read(r, 4096)
response = os.read(r, 4096)
...
@@ -41,13 +44,13 @@ for i in xrange(10):
...
@@ -41,13 +44,13 @@ for i in xrange(10):
t.stop()
t.stop()
os.close(r)
os.close(r)
os.close(w)
os.close(w)
if response.startswith("HTTP/1.1 200 OK"):
if response.startswith(
b
"HTTP/1.1 200 OK"):
success = True
success = True
break
break
else:
else:
time.sleep(0.5)
time.sleep(0.5)
except Exception as e:
except Exception as e:
print
e
print
(e)
# Remove the iptables rule
# Remove the iptables rule
assert(os.system(IPTABLE_RULE % ('D', SECDEV_IP4)) == 0)
assert(os.system(IPTABLE_RULE % ('D', SECDEV_IP4)) == 0)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment