TestHost on MP02
The SECN TestHost firmware is designed to support automated testing of SECN devices. The system uses a TestHost device and a Device Under Test (DUT).
The TestHost device periodically queries the DUT via HTTP in order to execute a test script on the DUT to collect test data which is returned to the Host.
The Host then adds further data such as time and date, and updates a test log file which can be accessed via the HTTP server on the TestHost.
The DUT can be running any firmware that supports a http server, and requires only the addition of two files - a CGI script and a Shell script - so that the operation of the installed firmware is not significantly altered by the testing.
Test Host Basic Operation
1. To run a test session, the TestHost device runs a shell script '/bin/testhost.sh' with arguments for the IP address of the DUT, and the number of minutes for which the test is to be run e.g.
# /bin/testhost.sh 10.130.1.20 60
This command will cause the script to look for a DUT at '10.130.1.20' and then run the tests for 60 minutes.
The script loops each minute, sending a 'wget' HTTP request to the DUT at the URL 'http://<DUT_IP_Address>:/cgi-bin/test.html'
Note: If the IP address is specified as 127.0.0.1 then the test will be run on the TestHost device itself.
2. The CGI script on the DUT calls a shell script '/bin/testscript.sh' which runs whatever tests are required on the DUT and assembles the test results into a string which is returned to the TestHost as the response to the 'wget' request.
Typical tests run on the DUT might include a ping test to a specific network address to check connectivity, CPU performance, and signal strength measurement. If the device is equipped with sensors then the sensor data might also be collected.
The 'testscript.sh' file can be easily edited to include whatever tests are required.
3. The 'testhost.sh' script on the TestHost device receives the response to the 'wget' request containing the test data from the DUT, and then runs further tests locally. These tests might include getting a time/date stamp for the log entry, signal strength measurements, ping tests or getting sensor data such as temperature.
The 'testhost.sh' file can be easily edited to include whatever tests are required.
The results of these tests are then added to the results from the DUT and used to create a new entry in the test log file '/tmp/testlog.txt'. This file is linked to 'www.testlog.txt' so that a browser pointed to the URL
will show the current contents of the test log.
1. TestHost Firmware
SECN TestHost firmware built specifically for the MP02 device is identified as 'MP02-TH' and is available on the VillageTelco Downloads page.
The SECN TestHost firmware may be installed in the normal manner, and the device will appear on the IP address '10.130.1.1'
The Ethernet WAN port is active, and the mesh interface is running, so the DUT can mesh with the TestHost and access the upstream network. A DUT running default SECN configuration will have a LAN Gateway IP address pointing to '10.130.1.1' and so will be able to use the TestHost as a gateway.
2. DUT Scripts
The two scripts for the DUT are available as a patch 'DUT-patch.tar.gz' which may be uploaded and installed using the Patch facility on the SECN Firmware Upgrade page.
Alternatively the two script files may be installed manually on the DUT in the appropriate directories. These files both require execute permissions.
1. TestHost Script
#! /bin/sh # /bin/testhost.sh Script to run on TestHost device # Setup DUT IP address and time to run DUT=$1 MAXMINS=$2 # Check for the DUT if !(ping -c 1 $DUT &> /dev/null) then echo "" echo "Unable to ping DUT IP address" echo "" exit fi # Set up www link to testlog file touch /tmp/testlog.txt if [ ! -e /www/testlog.txt ]; then ln -s /tmp/testlog.txt /www/testlog.txt fi # Initialise the testlog file DATE=$(date) echo "Log start: $DATE " > /tmp/testlog.txt echo "DUT: $DUT Duration: $MAXMINS mins" >> /tmp/testlog.txt echo "" >> /tmp/testlog.txt echo "" echo "Log start: $DATE " echo "DUT: $DUT Duration: $MAXMINS mins" echo "" # Start test run SEC=$(date +"%S") mins=0 while [ $mins -le $MAXMINS ] do SEC=$(date +"%S") # Run on the minute if [ $SEC == "00" ]; then # Increment the minutes counter mins=$(( mins+1 )) # Run tests on DUT and get results string TESTSTR=$(wget -q -O - http://$DUT/cgi-bin/test.html) # Get local test data TEMP=$(/bin/gettemp.sh) DATE=$(date +"20%y-%m-%d %H:%M:%S") RSSI=$(iw dev wlan0-1 station dump | grep "signal avg:"|cut -f 3|cut -d " " -f1,3) # Save to test log file echo "$DATE Temp: "$TEMP"C RSSI: $RSSI $TESTSTR" >> /tmp/testlog.txt echo "$DATE Temp: "$TEMP"C RSSI: $RSSI $TESTSTR" sleep 50 fi sleep 1 done echo "Test run completed" >> /tmp/testlog.txt echo "" echo "Test run completed" echo "" exit
2. DUT Test Script
!# /bin/sh # /bin/testscript.sh Script to run on DUT # Run tests # Test 1. Ping Internet address if ping -c 1 184.108.40.206 &> /dev/null then PING1="OK" else PING1="FAIL" fi # Test 2. Get CPU usage CPU=$(uptime|cut -d "," -f2|cut -d ":" -f 2) # Output the test results string echo "Ping: $PING1 CPU: $CPU " exit
DUT CGI Script
#!/bin/sh # /www/cgi-bin/test.html # For compatibility with uhttpd echo -en "Content-type: text/html\r\n\r\n" # Call main test script /bin/testscript.sh