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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [ld/] [testsuite/] [ld-pe/] [direct.exp] - Blame information for rev 866

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

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