public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/autodep:master commit in: test/1_access/, src/autodep/test/, src/autodep/test/1_access/, test/logger/, ...
@ 2011-07-13 13:43 Александр Берсенев
  0 siblings, 0 replies; only message in thread
From: Александр Берсенев @ 2011-07-13 13:43 UTC (permalink / raw
  To: gentoo-commits

commit:     84111f67a1a516fb202f620dbe3fe61ef3943875
Author:     Alexander Bersenev <bay <AT> hackerdom <DOT> ru>
AuthorDate: Wed Jul 13 19:43:18 2011 +0000
Commit:     Александр Берсенев <bay <AT> hackerdom <DOT> ru>
CommitDate: Wed Jul 13 19:43:18 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/autodep.git;a=commit;h=84111f67

tests

---
 src/autodep/logfs/fstracer.py                  |    3 +-
 src/autodep/logfs/logger_fusefs.py             |    2 +-
 src/autodep/logfs/logger_hooklib.py            |    2 +-
 src/autodep/runtests.py                        |    8 ++
 {test => src/autodep/test}/1_access/Makefile   |    0
 {test => src/autodep/test}/1_access/accesser.c |    0
 src/autodep/test/all_tests.py                  |   11 +++
 src/autodep/test/test_fusefs.py                |   72 +++++++++++++++
 src/autodep/test/test_hookfs.py                |   65 ++++++++++++++
 test/logger/test_fstracer.py                   |  112 ------------------------
 10 files changed, 160 insertions(+), 115 deletions(-)

diff --git a/src/autodep/logfs/fstracer.py b/src/autodep/logfs/fstracer.py
index c724b61..7eca160 100644
--- a/src/autodep/logfs/fstracer.py
+++ b/src/autodep/logfs/fstracer.py
@@ -151,7 +151,8 @@ def getfsevents(prog_name,arguments,approach="hooklib",filterproc=defaultfilter)
 		  print "Sending SIGKILL to child"
 		  os.kill(pid,signal.SIGKILL)
 		  os._exit(1)
-	  global signal
+	  import signal # signal must to be in this scope
+	  # global signal not works
  	  signal.signal(signal.SIGINT, signal_handler)
  	  
 	  epoll=select.epoll()

diff --git a/src/autodep/logfs/logger_fusefs.py b/src/autodep/logfs/logger_fusefs.py
index 6c135e8..7965d45 100644
--- a/src/autodep/logfs/logger_fusefs.py
+++ b/src/autodep/logfs/logger_fusefs.py
@@ -50,7 +50,7 @@ class logger:
 	os.environ["PARENT_PID"]=str(self.currpid)
 
 	# TODO: change
-	ret=subprocess.call(['/home/bay/gsoc/logger/src/hook_fusefs/hookfs',self.rootmountpath,
+	ret=subprocess.call(['/home/bay/gsoc/src/hook_fusefs/hookfs',self.rootmountpath,
 						 '-o','allow_other,suid'])
 	if ret!=0:
 	  print "failed to launch FUSE logger. Check messages above"

diff --git a/src/autodep/logfs/logger_hooklib.py b/src/autodep/logfs/logger_hooklib.py
index 008fc56..1c72279 100644
--- a/src/autodep/logfs/logger_hooklib.py
+++ b/src/autodep/logfs/logger_hooklib.py
@@ -5,7 +5,7 @@ import sys
 
 class logger:
   socketname=''
-  hooklibpath='/home/bay/gsoc/logger/src/hook_lib/file_hook.so' # TODO: change
+  hooklibpath='/home/bay/gsoc/src/hook_lib/file_hook.so' # TODO: change
   
   def __init__(self,socketname):
 	self.socketname=socketname

diff --git a/src/autodep/runtests.py b/src/autodep/runtests.py
new file mode 100644
index 0000000..4605cfb
--- /dev/null
+++ b/src/autodep/runtests.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python2
+
+#import test.test_fstracer
+
+import unittest
+import test.all_tests
+testSuite = test.all_tests.create_test_suite()
+text_runner = unittest.TextTestRunner().run(testSuite)
\ No newline at end of file

diff --git a/test/1_access/Makefile b/src/autodep/test/1_access/Makefile
similarity index 100%
rename from test/1_access/Makefile
rename to src/autodep/test/1_access/Makefile

diff --git a/test/1_access/accesser.c b/src/autodep/test/1_access/accesser.c
similarity index 100%
rename from test/1_access/accesser.c
rename to src/autodep/test/1_access/accesser.c

diff --git a/src/autodep/test/all_tests.py b/src/autodep/test/all_tests.py
new file mode 100644
index 0000000..9095742
--- /dev/null
+++ b/src/autodep/test/all_tests.py
@@ -0,0 +1,11 @@
+import glob
+import unittest
+
+def create_test_suite():
+    test_file_strings = glob.glob('test/test_fusefs.py')
+    module_strings = ['test.'+str[5:len(str)-3] for str in test_file_strings]
+    suites = [unittest.defaultTestLoader.loadTestsFromName(name) \
+              for name in module_strings]
+    testSuite = unittest.TestSuite(suites)
+    return testSuite
+    

diff --git a/src/autodep/test/test_fusefs.py b/src/autodep/test/test_fusefs.py
new file mode 100644
index 0000000..fb57de7
--- /dev/null
+++ b/src/autodep/test/test_fusefs.py
@@ -0,0 +1,72 @@
+import unittest
+import logfs.fstracer
+
+def simple_getfsevents(prog,args,approach="hooklib"):
+  ret=[]
+  events = logfs.fstracer.getfsevents(prog,args,approach)
+  #print events
+  for stage in events:
+	for filename in events[stage][0]:
+	  ret.append([filename,'success'])
+	for filename in events[stage][1]:
+	  ret.append([filename,'fail'])
+	  
+  return ret
+
+
+
+class fusefs_simple_tests(unittest.TestCase):
+  def test_open_unexists(self):
+	eventslist=simple_getfsevents('/bin/cat', ['/bin/cat','/f1','/f2'],approach="fusefs")
+	print eventslist
+	self.assertTrue(eventslist.count(['/f1',"fail"])==1)
+	self.assertTrue(eventslist.count(['/f2',"fail"])==1)
+	
+  def test_open_exists(self):
+	  eventslist=simple_getfsevents('/bin/cat', ['/bin/cat','/etc/passwd'],approach="fusefs")
+	  self.assertTrue(eventslist.count(['/etc/passwd','success'])>=1)
+
+  def test_open_many(self):
+	filesnum=200
+	eventslist=simple_getfsevents('/bin/cat',['/bin/cat']+
+									map(lambda x: '/file'+str(x),range(0,filesnum)), approach="fusefs")
+	for f in map(lambda x: ['/file'+str(x),'fail'],range(0,filesnum)):
+	  self.assertTrue(f in eventslist)
+
+  def test_parralel(self):
+	filesnum=400
+	procnum=8
+	
+	# create command
+	command=""
+	for p in xrange(0,procnum):
+  	  command+="/bin/cat "
+	  for f in xrange(0,filesnum):
+		command+="/file_%d_%d " % (p,f)
+	  command+="& "
+	command+=" 2>/dev/null"
+	#command+=" "+"A"*65536
+	
+	resultarray=simple_getfsevents('/bin/sh', ['/bin/sh','-c',command],approach="fusefs")
+
+	for p in xrange(0,procnum):
+	  for f in xrange(0,filesnum):
+		self.assertTrue(resultarray.count(['/file_%d_%d' % (p,f),"fail"])==1)
+
+  def test_open_very_many(self):
+	resultarray=simple_getfsevents('/bin/sh', ['/bin/sh','-c',
+									"for i in `seq 1 1000`; do cat /testmany$i;done 2> /dev/null"],approach="fusefs")
+	#print resultarray
+	for i in range(1,1000):
+	  self.assertTrue(resultarray.count(['/testmany'+str(i),'fail'])==1)
+
+  def test_exec(self):
+	eventslist=simple_getfsevents('test/helpers/exec', ['test/helpers/exec'],approach="fusefs")
+	for i in range(1,14):
+	  self.assertTrue(eventslist.count(['/f'+str(i),"fail"])==1)
+
+#if __name__ == '__main__':
+  #unittest.main()
+  #suite = unittest.TestLoader().loadTestsFromTestCase(fusefs_simple_tests)
+#  suite = unittest.TestLoader().loadTestsFromTestCase(hooklib_simple_tests)
+#  unittest.TextTestRunner(verbosity=2).run(suite)
\ No newline at end of file

diff --git a/src/autodep/test/test_hookfs.py b/src/autodep/test/test_hookfs.py
new file mode 100644
index 0000000..fdab1f0
--- /dev/null
+++ b/src/autodep/test/test_hookfs.py
@@ -0,0 +1,65 @@
+import unittest
+import logfs.fstracer
+
+def simple_getfsevents(prog,args,approach="hooklib"):
+  ret=[]
+  events = logfs.fstracer.getfsevents(prog,args,approach)
+  #print events
+  for stage in events:
+	for filename in events[stage][0]:
+	  ret.append([filename,'success'])
+	for filename in events[stage][1]:
+	  ret.append([filename,'fail'])
+	  
+  return ret
+
+class hooklib_simple_tests(unittest.TestCase):
+  def test_open_unexists(self):
+	eventslist=simple_getfsevents('/bin/cat', ['/bin/cat','/f1','/f2'],approach="hooklib")
+	print eventslist
+	self.assertTrue(eventslist.count(['/f1',"fail"])==1)
+	self.assertTrue(eventslist.count(['/f2',"fail"])==1)
+
+  def test_open_exists(self):
+	  eventslist=simple_getfsevents('/bin/cat', ['/bin/cat','/etc/passwd'],approach="hooklib")
+	  self.assertTrue(eventslist.count(['/etc/passwd','success'])>=1)
+
+  def test_open_many(self):
+	filesnum=200
+	eventslist=simple_getfsevents('/bin/cat',['/bin/cat']+
+									map(lambda x: '/file'+str(x),range(0,filesnum)), approach="hooklib")
+	for f in map(lambda x: ['/file'+str(x),'fail'],range(0,filesnum)):
+	  self.assertTrue(f in eventslist)
+
+  def test_parralel(self):
+	filesnum=400
+	procnum=8
+	
+	# create command
+	command=""
+	for p in xrange(0,procnum):
+  	  command+="/bin/cat "
+	  for f in xrange(0,filesnum):
+		command+="/file_%d_%d " % (p,f)
+	  command+="& "
+	command+=" 2>/dev/null"
+	#command+=" "+"A"*65536
+	
+	resultarray=simple_getfsevents('/bin/sh', ['/bin/sh','-c',command],approach="hooklib")
+
+	for p in xrange(0,procnum):
+	  for f in xrange(0,filesnum):
+		self.assertTrue(resultarray.count(['/file_%d_%d' % (p,f),"fail"])==1)
+
+  def test_open_very_many(self):
+	resultarray=simple_getfsevents('/bin/sh', ['/bin/sh','-c',
+									"for i in `seq 1 1000`; do cat /testmany$i;done 2> /dev/null"],approach="hooklib")
+	#print resultarray
+	for i in range(1,1000):
+	  self.assertTrue(resultarray.count(['/testmany'+str(i),'fail'])==1)
+
+  def test_exec(self):
+	eventslist=simple_getfsevents('test/helpers/exec', ['test/helpers/exec'],approach="hooklib")
+	for i in range(1,14):
+	  self.assertTrue(eventslist.count(['/f'+str(i),"fail"])==1)
+	
\ No newline at end of file

diff --git a/test/logger/test_fstracer.py b/test/logger/test_fstracer.py
deleted file mode 100644
index 15d4c27..0000000
--- a/test/logger/test_fstracer.py
+++ /dev/null
@@ -1,112 +0,0 @@
-import unittest
-
-import fstracer
-
-def simple_getfsevents(prog,args,approach="hooklib"):
-  ret=[]
-  events = fstracer.getfsevents(prog,args,approach)
-  #print events
-  for stage in events:
-	for filename in events[stage][0]:
-	  ret.append([filename,'success'])
-	for filename in events[stage][1]:
-	  ret.append([filename,'fail'])
-	  
-  return ret
-
-class hooklib_simple_tests(unittest.TestCase):
-  def test_open_unexists(self):
-	eventslist=simple_getfsevents('/bin/cat', ['/bin/cat','/f1','/f2'],approach="hooklib")
-	print eventslist
-	self.assertTrue(eventslist.count(['/f1',"fail"])==1)
-	self.assertTrue(eventslist.count(['/f2',"fail"])==1)
-
-  def test_open_exists(self):
-	  eventslist=simple_getfsevents('/bin/cat', ['/bin/cat','/etc/passwd'],approach="hooklib")
-	  self.assertTrue(eventslist.count(['/etc/passwd','success'])>=1)
-
-  def test_open_many(self):
-	filesnum=200
-	eventslist=simple_getfsevents('/bin/cat',['/bin/cat']+
-									map(lambda x: '/file'+str(x),range(0,filesnum)), approach="hooklib")
-	for f in map(lambda x: ['/file'+str(x),'fail'],range(0,filesnum)):
-	  self.assertTrue(f in eventslist)
-
-  def test_parralel(self):
-	filesnum=400
-	procnum=8
-	
-	# create command
-	command=""
-	for p in xrange(0,procnum):
-  	  command+="/bin/cat "
-	  for f in xrange(0,filesnum):
-		command+="/file_%d_%d " % (p,f)
-	  command+="& "
-	command+=" 2>/dev/null"
-	#command+=" "+"A"*65536
-	
-	resultarray=simple_getfsevents('/bin/sh', ['/bin/sh','-c',command],approach="hooklib")
-
-	for p in xrange(0,procnum):
-	  for f in xrange(0,filesnum):
-		self.assertTrue(resultarray.count(['/file_%d_%d' % (p,f),"fail"])==1)
-
-  def test_open_very_many(self):
-	resultarray=simple_getfsevents('/bin/sh', ['/bin/sh','-c',
-									"for i in `seq 1 1000`; do cat /testmany$i;done 2> /dev/null"],approach="hooklib")
-	#print resultarray
-	for i in range(1,1000):
-	  self.assertTrue(resultarray.count(['/testmany'+str(i),'fail'])==1)
-
-
-class fusefs_simple_tests(unittest.TestCase):
-  def test_open_unexists(self):
-	eventslist=simple_getfsevents('/bin/cat', ['/bin/cat','/f1','/f2'],approach="fusefs")
-	print eventslist
-	self.assertTrue(eventslist.count(['/f1',"fail"])==1)
-	self.assertTrue(eventslist.count(['/f2',"fail"])==1)
-	
-  def test_open_exists(self):
-	  eventslist=simple_getfsevents('/bin/cat', ['/bin/cat','/etc/passwd'],approach="fusefs")
-	  self.assertTrue(eventslist.count(['/etc/passwd','success'])>=1)
-
-  def test_open_many(self):
-	filesnum=200
-	eventslist=simple_getfsevents('/bin/cat',['/bin/cat']+
-									map(lambda x: '/file'+str(x),range(0,filesnum)), approach="fusefs")
-	for f in map(lambda x: ['/file'+str(x),'fail'],range(0,filesnum)):
-	  self.assertTrue(f in eventslist)
-
-  def test_parralel(self):
-	filesnum=400
-	procnum=8
-	
-	# create command
-	command=""
-	for p in xrange(0,procnum):
-  	  command+="/bin/cat "
-	  for f in xrange(0,filesnum):
-		command+="/file_%d_%d " % (p,f)
-	  command+="& "
-	command+=" 2>/dev/null"
-	#command+=" "+"A"*65536
-	
-	resultarray=simple_getfsevents('/bin/sh', ['/bin/sh','-c',command],approach="fusefs")
-
-	for p in xrange(0,procnum):
-	  for f in xrange(0,filesnum):
-		self.assertTrue(resultarray.count(['/file_%d_%d' % (p,f),"fail"])==1)
-
-  def test_open_very_many(self):
-	resultarray=simple_getfsevents('/bin/sh', ['/bin/sh','-c',
-									"for i in `seq 1 1000`; do cat /testmany$i;done 2> /dev/null"],approach="fusefs")
-	#print resultarray
-	for i in range(1,1000):
-	  self.assertTrue(resultarray.count(['/testmany'+str(i),'fail'])==1)
-
-if __name__ == '__main__':
-  #unittest.main()
-  #suite = unittest.TestLoader().loadTestsFromTestCase(fusefs_simple_tests)
-  suite = unittest.TestLoader().loadTestsFromTestCase(hooklib_simple_tests)
-  unittest.TextTestRunner(verbosity=2).run(suite)
\ No newline at end of file



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-07-13 13:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-13 13:43 [gentoo-commits] proj/autodep:master commit in: test/1_access/, src/autodep/test/, src/autodep/test/1_access/, test/logger/, Александр Берсенев

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox