Subversion Repositories Open64

[/] [regression_test/] [lib/] [test_multifile.exp] - Diff between revs 1931 and 1943

Only display areas with differences | Details | Blame | View Log

Rev 1931 Rev 1943
#!/usr/bin/expect -f
#!/usr/bin/expect -f
 
 
 
load_lib test_utils.exp
 
 
###############################################################################
###############################################################################
# Command to test a single case with multiple sources
# Command to test a single case with multiple sources
# We assume:
# We assume:
#  there is an shell script indicating how to testing the case
#  there is an shell script indicating how to testing the case
#  This shell script should return 0 for success while 1 for failure
#  This shell script should return 0 for success while 1 for failure
###############################################################################
###############################################################################
proc CheckOutput { targetfile makefileout errormsg } {
proc CheckOutput { targetfile makefileout errormsg } {
    if { ![string equal $targetfile all] } {
    if { ![string equal $targetfile all] } {
        puts $makefileout "\tif \[ ! -e $targetfile \]; then \\"
        puts $makefileout "\tif \[ ! -e $targetfile \]; then \\"
        puts $makefileout "\t\techo \"!!!Message:$errormsg (Cannot find output file)!!! \";\\"
        puts $makefileout "\t\techo \"!!!Message:$errormsg (Cannot find output file)!!! \";\\"
        puts $makefileout "\t\texit 1;\\"
        puts $makefileout "\t\texit 1;\\"
        puts $makefileout "\tfi;"
        puts $makefileout "\tfi;"
    }
    }
}
}
proc PrintLines { info } {
proc PrintLines { info } {
    global summary
    global summary
    set lines [ split $info "\n" ]
    set lines [ split $info "\n" ]
    foreach line $lines {
    foreach line $lines {
        puts $summary "        $line"
        puts $summary "        $line"
    }
    }
}
}
namespace eval C_CLASS {
namespace eval C_CLASS {
 
 
    proc TestMakefile { case caseexe case_out_dir log_out_dir summary checker } {
    proc TestMakefile { case caseexe case_out_dir summary checker } {
  global cc cxx fc cflags cxxflags fflags sim #Flags
  global cc cxx fc cflags cxxflags fflags sim #Flags
  global curdir
  global curdir
  global err_compile err_link err_build pass_build #Counters
  global C_CLASS::err_compile C_CLASS::err_link C_CLASS::err_build C_CLASS::pass_build #Counters
  global err_runexit err_runout err_run pass_run   #Counters
  global C_CLASS::err_runexit C_CLASS::err_runout C_CLASS::err_run C_CLASS::pass_run   #Counters
 
 
  system mkdir -p $case_out_dir
  system mkdir -p $case_out_dir
  system mkdir -p $log_out_dir
 
  system cp -rf $case/* $case_out_dir
  system cp -rf $case/* $case_out_dir
  #Parse and generate Makefile
  #Parse and generate Makefile
  set makefileout [open $case_out_dir/Makefile w]
  set makefileout [open $case_out_dir/Makefile w]
  set makefilein [open $case/Makefile r]
  set makefilein [open $case/Makefile r]
  set targetfile ""
  set targetfile ""
  set execute 1
  set execute 1
  puts $makefileout "CC=$cc"
  puts $makefileout "CC=$cc"
  puts $makefileout "CXX=$cxx"
  puts $makefileout "CXX=$cxx"
  puts $makefileout "FC=$fc"
  puts $makefileout "FC=$fc"
  puts $makefileout "CFLAGS=$cflags"
  puts $makefileout "CFLAGS=$cflags"
  puts $makefileout "CXXFLAGS=$cxxflags"
  puts $makefileout "CXXFLAGS=$cxxflags"
  puts $makefileout "FFLAGS=$fflags"
  puts $makefileout "FFLAGS=$fflags"
  puts $makefileout "TARGET=$case"
  puts $makefileout "TARGET=$case"
  puts $makefileout "SIM=$sim"
  puts $makefileout "SIM=$sim"
  puts $makefileout ""
  puts $makefileout ""
  set lineno 0
  set lineno 0
  while { [gets $makefilein line] >= 0 } {
  while { [gets $makefilein line] >= 0 } {
      set line [string trimright $line]
      set line [string trimright $line]
      set commentpos [string first "#" $line]
      set commentpos [string first "#" $line]
      if { [expr $commentpos == 0] } {
      if { [expr $commentpos == 0] } {
    switch -glob $line {
    switch -glob $line {
        "#NOEXEC" { set execute 0 }
        "#NOEXEC" { set execute 0 }
    }
    }
      }
      }
      set lineno [expr $lineno + 1]
      set lineno [expr $lineno + 1]
      if { [expr $commentpos >= 0] } {
      if { [expr $commentpos >= 0] } {
    set line [string range $line 0 [expr $commentpos - 1]]
    set line [string range $line 0 [expr $commentpos - 1]]
      }
      }
      if { [string is space [string index $line 0]] } { #Parsing command lines
      if { [string is space [string index $line 0]] } { #Parsing command lines
    if { [string equal $line ""] } {
    if { [string equal $line ""] } {
        if { ![string equal $targetfile ""] } {
        if { ![string equal $targetfile ""] } {
      CheckOutput $targetfile $makefileout $errormsg
      CheckOutput $targetfile $makefileout $errormsg
      set targetfile ""
      set targetfile ""
        }
        }
        puts $makefileout $line
        puts $makefileout $line
    } elseif {[string equal [string index $line end] "\\"] || [string equal $targetfile ""]} {
    } elseif {[string equal [string index $line end] "\\"] || [string equal $targetfile ""]} {
        puts $makefileout $line
        puts $makefileout $line
    } else {
    } else {
        puts $makefileout "$line >& $log_out_dir/$targetfile.ci || (echo \"!!!Message:$errormsg (Makefile:$lineno) !!!\" && exit 1)"
        puts $makefileout "$line >& $case_out_dir/$targetfile.ci || (echo \"!!!Message:$errormsg (Makefile:$lineno) !!!\" && exit 1)"
    }
    }
      } else {  #Parsing headers
      } else {  #Parsing headers
    set colonpos [string first ":" $line]
    set colonpos [string first ":" $line]
    if { [expr $colonpos >= 0] } {
    if { [expr $colonpos >= 0] } {
        set targetfile [string range $line 0 [expr $colonpos - 1]]
        set targetfile [string range $line 0 [expr $colonpos - 1]]
        set targetfile [string trimright $targetfile]
        set targetfile [string trimright $targetfile]
        if { [string match -nocase "*.o" $targetfile] || [string match -nocase "*.s" $targetfile] } {
        if { [string match -nocase "*.o" $targetfile] || [string match -nocase "*.s" $targetfile] } {
      set errormsg "\[$targetfile\] Fail at compiling"
      set errormsg "\[$targetfile\] Fail at compiling"
        } else {
        } else {
      set errormsg "\[$targetfile\] Fail at linking"
      set errormsg "\[$targetfile\] Fail at linking"
        }
        }
        puts $makefileout $line
        puts $makefileout $line
    } else {
    } else {
        puts $makefileout $line
        puts $makefileout $line
    }
    }
      }
      }
  }
  }
  if { ![string equal $targetfile ""] } {
  if { ![string equal $targetfile ""] } {
      CheckOutput $targetfile $makefileout $errormsg
      CheckOutput $targetfile $makefileout $errormsg
      set targetfile ""
      set targetfile ""
  }
  }
  close $makefilein
  close $makefilein
  close $makefileout
  close $makefileout
  cd $case_out_dir
  cd $case_out_dir
  set buildres 0
  set buildres 0
  set runres 0
  set runres 0
  set cmpres 0
  set cmpres 0
  if { [catch {exec make -s} makeresult] } {
  if { [catch {exec make -s} makeresult] } {
      incr err_build
      incr err_build
      set mpos [string first "!!!Message:" $makeresult]
      set mpos [string first "!!!Message:" $makeresult]
      if { [expr $mpos < 0] } {
      if { [expr $mpos < 0] } {
    #Bad Makefile
    #Bad Makefile
    set buildres -1
    set buildres -1
      } else {
      } else {
    set mpos2 [string first "!!!" $makeresult 11]
    set mpos2 [string first "!!!" $makeresult 11]
    set makeresult [string range $makeresult 11 [expr $mpos2 - 1]]
    set makeresult [string range $makeresult 11 [expr $mpos2 - 1]]
    set mpos3 [string first "]" $makeresult]
    set mpos3 [string first "]" $makeresult]
    catch {exec cat $log_out_dir/[string range $makeresult 1 [expr $mpos3 - 1]].ci} cioutput
 
    set buildres -1
    set buildres -1
      }
      }
  } else {
  } else {
      incr pass_build
      incr pass_build
      if { $execute == 1 } {
      if { $execute == 1 } {
    set rc [catch {exec ./$caseexe > $log_out_dir/$caseexe.run}]
    set rc [catch {exec ./$caseexe > $case_out_dir/$caseexe.run}]
    set runresult ""
    set runresult ""
    if { $rc } {
    if { $rc } {
        set runres -1
        set runres -1
        incr err_run
        incr err_run
    } else {
    } else {
        catch {exec cat $log_out_dir/$caseexe.run} runresult
        catch {exec cat $case_out_dir/$caseexe.run} runresult
        if { [expr [$checker $runresult] == 1]} {
        if { [expr [$checker $runresult] == 1]} {
      incr pass_run
      incr pass_run
        } else {
        } else {
      set cmpres 1
      set cmpres 1
      incr err_run
      incr err_run
        }
        }
    }
    }
    PrintLines $runresult
 
      }
      }
  }
  }
  Report_TestCase_Result $case $buildres $runres $cmpres
  Report_TestCase_Result $case $buildres $runres $cmpres
  cd $curdir
  cd $curdir
    }
    }
}
}