[tracker] functional-tests: Add bootup test cases



commit 0a3085738773aaa9106e7fadd4cc7a1f8e09c1f8
Author: Amit Jain <ext-amit 1 jain nokia com>
Date:   Thu Apr 1 11:14:38 2010 +0200

    functional-tests: Add bootup test cases

 tests/functional-tests/Makefile.am           |    3 +-
 tests/functional-tests/bootup-tc.py          |  140 ++++++++++++++++++++++++++
 tests/functional-tests/configuration.py      |    9 +-
 tests/functional-tests/configuration.py.orig |   75 ++++++++++++++
 4 files changed, 223 insertions(+), 4 deletions(-)
---
diff --git a/tests/functional-tests/Makefile.am b/tests/functional-tests/Makefile.am
index e99872d..c18a8e1 100644
--- a/tests/functional-tests/Makefile.am
+++ b/tests/functional-tests/Makefile.am
@@ -19,7 +19,8 @@ config_SCRIPTS =		\
 	07-graph.py		\
 	08-unique-insertions.py \
 	virtual-files-tc.py	\
-	performance-tc.py
+	performance-tc.py	\
+	bootup-tc.py
 
 EXTRA_DIST = $(config_SCRIPTS)
 endif
diff --git a/tests/functional-tests/bootup-tc.py b/tests/functional-tests/bootup-tc.py
new file mode 100644
index 0000000..8f3c831
--- /dev/null
+++ b/tests/functional-tests/bootup-tc.py
@@ -0,0 +1,140 @@
+#!/usr/bin/env python2.5
+
+# Copyright (C) 2008, Nokia (urho konttori nokia com)
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA  02110-1301, USA.
+
+
+import sys,os,dbus
+import unittest
+import time
+import random
+import commands
+import string
+import configuration
+
+TRACKER = 'org.freedesktop.Tracker1'
+TRACKER_OBJ = '/org/freedesktop/Tracker1/Resources'
+RESOURCES_IFACE = "org.freedesktop.Tracker1.Resources"
+
+IMAGES_DEFAULT = configuration.MYDOCS_IMAGES
+MUSIC_DEFAULT  = configuration.MYDOCS_MUSIC
+VIDEOS_DEFAULT = configuration.MYDOCS_VIDEOS
+
+
+
+def files_list(dirName):            
+        fileList = []                                              
+        for file in os.listdir(dirName):
+            dirfile = os.path.join(dirName, file)
+            if dirName == IMAGES_DEFAULT :     
+                    if os.path.isfile(dirfile):
+                      if file.split('.')[1]== 'jpg' :              
+                         fileList.append(dirfile)
+                          
+            elif dirName == MUSIC_DEFAULT :
+                    if os.path.isfile(dirfile):
+                      if file.split('.')[1]== 'mp3' :
+                         fileList.append(dirfile)        
+                                                                                                                  
+            elif dirName == VIDEOS_DEFAULT :                                                 
+                    if os.path.isfile(dirfile):
+                      if file.split('.')[1]== 'avi' :
+                         fileList.append(dirfile)                                                              
+                                                                                                        
+
+        return fileList
+
+
+
+class TestUpdate (unittest.TestCase):
+        
+        def setUp(self):
+                bus = dbus.SessionBus()
+                tracker = bus.get_object(TRACKER, TRACKER_OBJ)
+                self.resources = dbus.Interface (tracker,
+                                                 dbus_interface=RESOURCES_IFACE)
+
+
+        def sparql_update(self,query):
+                return self.resources.SparqlUpdate(query)
+
+        def query(self,query):
+                return self.resources.SparqlQuery(query)
+	
+        def check ( self , appcn ):
+		pid = commands.getoutput("ps -ef| grep tracker | awk '{print $3}'").split()                      
+                if appcn in  pid :                                                  
+		   return 1
+                else :                                                                                           
+		   return 0	
+
+class tracker_daemon(TestUpdate):
+
+	def test_miner_01(self) :
+	    appcn = configuration.TRACKER_MINER
+	    result=self.check(appcn)
+	    self.assert_(result==1,"tracker miner is not running" )
+
+	def test_store_02(self) :
+	    appcn = configuration.TRACKER_STORE  
+            result=self.check(appcn)
+            self.assert_(result==1,"tracker store is not running" )
+			
+class default_content(TestUpdate):	   
+	
+	def test_images_01(self) :
+	    """
+	       1.Check the no.of files in default folder
+	       2.Make tracker search for images and check if files are listed from default folders and count them.
+	       3.Check if no.of files from default folder is equal to tracker search results
+	    """
+	    default_Images=files_list(IMAGES_DEFAULT)
+	    Images  = commands.getoutput('tracker-search -i -l 10000 | grep /home/user/MyDocs/.images/|wc -l' )
+	    self.assert_(len(default_Images)==int(Images) , "Files are not indexed from default folder")
+
+
+	def test_music_02(self) :
+	
+	    """
+	       1.Check the no.of files in default folder
+	       2.Make tracker search for songs and check if files are listed from default folders and count them.
+	       3.Check if no.of files from default folder is equal to tracker search results
+	    """
+	    default_music=files_list(MUSIC_DEFAULT)
+	    Music  = commands.getoutput('tracker-search -u -l 10000 | grep /home/user/MyDocs/.sounds/|wc -l' )
+	    self.assert_(len(default_music)==int(Music) , "Files are not indexed from default folder")
+
+
+	def test_Video_03(self) :
+	
+	    """
+	       1.Check the no.of files in default folder
+	       2.Make tracker search for videos and check if files are listed from default folders and count them.
+	       3.Check if no.of files from default folder is equal to tracker search results
+	    """
+
+	    default_videos=files_list(VIDEOS_DEFAULT)
+	    Videos  = commands.getoutput('tracker-search -v -l 10000 | grep /home/user/MyDocs/.videos/|wc -l' )
+	    self.assert_(len(default_videos)==int(Videos) , "Files are not indexed from default folder")
+
+
+
+
+if __name__ == "__main__":
+	unittest.main()
+
+
diff --git a/tests/functional-tests/configuration.py b/tests/functional-tests/configuration.py
index a736ec7..cb0154b 100644
--- a/tests/functional-tests/configuration.py
+++ b/tests/functional-tests/configuration.py
@@ -19,8 +19,7 @@
 #
 
 # This is the configuration file for tracker testcases.
