testability-driver-runner 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/tdrunner.rb +48 -16
  2. data/lib/tdrunner_command_tool.rb +137 -0
  3. metadata +5 -4
data/lib/tdrunner.rb CHANGED
@@ -20,6 +20,7 @@
20
20
 
21
21
  require File.expand_path( File.join( File.dirname( __FILE__ ), 'tdrunner_monitor' ) )
22
22
  require File.expand_path( File.join( File.dirname( __FILE__ ), 'tdrunner_profile' ) )
23
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'tdrunner_command_tool' ) )
23
24
  require 'yaml'
24
25
 
25
26
  #Sophisticated Interface for Running Random Automation
@@ -49,7 +50,9 @@ module TDRunner
49
50
  elsif args[0]=='--version'
50
51
  puts '1.0.0'
51
52
  elsif args[0]=='--websi'
52
- start_websi()
53
+ start_websi(args[1, args.size])
54
+ elsif args[0]=='--cmd'
55
+ tool = TDRunnerCommandTool.new(args[1, args.size])
53
56
  elsif args[0]=='-p'
54
57
  profile = TDRunnerProfileLoader.new(args)
55
58
  tdrunner_profiles=profile.get_execution_profiles
@@ -63,8 +66,9 @@ module TDRunner
63
66
  start_tdrunner(args)
64
67
  end
65
68
  end
69
+
66
70
  #Start tdrunner web UI
67
- def start_websi()
71
+ def start_websi(args=[])
68
72
  websi_dir=[]
69
73
  tdrunner_location=File.dirname(__FILE__)
70
74
  websi_dir_arr=tdrunner_location.split('/')
@@ -74,11 +78,12 @@ module TDRunner
74
78
  websi_path=websi_dir.join('/')
75
79
  begin
76
80
  Dir.chdir(websi_path+'/websi')
77
- system ("ruby script/server")
81
+ system("ruby", "script/server", *args)
78
82
  rescue
79
83
  ensure
80
84
  end
81
85
  end
86
+
82
87
  #Executes the tdrunner command
83
88
  #Loads the tdrunner command parameters in to memory for test execution control
84
89
  def execute_test_unit_tests(test_parameters)
@@ -180,7 +185,8 @@ module TDRunner
180
185
  puts 'tdrunner -e my_execution_profile my_test_folder'
181
186
  puts 'tdrunner --ordered -e my_execution_profile my_test_folder'
182
187
  puts ''
183
- puts 'Create a execution profile of all Test::Unit tests which failed when tests were run using an execution profile:'
188
+ puts 'Create a execution profile of all Test::Unit tests which failed when tests were'
189
+ puts 'run using an execution profile:'
184
190
  puts 'tdrunner -t my_failed_test_cases.sip -e my_execution_profile my_test_case_folder'
185
191
  puts ''
186
192
  puts 'Runs tests using a predefined profiles:'
@@ -191,18 +197,44 @@ module TDRunner
191
197
  puts 'tdrunner -c C:/tdriver_reports/test_run_yyyyddmmhhss my_test_suite_folder'
192
198
  puts ''
193
199
  puts ''
194
- puts "\t-H i\t\t\tDefines how many hours tdrunner will run i as number of hours."
195
- puts "\t-i i\t\t\tDefines how many iterations tdrunner will run the tests i as number of iterations."
196
- puts "\t-d \"date time\"\t\tDefines end date and time when tdrunner will stop testing"
197
- puts "\t-e execution_profile \tDefines tdrunner to use execution profile for running tests"
198
- puts "\t-m execution_profile \tDefines tdrunner to create execution profile without running tests"
199
- puts "\t-t execution_profile \tDefines tdrunner to create execution profile of failed Test::Unit tests"
200
- puts "\t--teardown\t\tRun test unit teardown only when the testcase is failed."
201
- puts "\t--ordered\t\tUse this parameter with execution profile to run tests as they are ordered in the sip file."
202
- puts "\t--websi\t\tUse this parameter to start tdrunner web interface which is then found from address http://localhost:3000/websi/"
203
- puts "\t-p profile_name\t\tPull commandline arguments from tdrunner.yml which can be defined as strings or arrays."
204
- puts "\t--version\t\tShow version."
205
- puts "\t-h, --help\t\tYou're looking at it."
200
+
201
+ puts "-H i\t\tDefines how many hours tdrunner will run i as number of hours."
202
+
203
+ puts "-i i\t\tDefines how many iterations tdrunner will run the tests i as"
204
+ puts "\t\tnumber of iterations."
205
+
206
+ puts "-d \"date time\"\tDefines end date and time when tdrunner will stop testing"
207
+
208
+ puts "-e execution_profile"
209
+ puts "\t\tUse execution profile for running tests"
210
+
211
+ puts "-m execution_profile"
212
+ puts "\t\tCreate execution profile without running tests"
213
+
214
+ puts "-t execution_profile"
215
+ puts "\t\tCreate execution profile of failed Test::Unit tests"
216
+
217
+ puts "--cmd sut sut_id httpd server_port [usb powerup|powerdown|reset] [status]"
218
+ puts "\t\tProbe status of given sut and given httpd server."
219
+ puts "\t\t(Used by tdrunner_ui.)"
220
+ puts "--cmd sut sut_id usb powerup|powerdown|reset"
221
+ puts "\t\tPerform given usb command using given sut."
222
+ puts "\t\t(Used by tdrunner_ui.)"
223
+
224
+ puts "--teardown\tRun test unit teardown only when the testcase is failed."
225
+
226
+ puts "--ordered\tUse with execution profile to run tests as they are ordered"
227
+ puts "\t\tin the sip file."
228
+
229
+ puts "--websi [optional arguments]"
230
+ puts "\t\tStarts tdrunner web interface, by default at URL"
231
+ puts "\t\thttp://localhost:3000/websi/"
232
+
233
+ puts "-p profile_name\tPull commandline arguments from tdrunner.yml which can be"
234
+ puts "\t\tdefined as strings or arrays."
235
+
236
+ puts "--version\tShow version."
237
+ puts "-h, --help\tYou're looking at it."
206
238
  end
