OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.cni/] [cni.exp] - Blame information for rev 765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
# Tests for CNI code.
2
 
3
# Compile a single C++ file and produce a .o file.  OPTIONS is a list
4
# of options to pass to the compiler.  Returns 0 on failure, 1 on
5
# success.
6
proc gcj_cni_compile_cxx_to_o {file {options {}}} {
7
  global srcdir subdir
8
 
9
  set name [file rootname [file tail $file]]
10
  set oname ${name}.o
11
 
12
  # Find the generated header.
13
  lappend options "additional_flags=-I. -I.. -I$srcdir/$subdir -fdollars-in-identifiers"
14
  # Find libgcj headers.
15
  lappend options "additional_flags=-I$srcdir/.."
16
 
17
  set x [libjava_prune_warnings \
18
           [target_compile $file $oname object $options]]
19
  if {$x != ""} {
20
    verbose "target_compile failed: $x" 2
21
    fail "[file tail $file] compilation"
22
    return 0
23
  }
24
 
25
  pass "[file tail $file] compilation"
26
  return 1
27
}
28
 
29
# Build header files given name of .java file.  Return 0 on failure.
30
proc gcj_cni_build_headers {file} {
31
  global libgcj_jar
32
 
33
  set gcjh [find_gcjh]
34
 
35
  # Currently we only build a header file for the main class from the
36
  # .java file, and then others on an ad hoc basis.
37
  set list {}
38
  set main [file rootname [file tail $file]]
39
  lappend list $main
40
  # ... for instance, an obvious hack.
41
  if {$main == "shortfield"} {
42
    lappend list shortfieldbase
43
  }
44
 
45
  foreach file $list {
46
    set cmd "$gcjh -cni -force -classpath .:$libgcj_jar $file"
47
    verbose $cmd
48
    set x [string trim [libjava_prune_warnings \
49
                          [lindex [local_exec $cmd "" "" 300] 1]]]
50
    if {$x != ""} {
51
      verbose "local_exec failed: $x" 2
52
      fail "$main header generation"
53
      return 0
54
    }
55
  }
56
 
57
  pass "$main header generation"
58
  return 1
59
}
60
 
61
# Do all the work for a single CNI test.  Return 0 on failure.
62
proc gcj_cni_test_one {file} {
63
  global runtests
64
 
65
  # The base name.  We use it for several purposes.
66
  set main [file rootname [file tail $file]]
67
  if {! [runtest_file_p $runtests $main]} {
68
    # Simply skip it.
69
    return 1
70
  }
71
 
72
#   if {! [bytecompile_file $file [pwd]]} {
73
#     fail "bytecompile $file"
74
#     # FIXME - should use `untested' on all remaining tests.
75
#     # But that is hard.
76
#     return 0
77
#   }
78
#   pass "bytecompile $file"
79
 
80
#   if {! [gcj_cni_build_headers $file]} {
81
#     # FIXME
82
#     return 0
83
#   }
84
 
85
  set cfile [file join [file dirname $file] nat$main.cc]
86
  if {! [gcj_cni_compile_cxx_to_o $cfile]} {
87
    # FIXME
88
    return 0
89
  }
90
 
91
  if {! [gcj_link $main $main [list $file nat$main.o]]} {
92
    # FIXME
93
    return 0
94
  }
95
 
96
  if {! [gcj_invoke $main [file rootname $file].out {}]} {
97
    # FIXME
98
    return 0
99
  }
100
 
101
  # When we succeed we remove all our clutter.
102
  eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main nat$main.o]
103
 
104
  return 1
105
}
106
 
107
# Run the CNI tests.
108
proc gcj_cni_run {} {
109
  global srcdir subdir
110
  global build_triplet host_triplet
111
 
112
  # For now we only test CNI on native builds.
113
  if {$build_triplet == $host_triplet} {
114
    catch { lsort [glob -nocomplain ${srcdir}/${subdir}/*.jar] } srcfiles
115
 
116
    foreach x $srcfiles {
117
      gcj_cni_test_one $x
118
    }
119
  } else {
120
    verbose "CNI tests not run in cross-compilation environment"
121
  }
122
}
123
 
124
gcj_cni_run

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.