check_ppg.sh
上传用户:gzpyjq
上传日期:2013-01-31
资源大小:1852k
文件大小:13k
源码类别:

手机WAP编程

开发平台:

WINDOWS

  1. #!/bin/sh
  2. #
  3. # Use 'test/test_ppg' and 'test/test_http_server' to test PPG. It presumes
  4. # using of http smsc.
  5. #
  6. # Note: Running this script can take quite a long time, if your input does have
  7. # many files. Two (ok ip and sms control document) should be quite enough for 
  8. # a general make check. Use more only if you are interested of detailed test-
  9. # ing of ppg.
  10. set -e
  11. #set -x
  12. list_port=8082
  13. server_port=8081
  14. push_port=8080
  15. loglevel=0
  16. username="foo"
  17. password="bar"
  18. prefix="test"
  19. contents="sl" 
  20. # Kannel configuration file
  21. conf_file="gw/pushkannel.conf"
  22. # Push content. Use only sl, because compilers should be tested separately
  23. content_file="$prefix/sl.txt"
  24. # Ok ip control files
  25. ip_control_files="$prefix/*iptest*"
  26. # Ok sms control files
  27. sms_control_files="$prefix/*smstest*"
  28. # Erroneous ip control files
  29. wrong_ip_files="$prefix/*witest*"
  30. # Erroneous sms control files
  31. wrong_sms_files="$prefix/*wstest*"
  32. # File containing the blacklist
  33. blacklist="$prefix/blacklist.txt"
  34. # File containing the whitelist
  35. whitelist="$prefix/whitelist.txt"
  36. test/test_http_server -p $list_port -w $whitelist -b $blacklist > check_http_list.log 2>&1 & listid=$
  37. error=no
  38. # ok control files requesting an ip bearer. Names contain string 'ip'. Bearer-
  39. # box should not use smsc (do a http fetch) when ip bearer is requested.
  40. for control_file in $ip_control_files;
  41.     do 
  42.         if [ -e $control_file ]
  43.         then
  44.             gw/bearerbox -v $loglevel $conf_file > check_bb.tmp 2>&1 & bbpid=$!
  45.             sleep 2 
  46.             gw/wapbox -v $loglevel $conf_file > check_wap.tmp 2>&1 & wappid=$!
  47.             sleep 2
  48.             test/test_ppg -c $contents http://localhost:$push_port/cgi-bin/wap-push.cgi?username=$username'&'password=$password $content_file $control_file > check_ppg.tmp 2>&1 
  49.             sleep 1
  50.             if ! grep "and type push response" check_ppg.tmp > /dev/null
  51.             then
  52.                 cat check_ppg.tmp >> check_ppg.log 2>&1
  53.                 error=yes
  54.                 echo "ppg failed with control file $control_file"
  55.             fi
  56.             if ! grep "Connectionless push accepted" check_wap.tmp > /dev/null
  57.             then
  58.                 cat check_wap.tmp >> check_wap.log 2>&1
  59.                 error="yes"
  60.                 echo "wap failed with control file $control_file"
  61.             fi
  62.         
  63.             if ! grep "got wdp from wapbox" check_bb.tmp > /dev/null
  64.             then
  65.                 cat check_bb.tmp >> check_bb.log 2>&1
  66.                 error=yes
  67.                 echo "bb failed with control file $control_file"
  68.             fi
  69.             kill -INT $wappid
  70.             sleep 2
  71.             kill -INT $bbpid
  72.             sleep 2
  73. # We can panic when we are going down, too
  74.             if [ $error != yes ]
  75.             then
  76.                 if grep 'WARNING:|ERROR:|PANIC:' check_bb.tmp > /dev/null
  77.                 then
  78.                     cat check_bb.tmp >> check_bb.log 2>&1
  79.                     error="yes"
  80.                     echo "got errors in bb when going down when $control_file"
  81.                 fi
  82.                 if grep 'WARNING:|ERROR:|PANIC:' check_wap.tmp > /dev/null
  83.                 then
  84.                     cat check_wap.tmp >> check_wap.log 2>&1
  85.                     error="yes"
  86.                     echo "got errors in wap when going down when $control_file"
  87.                 fi 
  88.                 if grep 'WARNING:|ERROR:|PANIC:' check_ppg.tmp > /dev/null
  89.                 then
  90.                     cat check_ppg.tmp >> check_ppg.log 2>&1
  91.                     error="yes"
  92.                     echo "got errors in ppg when going down when $control_file"
  93.                 fi 
  94.            fi
  95.          
  96.            rm -f check_bb.tmp check_wap.tmp check_ppg.tmp
  97.         fi;
  98.     done
  99. # Erroneous control files requesting an ip bearer. Ppg should reject these and
  100. # report pi. Names contain string 'wi'.
  101. for control_file in $wrong_ip_files;
  102.     do 
  103.         if [ -e $control_file ]
  104.         then
  105.             have_iperrors=yes
  106.             gw/bearerbox -v $loglevel $conf_file > check_bb.tmp 2>&1 & bbpid=$!
  107.             sleep 2 
  108.             gw/wapbox -v $loglevel $conf_file > check_wap.tmp 2>&1 & wappid=$!
  109.             sleep 2
  110.             test/test_ppg -c $contents http://localhost:$push_port/cgi-bin/wap-push.cgi?username=$username'&'password=$password $content_file $control_file > check_ppg.tmp 2>&1
  111.             sleep 1
  112.             if ! grep "and type push response" check_ppg.tmp > /dev/null &&
  113.                ! grep "and type bad message response" check_ppg.tmp > /dev/null
  114.             then
  115.                 cat check_ppg.tmp >> check_ppg.log 2>&1
  116.                 error=yes
  117.                 echo "ppg failed when control file $control_file"
  118.             fi
  119.             if grep "Connectionless push accepted" check_wap.tmp > /dev/null &&
  120.                grep "WARNING" check_wap.tmp > /dev/null 
  121.             then
  122.                 cat check_wap.tmp >> check_wap.log 2>&1
  123.                 error="yes"
  124.                 echo "wap failed when control file $control_file"
  125.             fi
  126.         
  127.             if grep "got wdp from wapbox" check_bb.tmp > /dev/null
  128.             then
  129.                 cat check_bb.tmp >> check_bb.log 2>&1
  130.                 error=yes
  131.                 echo "bb failed when control file $control_file"
  132.             fi
  133.             kill -INT $wappid
  134.             sleep 2
  135.             kill -INT $bbpid
  136.             sleep 2
  137. # We can panic when we are going down, too
  138.             if [ $error != yes ]
  139.             then
  140.                 if grep 'ERROR:|PANIC:' check_bb.tmp > /dev/null
  141.                 then
  142.                     cat check_bb.tmp >> check_bb.log 2>&1
  143.                     error="yes"
  144.                     echo "got errors in bb when going down with $control_file"
  145.                 fi
  146.                 if grep 'ERROR:|PANIC:' check_wap.tmp > /dev/null
  147.                 then
  148.                     cat check_wap.tmp >> check_wap.log 2>&1
  149.                     error="yes"
  150.                     echo "got errors in wap when going down with $control_file"
  151.                 fi 
  152.                 if grep 'ERROR:|PANIC:' check_ppg.tmp > /dev/null
  153.                 then
  154.                     cat check_ppg.tmp >> check_ppg.log 2>&1
  155.                     error="yes"
  156.                     echo "got errors in ppg when going down with $control_file"
  157.                 fi 
  158.            fi
  159.          
  160.            rm -f check_bb.tmp check_wap.tmp check_ppg.tmp
  161.         fi;
  162.     done
  163. # Ok control files requesting a sms bearer. Names contain string 'sms'. Ppg
  164. # should use smsc (do a http fetch).
  165. for control_file in $sms_control_files;
  166.     do 
  167.         if [ -e $control_file ]
  168.         then
  169.             test/test_http_server -p $server_port > check_http_sim.tmp 2>&1 & simid=$
  170.             sleep 1
  171.             gw/bearerbox -v $loglevel $conf_file > check_bb.tmp 2>&1 & bbpid=$!
  172.             sleep 2 
  173.             gw/wapbox -v $loglevel $conf_file > check_wap.tmp 2>&1 & wappid=$!
  174.             sleep 2
  175.             test/test_ppg -c $contents http://localhost:$push_port/cgi-bin/wap-push.cgi?username=$username'&'password=$password $content_file $control_file > check_ppg.tmp 2>&1 
  176.             sleep 1
  177.             if ! grep "and type push response" check_ppg.tmp > /dev/null
  178.             then
  179.                 cat check_ppg.tmp >> check_ppg.log 2>&1
  180.                 error=yes
  181.                 echo "ppg failed with control file $control_file"
  182.             fi
  183.             if ! grep "Connectionless push accepted" check_wap.tmp > /dev/null
  184.             then
  185.                 cat check_wap.tmp >> check_wap.log 2>&1
  186.                 error="yes"
  187.                 echo "wap failed with control file $control_file"
  188.             fi
  189.         
  190.             if ! grep "got sms from wapbox" check_bb.tmp > /dev/null
  191.             then
  192.                 cat check_bb.tmp >> check_bb.log 2>&1
  193.                 error=yes
  194.                 echo "bb failed with control file $control_file"
  195.             fi
  196.            
  197.             kill -INT $wappid
  198.             kill -INT $bbpid
  199.             sleep 2
  200.             test/test_http -qv 4 http://localhost:$server_port/quit
  201.             sleep 1
  202. # We can panic when we are going down, too
  203.             if [ $error != yes ] 
  204.             then
  205.                 if grep 'WARNING:|ERROR:|PANIC:' check_bb.tmp > /dev/null
  206.                 then
  207.                     cat check_bb.tmp >> check_bb.log 2>&1
  208.                     error="yes"
  209.                     echo "got errors in bb when going down with $control_file"
  210.                 fi 
  211.                 if grep 'WARNING:|ERROR:|PANIC:' check_wap.tmp > /dev/null
  212.                 then
  213.                     cat check_wap.tmp >> check_wap.log 2>&1
  214.                     error="yes"
  215.                     echo "got errors in wap when going down with $control_file"
  216.                 fi 
  217.                 if grep 'WARNING:|ERROR:|PANIC:' check_ppg.tmp > /dev/null
  218.                 then
  219.                     cat check_ppg.tmp >> check_ppg.log 2>&1
  220.                     error="yes"
  221.                     echo "got errors in ppg when going down with $control_file"
  222.                 fi
  223.                 if grep 'WARNING:|ERROR:|PANIC:' check_http_sim.tmp > /dev/null
  224.                 then
  225.                     cat check_sim.tmp >> check_sim.log 2>&1
  226.                     error="yes"
  227.                     echo "errors, http_sim when going down with $control_file"
  228.                 fi 
  229.             fi
  230.          
  231.             rm -f check_bb.tmp check_wap.tmp check_ppg.tmp check_http_sim.tmp
  232.         fi;
  233.     done
  234. # Erroneous control documents requesting a sms bearer. Ppg should reject these
  235. # and inform pi. Names contain the string 'ws'.
  236. for control_file in $wrong_sms_files;
  237.     do 
  238.         if [ -e $control_file ]
  239.         then
  240.             test/test_http_server -p $server_port > check_http_sim.tmp 2>&1 & simid=$
  241.             sleep 1
  242.             gw/bearerbox -v $loglevel $conf_file > check_bb.tmp 2>&1 & bbpid=$!
  243.             sleep 2 
  244.             gw/wapbox -v $loglevel $conf_file > check_wap.tmp 2>&1 & wappid=$!
  245.             sleep 2
  246.             test/test_ppg -c $contents http://localhost:$push_port/cgi-bin/wap-push.cgi?username=$username'&'password=$password $content_file $control_file > check_ppg.tmp 2>&1
  247.             sleep 1
  248.             if ! grep "and type push response" check_ppg.tmp > /dev/null &&
  249.                ! grep "and type bad message response" check_ppg.tmp > /dev/null
  250.             then
  251.                 cat check_ppg.tmp >> check_ppg.log 2>&1
  252.                 error=yes
  253.                 echo "ppg failed, going down with control file $control_file"
  254.             fi
  255.             if grep "Connectionless push accepted" check_wap.tmp > /dev/null &&
  256.                grep "WARNING" check_wap.tmp > /dev/null 
  257.             then
  258.                 cat check_wap.tmp >> check_wap.log 2>&1
  259.                 error="yes"
  260.                 echo "wap failed, going down with control file $control_file"
  261.             fi
  262.         
  263.             if grep "got sms from wapbox" check_bb.tmp > /dev/null
  264.             then
  265.                 cat check_bb.tmp >> check_bb.log 2>&1
  266.                 error=yes
  267.                 echo "bb failed, going down with control file $control_file"
  268.             fi
  269.             kill -INT $wappid
  270.             sleep 2
  271.             kill -INT $bbpid
  272.             sleep 2
  273.             test/test_http -qv 4 http://localhost:$server_port/quit
  274.             sleep 1
  275. # We can panic when we are going down, too
  276.             if [ $error != yes ]
  277.             then
  278.                 if grep 'ERROR:|PANIC:' check_bb.tmp > /dev/null
  279.                 then
  280.                     cat check_bb.tmp >> check_bb.log 2>&1
  281.                     error="yes"
  282.                     echo "got errors in bb when ending tests"
  283.                 fi
  284.                 if grep 'ERROR:|PANIC:' check_wap.tmp > /dev/null
  285.                 then
  286.                     cat check_wap.tmp >> check_wap.log 2>&1
  287.                     error="yes"
  288.                     echo "got errors in wap when ending tests"
  289.                 fi 
  290.                 if grep 'ERROR:|PANIC:' check_ppg.tmp > /dev/null
  291.                 then
  292.                     cat check_ppg.tmp >> check_ppg.log 2>&1
  293.                     error="yes"
  294.                     echo "got errors in ppg when ending tests"
  295.                 fi 
  296.                 if grep 'ERROR:|PANIC:' check_http_sim.tmp > /dev/null
  297.                 then
  298.                     cat check_http_sim.tmp >> check_http_sim.log 2>&1
  299.                     error=yes
  300.                     echo "got errors in http_sim when ending tests"
  301.                 fi
  302.             fi
  303.          
  304.             rm -f check_bb.tmp check_wap.tmp check_ppg.tmp
  305.         fi;
  306. done
  307. test/test_http -qv 4 http://localhost:$list_port/quit
  308. wait
  309. if [ $error == yes ]
  310. then
  311.         echo "check_ppg failed" 1>&2
  312. echo "See check_bb.log, check_wap.log, check_ppg.log," 1>&2
  313. echo "check_http_list.log, check_http_sim.log for info" 1>&2
  314. exit 1 
  315. fi
  316. rm -f check_bb.log check_wap.log check_ppg.log check_http_list.log check_http_sim.log
  317. exit 0