207
239
  end
208
240
  end
@@ -0,0 +1,137 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of Testability Driver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+ require 'tdriver'
21
+
22
+ module TDRunner
23
+ #TDRunner monitor module for controlling the SIERRA execution
24
+ class TDRunnerCommandTool
25
+ def initialize(args)
26
+ @sut_arg = ""
27
+ @httpd_port = 0
28
+
29
+ while not args.empty?
30
+
31
+ case arg=args.shift
32
+
33
+ when 'httpd' then
34
+ @httpd_port = args.shift.to_i
35
+
36
+ when 'sut' then
37
+ @sut_arg = args.shift
38
+
39
+ when 'usb' then
40
+ raise "Argument error: sut must be given before 'usb' command" if @sut_arg.empty?
41
+
42
+ case arg2=args.shift
43
+
44
+ when 'powerup'
45
+ uperror = ""
46
+ begin
47
+ sut = TDriver.sut(:Id => @sut_arg)
48
+ sut.power_up
49
+ rescue
50
+ uperror = " ERROR (#{$!.to_s.gsub(/\s+/, ' ')})"
51
+ end
52
+ puts "USB: Power up"+uperror
53
+
54
+ when 'powerdown'
55
+ downerror = ""
56
+ begin
57
+ sut = TDriver.sut(:Id => @sut_arg)
58
+ sut.power_down
59
+ rescue
60
+ downerror = " ERROR (#{$!.to_s.gsub(/\s+/, ' ')})"
61
+ end
62
+ puts "USB: Power down"+downerror
63
+
64
+ when arg+' '+'reset'
65
+ sut = TDriver.sut(:Id => @sut_arg)
66
+ sut.reset
67
+
68
+ else
69
+ raise "Argument error: Unrecognized 'usb' subcommand '#{arg2}'"
70
+
71
+ end
72
+ # end of main command 'usb'
73
+
74
+ when 'status'
75
+ if not @sut_arg.empty?
76
+ sut = TDriver.sut(:Id => @sut_arg)
77
+ puts "Selected SUT: #{@sut_arg}"
78
+
79
+ STDOUT.sync
80
+ sutstatus=''
81
+ begin
82
+ sut.refresh
83
+ sutstatus="OK"
84
+ rescue
85
+ sutstatus = "ERROR (#{$!.to_s.gsub(/\s+/, ' ')})"
86
+ end
87
+ puts "SUT connection: #{sutstatus}"
88
+ else
89
+ puts "Selected SUT: N/A"
90
+ puts "SUT connection: N/A"
91
+ end
92
+
93
+ # note: in tdrunner_gui, '?' also has the special meaning of not updating existing value in status display
94
+ # if line below is changed, tdrunner_gui code needs to be changed accordingly
95
+ puts "USB: ?"
96
+
97
+ STDOUT.sync
98
+ sutlist=''
99
+ #paramfilename = '/etc/tdriver/tdriver_params.xml'
100
+ begin
101
+ #paramfile = File.new(paramfilename)
102
+ #sutlist = paramfile.readlines.join.scan(/<sut +id *= *"([^"]+)"/).map{|i| i[0]}.join(' ')
103
+ sutlist = MobyUtil::ParameterXml.instance.sut_list.reject { |item| item.to_s == 'sut_generic' }.join(' ')
104
+ rescue
105
+ #sutlist = "Failed to read '#{paramfilename}': #{$!.to_s.gsub(/\s+/, ' ')}"
106
+ sutlist = "ERROR (#{$!.to_s.gsub(/\s+/, ' ')})"
107
+ end
108
+ puts "Available SUTs: #{sutlist}"
109
+ # end of main command 'status'
110
+
111
+ if @httpd_port > 0
112
+ httpd_str = "N/A"
113
+
114
+ if require('net/http')
115
+ uri = URI.parse("http://localhost:#{@httpd_port}/")
116
+ begin
117
+ response = Net::HTTP.get_response(uri)
118
+ httpd_str = "ALIVE (#{uri})"
119
+ rescue
120
+ httpd_str = "FAILED (#{uri})"
121
+ end
122
+ else
123
+ httpd_str = "ERROR (required ruby gem status: net/http:#{req1} uri:#{req2})"
124
+ end
125
+
126
+ puts "HTTPD: #{httpd_str}"
127
+ end #httpd status
128
+
129
+ else
130
+ raise "Argument error: Unrecognized command '#{arg}'"
131
+ end
132
+
133
+ end
134
+
135
+ end
136
+ end
137
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testability-driver-runner
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Testability Driver team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-21 00:00:00 +02:00
18
+ date: 2011-01-25 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -93,6 +93,7 @@ files:
93
93
  - bin/sierra
94
94
  - bin/tdrunner
95
95
  - lib/tdrunner_test_unit.rb
96
+ - lib/tdrunner_command_tool.rb
96
97
  - lib/tdrunner.rb
97
98
  - lib/tdrunner_cucumber_runners.rb
98
99
  - lib/tdrunner_file_finder.rb