Posts tagged LDTP
LDTP Editor
1Want to use LDTP to test your application? Or do you want to automate the actions you do often? Or are you a GNU/Linux user who want to show “magic” to your friends by recording your actions and playing them back? You can use LDTP for this. But one small issue with LDTP is that you should know the LDTP Python API to write any test suite. But with the new LDTP Editor, this makes your job really simple. A screenshot of the LDTP Editor is shown below.
This is a simple HOWTO for recording and playing back the recorded script.
Installing LDTP.
- Download the lastest LDTP source code from http://people.freedesktop.org/~nagappan/ldtp-0.9.2.tar.gz.
- Uncompress the file.
- Compile the code using ./configure and make
- If you don’t have the access to install softwares, run the ldtpeditor file in the python folder
- If you have access to install softwares, then run “make install”
Note:: After installing LDTP Editor, i when i tried to run ldtpeditor, got an error saying
hari@hari-laptop:~/ldtp/ldtp-0.9.2$ ldtpeditor
(ldtpeditor:11130): libglade-WARNING **: could not find glade file '/usr/share/local/ldtp/glade/ldtpeditor.glade'
Glade file not found
The ldtpeditor.glade file is present in the python folder. I got this error because i compiled the code as ./configure. If i had done it as ‘./configure –prefix=/usr’, then i wouldn’t have got this error. Anyway i copied the file manually to that folder.
hari@hari-laptop:~/ldtp/ldtp-0.9.2$ sudo mkdir -p /usr/share/local/ldtp/glade/
hari@hari-laptop:~/ldtp/ldtp-0.9.2$ sudo cp python/ldtpeditor.glade /usr/share/local/ldtp/glade/
hari@hari-laptop:~/ldtp/ldtp-0.9.2$ ldtpeditor
After that when i ran ldtpeditor, it ran without any issues.
Recording using LDTP Editor
For this let us consider recording the actions performed in gcalctool.
- First make sure Assistive Technology is enabled in your desktop. If you are not sure about this, open gnome-control-center and in that open Assistive Technology Preferences. You should have Enable Assistive Technologies checked to use LDTP.
- If you are enabling Assistive Technology only now, logout and login again.
- Run ldtpeditor and gcalctool.
- Make sure both you have enabled ‘Always on Top’ or both the applications and both the window doesn’t overlap with each other.
- Click the Start button the LDTP Editor. All actions performed after this are recorded.
- Perform actions in the gcalctool. Check out this video to see the actions i recored in my computer .
- After you’re done with the actions in the gcalctool, click the Stop button in the LDTP Editor.
- You can see that the ‘Recorded Code’ tab is updated with code as when you perform actions in gcalctool.
- Click the convert button in the LDTP Editor. You’ll see that the Generated LDTP Code and Generated LDTP XML tabs are filled with generated code.
- The Play button is not working now. I wrote the patch for that yesterday night ;-).
- Save the contents of the ‘Generated LDTP Code’ into a python file (for ex frisco.py) . Note that if the file name you specify already exists, then it OVERWRITES the filename without any warning.
- Then run
hari@hari-laptop:~$ python frisco.py - The actions you performed while recording will be played back again :-)
Currently the Play button in the LDTP Editor is not enabled. But you can make it work by applying the patch mentioned below. I guess this patch will be added to LDTP Editor in a week or so. So check the ChangeLog file before applying the patch.
LDTP Editor Preferences
Using the LDTP Prefereces, you can control what all actions you can control. A brief summary about the options given in the Preferences window.
- Listen key events
This option is not yet implemented. Checking/Unchecking this doesn’t make any difference now. - Listen mouse events
This option is not yet implemented. Checking/Unchecking this doesn’t make any difference now. - Generate LDTP Code
Only when if this option is enabled, Convert will generated to LDTP code in the ‘Generated LDTP Code’ tab. This is enabled by default when you run LDTP Editor. - Generate Data XML
If this option is enabled, the LDTP Editor will generate data XML for the actions you perform. - Generate keyboard events code
Generates code for the keyboard events you performed during the recording session. - Generate wait time code
Calculates the delay one takes between each action during the recording session and generates code so that similar time delay is generated while play back. - Generate Memory / CPU statistics.
The code to generate Memory and CPU statistics will be generated. You need to install pystatgrab and libstatgrab packages.
Patching to make the Run button work
- Copy this patch file to your ldtp folder.
- Run
hari@hari-laptop:~/ldtp/ldtp-0.9.2$ cd ldtp-0.9.2
hari@hari-laptop:~/ldtp/ldtp-0.9.2$ patch -p0 < ldtpeditor_runbutton.patch - Compile the code again and run ldtpeditor. This time after you Convert the Code, you can Run the code from the LDTP Editor. :-)
Note:: The generated code had many unwanted waittillguiexist. I saw waittillguiexist(“dlg0″) in many places. If your playback is stopped because of this, remove that before running the scripts.
Sometime the resource will go high as the application map info is collected from the application, so no need to worry.
If you find any issues regarding LDTP Editor, report it to ldtp-dev@lists.freedesktop.org or nagappan@gmail.com or sp2hari@gmail.com
All patches are welcome. :-)
My Tinderbox is working…
0So in this post, i am going to mention about all issues i faced in setting up a tinderbox and steps to fix them.
Yeah before you start reading this
http://sp2hari.blogspot.com/2007/06/conquered-solaris.html and
http://sp2hari.blogspot.com/2007/06/tinderbox.html has instructions about how to setup Tinderbox in Solaris environment.
Ok the first error i got was
cc -o jsinterp.o -c -DOSTYPE=\”SunOS5\” -DOSARCH=SunOS -DEXPORT_JS_API -DJS_USE_SAFE_ARENA -I../../dist/include -I../../dist/include/js -I../../dist/include/nspr -DMOZ_PNG_READ -DMOZ_PNG_WRITE -I../../dist/sdk/include -I. -KPIC -xlibmil -xstrconst -xbuiltin=%all -mt -DNDEBUG -DTRIMMED -xO4 -DMOZILLA_VERSION=\”1.9a7pre\” -DMOZILLA_VERSION_U=1.9a7pre -DSOLARIS=1 -DNSCAP_DISABLE_DEBUG_PTR_TYPES=1 -DD_INO=d_ino -DSTDC_HEADERS=1 -DHAVE_ST_BLKSIZE=1 -DHAVE_SIGINFO_T=1 -DHAVE_INT16_T=1 -DHAVE_INT32_T=1 -DHAVE_INT64_T=1 -DHAVE_UINT=1 -DHAVE_UINT_T=1 -DHAVE_UINT16_T=1 -DHAVE_DIRENT_H=1 -DHAVE_SYS_BYTEORDER_H=1 -DHAVE_GETOPT_H=1 -DHAVE_MEMORY_H=1 -DHAVE_UNISTD_H=1 -DHAVE_NL_TYPES_H=1 -DHAVE_MALLOC_H=1 -DHAVE_X11_XKBLIB_H=1 -DHAVE_SYS_STATVFS_H=1 -DHAVE_SYS_STATFS_H=1 -DHAVE_LIBM=1 -DHAVE_LIBDL=1 -DHAVE_LIBSOCKET=1 -DFUNCPROTO=15 -DHAVE_XSHM=1 -D_REENTRANT=1 -DHAVE_RANDOM=1 -DHAVE_STRERROR=1 -DHAVE_LCHOWN=1 -DHAVE_FCHMOD=1 -DHAVE_SNPRINTF=1 -DHAVE_MEMMOVE=1 -DHAVE_RINT=1 -DHAVE_STAT64=1 -DHAVE_LSTAT64=1 -DHAVE_FLOC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Z_PROFILELOCKING=1 -DMOZ_RDF=1 -DMOZ_MORKREADER=1 -DMOZ_DLL_SUFFIX=\”.so\” -DXP_UNIX=1 -DUNIX_ASYNC_DNS=1 -DJS_THREADSAFE=1 -DMOZ_ACCESSIBILITY_ATK=1 -DATK_MAJOR_VERSION=1 -DATK_MINOR_VERSION=12 -DATK_REV_VERSION=3 -DMOZILLA_LOCALE_VERSION=\”1.9a1\” -DMOZILLA_REGION_VERSION=\”1.9a1\” -DMOZILLA_SKIN_VERSION=\”1.8\” -D_MOZILLA_CONFIG_H_ -DMOZILLA_CLIENT jsinterp.c
ube: error: Assert has been violated at ‘/set/venus/builds.intel-S2/nightly.Thu/intel-S2/lang/ube/graphs/src/scregion.c 305′.
cc: ube failed for jsinterp.c
gmake[4]: *** [jsinterp.o] Error 2
Steps to add a patch in Solaris are given below. The commands are for patch 121016-05. Change the id according to the patch you are installing.
1. Download 121016-05.zip and extract the contents in your current directory
2. Login as root
3. root@home# patchadd 121016-05
Note :: If the above command doesn’t work, then try
root@home# patchadd . 121016-05
# ls
120759-06 121016-05
That fixed the above problem :).
The next error i got was
jsinterp.c
ir2hf: error: Ran out of memory
cc: ir2hf failed for jsinterp.c
Finally i got an error saying,
gmake[3]: Leaving directory `/export/home/hari/tinderbox
gmake[2]: Leaving directory `/export/home/hari/tinderbox
make[1]: Leaving directory `/export/home/hari/tinderbox
firefox-bin built successfully.
firefox-bin built successfully.
firefox-bin binary exists, build successful.
Unable to find path to Talkback client. Proceeding as if Talkback was not installed.
Running regxpcom test …
Timeout = 120 seconds.
Begin: Fri Aug 24 08:08:37 2007
cmd = /export/home/hari/tinderbox
End: Fri Aug 24 08:08:38 2007
———– Output from regxpcom ————-
———– End Output from regxpcom ———
regxpcom: test failed
No profile found, creating profile.
Begin: Fri Aug 24 08:08:38 2007
cmd = /export/home/hari/tinderbox
End: Fri Aug 24 08:08:39 2007
———– Output from Profile Creation ————-
Xlib: connection to “:0.0″ refused by server
Xlib: No protocol specified
(firefox-bin:6432): Gtk-WARNING **: cannot open display:
———– End Output from Profile Creation ———
ERROR: profile /export/home/hari/tinderbox
no pref file found
hari@home:~$/usr/openwin/bin/xhost +
access control disabled, clients can connect from any host
Few other things to note while trying to compile firefox under tinderbox are
1. Never ever run two instances of tinderbox at the same time. Make sure the first one is killed before starting a new one.
2. Delete the SunOS_5.11_Depend folder when you are facing any compilation errors.
3. Use -XO3 for CFLAGS and CXXFLAGS
4. Make sure your mozconfig file has these lines
ac_add_options –disable-freetype2
ac_add_options –disable-debug
ac_add_options –disable-tests
SOC ….
0Updates about SOC.
30 test scripts are working fine without any issue :). My target is to write 50 test cases and i will try to reach that this weekend :) :).
The scripts can be downloaded from here.
Things to be modified when you run your script in your environment are.
1. In the file firefox.xml, change the value of <filepath> for
Let me give a detailed HOW TO for running these scripts.
1. First, LDTP must be installed in your system.
The CVS page in ldtp.freedesktop.org provides the instructions for getting the LDTP code through CVS.
Note : I had a small issue compiling the code which i got from CVS.
While using ./configure it gave me an error saying
./configure: line 3998: syntax error near unexpected token `LIBXML2,’
./configure: line 3998: `PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= 2.0.0)’
The above error is because autoconf and pkg-conf are installed at two different locations. For more details check http://lists.freedesktop.org/pipermail/xserver/2003-December/000573.html
So i used this package which compiled without any issue :).
For more details on how to install, check here.
2. Enable Accessibility from gnome-control-center
3. Download and start Firefox3.0a*pre from here ( Any FF3.0 alpha release should work, though with FF3.0a8pre, it is tested throughly.
Note :: When you start firefox, make sure you don’t have any other instance of firefox running.
4.Run the command
hari@home:~/soc/tinderbox$ ldtprunner run.xml
If you have set LDTP_DEBUG=1 in your shell, then it will show lots of output. Don’t get scared. It only means things are working fine :)
Note :: You can also work with LDTP_DEBUG unset, if you want a “clean” output.
Once that command is executed, then it will run the test cases provided in the run.xml.
A file called log.xml gives the details about the test cases run. The last three lines in the log file should be like this if the test case ran properly for all the 30 test cases provided.
<groupsstatus total=”30″ pass=”30″ fail=”0″/>
</group>
</ldtp>
The screen record video on Solaris 11 is given can be viewed from here.
http://download.freedesktop
The current status of the test cases can be viewed from here.
http://ldtp.freedesktop.org/wiki/Firefox_Test_Cases
file-roller …
3When i saw the mail from nags saying
” Can somebody evaluate it and send me back the results. It was done by Yazhini, long time back, but I could not check them.”
So wrote the test cases for file-roller according to the new file-roller and new LDTP.
1. Names of objects in applications.
This has changed a lot, especially in the frame names. In the old scripts for file roller, it will be like
selectmenuitem (‘ArchiveManager’,'mnuHelp;mnuAbout’)
But according to the new LDTP, it is better to have
selectmenuitem (‘frmArchiveManager’,'mnuHelp;mnuAbout’)
2. Runner XML.
#To create a new archive
log (‘Create New Archive’, ‘teststart’)
execfile (‘create-archive.py’)
log (‘Create New Archive’, ‘testend’)
time.sleep(2)
#To open an existing archive and extracing them.
log (‘Open Extract Archive ‘, ‘teststart’)
execfile (‘open-extract.py’)
log (‘Open Extract Archive’, ‘testend’)
<ldtp>
<logfileoverwrite>1</logfileoverwrite>
<logfile>log.xml</logfile>
<group>
<script>
<name>create-archive.py</name>
<data>fileroller.xml</data>
</script>
<script>
<name>open-extract.py</name>
<data>fileroller.xml</data>
</script>
</group>
</ldtp>
Scripts can be easily added, removed and grouped using the runner.xml .
3. waittillguiexist() and waittillguinotexist().
4. LDTPExecutionError :
except LdtpExecutionError, msg:
msg = ‘open-extract test case failed’
log (msg, ‘error’)
raise LdtpExecutionError (msg)
5. Data XML.
6. Appmap file.
Therefore you can remove the following piece of code if you find it in your test case.
if len (sys.argv) == 1:
if os.access (‘./file-roller.map’, os.F_OK | os.R_OK) == 0:
print ‘Appmap path missing’
sys.exit(0);
else:
appmap_path = ‘.’
else:
appmap_path = sys.argv[1]
initappmap (appmap_path + ‘/file-roller.map’)
Coding Style …
2Some tips/tricks for nice coding skills are,
A few examples for C is posted here .
Sample Code 1 :
if (a == 5) {
}
else {
b = 20;
}
Things to be noticed in the above snippet are.
1. A space between if and “(” .
2. Space in both the sides of the comparison operator.
3. Space between “)” and “{“
4. Space between both the sides of assignment operator (line 2 & 5) . This is true for almost all the operators.
5. Proper indentation of lines 2 & 5. If you are using emacs or vi, check here for your .emacs or .vimrc file .
Sample Code 2
Let us have a function which takes two integers and returns their sum .
The code should be like
int add_numbers (int num1, int num2) {
return (num1 + num2);
}
The function call will be something like,
int sum;
sum = add_numbers (10, 20);
Things to be noticed in the above snippet is
In the first line in the function declaration,
1. The function name should be as clear as possible.
2. A space between the end of function name and “(” .
3. Spaces are given after every “,” in the function argument list.
4. A space is given between “)” and “{“.
In the second line in the function declaration,
1. A space before “(“. [ This rule is almost global. Apply it everywhere whenever you use "(" ] .
3. The indentation about which was mentioned earlier.
But yes, if your girl friend is a geek or a nerd or a psycho or a fundoo, then you better go for this. ;-)
#define MAGIC “eilouvy43605321″
#define _(p,o,q) (t o#p[0])?(q)
#define __(p,o,q) _(p,o,t-q)
int main(){int t, i; for(i=8;i>0;i–)printf(“%c”, MAGIC[(((t=(MAGIC+7)[i-1])==’_')?62:_(.,==,63):_(@,==,64):__(a,>=,’a'+36):__(A,>=,’A'+10):(t-’0′))]);}
Note :: I wont say the coding style i use is the perfect one. It always depends upon what your team was using till now and how easy it is to read, debug and maintain the code.
Useful Links :













