Skip to content

Reference: Setup test Env

Liu Wenlong edited this page Jul 31, 2017 · 3 revisions
The detail of how to set LTP test environment was introduced in this part.  
1. Hardware  
This is about the hardware links and environment settings.  

1.1 Hardware Setting:  
Some testcases require two machines. And each machine needs to have 2 or more  	
interfaces. These tests assume that they run on the following topology.  

                      Control Link  
            +------------------------------------+  
            |                                    |  
    +-------+-------+                    +-------+-------+  
    |               +---- Test Link 0 ---+               |  
    |  Local Host   +          :         +  Remote Host  |  
    |               +---- Test Link n ---+               |  
    +---------------+                    +---------------+  								

For example,  
* Local host is M3 and remote host is Ubuntu16.04.  
* Control Link: eth0(192.168.10.64) on M3, enx004c00002787(192.168.10.11) on Ubuntu16.04.  
* Test Link 0: eth1(192.168.1.3) on M3, enx004c00002788(192.168.1.11) on Ubuntu16.04.  
* Test Link 1: eth2(192.168.2.3) on M3, enx004c00002789(192.168.2.11) on Ubuntu16.04.  
The above is just a example, eth0/eth1/enx004c00002787... maybe different in your machine.  
To set enx004c00002787/enx004c00002788/enx004c00002789 static IPv4 if possible.  
														
1.2 Environment Setting:								
Settings on M3 which can be written to file saved(environment-ltp-network) on M3.			
Execute command "source environment-ltp-network" before test start.	
							
The following setting should be modified to adapt your test environment.		
 export RHOST=192.168.10.11			              # IP of Control Link on Ubuntu.(Our test server IP)
 export PASSWD=  
 export LHOST_HWADDRS="00:05:1b:a4:5b:7c 00:0e:c6:c5:c0:b4"   # HWaddr of Test Link 0/1 on M3.  
 export RHOST_HWADDRS="00:4c:00:00:27:88 00:0e:c6:c5:b2:fe"   # HWaddr of Test Link 0/1 on Ubuntu.  
 export LHOST_IFACES="eth1 eth2" 		              # Interface of Test Link 0/1 on M3.  
 export RHOST_IFACES="enx004c00002788 enx000ec6c5b2fe"        # Interface of Test Link 0/1 on Ubuntu.  				
 export LTP_RSH=ssh  
Apply those environment before test start(You can add those to the target board config)						
								
2. Software:  
This is about the sofrware environment configuration on Server/Client. 
								
2.1 Server Software Environment:  
1) First, there MUST be another test machine setup to act as the server  
   to these client side tests.  This machine MUST have the LTP installed  	
   in the same exact location, LTP_PATH:/home/extend/target_bin/.  Make  	
   sure to compile the LTP on this server machine also. 
					
   Package(automake/autoconf/m4-1.4.7) should be installed first.  
   Commands:[On VM]  
   $ apt-get install automake  
   $ apt-get install autoconf  
							
   Make sure package(libtirpc) have installed before compile.(* Important)  
   $ apt-get install libtirpc-dev  
								
   Download and install the LTP:(if no git installed, do "apt-get install git" first)  
   $ mkdir /home/extend/  
   $ cd /home/extend/  
   $ git clone https://github.com/linux-test-project/ltp.git  	
   $ cd ./ltp  
   $ make autotools  
   $ ./configure --prefix=$SETTING_PATH/target_bin/  
   # $SETTING_PATH should be same with the variable "$JTA_HOME/jta.LTP" your target board config
   $ make  
   $ make install		
						
   Next, some service should be installed on Ubuntu16.04.  	
	
   Some Packages should be installed first.  
   $ apt-get install nfs-kernel-server 
   $ apt-get install telnetd cfingerd rdist rsync
   $ apt-get install udhcpd lightttpd xinetd rpcbind rstatd
							
2) Second, the server must be setup to allow the client to connect using		
   the "r" commands, such as rsh/ssh without password.			
								
   commands: [executed on M3]						
   $ ssh-keygen -t rsa						
   $ scp ~/.ssh/id_rsa.pub  username@server-ip:/root/.ssh/authorized_keys		
      * username@server-ip : E.G. root@192.168.10.11	
   $ ssh 192.168.10.11 ls							
      * The filename on ubuntu16.04(/home/root) listed on console and 	
      * no password needed.	
       $ echo "192.168.10.11 $HOSTNAME-SERVER" >> /etc/hosts
       # $HOSTNAME is the hostname of server(here should be "ubuntu-Virtural-box" in this example)			
							
   Add /home/extend/target_bin/testcase/bin to $PATH:			
   commands: [Execute on Ubuntu16.04]				
   $ echo "/home/extend/target_bin/testcase/bin" > /etc/profile
       $ echo "192.168.10.11 $HOSTNAME-SERVER" >> /etc/hosts
       # $HOSTNAME is the hostname of client(here should be "m3ulcb" in this example)
       $ echo "m3ulcb root" > /root/.rhosts
       $ sudo vi /etc/ssh//sshd_config
       # change "PermitRootLogin prohibit-password" to "PermitRootLogin yes", 
       # which will allow remote terminal login via ssh with user "root".
       $ sudo systemctl restart sshd
								
