Hi

Here is my patch for improved versions of xeno-info/load/config/test
as well as a Ruby test script for the maintainers.

The modified scripts pass the test for most options to xeno-test. The only 
exception is "-v" for verbose. As I have no clue how/what this option should 
do I left it as is.

The modifications are:
- busybox supported
- The load jobs (dd) are killed correctly
- two new lines for my buildbot "xeno-test started" and "xeno-test finished"
- the options -m / -L are no more silent, but echo also on the standard out.
  If the old behaviour is preferred, it would be simple to restore it. But
  the actual behaviour is easier to debug and fits better into the buildbot
  logs.

The tests under the busybox are not as good as with a normal shell, but work 
good enough with my buildbot. I will try to integrate them later into the 
Ruby test script.

Attached are also all log files of my testruns, if you want to verify that 
everything work as expected. A manual inspection of all logfiles did not 
reveal anymore hidden bugs to me (after quite a few runs to improve my test 
cases -).

After generating all logs, the testscript resumed the results like this:
> Thu Jun 22 23:31:34 CEST 2006: 14 PASSED:   0 seconds. opts <-M
> [EMAIL PROTECTED] -xxxx > returned 0 Writing tst to
> /mnt/data.ng/hcu/kernel/xenomai-head/scripts/test/logs/xeno-test.store Thu
> Jun 22 23:31:34 CEST 2006:  9 PASSED: -N marker:
> ["markertest-2.6.14-1252M-ppc-060622.232920"] Thu Jun 22 23:31:34 CEST
> 2006:  8 PASSED: -L: ["/tmp/test-2.6.14-1252M-ppc-060622.232417",
> "/tmp/test-2.6.14-1252M-ppc-060622.232452",
<..>
> "/tmp/test-2.6.14-1252M-ppc-2006-marker-06-marker",
> "/tmp/test-2.6.14-1252M-ppc-060622.233100"] running all Checks
> CHK 10 FAILED opts -v could not find xeno-test: finished
>   searched in
> /mnt/data.ng/hcu/kernel/xenomai-head/scripts/test/logs/test_xeno_test.log.1
>0 CHK 10 FAILED, could not find xeno-test: finished in
> /mnt/data.ng/hcu/kernel/xenomai-head/scripts/test/logs/test_xeno_test.log.1
>0 completed all Checks

Unless you spot any error in my tests, I will not improve my scripts nor the 
xeno-test scripts in the near future. Also I would appreciate go know whether 
the error is already present in the current version of xeno-test.

As rc3 is still not out, I do not see any reason not to check in this patch.
But I would like to see this happen soon, as I will not be able to fix errors 
after next Wednesday.

Best regards

-- 
Niklaus Giger
Index: scripts/xeno-config.in
===================================================================
--- scripts/xeno-config.in	(Revision 1254)
+++ scripts/xeno-config.in	(Arbeitskopie)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 
 staging=${DESTDIR}
 prefix="@prefix@"
Index: scripts/xeno-info
===================================================================
--- scripts/xeno-info	(Revision 1254)
+++ scripts/xeno-info	(Arbeitskopie)
@@ -1,31 +1,46 @@
-#!/bin/sh
+#! /bin/sh
 #
 # This file has been lifted 'as is' from linux/scripts/ver_linux.
-#
+# Adapted to be run also under the BusyBox. If you want to test it under the BusyBox use
+# busybox sh xeno-info 
 
 PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:$PATH
 echo 'If some fields are empty or look unusual you may have an old version.'
 echo 'Compare to the current minimal requirements in Documentation/Changes.'
 echo ' '
 
+withBusybox=0
+if sh --help 2>&1| grep -q BusyBox; then
+    withBusybox=1;
+# else running a real /bin/sh (bash) shell
+fi
+
+if test $withBusybox -eq 1; then busybox | grep -i "BusyBox v" ; fi
+
 uname -a
 echo ' '
 
+if test -n "`which gcc`" ; then
 gcc --version 2>&1| head -n 1 | grep -v gcc | awk \
 'NR==1{print "Gnu C                 ", $1}'
 
 gcc --version 2>&1| grep gcc | awk \
 'NR==1{print "Gnu C                 ", $3}'
