From 39405e35332fa49b762db5d0db2d4500e9d01df3 Mon Sep 17 00:00:00 2001 From: Nimika Keshri Date: Fri, 15 Oct 2010 14:56:19 +0300 Subject: [PATCH] Changes: Refactored the performance test to use xresponse for startup times RevBy: TrustMe --- debian/applauncherd-testscripts.install | 3 + debian/control | 2 +- tests/TestScripts/CMakeLists.txt | 3 + tests/TestScripts/fala_wid | 2 + tests/TestScripts/fala_xres_wl | 5 ++ tests/TestScripts/fala_xres_wol | 3 + tests/TestScripts/test-perf.rb | 83 +++++++++++++++++-------- 7 files changed, 74 insertions(+), 27 deletions(-) create mode 100755 tests/TestScripts/fala_wid create mode 100755 tests/TestScripts/fala_xres_wl create mode 100755 tests/TestScripts/fala_xres_wol diff --git a/debian/applauncherd-testscripts.install b/debian/applauncherd-testscripts.install index b4a7413..4f4d375 100644 --- a/debian/applauncherd-testscripts.install +++ b/debian/applauncherd-testscripts.install @@ -6,4 +6,7 @@ usr/share/applauncherd-testscripts/tc_theming.rb usr/share/applauncherd-testscripts/test-perf.rb usr/share/applauncherd-testscripts/utils.py usr/share/applauncherd-testscripts/test-security.py +usr/share/applauncherd-testscripts/fala_wid +usr/share/applauncherd-testscripts/fala_xres_wl +usr/share/applauncherd-testscripts/fala_xres_wol usr/share/applauncherd-testscripts/signal-forward/* diff --git a/debian/control b/debian/control index 9392306..6849737 100644 --- a/debian/control +++ b/debian/control @@ -65,7 +65,7 @@ Description: applauncherd unit tests Package: applauncherd-testscripts Priority: extra Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-testapps, testrunner-lite, applauncherd, ci-testing, testability-driver, libcreds2 [arm armel], libcreds2-tools [arm armel], meego-env, mcetools (>= 1.10.40), rdoc, python, ruby +Depends: ${shlibs:Depends}, ${misc:Depends}, applauncherd-testapps, testrunner-lite, applauncherd, ci-testing, testability-driver, libcreds2 [arm armel], libcreds2-tools [arm armel], meego-env, mcetools (>= 1.10.40), rdoc, python, ruby, xresponse XB-Maemo-CI-Packages: applauncherd XB-Maemo-CI-Stage: fast, staging, acceptance, validation Description: applauncherd testscripts diff --git a/tests/TestScripts/CMakeLists.txt b/tests/TestScripts/CMakeLists.txt index 64c7598..1be8dbd 100644 --- a/tests/TestScripts/CMakeLists.txt +++ b/tests/TestScripts/CMakeLists.txt @@ -10,6 +10,9 @@ install(PROGRAMS ts_prestartapp.rb tc_theming.rb test-perf.rb + fala_wid + fala_xres_wl + fala_xres_wol DESTINATION /usr/share/applauncherd-testscripts) add_subdirectory (signal-forward) diff --git a/tests/TestScripts/fala_wid b/tests/TestScripts/fala_wid new file mode 100755 index 0000000..90625a3 --- /dev/null +++ b/tests/TestScripts/fala_wid @@ -0,0 +1,2 @@ +#!/bin/sh +for wid in $(xwininfo -root -tree| awk '/864x480\+0\+0/{print $1}'); do echo $wid $(xprop -id $wid | awk '/_NET_WM_PID/{print $3}') | awk -v BOOSTERPID=$(pidof booster-m) '{if (BOOSTERPID == $2) print $1}'; done diff --git a/tests/TestScripts/fala_xres_wl b/tests/TestScripts/fala_xres_wl new file mode 100755 index 0000000..43d8f03 --- /dev/null +++ b/tests/TestScripts/fala_xres_wl @@ -0,0 +1,5 @@ +#!/bin/sh +x=`sh /usr/bin/fala_wid` +xresponse -a 'duihome' -w 0 -id $x -c $1 -u > /tmp/app_xresponse.log& +echo $x + diff --git a/tests/TestScripts/fala_xres_wol b/tests/TestScripts/fala_xres_wol new file mode 100755 index 0000000..4a8a6ad --- /dev/null +++ b/tests/TestScripts/fala_xres_wol @@ -0,0 +1,3 @@ +#!/bin/sh +xresponse -a 'duihome' -w 0 -a 'fala_wol' -c $1 -u > /tmp/app_xresponse.log& + diff --git a/tests/TestScripts/test-perf.rb b/tests/TestScripts/test-perf.rb index 05a2e52..e79fbe3 100755 --- a/tests/TestScripts/test-perf.rb +++ b/tests/TestScripts/test-perf.rb @@ -26,9 +26,12 @@ include TDriverVerify class TC_PerformanceTests < Test::Unit::TestCase - COUNT = 5 + COUNT = 3 + APP_WITH_LAUNCHER = 'fala_wl' + APP_WITHOUT_LAUNCHER = 'fala_wol' @start_time = 0 @end_time = 0 + @pos = 0 $path = string = `echo $PATH ` @@ -56,30 +59,37 @@ class TC_PerformanceTests < Test::Unit::TestCase def open_Apps(appName) #Remove the Log file if it exists - if FileTest.exists?("/tmp/testapp.log") - system "rm /tmp/testapp.log" + if FileTest.exists?("/tmp/app_xresponse.log") + system "rm /tmp/app_xresponse.log" end - - count = 0 - + #Open the Application from the application grid @meegoHome = @sut.application(:name => 'duihome') - @meegoHome.MButton(:name => "ToggleLauncherButton").tap sleep(2) if @meegoHome.test_object_exists?("LauncherButton", :text => appName) icon = @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName) - totalPages = @meegoHome.children(:type => 'LauncherPage').length - while icon.attribute('visibleOnScreen') == 'false' and count < totalPages - @meegoHome.PagedViewport(:name => 'LauncherPagedViewport').MWidget(:name => 'glass').gesture(:Left, 1, 800) + while icon.attribute('visibleOnScreen') == 'false' + @meegoHome.Launcher.MPannableViewport( :name => 'SwipePage' ).MWidget( :name => 'glass' ).gesture(:Up, 1, 300) sleep(0.2) - count = count +1 icon.refresh end + xpos = @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName).attribute('x') + ypos = @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName).attribute('y') + @pos = "#{xpos}x#{ypos}" + + if appName == APP_WITH_LAUNCHER + @winId = `sh /usr/bin/fala_xres_wl #{@pos}` + @winId = @winId.split("\n")[0] + else + system "sh /usr/bin/fala_xres_wol #{@pos}" + end + @meegoHome.LauncherButton(:name => "LauncherButton", :text => appName).tap sleep (2) @app = @sut.application(:name => appName) sleep (2) @app.MEscapeButtonPanel.MButton( :name => 'CloseButton' ).tap + system "pkill xresponse" else #icon does not #raise error and exit @@ -88,18 +98,37 @@ class TC_PerformanceTests < Test::Unit::TestCase end end - def read_file - #Reading the log file to get the time - file_name="/tmp/testapp.log" - last_line = `tail -n 2 #{file_name}` - @start_time = `head -n 1 #{file_name}` - @end_time = last_line.split(" ")[0] + def read_file(appName) + #Reading the log file to get the time + file_name="/tmp/app_xresponse.log" + search_str1 = "Button 1 pressed at #{@pos}" + x = check_file('/tmp/app_xresponse.log', search_str1) + @start_time = x.split(':')[0].split('ms')[0] + + if appName == APP_WITH_LAUNCHER + search_str2 = "Got damage event 864x480+0+0 from #{@winId}" + y = check_file('/tmp/app_xresponse.log', search_str2) + @end_time = y.split(':')[0].split('ms')[0] + else + search_wId = check_file('/tmp/app_xresponse.log',APP_WITHOUT_LAUNCHER ) + @winId = search_wId.split(" ")[6] + search_str2 = "Got damage event 864x480+0+0 from #{@winId}" + y = check_file('/tmp/app_xresponse.log', search_str2) + @end_time = y.split(':')[0].split('ms')[0] + end + end + + def check_file( file, string ) + File.open( file ) do |io| + io.each {|line| line.chomp! ; + return line if line.include? string} + end + nil end def measure_time #Measuring the Startup Time for applications - start_t = "%10.6f" % @start_time.to_f - app_t = Float(@end_time) - Float(start_t) + app_t = @end_time.to_i - @start_time.to_i return app_t end @@ -111,22 +140,23 @@ class TC_PerformanceTests < Test::Unit::TestCase #Run Application with invoker for i in 1..COUNT - open_Apps("fala_wl") - print "Now Launching fala_wl %d times\n" %i + print "Now Launching APP_WITH_LAUNCHER %d times\n" %i + open_Apps(APP_WITH_LAUNCHER) sleep (5) - read_file + read_file(APP_WITH_LAUNCHER) wL.push(measure_time) end + #Run Application without invoker for i in 1..COUNT - open_Apps("fala_wol") - print "Now Launching fala_wol %d times\n" %i + print "Now Launching APP_WITHOUT_LAUNCHER %d times\n" %i + open_Apps(APP_WITHOUT_LAUNCHER) sleep (5) - read_file + read_file(APP_WITHOUT_LAUNCHER) woL.push(measure_time) end - + print "Startup time in milliseconds\n" print "With Launcher \t\t Without Launcher\n" #Printing the data @@ -137,6 +167,7 @@ class TC_PerformanceTests < Test::Unit::TestCase end print "\nAverage Values \n" print "%.2f \t\t\t %.2f\n\n" %[wLsum/COUNT, woLsum/COUNT] + end end