-# Define the location of the test data in testDataDir
-# This also checks if the program is running in target or in host and return the column of pid
+# It has many common utility defined.
 
 import os, sys
 
@@ -35,8 +34,10 @@ TEST_DATA_IMAGES = prefix + '/share/tracker-tests/data/Images/'
 """
 dir_path = os.environ['HOME']
 """
+MYDOCS = '/home/user/MyDocs/'
 MYDOCS_MUSIC = '/home/user/MyDocs/.sounds/'
 MYDOCS_IMAGES = '/home/user/MyDocs/.images/'
+MYDOCS_VIDEOS = '/home/user/MyDocs/.videos/'
 WB_TEST_DIR_DEVICE = '/home/user/MyDocs/tracker-wb-test'
 WB_TEST_DIR_HOST = prefix + '/share/tracker-tests/data/tracker-wb-test'
 
@@ -45,11 +46,13 @@ URL_PREFIX = 'file://'
 """processes """
 TRACKER_WRITEBACK = prefix + '/lib/tracker/tracker-writeback'
 TRACKER_EXTRACT = prefix + '/lib/tracker/tracker-extract'
+TRACKER_MINER = prefix + '/lib/tracker/tracker-miner-fs'
+TRACKER_STORE = prefix + '/lib/tracker/tracker-store'
 
+'''
 def dir_path():
         return testDataDir
 
-'''
 def check_target():
         on_target = 'OSSO_PRODUCT_NAME'
         try :
diff --git a/tests/functional-tests/configuration.py.orig b/tests/functional-tests/configuration.py.orig
new file mode 100644
index 0000000..a736ec7
--- /dev/null
+++ b/tests/functional-tests/configuration.py.orig
@@ -0,0 +1,75 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2010, Nokia <ivan frade nokia com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+
+# This is the configuration file for tracker testcases.
+# Define the location of the test data in testDataDir
+# This also checks if the program is running in target or in host and return the column of pid
+
+import os, sys
+
+prefix = sys.prefix
+
+"""directory paths """
+TEST_DIR = prefix + '/share/tracker-tests/'
+TEST_DATA_DIR = prefix + '/share/tracker-tests/data/'
+TEST_DATA_MUSIC = prefix + '/share/tracker-tests/data/Music/'
+TEST_DATA_IMAGES = prefix + '/share/tracker-tests/data/Images/'
+
+"""
+dir_path = os.environ['HOME']
+"""
+MYDOCS_MUSIC = '/home/user/MyDocs/.sounds/'
+MYDOCS_IMAGES = '/home/user/MyDocs/.images/'
+WB_TEST_DIR_DEVICE = '/home/user/MyDocs/tracker-wb-test'
+WB_TEST_DIR_HOST = prefix + '/share/tracker-tests/data/tracker-wb-test'
+
+URL_PREFIX = 'file://'
+
+"""processes """
+TRACKER_WRITEBACK = prefix + '/lib/tracker/tracker-writeback'
+TRACKER_EXTRACT = prefix + '/lib/tracker/tracker-extract'
+
+def dir_path():
+        return testDataDir
+
+'''
+def check_target():
+        on_target = 'OSSO_PRODUCT_NAME'
+        try :
+                if os.environ[on_target]:
+                #if os.environ['DBUS_SESSION_BUS_ADDRESS'] == 'unix:path=/tmp/session_bus_socket':
+                        awk_print = '1'
+                        return awk_print
+       except KeyError:
+                awk_print = '2'
+                return awk_print
+'''
+
+def check_target():
+        sboxindicator='/targets/links/scratchbox.config'
+        try :
+                if os.path.islink(sboxindicator) and os.path.isfile(os.readlink(sboxindicator)) :
+                        awk_print = '3'
+                else:
+                        awk_print = '2'
+                return awk_print
+
+        except OSError:
+                awk_print = '2'



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]