+fi
 
+if test -n "`which gcc`" ; then
 make --version 2>&1 | awk -F, '{print $1}' | awk \
       '/GNU Make/{print "Gnu make              ",$NF}'
+fi
 
 ld -v 2>&1 | awk -F\) '{print $1}' | awk \
       '/BFD/{print "binutils              ",$NF}'
 
+if test 0 -eq $withBusybox ; then 
 fdformat --version | awk -F\- '{print "util-linux            ", $NF}'
 
 mount --version | awk -F\- '{print "mount                 ", $NF}'
+fi 
 
 depmod -V  2>&1 | awk 'NR==1 {print "module-init-tools     ",$NF}'
 
@@ -50,21 +65,26 @@
 isdnctrl 2>&1 | grep version | awk \
 'NR==1{print "isdn4k-utils          ", $NF}'
 
+if test -n "`which ldd`" ; then
 ls -l `ldd /bin/sh | awk '/libc/{print $3}'` | sed \
 -e 's/\.so$//' | awk -F'[.-]'   '{print "Linux C Library        " \
 $(NF-2)"."$(NF-1)"."$NF}'
 
 ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n1 | awk \
 'NR==1{print "Dynamic linker (ldd)  ", $NF}'
+fi
 
 ls -l /usr/lib/lib{g,stdc}++.so  2>/dev/null | awk -F. \
        '{print "Linux C++ Library      " $4"."$5"."$6}'
 
+if test 0 -eq $withBusybox ; then 
 ps --version 2>&1 | awk 'NR==1{print "Procps                ", $NF}'
+fi 
 
 ifconfig --version 2>&1 | grep tools | awk \
 'NR==1{print "Net-tools             ", $NF}'
 
+if test 0 -eq $withBusybox ; then 
 # Kbd needs 'loadkeys -h',
 loadkeys -h 2>&1 | awk \
 '(NR==1 && ($3 !~ /option/)) {print "Kbd                   ", $3}'
@@ -74,6 +94,7 @@
 '(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools         ", $3}'
 
 expr --v 2>&1 | awk 'NR==1{print "Sh-utils              ", $NF}'
+fi 
 
 if [ -e /proc/modules ]; then
     X=`cat /proc/modules | sed -e "s/ .*$//"`
