Monday, June 13, 2011

CUnit test - Installation and sample Test

I tried installing CUnit with default prefix and settings in Ubuntu11.04, but I always got error during compilation. Major error was "Fatal error: CUnit/Basic.h: No such file or directory". After doing a bit of googling, I stumble upon to the following URL with the instructions given below.
http://ubuntuforums.org/archive/index.php/t-1727067.html

Step 1: Download CUnit package from Source Forge.
Step 2: Find where you saved the package on your system, and uncompress it:
tar xjf CUnit-2.1-2-src.tar.bz2

Step 3: Go into the CUnit-2.1.2 directory.
cd CUnit-2.1.2

Step 4: Run the following sequence of commands:
mkdir -p $HOME/local

./configure --prefix=$HOME/local
make clean
make
make install

Step 5: Goto the directory $HOME/local. Verify that you have the following sub-directories: doc, include, lib, and share. Each of these should have the products you seek.

Step 6. To build an application using CUnit, something like this is used:

gcc -Wall -I$HOME/local/include MyProg.cpp -L$HOME/local/lib -lcunit -o myprog

OR

g++ -Wall -I$HOME/local/include MyProg.cpp -L$HOME/local/lib -lcunit -o myprog

Note: In your source code, include CUnit header files such as:

#include "CUnit/CUnit.h";
#include "CUnit/Basic.h";

==How to run the program

Since this library is not part of the system lib path, we need to include it each time into system variables or pass them as flag (as we did in gcc/g++ command above).

lets include this path into system variable.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/local/lib

Now run the program

./myprog

==== Now with System wide installation and Testing====

After practicing above sequence and commands for compilation and execution, I tried the same logic with system wide installation which was giving me errors early on. In Ubuntu, CUnit's head files are located at /usr/local/include and its libs are available at /usr/lib. So the compilation command would be something like this.

gcc -Wall -I/usr/local/include MyProgram.cpp -L/usr/lib -lcunit -o myprogram

To run, simply try ./myprogram and it should work. in case if it doesn't, set the LD_LIBRARY_PATH as we did above.
first make sure /usr/lib is not part of the LD_LIBRARY_PATH by printing this variable by 'echo $LD_LIBRARY_PATH'
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib

==Mac OS X (10.6)
The same system-wide installation and execution instructions work for mac os x 10.6.

Thursday, June 9, 2011

Apache WebServer2 with Tomcat 7

On Mac OS X (10.6)

download Tomcat 7 from official site.
preinstalled and configured apache httpd server on Mac.

you have to download and installed mod_jk apache connector.

A mix of the following two articles enable me to use Apache webserver to server usual contents and tomcat to serve the jsp or servlet.
http://macdevcenter.com/pub/a/mac/2002/08/20/tomcat_integration.html?page=1

mod_jk installation instrcution from the this link
http://www.bartbusschots.ie/blog/?p=1347

though the first link can be used for the entire working, however the instructions for compiling and installing mod_jk are complex.

After doing all this, I got the following error message in mod_jk.log
[Thu Jun 09 13:40:27 2011] [53894:140735072558240] [info] ajp_connection_tcp_get_message::jk_ajp_common.c (1216): (ajp13) can't receive the response header message from tomcat, tomcat (127.0.0.1:8080) has forced a connection close for socket 20
[Thu Jun 09 13:40:27 2011] [53894:140735072558240] [error] ajp_get_reply::jk_ajp_common.c (2058): (ajp13) Tomcat is down or refused connection. No response has been sent to the client (yet)
[Thu Jun 09 13:40:27 2011] [53894:140735072558240] [info] ajp_service::jk_ajp_common.c (2543): (ajp13) sending request to tomcat failed (recoverable), (attempt=2)
[Thu Jun 09 13:40:27 2011] [53894:140735072558240] [error] ajp_service::jk_ajp_common.c (2562): (ajp13) connecting to tomcat failed.
[Thu Jun 09 13:40:27 2011] [53894:140735072558240] [info] jk_handler::mod_jk.c (2627): Service error=0 for worker=ajp13


After googling and hit a try, I came to know that the port mentioned in worker.properties and AJP connector settings in server.xml should be same. After chaning the port in worker.properties to 8009 (default in AJP/1.3 connector), things were working like charm.

Thursday, March 17, 2011

creating a ubuntu 10.04 server image for KVM

KVM a hypervisor.

on ubuntu machine, follow these steps

0-download ubuntu 10.04 or other releases
lets call this file ubuntu-10.04-server-i386.iso

1- install kvm using
aptitude install kvm

2- create a disk image using dd. let say 5GB disk image
dd if=/dev/zero of=ubuntu-server.img bs=1G count=5

3-assuming that iso and ubuntu-server.img files are in the same directory.
create kvm vm using the following command. This vm will have 512 MB memory.

kvm -m 512 -cdrom ubuntu-10.04.iso -boot d ubuntu-server.img

to test it, run the vm using

kvm -m 512 -cdrom ./ubuntu-10.04-server-i386.iso ubuntu_server.img

done

Friday, February 18, 2011

increase hard disk for your xen vm

Yesterday, when I was running my simulations, I came across a problem with available hard disk space. My simulations were generating tremendously amounts of logs and soon my hard disk was full and I could not complete other runs in my simulations. Fortunately, the issue was solved with few commands.

1- create an empty image using dd command
dd if=/dev/zero of=disk2.img count=5 bs=1G

this will create a file named disk2.img of size 5GB.

2- append this img to the existing img file of your xen vm. For instance, the name of my img file was disk.img
cat disk2.img >> disk.img

3- now you need to recreate the format
e2fsck -f disk.img

4-last step is to resize the img file using resize2fs. this will scan the img and looks for some changes happened and updates the filesystem table accordingly.
resize2fs disk.img

reboot your xen vm and use the command to get the available harddisk space. In ubuntu, use df -H to see the increased hard disk space.