[llvm-commits] [hlvm] r38037 - in /hlvm/trunk/test: Makefile config/ config/unix.exp lib/ lib/identity.exp lib/xml2xml.exp xml2xml/ xml2xml/bundle.hlx xml2xml/dg.exp

Reid Spencer reid at x10sys.com
Sat Jul 7 16:59:11 PDT 2007


Author: reid
Date: Sat Jul  7 18:59:11 2007
New Revision: 38037

URL: http://llvm.org/viewvc/llvm-project?rev=38037&view=rev
Log:
Provide an initial dejagnu testing framework for the identity tests. These
tests, in xml2xml transform XML -> AST -> XML. We "diff" the input and output
XML. If they are identical, the identity test passes. This approach can be
used with any tool that can read its input and echo its output.

Added:
    hlvm/trunk/test/config/
    hlvm/trunk/test/config/unix.exp
    hlvm/trunk/test/lib/
    hlvm/trunk/test/lib/identity.exp
    hlvm/trunk/test/lib/xml2xml.exp
    hlvm/trunk/test/xml2xml/
    hlvm/trunk/test/xml2xml/bundle.hlx
    hlvm/trunk/test/xml2xml/dg.exp
Modified:
    hlvm/trunk/test/Makefile

Modified: hlvm/trunk/test/Makefile
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/Makefile?rev=38037&r1=38036&r2=38037&view=diff

==============================================================================
--- hlvm/trunk/test/Makefile (original)
+++ hlvm/trunk/test/Makefile Sat Jul  7 18:59:11 2007
@@ -1,13 +1,28 @@
-##===- test/Makefile ---------------------------------------*- Makefile -*-===##
+LEVEL  = ..
+DIRS   = 
+DISABLE_AUTO_DEPENDENCIES=1 
 
-#
-# Relative path to the top of the source tree.
-#
-LEVEL=..
+include ${LEVEL}/Makefile.hlvm
 
-#
-# List all of the subdirectories that we will compile.
-#
-DIRS=
+all:: check-local
 
-include $(LEVEL)/Makefile.hlvm
+check-local:: site.exp
+	@DEJAGNU=./site.exp runtest --tool xml2xml
+
+site.exp: Makefile $(PROJ_OBJ_ROOT)/Makefile.config
+	@echo 'Making a new site.exp file...'
+	@echo '## these variables are automatically generated by make ##' >site.tmp
+	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
+	@echo '# edit the last section' >>site.tmp
+	@echo 'set target_triplet "$(TARGET_TRIPLE)"' >> site.tmp
+	@echo 'set srcdir "$(PROJ_SRC_ROOT)/test"' >>site.tmp
+	@echo 'set objdir "$(PROJ_OBJ_ROOT)/test"' >>site.tmp
+	@echo 'set srcrootdir "$(PROJ_SRC_ROOT)"' >>site.tmp
+	@echo 'set objrootdir "$(PROJ_OBJ_ROOT)"' >>site.tmp
+	@echo 'set tmpdir "$$objdir/tmp"' >> site.tmp
+	@echo '## All variables above are generated by configure. Do Not Edit ## ' >>site.tmp
+	@test ! -f site.exp || \
+	sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+	@-rm -f site.bak
+	@test ! -f site.exp || mv site.exp site.bak
+	@mv site.tmp site.exp

Added: hlvm/trunk/test/config/unix.exp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/config/unix.exp?rev=38037&view=auto

==============================================================================
--- hlvm/trunk/test/config/unix.exp (added)
+++ hlvm/trunk/test/config/unix.exp Sat Jul  7 18:59:11 2007
@@ -0,0 +1,22 @@
+#   Copyright (C) 1997 - 2001 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-dejagnu at gnu.org
+
+proc foo_load {} {}
+proc foo_exit {} {}
+

Added: hlvm/trunk/test/lib/identity.exp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/lib/identity.exp?rev=38037&view=auto

==============================================================================
--- hlvm/trunk/test/lib/identity.exp (added)
+++ hlvm/trunk/test/lib/identity.exp Sat Jul  7 18:59:11 2007
@@ -0,0 +1,70 @@
+#===-test/lib/identity.exp - Script for identity tests ---------------------===#
+#
+#                      High Level Virtual Machine (HLVM)
+# 
+#  Copyright (C) 2006 Reid Spencer. All Rights Reserved.
+# 
+#  This software is free software; you can redistribute it and/or modify it 
+#  under the terms of the GNU Lesser General Public License as published by 
+#  the Free Software Foundation; either version 2.1 of the License, or (at 
+#  your option) any later version.
+# 
+#  This software is distributed in the hope that it will be useful, but WITHOUT
+#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+#  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for 
+#  more details.
+# 
+#  You should have received a copy of the GNU Lesser General Public License 
+#  along with this library in the file named LICENSE.txt; if not, write to the 
+#  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+#  MA 02110-1301 USA
+# 
+#===------------------------------------------------------------------------===#
+proc hlvm-identity-tests { prog pat } {
+  global srcdir subdir objdir tmpdir objrootdir
+  set outdir [file join $objdir $subdir]
+  set tool [file join $objrootdir Debug bin $prog ]
+  set source [file join $srcdir $subdir ]
+  set files [lsort [
+    glob -nocomplain -tails -types {f r} -directory $source $pat]]
+  set dirs [lsort [
+    glob -nocomplain -tails -types {d r} -directory $source *]]
+
+  if { [file isdirectory $outdir] } {
+    cd $outdir
+  } else {
+    if { [file exists $outdir] } {
+      fail "identity: $outdir exists and is not a directory. Remove it"
+      exit(2)
+    } else {
+      file mkdir $outdir
+    }
+  }
+  
+  foreach test $files {
+    set output [file join $outdir ${test}.out]
+    set testsrc [file join $source $test]
+    set retval [ catch {exec $tool $testsrc -o $output >>&$output } ]
+    if { $retval == 1 } {
+      #Get output
+      set outputFile [open $output {RDONLY}]
+      set result [read $outputFile]
+      close $outputFile
+      fail "$test: $tool returned $retval\n$result"
+    } else {
+      # Do the identity test
+      set diffout [file join ${output}.diff]
+      set retval [ catch {exec diff $testsrc $output >&$diffout } ]
+      if {$retval == 1} {
+        #Get output
+        set difffile [open $diffout {RDONLY}]
+        set result [read $difffile]
+        close $difffile
+        fail "$test: identity test failed:\n$result"
+      } else {
+        file delete $diffout
+        pass "$test"
+      }
+    }
+  }
+}

Added: hlvm/trunk/test/lib/xml2xml.exp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/lib/xml2xml.exp?rev=38037&view=auto

==============================================================================
    (empty)

Added: hlvm/trunk/test/xml2xml/bundle.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/bundle.hlx?rev=38037&view=auto

==============================================================================
--- hlvm/trunk/test/xml2xml/bundle.hlx (added)
+++ hlvm/trunk/test/xml2xml/bundle.hlx Sat Jul  7 18:59:11 2007
@@ -0,0 +1,4 @@
+<hlvm>
+ <bundle pubid="name">
+ </bundle>
+</hlvm>

Added: hlvm/trunk/test/xml2xml/dg.exp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/xml2xml/dg.exp?rev=38037&view=auto

==============================================================================
--- hlvm/trunk/test/xml2xml/dg.exp (added)
+++ hlvm/trunk/test/xml2xml/dg.exp Sat Jul  7 18:59:11 2007
@@ -0,0 +1,3 @@
+load_lib identity.exp
+
+hlvm-identity-tests hlvm-xml2xml "*.hlx"





More information about the llvm-commits mailing list