Index: scripts/maint/test-xeno-test.rb
===================================================================
--- scripts/maint/test-xeno-test.rb	(Revision 0)
+++ scripts/maint/test-xeno-test.rb	(Revision 0)
@@ -0,0 +1,301 @@
+#!/usr/bin/env ruby
+
+# Funning xeno-test once with each option takes a long time (around 15 minutes)
+# For each test a full log is stored in the logs subdirectory.
+# Therefore the results of the tests (the ruby variable) is stored using Pstore in
+# the file logs/xeno-test.store.
+# If this file exists and is newer than xeno-test and the first parameter is != clean
+# The tst variable is fetched from the file.
+# This is convenient if you want to add new checks.
+#
+# Todo: - Why do the mailing tests not work  ?
+#       - How does xeno-test react to Ctrl-C ?
+#       - Thorougher analyses of the log files
+#
+require 'timeout'
+require 'ostruct'
+require 'ftools'
+require 'pstore'
+require 'tempfile'
+
+XenoInstall = "/usr/xenomai/bin"
+XenoHead    = File.expand_path(File.dirname(File.dirname(__FILE__)))
+XenoTestOrg = XenoHead+'/xeno-test.in'
+XenoTestRun = XenoInstall+'/xeno-test'
+LogDir      = XenoHead+'/logs'
+MainLog     = LogDir+'/runtest.log'
+StorageName = LogDir+'/xeno-test.store'
+withFinished = `grep finished /usr/xenomai/bin/xeno*`
+withFinished.size > 0 ? FinishedMsg = "xeno-test: finished" : FinishedMsg = nil
+
+$clean  = ARGV[0] == 'clean' && ! (
+	  File.exists?(XenoTestRun) &&
+          File.exists?(StorageName) &&
+          File.stat(XenoTestRun).mtime >  File.stat(StorageName).mtime
+          )
+if $clean && File.exists?(StorageName) then
+  puts "Do you really want to run all tesst? <Ctrl-C> to abort"
+  STDIN.getc
+end
+
+class XenoTest
+  attr_reader :mainLog
+  attr_reader :blockDevice
+  attr_writer :maxTimeout
+  attr_writer :chkProc
+
+  def initialize(options)
+    @from    = XenoHead
+    @inst    = XenoInstall
+    @busybox = false
+    File.makedirs(LogDir) if defined?(LogDir) && ! File.directory?(LogDir)
+    @@mainLog = open(MainLog,"w");
+    @@mainLog.puts("#{Time.now}: started run")
+    @@mainLog.sync = true
+    options.each { |name,val|
+      if val.class == String then
+        cmd =  "@#{name}='#{val}'"
+      else
+	cmd =  "@#{name}=#{val}"
+      end
+      eval cmd
+    }
+  end
+
+  def add(opts,  chkProc=nil)
+    @nr   = -1        if !defined?(@nr)
+    @tsts = Array.new if !defined?(@tsts)
+    @nr  += 1
+    elem = OpenStruct.new({'nr' => @nr, 'opts'=>opts})
+    elem.chkProc = chkProc if chkProc
+    @tsts << elem
+    return elem
+  end
+
+  def runTests
+    @tsts.each { |x| runOneTest(x) ; }
+  end
+
+  def XenoTest::writeLogEntry(tst, logMsg)
+    msg = "#{Time.now}: #{sprintf("%2d", tst.nr)} "+ logMsg
+    if ! File.exists?(MainLog) then
+      puts msg
+    end
+    outs = [ STDOUT]
+    outs << @@mainLog if defined?(@@mainLog) && @@mainLog
+    outs.each {|dev| dev.puts msg }
+  end
+
+  def runOneTest(x)
+    puts "runOneTest #{x.inspect}"  if $VERBOSE
+    opts = x.opts
+    startTime = Time.now
+    tstRes = nil
+    x.tst  = `which xeno-test`.chomp
+    x.log  = "#{LogDir}/test_xeno_test.log.#{x.nr}"
+    x.cmd  = "#{x.tst} -T 1 #{x.opts} | tee #{x.log}"   # -T 1 to make the test time shorter
+
+    # Start thread to enfore maxTimeout
+    if @maxTimeout then
+      @rThread = Thread.new{
+	    puts "@rThread: "+Process.pid.to_s if $VERBOSE
+	    writeLogEntry(x, "started: #{opts} Timeout [EMAIL PROTECTED]")
+	    sleep(@maxTimeout);
+	    writeLogEntry(x, "rThread will kill #{$childPid.inspect}")
+	    system("kill -9 #{$childPid}") if $childPid
+	    raise Timeout::Error 
+      }
+    end
+    # Now we are doing calling our script
+    $childPid = nil
+    Dir.chdir(@inst)
+    res = IO.popen(x.cmd) { |f|
+      puts "cmd: "+Process.pid.to_s if $VERBOSE
+      $childPid = Process.pid
+      f.each{|a| puts a}
+    } 
+    tstRes = $?
+  rescue Timeout::Error => details
+    puts detail.backtrace.join("\n")
+    writeLogEntry(x, "FAILED: #{opts} Timeout error #{$childPid}")
+    system("kill -9 #{$childPid}")
+  rescue => details
+    writeLogEntry(x, "FAILED: #{opts} runtime error [EMAIL PROTECTED] pid #{$childPid.inspect}")
+    puts details.backtrace.join("\n")
+    system("kill -9 #{$childPid}")
+    @rThread.kill if defined?(@rThread)
+  ensure
+    # save results,
+    # clean up dd process if there are any, if xeno-test did not clean it up as it should have
+    endTime = Time.now
+    duration = (endTime-startTime).round
+    if duration <= 5 then
+      str    =  "FAILED"
+      tstRes =  'too fast'
+    else
+      str = tstRes ? 'PASSED' : 'FAILED'
+    end
+    x.tstRes   = tstRes
+    x.duration = duration
+    XenoTest::writeLogEntry(x, "#{str}: #{sprintf("%3d", duration)} seconds. opts <#{x.opts}> returned #{tstRes}")
+
+    IO.popen("ps -ef | grep -w dd") { |f|
+      line= f.gets
+      if ! line.index('grep') then
+	msg = "#{Time.now}: #{sprintf("%2d", x.nr)} FAILED: dd not killed \n    >>> #{line}"
+	[ STDOUT, @@mainLog].each {|dev| dev.puts msg if dev}
+	system "killall dd"
+      end
+    }
+    @rThread.kill if @rThread
+    @rThread = nil
+  end
+
+  def runChecks
+    puts "running all Checks"
+    @tsts.each { |aTst|
+      checkFinished(aTst)
+      chks = aTst.chkProc
+      next if ! chks
+      z = eval "#{chks[0]}"+"(aTst, chks[1])" if chks[1]
+    }
+    puts "completed all Checks"
+  end
+
+  def checkFinished(tst)
+    return if ! FinishedMsg
+    logInhalt = IO.readlines(tst.log)
+    finished  = false
+    logInhalt.each{|line|
+      finished =  true if line.index(FinishedMsg)
+    }
+    if !finished then
+      puts "CHK #{tst.nr} FAILED opts #{tst.opts} could not find #{FinishedMsg}"
+      puts "  searched in #{tst.log}" 
+    end
+  end
+
+  def getTstByOpt(opts)
+    @tsts.each{ |aTst|
+      return aTst if aTst.opts == opts
+    }
+    return nil
+  end
+end
+
+# Here follow the various routines, that check the effect of each options
+def expectInLogFile(x, string)
+  puts "x #{x.inspect}\nlooking for #{string}" if $VERBOSE
+  logInhalt = IO.readlines(x.log)
+  found = false
+  logInhalt.each{|line|
+    found = true if line.index(string)
+  }
+  puts "CHK #{x.nr} FAILED, could not find #{string} in #{x.log}" if !found
+end
+
+# Get a name for a temporary file as a target to upload via curl (option -U)
+tf = Tempfile.new("xeno-test")
+TstUrlTarget = tf.path
+tf.close
+File.delete if File.exists?(TstUrlTarget)
+
+tst   = nil
+store = nil
+File.delete(StorageName) if $clean &&  File.exists?(StorageName)
+if File.exists?(StorageName) then
+  # Read in our saved test state (if we have a valid combination)
+  store = PStore.new(StorageName)
+  puts "reading tst from #{StorageName}"
+  store.transaction do
+    tst = store['tst']
+  end
+else
+  # we prepare to run our tests
+
+  # Get the first block-Device
+  blockDevices = `mount | cut -d\\  -f1 | egrep -ve 'sysfs|proc|depts'`
+  blockDevices = blockDevices[0..blockDevices.index("\n")].chomp
+  bDev = blockDevices
+
+  tst = XenoTest.new({'blockDevice' => bDev})
+  tst.maxTimeout = 120
+
+  # Define test run for each option and/or combination thereof
+  
+  # Test for a bad option. This happens to be fast, too
+  tst_0  = tst.add("-O",                [ 'expectInLogFile', "xeno-test [options]"])
+  tst_1  = tst.add("",                  [ 'expectInLogFile', FinishedMsg])
+  tst_2  = tst.add("-T 5")
+  if true then # To speed up our test,s we may turn off defining more testruns
+      tst_3  = tst.add("-p 200",        ['expectInLogFile',"Sampling period: 200 us"])
+      tst_4  = tst.add("-w 2",          ['expectInLogFile',FinishedMsg])
+      tst_5  = tst.add("-d #{bDev}",
+	  ['expectInLogFile',"creating workload using dd if=#{bDev}"])
+
+      tst_6  = tst.add("-w /bin/dd #{bDev}",
+					['expectInLogFile',FinishedMsg])
+      tst_7  = tst.add("-P 'echo marker'", 
+					['expectInLogFile',FinishedMsg])
+      tst_8  = tst.add("-L",            ['expectInLogFile',FinishedMsg])
+      tst_9  = tst.add("-N marker",     ['expectInLogFile',FinishedMsg])
+      tst_10 = tst.add("-v",            ['expectInLogFile',FinishedMsg])
+      tst_11 = tst.add("-U #{TstUrlTarget}",
+                                        ['expectInLogFile',FinishedMsg])
+      tst_12 = tst.add("-D '%Ymarker%Mmarker%D'", 
+                                        ['expectInLogFile',FinishedMsg])
+#      tst_13 = tst.add("-M #{ENV['USER'[EMAIL PROTECTED]", 
+#					['expectInLogFile',FinishedMsg])
+#      tst_14 = tst.add("-m",            ['expectInLogFile',FinishedMsg])
+  end
+
+  # Remove files, we might have left behind in a previous test
+  ( Dir.glob("/tmp/test-#{`uname -r`.chomp}*") + 
+    Dir.glob("#{XenoInstall}/marker*")).each { |file|
+    puts "Removing #{file}"
+    File.delete file
+  }
+  tst.runTests
+
+  # Now we are ready to store our testresult (our ruby variable) to file
+  puts "Writing tst to #{StorageName}"
+  store = PStore.new(StorageName)
+  store.transaction do
+    store['tst'] = tst
+  end
+end
+
+# If we did run the curl/-N, -L test, did it generate the expected file?
+{
+ "-U #{TstUrlTarget}" => TstUrlTarget,
+ "-L" => "/tmp/test-#{`uname -r`.chomp}*",
+ "-N marker" =>  "#{XenoInstall}/marker*",
+}.each { |opt, path|
+  myTst  = tst.getTstByOpt(opt)
+  if myTst && Dir.glob(path).size == 0  then
+    XenoTest::writeLogEntry(myTst, "FAILED: #{opt}: no file #{path} found")
+  else 
+    XenoTest::writeLogEntry(myTst, "PASSED: #{opt}: #{Dir.glob(path).inspect}")
+  end if myTst
+}
+
+# This string is probably wrong, but I think xeno-test doesn't accept this
+# string as it should neither
+myTst  = tst.getTstByOpt("-D '%Ymarker%Mmarker%D'")
+tstString = "-D #{Time.now.strftime('%Ymarker%Mmarker%D')}"
+tstString = "marker"
+expectInLogFile(myTst, tstString) if myTst
+
+# Test whether we really take more time with -T 5 than with the default -T 1
+long  = tst.getTstByOpt("-T 5")
+short = tst.getTstByOpt("")
+if long and short then
+  if long.duration < short.duration + 5
+  then
+    XenoTest::writeLogEntry(long, 
+      "FAILED: with '#{short.opts}' #{sprintf("%3d", short.duration)} "+
+      "+ 5 not smaller <  #{sprintf("%3d", long.duration)} seconds with '#{long.opts}'.")
+  end
+end
+
+tst.runChecks

