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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [ld/] [testsuite/] [ld-pe/] [pe-run.exp] - Blame information for rev 184

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 92 khays
# Expect script for complex PE tests that require a C compiler and the ability
2
# to run target executables natively, in addition to the just-built binutils.
3
#   Copyright 2006, 2007, 2009
4
#   Free Software Foundation, Inc.
5
#
6
# This file is part of the GNU Binutils.
7
#
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21
# MA 02110-1301, USA.
22
#
23
# Written by Pedro Alves 
24
#
25
 
26
# Note:
27
#
28
# This test checks the "direct linking to a dll" functionality.
29
#
30
# The test has 7 stages:
31
#
32
# 1. compile and link a test dll with ".dll" extension.
33
#
34
# 2. compile and link a test dll with ".sl" (i.e. != ".dll") extension.
35
#
36
# 3. compile and link a client application linking directly to the ".dll" dll built in 1.
37
#    This should produce no errors.
38
#
39
# 4. compile and link a client application linking directly to the ".sl" dll built in 2.
40
#    This should produce no errors.
41
#
42
# 5. compile and link a client application linking directly to a symlink into
43
#    the ".dll" dll built in 1.
44
#    This should produce no errors.
45
#
46
# 6. compile and link a client application linking directly to a symlink into
47
#    the ".sl" dll built in 1.
48
#    This should produce no errors.
49
#
50
# 7. run the produced executables
51
 
52
# This test can only be run on PE/COFF platforms.
53
if {![is_pecoff_format]} {
54
    return
55
}
56
 
57
# No compiler, no test.
58
if { [which $CC] == 0 } {
59
    untested "Direct linking to dll test"
60
    return
61
}
62
 
63
set tmpdir tmpdir
64
 
65
proc test_direct_link_dll {} {
66
    global CC
67
    global CFLAGS
68
    global srcdir
69
    global subdir
70
    global tmpdir
71
 
72
    # Compile the dll.
73
    if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct_dll.c $tmpdir/direct_dll.o ] {
74
        fail "compiling shared lib"
75
    } elseif ![ld_simple_link "$CC -shared" $tmpdir/direct_dll.dll "$tmpdir/direct_dll.o" ] {
76
        fail "linking shared lib (.dll)"
77
    } elseif ![ld_simple_link "$CC -shared" $tmpdir/direct_dll.sl "$tmpdir/direct_dll.o" ] {
78
        fail "linking shared lib (.sl)"
79
    } else {
80
        # Compile and link the client program.
81
        if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct_client.c $tmpdir/direct_client.o ] {
82
            fail "compiling client"
83
        } else {
84
            # Check linking directly to direct_dll.dll.
85
            set msg "linking client (.dll)"
86
            if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_dll.exe \
87
              "$tmpdir/direct_client.o $tmpdir/direct_dll.dll" ] {
88
                pass $msg
89
            } else {
90
                fail $msg
91
            }
92
 
93
            # Check linking directly to direct_dll.sl.
94
            set msg "linking client (.sl)"
95
            if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_sl.exe \
96
              "$tmpdir/direct_client.o $tmpdir/direct_dll.sl" ] {
97
                pass $msg
98
            } else {
99
                fail $msg
100
            }
101
 
102
            # Check dll direct linking through symlink to .dll.
103
            # Create symbolic link.
104
            catch "exec ln -fs direct_dll.dll $tmpdir/libdirect_dll.dll.a" ln_catch
105
            set msg "linking client (symlink -> .dll)"
106
            if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_dll.exe \
107
              "$tmpdir/direct_client.o $tmpdir/libdirect_dll.dll.a" ] {
108
                pass $msg
109
            } else {
110
                fail $msg
111
            }
112
 
113
            # Check dll direct linking through symlink to .sl.
114
            # Create symbolic link.
115
            catch "exec ln -fs direct_dll.sl $tmpdir/libdirect_sl.dll.a" ln_catch
116
            set msg "linking client (symlink -> .sl)"
117
            if [ld_simple_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_sl.exe \
118
              "$tmpdir/direct_client.o $tmpdir/libdirect_sl.dll.a" ] {
119
                pass $msg
120
            } else {
121
                fail $msg
122
            }
123
        }
124
    }
125
}
126
 
127
proc directdll_execute {exe msg} {
128
    set expected ""
129
    catch "exec $exe" prog_output
130
    if [string match $expected $prog_output] then {
131
        pass $msg
132
    } else {
133
        verbose $prog_output
134
        fail $msg
135
    }
136
}
137
 
138
test_direct_link_dll
139
 
140
# This is as far as we can go with a cross-compiler
141
if ![isnative] then {
142
    verbose "Not running natively, so cannot execute binaries"
143
    return
144
}
145
 
146
directdll_execute "$tmpdir/direct_client_dll.exe" "running direct linked dll (.dll)"
147
directdll_execute "$tmpdir/direct_client_sl.exe" "running direct linked dll (.sl)"
148
directdll_execute "$tmpdir/direct_client_symlink_sl.exe" "running direct linked dll (symlink -> .sl)"
149
directdll_execute "$tmpdir/direct_client_symlink_dll.exe" "running direct linked dll (symlink -> .dll)"

powered by: WebSVN 2.1.0

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