[llvm-commits] [hlvm] r38275 - in /hlvm/trunk/test: SConscript error/ error/badbin.hlx error/baddec.hlx error/badhex.hlx error/badoct.hlx error/dg.exp error/range16.hlx error/range32.hlx error/range64.hlx error/range8.hlx lib/error.exp

Reid Spencer reid at x10sys.com
Sat Jul 7 17:01:52 PDT 2007


Author: reid
Date: Sat Jul  7 19:01:52 2007
New Revision: 38275

URL: http://llvm.org/viewvc/llvm-project?rev=38275&view=rev
Log:
Implement error tests where an error result is expected. Initial tests in this
class consist of numeric literal constant validity and range checks.

Added:
    hlvm/trunk/test/error/
    hlvm/trunk/test/error/badbin.hlx
    hlvm/trunk/test/error/baddec.hlx
    hlvm/trunk/test/error/badhex.hlx
    hlvm/trunk/test/error/badoct.hlx
    hlvm/trunk/test/error/dg.exp
    hlvm/trunk/test/error/range16.hlx
    hlvm/trunk/test/error/range32.hlx
    hlvm/trunk/test/error/range64.hlx
    hlvm/trunk/test/error/range8.hlx
    hlvm/trunk/test/lib/error.exp
Modified:
    hlvm/trunk/test/SConscript

Modified: hlvm/trunk/test/SConscript
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/SConscript?rev=38275&r1=38274&r2=38275&view=diff

==============================================================================
--- hlvm/trunk/test/SConscript (original)
+++ hlvm/trunk/test/SConscript Sat Jul  7 19:01:52 2007
@@ -24,4 +24,4 @@
 Import('env')
 if 'check' in COMMAND_LINE_TARGETS:
   from build import check
-  check.Check(env,['xml2xml','return0'])
+  check.Check(env,['xml2xml','error','return0'])

Added: hlvm/trunk/test/error/badbin.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/error/badbin.hlx?rev=38275&view=auto

==============================================================================
--- hlvm/trunk/test/error/badbin.hlx (added)
+++ hlvm/trunk/test/error/badbin.hlx Sat Jul  7 19:01:52 2007
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/error/badbin.hlx">
+  <bundle id="badbin">
+    <constant id="0000" type="s8"><bin>12345</bin></constant>
+  </bundle>
+</hlvm>

Added: hlvm/trunk/test/error/baddec.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/error/baddec.hlx?rev=38275&view=auto

==============================================================================
--- hlvm/trunk/test/error/baddec.hlx (added)
+++ hlvm/trunk/test/error/baddec.hlx Sat Jul  7 19:01:52 2007
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/error/baddec.hlx">
+  <bundle id="baddec">
+    <constant id="0000" type="s8"><dec>1234abc</dec></constant>
+  </bundle>
+</hlvm>

Added: hlvm/trunk/test/error/badhex.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/error/badhex.hlx?rev=38275&view=auto

==============================================================================
--- hlvm/trunk/test/error/badhex.hlx (added)
+++ hlvm/trunk/test/error/badhex.hlx Sat Jul  7 19:01:52 2007
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/error/badhex.hlx">
+  <bundle id="badhex">
+    <constant id="0000" type="s8"><hex>$!%^@$</hex></constant>
+  </bundle>
+</hlvm>

Added: hlvm/trunk/test/error/badoct.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/error/badoct.hlx?rev=38275&view=auto

==============================================================================
--- hlvm/trunk/test/error/badoct.hlx (added)
+++ hlvm/trunk/test/error/badoct.hlx Sat Jul  7 19:01:52 2007
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/error/badoct.hlx">
+  <bundle id="badoct">
+    <constant id="0000" type="s8"><oct>29</oct></constant>
+  </bundle>
+</hlvm>

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