Eigenschaftsänderungen: scripts/maint/test-xeno-test.rb
___________________________________________________________________
Name: svn:executable
   + *

Index: scripts/xeno-load.in
===================================================================
--- scripts/xeno-load.in	(Revision 1254)
+++ scripts/xeno-load.in	(Arbeitskopie)
@@ -1,7 +1,9 @@
-#! /bin/bash
+#! /bin/sh
 # Xenomai application loader script.
 # (Processes the .runinfo files)
 # June 2004, <[EMAIL PROTECTED]>
+# Adapted to be run also under the BusyBox. If you want to test it under the BusyBox use
+# busybox sh xeno-info 
 
 usage='usage: xeno-load [[dir:]target]'
 prefix="@prefix@"
@@ -23,7 +25,7 @@
   shift
 fi
 
-if test "x$1" = x--; then
+if test -z "$1" || test "x$1" = x--; then
   target_dir=`pwd`
   target_name=default
 else
@@ -80,7 +82,7 @@
 
 eval $user_moddir
 
-if `$sudo $modprobe -nq xeno_nucleus >& /dev/null`; then
+if `$sudo $modprobe -nq xeno_nucleus > /dev/null 2>&1`; then
    target_deps="${target_deps}nucleus+"
 else
    target_deps=
@@ -92,8 +94,8 @@
 
 test $verbose = 1 && echo "Running $target_name from $run_info_file"
 
