Skip to content

Commit d6ea34c

Browse files
author
testkit
committed
testkit-lite 1.0
1 parent d4f6b70 commit d6ea34c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+6148
-2
lines changed

ChangeLog

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
testkit-lite 1.0.5:
2+
===================
3+
* Tue Jul 27 2011 Wang, Jing <[email protected]> 1.0.5-1
4+
- Refresh test-definition schema
5+
- Add support for latest test-definition schema
6+
7+
* Tue Jul 14 2011 Wang, Jing <[email protected]> 1.0.4-1
8+
- add -o output option, let user specify result file location
9+
- add external reporter plugin support
10+
11+
* Sat Apr 23 2011 Wei, Zhang <[email protected]> 1.0.3-1
12+
- add separate log for each case
13+
14+
* Fri Nov 12 2010 Wei, Zhang <[email protected]> 1.0.2-1
15+
- refresh the schema file from http://gitorious.org/qa-tools/test-definition/
16+
- use explicit step to replace pseudo step for descrption
17+
18+
* Wed Sep 27 2010 Wei, Zhang <[email protected]> 1.0.1-1
19+
- add option -T to strip those non-executed cases in result xml
20+
- not print empty presteps or poststeps in result xml
21+
22+
* Wed Jul 21 2010 Wei, Zhang <[email protected]> 1.0.0-1
23+
- for 1.0.0 release
24+
25+
* Mon Jul 19 2010 Wei, Zhang <[email protected]> 0.6.1-3
26+
- add normal user running support for command testkit-lite
27+
- deal with non-params as -h
28+
29+
* Wed Jul 14 2010 Wei, Zhang <[email protected]> 0.6.1-2
30+
- install directory changes from /opt/testkit-lite to /opt/testkit/lite
31+
- encode to utf8 when xml content is transfered to unicode object by lxml
32+
33+
* Fri Jul 09 2010 Wei, Zhang <[email protected]> 0.6.1-1
34+
- pre_steps and post_steps are forced automated. (align with nokia's testrunner)
35+
- deal with manual tests which has description element, it's the requirement of tests.xml exported from testlink.
36+
- imporve testparser to handle unicode object from tests.xml
37+
38+

LICENSE

+340
Large diffs are not rendered by default.

MANIFEST

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
ChangeLog
2+
LICENSE
3+
MANIFEST.in
4+
README
5+
TODO
6+
fakeinstall
7+
postinstall
8+
setup.cfg
9+
setup.py
10+
testkit-lite
11+
./__init__.py
12+
./autoexec.py
13+
./basicstruct.py
14+
./manexec.py
15+
./runner.py
16+
./str2.py
17+
./testfilter.py
18+
./testparser.py
19+
./textreport.py
20+
./tree.py
21+
./unit.py
22+
./validate.py
23+
./xmlreport.py
24+
man/testkit-lite.1
25+
unittest/autoexec_unittest.py
26+
unittest/basicstruct_unittest.py
27+
unittest/complex.xml
28+
unittest/informal.xml
29+
unittest/manexec
30+
unittest/manexec.sh
31+
unittest/manexec_unittest.py
32+
unittest/manual.xml
33+
unittest/runauto.py
34+
unittest/runmanual.py
35+
unittest/runner_unittest.py
36+
unittest/simple.xml
37+
unittest/simplelonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglong.xml
38+
unittest/str2_unittest.py
39+
unittest/testfilter_unittest.py
40+
unittest/testparser_unittest.py
41+
unittest/textreport_unittest.py
42+
unittest/tree_unittest.py
43+
unittest/unit_unittest.py
44+
unittest/validate_unittest.py
45+
unittest/xmlreport_unittest.py
46+
unittest/tree_test_graph/test1PrintTree.graph
47+
unittest/tree_test_graph/test2SetNodeKey.graph
48+
unittest/tree_test_graph/test3SetNodeShow.graph
49+
unittest/tree_test_graph/test4PrintNodeTreeReverse.graph
50+
unittest/tree_test_graph/test5DelNode.graph
51+
unittest/tree_test_graph/test6UpdateNode.graph
52+
unittest/tree_test_graph/test7PrintNodeTree.graph
53+
xsd/testdefinition-results.xsd
54+
xsd/testdefinition-syntax.xsd

MANIFEST.in

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include xsd/*
2+
include man/*
3+
include unittest/*
4+
include unittest/tree_test_graph/*
5+
include LICENSE
6+
include README
7+
include ChangeLog
8+
include MANIFEST.in
9+
include TODO
10+
include fakeinstall
11+
include postinstall

README

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
Quick Start:
2+
=================
3+
4+
At first, prepare one tests.xml file aligned with schema files: /opt/testkit/lite/xsd/testdefinition-syntax.xsd.
5+
6+
And then,
7+
8+
1) You can simply conduct one or more tests.xml:
9+
testkit-lite -f <somewhere1>/tests.xml <somewhere2>/tests.xml
10+
11+
2) You can also arrange several tests.xml to one testsxmlconfig, and run
12+
testkit-lite --testxmlconfig <somewhere1>/testsxmlconfig
13+
Also, it supports multi testsxmlconfig:
14+
testkit-lite --testxmlconfig <somewhere1>/testsxmlconfig <somewhere2>/testsxmlconfig
15+
The testsxmlconfig is like this:
16+
##############################
17+
# /opt/browser/tests.xml #
18+
# /opt/ofono/tests.xml #
19+
# /opt/gfx/tests.xml #
20+
# /opt/pulseaudio/tests.xml #
21+
##############################
22+
23+
3) If you want to validate one new tests.xml:
24+
testkit-lite -f tests.xml -V
25+
26+
4) If you just want to get the statistic (such as the testcases number or the structure), dryrun could help:
27+
testkit-lite -f tests.xml -D
28+
29+
5) If you want to execute auto tests:
30+
testkit-lite -f tests.xml
31+
32+
6) If you just want to execute manual tests:
33+
testkit-lite -f tests.xml -M
34+
35+
7) If you want to execute all the auto and manual tests:
36+
testkit-lite -f tests.xml -A
37+
38+
8) If you just want to execute the significant tests:
39+
testkit-lite -f tests.xml -S
40+
41+
9) If you want to choose some filters:
42+
testkit-lite -f tests1.xml tests2.xml --level level1 level2 --type type1 type2 --Ntestcase gfx1 gfx2...
43+
Note that the test cases will be filtered out by both black rules and white rules.
44+
45+
10) At last, you can freely compose the above paramters together:
46+
testkit-lite -f tests1.xml tests2.xml --testxmlconfig config1 config2 -D -A -S -C --level level1 level2 --type type1 type2 ...
47+
48+
11) One more parameter is prepared for customized compatible mode for test report:
49+
testkit-lite -f tests.xml -C
50+
51+
52+
Get Results:
53+
=================
54+
Two kinds of test report will be generated:
55+
1) <tests xml name>.textresult
56+
example:
57+
===================================TestReport===================================
58+
TYPE PASS FAIL N/A
59+
---/usr/share/mnts1.0-distromisc-test/tests.xml XML 0 0 24
60+
`---Distro Misc SUITE 0 0 24
61+
|---General shortkeys SET 0 0 2
62+
| |---general_shortkeys_console_switch CASE 0 0 1
63+
| `---general_shortkeys_standard_shortkeys CASE 0 0 1
64+
|---Linux Usability SET 0 0 4
65+
| |---linux_usability_common_commands CASE 0 0 1
66+
| |---linux_usability_default_app_and_MIME CASE 0 0 1
67+
| |---linux_usability_gconf_database CASE 0 0 1
68+
| `---linux_usability_security_usability CASE 0 0 1
69+
|---Log system SET 0 0 4
70+
| |---log_system_UI_process CASE 0 0 1
71+
| |---log_system_monitor_log_access CASE 0 0 1
72+
| |---log_system_process_pulseaudio_daemon CASE 0 0 1
73+
| `---log_system_sreadhead CASE 0 0 1
74+
|---Non-defult integrated applications SET 0 0 3
75+
| |---non_default_apps_installation CASE 0 0 1
76+
| |---non_default_apps_sanity_check CASE 0 0 1
77+
| `---non_default_apps_uninstallation CASE 0 0 1
78+
|---Package check SET 0 0 3
79+
| |---package_check_core_debuginfo CASE 0 0 1
80+
| |---package_check_core_dependency CASE 0 0 1
81+
| `---package_check_core_version CASE 0 0 1
82+
|---Peripheral Devices SET 0 0 6
83+
| |---peripheral_devices_automount CASE 0 0 1
84+
| |---peripheral_devices_external_bluetooth CASE 0 0 1
85+
| |---peripheral_devices_external_cdrom CASE 0 0 1
86+
| |---peripheral_devices_usb_hotplug CASE 0 0 1
87+
| |---peripheral_devices_usb_hub CASE 0 0 1
88+
| `---peripheral_devices_usb_mount_umount CASE 0 0 1
89+
`---User actions on the stage of system boot-up SET 0 0 2
90+
|---user_actions_at_bootup_keyboard_operations CASE 0 0 1
91+
`---user_actions_at_bootup_mouse_operations CASE 0 0 1
92+
93+
2) <tests xml name>.xmlresult
94+
xml result files aligned with schema files: /opt/testkit/lite/xsd/testdefinition-results.xsd
95+
example: <ignore>
96+
97+
The result will be under /opt/testkit/lite/latest after execution, you can also check the history results in /opt/testkit/lite/yyyy-mm-dd-HH:MM:SS.NNNNNN.
98+
99+
100+
Notes:
101+
=================
102+
testkit-lite's TestLog is stored to /opt/testkit/lite/latest
103+
testkit-lite enables only automatic tests by default
104+
Obviously -A and -M are conflict options.
105+
106+
107+
Detail Options:
108+
=================
109+
Options:
110+
-f, --testxmls Specify the test.xml, support multi test.xml
111+
Refer to --testxmlconfig to add by filelist
112+
--testxmlconfig Specify the file listing group of testxmls
113+
Support multi testxmlconfig files
114+
-D, --dryrun Dry-run the selected test cases
115+
-V, --validate-only Do only input xml validation, do not execute tests
116+
-M, --manual-only Enable only manual tests to be executed
117+
-A, --all Enable both automatic and manual tests
118+
-S, --significant-only
119+
Enable only significant tests to be executed
120+
-C, --compatibleresultxml
121+
use nokia compatible result xml format
122+
--domain Select the specified white-rules filter: domain
123+
--requirement Select the specified white-rules filter: requirement
124+
--testsuite Select the specified white-rules filter: testsuite
125+
--testset Select the specified white-rules filter: testset
126+
--environment Select the specified white-rules filter: environment
127+
--level Select the specified white-rules filter: level
128+
--feature Select the specified white-rules filter: feature
129+
--testcase Select the specified white-rules filter: testcase
130+
--subfeature Select the specified white-rules filter: subfeature
131+
--type Select the specified white-rules filter: type
132+
--Ndomain Select the specified black-rules filter: domain
133+
--Nrequirement Select the specified black-rules filter: requirement
134+
--Ntestsuite Select the specified black-rules filter: testsuite
135+
--Ntestset Select the specified black-rules filter: testset
136+
--Nenvironment Select the specified black-rules filter: environment
137+
--Nlevel Select the specified black-rules filter: level
138+
--Nfeature Select the specified black-rules filter: feature
139+
--Ntestcase Select the specified black-rules filter: testcase
140+
--Nsubfeature Select the specified black-rules filter: subfeature
141+
--Ntype Select the specified black-rules filter: type
142+
-h, --help show this help message and exit

README.md

-2
This file was deleted.

TODO

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
TODO:
2+
========
3+
1. add --verbose and logging level.
4+
2. support html view when execute manual test
5+

__init__.py

Whitespace-only changes.

autoexec.py

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright (C) 2010, Intel Corporation.
4+
#
5+
# This program is free software; you can redistribute it and/or modify it
6+
# under the terms and conditions of the GNU General Public License,
7+
# version 2, as published by the Free Software Foundation.
8+
#
9+
# This program is distributed in the hope it will be useful, but WITHOUT
10+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
# for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License along with
15+
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16+
# Place - Suite 330, Boston, MA 02111-1307 USA.
17+
#
18+
# Authors:
19+
# Wei, Zhang <[email protected]>
20+
#
21+
22+
import os
23+
import sys
24+
import time
25+
import threading
26+
import subprocess
27+
from multiprocessing import Process
28+
from multiprocessing import Value
29+
30+
31+
###############################################################################
32+
def shell_exec(cmd, timeout=None, boutput=False):
33+
34+
"""shell executor, return [exitcode, stdout/stderr]
35+
timeout: None means unlimited timeout
36+
boutput: specify whether print output during the command running
37+
"""
38+
BUFFILE1 = os.path.expanduser("~") + "/.shellexec_buffile_stdout"
39+
BUFFILE2 = os.path.expanduser("~") + "/.shellexec_buffile_stderr"
40+
41+
LOOP_DELTA = 0.01
42+
43+
exit_code = None
44+
stdout_log = ""
45+
stderr_log = ""
46+
47+
wbuffile1 = file(BUFFILE1, "w")
48+
wbuffile2 = file(BUFFILE2, "w")
49+
rbuffile1 = file(BUFFILE1, "r")
50+
rbuffile2 = file(BUFFILE2, "r")
51+
52+
# start execution process
53+
cmdPopen = subprocess.Popen(args=cmd, shell=True, close_fds=True,
54+
stdout=wbuffile1, stderr=wbuffile2)
55+
56+
def print_log():
57+
sys.stdout.write(rbuffile1.read())
58+
sys.stdout.write(rbuffile2.read())
59+
sys.stdout.flush()
60+
61+
# loop for timeout and print
62+
rbuffile1.seek(0)
63+
rbuffile2.seek(0)
64+
t = timeout
65+
while True:
66+
67+
exit_code = cmdPopen.poll()
68+
if exit_code is not None:
69+
break
70+
71+
if boutput:
72+
print_log()
73+
74+
if t is not None:
75+
if t <= 0:
76+
# timeout, kill command
77+
try:
78+
cmdPopen.kill()
79+
except:
80+
pass
81+
break
82+
else:
83+
t -= LOOP_DELTA
84+
85+
time.sleep(LOOP_DELTA)
86+
87+
88+
# print left output
89+
if boutput:
90+
# flush left output in log
91+
print_log()
92+
93+
# store the log from buffile
94+
rbuffile1.seek(0)
95+
rbuffile2.seek(0)
96+
stdout_log = rbuffile1.read()
97+
stderr_log = rbuffile2.read()
98+
99+
# close file
100+
wbuffile1.close()
101+
wbuffile2.close()
102+
rbuffile1.close()
103+
rbuffile2.close()
104+
os.remove(BUFFILE1)
105+
os.remove(BUFFILE2)
106+
107+
return [exit_code, stdout_log.strip('\n'), stderr_log.strip('\n')]

0 commit comments

Comments
 (0)