==============================================================================
--- hlvm/trunk/test/error/dg.exp (added)
+++ hlvm/trunk/test/error/dg.exp Sat Jul  7 19:01:52 2007
@@ -0,0 +1,3 @@
+load_lib error.exp
+
+hlvm-error-tests hlvm-xml2xml "*.hlx"

Added: hlvm/trunk/test/error/range16.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/error/range16.hlx?rev=38275&view=auto

==============================================================================
--- hlvm/trunk/test/error/range16.hlx (added)
+++ hlvm/trunk/test/error/range16.hlx Sat Jul  7 19:01:52 2007
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/error/range16.hlx">
+  <bundle id="range16">
+    <constant id="0001" type="s16"><dec>32768</dec></constant>
+    <constant id="0002" type="s16"><dec>-32769</dec></constant>
+    <constant id="0003" type="u16"><dec>65536</dec></constant>
+    <constant id="0004" type="u16"><dec>-1</dec></constant>
+  </bundle>
+</hlvm>

Added: hlvm/trunk/test/error/range32.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/error/range32.hlx?rev=38275&view=auto

==============================================================================
--- hlvm/trunk/test/error/range32.hlx (added)
+++ hlvm/trunk/test/error/range32.hlx Sat Jul  7 19:01:52 2007
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/error/range32.hlx">
+  <bundle id="range32">
+    <constant id="0001" type="s32"><dec>2147483648</dec></constant>
+    <constant id="0002" type="s32"><dec>-2147483649</dec></constant>
+    <constant id="0003" type="u32"><dec>4294967296</dec></constant>
+    <constant id="0004" type="u32"><dec>-1</dec></constant>
+  </bundle>
+</hlvm>

Added: hlvm/trunk/test/error/range64.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/error/range64.hlx?rev=38275&view=auto

==============================================================================
--- hlvm/trunk/test/error/range64.hlx (added)
+++ hlvm/trunk/test/error/range64.hlx Sat Jul  7 19:01:52 2007
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/error/range64.hlx">
+  <bundle id="range64">
+    <constant id="0001" type="s8"><dec>9223372036854775808</dec></constant>
+    <constant id="0002" type="s8"><dec>-9223372036854775809</dec></constant>
+    <constant id="0003" type="u8"><hex>ffffffffffffffff</hex></constant>
+    <constant id="0004" type="u8"><dec>-1</dec></constant>
+  </bundle>
+</hlvm>

Added: hlvm/trunk/test/error/range8.hlx
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/test/error/range8.hlx?rev=38275&view=auto

==============================================================================
--- hlvm/trunk/test/error/range8.hlx (added)
+++ hlvm/trunk/test/error/range8.hlx Sat Jul  7 19:01:52 2007
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hlvm xmlns="http://hlvm.org/src/hlvm/Reader/XML/HLVM.rng" pubid="http://hlvm.org/src/hlvm/test/error/range8.hlx">
+  <bundle id="range8">
+    <constant id="0001" type="s8"><dec>128</dec></constant>
+    <constant id="0002" type="s8"><dec>-129</dec></constant>
+    <constant id="0003" type="u8"><dec>256</dec></constant>
+    <constant id="0004" type="u8"><dec>-1</dec></constant>
+  </bundle>
+</hlvm>

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

==============================================================================
--- hlvm/trunk/test/lib/error.exp (added)
+++ hlvm/trunk/test/lib/error.exp Sat Jul  7 19:01:52 2007
@@ -0,0 +1,55 @@
+#===-test/lib/error.exp - Script for error check 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-error-tests { prog pat } {
+  global srcdir subdir objdir tmpdir objrootdir
+  set outdir [file join $objdir $subdir]
+  set tool [file join $objrootdir tools $prog $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 execout ""
+    set retval [ catch { exec -keepnewline $tool $testsrc -o $output } msg ]
+    if { $retval != 0 } {
+      pass "$test"
+    } else {
+      fail "$test: $tool return $retval\n$msg"
+    }
+  }
+}





More information about the llvm-commits mailing list