-if test \! "x`type -t sudo`" = x; then
-  sudo=sudo
+if test -n "`which sudo`"; then
+  sudo=`which sudo`
 fi
 
 if test \! "x$target_mesg" = x; then
@@ -161,7 +163,7 @@
 	   echo "ERROR: cannot load $xeno_moddir/xeno_$mod$modext"
 	   break
         fi
-     elif `$sudo $modprobe -n xeno_$mod >& /dev/null`; then
+     elif `$sudo $modprobe -n xeno_$mod > /dev/null 2>&1`; then
         test $verbose = 1 && echo "+ $modprobe xeno_$mod"
         $sudo $modprobe xeno_$mod
         inslist="xeno_$mod $inslist"
Index: scripts/xeno-test.in
===================================================================
--- scripts/xeno-test.in	(Revision 1254)
+++ scripts/xeno-test.in	(Arbeitskopie)
@@ -1,5 +1,7 @@
-#!/bin/bash
-
+#! /bin/sh
+# Adapted to be run also under the BusyBox. If you want to test it under the BusyBox use
+# busybox sh xeno-test 
+# A BusyBox >= 1.1.3 with a make defconfig should provide all needed applets.
 myusage() {
     cat >&1 <<EOF
 xeno-test [options]
@@ -37,11 +39,52 @@
     exit 1
 }
 