2.2 Client Software Environment:						
The client service is a bit difficult to install/start.		
1) lighttpd: install httpd-server on client. 			
2) rpcbind/portmap/nfs: install the rpc/nfs-service on client.	
3) ftp/vsftpd: install the ftp client and server on client.	
   … … (Refer to page:"Introduction of Tests, you'll know which packages should be installed)							

    Start the services before test start,[executed on M3]		
      $ systemctl start rpcbind
      $ systemctl start crond
      $ systemctl start vsftpd
      $ systemctl start lighttpd
      $ systemctl start xinetd

      $ touch /var/log/messages
      $ echo 'OPTIONS="-O /var/log/messages"' >> /etc/default/busybox-syslog
      $ systemctl restart syslog
				
3. Test Sample to check if LTP installed successful on the server: [executed on Server]					
$ cd /home/extend/target_bin	
$ ./runltp -f math

4. How to login and set IP automatically on M3		
Background:						
It'll be convenient if users can login and set the IP automatically when the machine started each time.	
M3 now use systemd to initialize the system and launcher the necessary service/application.											
So, the work should be done under systemd.											
									
4.1. Set auto-login on M3.											
  1) Goto the folder named "/etc/systemd/system/getty.target.wants/"											
      root@m3ulcb:/# cd /etc/systemd/system/getty.target.wants/
      root@m3ulcb:/etc/systemd/system/getty.target.wants/# ls
      getty@tty1.service  serial-getty@ttySC0.service"													
											
  2) Modify the file "serial-getty@ttySC0.service"											
      root@m3ulcb:/etc/systemd/system/getty.target.wants/# vi ./serial-getty@ttySC0.service										
      # Add "-a root" in line24, as follows,										
      Before: 										
        Environment="TERM=xterm"										
        ExecStart=-/sbin/agetty -8 -L %I 115200 $TERM										
	Type=idle										
      After:   										
	Environment="TERM=xterm"										
	ExecStart=-/sbin/agetty -8 -L -a root %I 115200 $TERM										
	Type=idle
									
  3) Now, you can restart your M3. 											
     You'll find the M3 can login automatically. In other word, it's no need to type "root" manually 
     if you're using serial console.											
											
4.2. Set auto-IP on M3.											
  1) First, we should write an script(named "ipsetting.sh" as follows) to set IP on M3.											
      root@m3ulcb:/# cat /bin/ipsetting.sh
      #!/bin/sh
	
      sleep 5
      ifconfig eth0 192.168.10.6
      root@m3ulcb:/# ls -l /bin/ipsetting.sh
      -rwxrwxrwx. 1 root root 46 Jan 19 04:18 /bin/ipsetting.sh"										
							
      Note: For "ifconfig eth0 192.168.10.6" in this script, "eth0" and "192.168.10.6" should be your own
	    expected value here.										
	    In roder to check if the script can works well, now, you can run "ipsetting.sh" manually, 
	    then check the IP.										
  2) Then, write a service(named "ipsetting.service" as follows) which should be executed automatically 
     when the system started.											
      root@m3ulcb:/# cat /lib/systemd/system/ipsetting.service
      [Unit]
      Description=IP Setting
      After=network.target
	
      [Service]
      ExecStart=/bin/ipsetting.sh
	
      [Install]
      WantedBy=multi-user.target
      root@m3ulcb:/# systemctl enable /lib/systemd/system/ipsetting.service
      Created symlink from /etc/systemd/system/multi-user.target.wants/ipsetting.service to 
      /lib/systemd/system/ipsetting.service
      root@m3ulcb:/# ls /etc/systemd/system/multi-user.target.wants/
      afm-system-daemon.service  busybox-klogd.service  crond.service         ipsetting.service       
      rc.pvr.service   vsftpd.service     audiomanger.service busybox-syslog.service cynara.service
      ofono.service    remote-fs.service  weston.service avahi-daemon.service connman.service  
      dnsmaso.service  splash-quit.service  tcf-agent.service"										
								
  3) Now, you can restart your M3. 											
     You'll find the M3 can set the IP automatically. In other word, it's no need to set IP manually each time
     the M3 restarted.												
Clone this wiki locally