+echo "xeno-test: started $*"
 #set -e	# ctrl-C's should end everything, not just subshells. 
 	# commenting it out may help to debug stuff.
 
 set -o notify	# see dd's finish immediately.(or not!)
 
+withBusybox=0
+if sh --help 2>&1| grep -q BusyBox; then
+    withBusybox=1;
+# else running a real /bin/sh (bash) shell
+fi
+echo withBusybox is $withBusybox
+pidFile=/var/lock/`basename $0.$$`.pids
+
+checkUtilities() {
+  # Check for needed helper utilities
+  local neededApplets="awk basename cut date dd dirname egrep grep getopt
+		       head kill md5sum mount sleep test top uname zcat"
+  local foundAll=1
+  for  _j in $neededApplets
+  do
+    if test -z "`which $_j`"; then
+      echo "Please build busybox with support for applet $_j"
+      foundAll=0
+    fi
+  done
+  if test $foundAll -eq 0 ; then exit 3 ; fi
+}
+
+checkHelpers() {
+  local foundAll=1
+  if test -z "`which script`" -a -n "$logging"; then
+      echo "You will not be able to log (-L option) as script is missing"
+      foundAll=0
+  fi
+  if test -z "`which mail`" -a "$sendit" = 'm' ; then
+      echo "You will not be able send mail (-m/-M options) as mail is missing"
+      foundAll=0
+  fi
+  if test -z "`which curl`" -a "$sendit" = 'm' ; then
+      echo "You will not be able to upload (-U option) as curl is missing"
+      foundAll=0
+  fi
+  if test $foundAll -eq 0 ; then exit 3 ; fi
+}
+
 loudly() {
     [ "$1" = "" ] && return
     # run task after announcing it
@@ -53,31 +96,46 @@
 
 # defaults for cpu workload 
 device=/dev/zero	
-typeset -a dd_jobs
-dd_jobs=()
+dd_jobs=
 
 # used in generate-loads
-mkload() { exec dd if=$device of=/dev/null $* ; }
+mkload() { dd if=$device of=/dev/null $* & }
 
 generate_loads() {
-    local jobsct=$1; shift;
+    local jobsct=$1;
+    # if test -z "$1"; then echo Skipping generate_loads; return; fi
+    shift 1
+    if test 0 -eq $withBusybox ; then
+	reaper() { echo something died a $! or $* ; sleep 1;  }
+	trap reaper CHLD
+	trap cleanup_load EXIT	# under all exit conditions
+    fi
+    while test $jobsct -ge 1; do 
+        jobsct=$((jobsct-1)); 
+        mkload
+        dd_jobs="$dd_jobs $!" ;
+    done
 
-    reaper() { echo something died $*; }
-    trap reaper CHLD
-    trap cleanup_load EXIT	# under all exit conditions
-    
-    for (( ; $jobsct ; jobsct-- )) ; do
-	mkload &
-	dd_jobs[${#dd_jobs[*]}]=$!
-    done;
-
-    echo dd workload started, pids ${dd_jobs[*]}
+    echo dd workload started, pids $dd_jobs stored in $pidFile
+    echo  $dd_jobs > $pidFile
 }
 
 cleanup_load() {
     # kill the workload
-    echo killing workload pids ${dd_jobs[*]}
-    kill ${dd_jobs[*]};
+    if test -z "$dd_jobs" -a -r $pidFile; then
+      dd_jobs=`cat $pidFile`
+      rm -f $pidFile
+    fi
+
+    if test -z "$dd_jobs" ; then
+        echo "cleanup_load: no dd_jobs found"
+    else
+	for _j in $dd_jobs
+	do
+	  ps | grep $_j
+	  kill $_j
+	done
+    fi
     unset dd_jobs;
 }
 
@@ -85,21 +143,20 @@
 
 
 boxinfo() { # static info, show once
+    loudly `dirname $0`/xeno-config --verbose
+    loudly `dirname $0`/xeno-info
 
-    loudly ./xeno-config --verbose
-    loudly ./xeno-info
-
     loudly cat /proc/cpuinfo	# bogomips changes under CPU_FREQ
-    loudly cksum /proc/cpuinfo	'# cpuinfo fingerprint'
+    loudly md5sum /proc/cpuinfo	'# cpuinfo fingerprint'
 
     # how much of the config do we want ?
-    local cmd="zgrep -E '$whatconf'"
-    [ "$verbose" = 1 ] && cmd=cat
-
-    if [ -f /proc/config.gz ]; then	# get the config
-	loudly $cmd /proc/config.gz
-    elif [ -f /lib/modules/`uname -r`/build/.config ]; then
-	loudly $cmd /lib/modules/`uname -r`/build/.config
+    local filter=" grep -E '$whatconf'"
+    [ "$verbose" = 1 ] && filter=
+    if test -f /proc/config.gz; then # get the config
+         loudly zcat /proc/config.gz | $filter
+    elif test -f /lib/modules/`uname -r`/build/.config
+    then
+	loudly cat /lib/modules/`uname -r`/build/.config | $filter
     fi
 
     [ -d /proc/adeos ] && for f in /proc/adeos/*; do loudly cat $f; done
@@ -107,7 +164,6 @@
 }
 
 boxstatus() {     # get dynamic status
-
     loudly cat /proc/interrupts
     loudly cat /proc/loadavg
     loudly cat /proc/meminfo
@@ -117,7 +173,11 @@
 	for f in /proc/xenomai/*/*; do [ -f $f ] && loudly cat $f; done
     fi
     [ -n "$prepost" ] && loudly $prepost
-    loudly top -bn1c | head -n $(( 12 + $workload ))
+    if test 0 -eq $withBusybox ; then
+	loudly top -bn1c | head -n $(( 12 + $workload ))
+    else
+	loudly top | head -n $(( 12 + $workload ))
+    fi
 }
 
 
@@ -129,25 +189,34 @@
     loudly generate_loads $workload
     boxstatus
     (
-	cd ../testsuite/latency
+        cd `dirname $0`/../testsuite/latency
 	loudly ./run --  $opts -t0
 	loudly ./run --  $opts -t1
 	loudly ./run --  $opts -t2
     )
-    (	cd ../testsuite/switch 
+    (	cd `dirname $0`/../testsuite/switch
 	loudly ./run --  '# switch'
     )
-    (	cd ../testsuite/cyclic
+    (	cd `dirname $0`/../testsuite/cyclic
 	loudly ./run -- -p 10 -n -l 1000 '# cyclictest'
     )
-
     boxstatus
+    cleanup_load
 }
 
-
 #####################
 # MAIN
+checkUtilities
 
+if [ -f /proc/config.gz ] ; then
+
+    # check/warn on problem configs
+    eval `zcat /proc/config.gz | grep CONFIG_CPU_FREQ` ;
+    if [ ! -z "$CONFIG_CPU_FREQ" ] ; then
+	echo "warning: CONFIG_CPU_FREQ=$CONFIG_CPU_FREQ may be problematic"
+    fi
+fi
+
 workload=1	# default = 1 job
 
 # *pass get all legit options, except -N, -L
@@ -155,7 +224,7 @@
 loadpass=	# pass thru to subshell, not to actual tests
 
 logging=	# no logging by default
-logfile=	# defaults to test-`uname -r`-<datestampe>
+logfile=test-`uname -r` # defaults to test-`uname -r`-<datestampe>
 logprefix=/tmp/	# someplace usually there
 prepost=	# command to run pre, and post test (ex ntpq -p)
 
@@ -168,18 +237,20 @@
 
 sendit() {
     local file=$1
-    
-    if [ "$sendit" == 'm' ]; then
+    if test "$sendit" = 'm' ; then
 	echo "mailing $file to $email"
-	if [ "$file" != '' ]; then
+	if test -n "$file" ; then
 	    mail -s 'xeno-test results' $email -- -F $sentby < $file
 	else
 	    cat - | mail -s 'xeno-test results' $email -- -F $sentby
 	fi
-    elif [ "$sendit" == 'u' ]; then
+    elif test "$sendit" = 'u' ; then
+	echo "uploading $file to $url"
 	which curl && curl -T $file $url
 	# -x $proxy >/tmp/.submit_result
 	# which wget && curl -T $file $url \
+    else
+	echo "sendit unsupported option '$sendit'"
     fi
 }
 
@@ -199,7 +270,7 @@
 	    if !(mount | grep -q ^$device) ; then
 		echo d option must be a block device, ie one of:
 		mount | cut -d\  -f1 | egrep -ve 'sysfs|proc|depts'
-		exit;
+		exit 1;
 	    fi
 	    loadpass="$loadpass -d $device"
 	    ;;
@@ -245,27 +316,39 @@
     handle_options;
 done
 
+checkHelpers
+
 # all args have been handled, and split into 2 passthrus
 shift $(($OPTIND - 1));
 
+if test -f pidFile && ! test -w $pidFile ; then
+  echo  "pidfile $pidFile not writable "; 
+  exit 4
+fi
 
-if [ "$logging" != "" ]; then
+echo "xeno-test: running tests"
+
+wfile=$logprefix$logfile-`date $dateargs`
+if test "$logging" != "" ; then
     # restart inside a script invocation, passing appropriate args
-    wfile=$logprefix$logfile-`date $dateargs`
-    script -c "./xeno-test $loadpass $pass $*" $wfile && sendit $wfile
+    script -c "`dirname $0`/xeno-test $loadpass $pass $*" $wfile
+    res="$?"
+    if test "$res" == "0" ; then
+	sendit $wfile
+    fi
 else
-    if [ "$altwork" != "" ]; then
+    if test "$altwork" != "" ; then
 	mkload() { exec $altwork; }
     fi
-    echo starting $0 $pass $loadpass $*
-    if [ "$sendit" != '' ]; then
-	run_w_load $pass $* 2>&1 | sendit
-    else
-	run_w_load $pass $*
+    run_w_load $pass $* 2>&1 | tee $wfile
+    res="$?"
+    if test "$sendit" != '' && test $res -eq 0  ; then
+       sendit $wfile
     fi
 fi
 
-exit;
+echo "xeno-test: finished"
+exit 0
 
 
 #################################################
@@ -297,15 +380,20 @@
 will eventually finish, and should be restarted to keep the load up.
 Figure out why killall didnt work properly.
 
-2. Much more testing.  Heres a weak start..
+2. Much more testing.  Heres a weak start. You migth be better off
+using and improving test/test-xeno-test.rb.
 
 #!/bin/bash
 PATH=.:$PATH
 xeno-test -L
 xeno-test -N foo -T 18 -l 6 -s
 xeno-test -L -N foo1-
+xeno-test -m
+xeno-test -T 1 -M [EMAIL PROTECTED]
 xeno-test -N foo0 -w0 -l 5 -T 30 -h
 xeno-test -L -N foo4- -w4
 xeno-test -L -N foo4W- -w4 -W 'dd if=/dev/hda1 of=/dev/null'
 
-3.
+3. Repeat the same tests under the BusyBox.
+
+4. Check for border cases like missing awk, curl, mail, script, /proc/config.gz

Attachment: logs.tar.bz2
Description: application/tbz

_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to