Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / ar-lib.test
1 #! /bin/sh
2 # Copyright (C) 2010 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Make sure `ar-lib' wraps the Microsoft Library Manager (lib) correctly
18
19 required=xsi-shell
20 . ./defs || Exit 1
21
22 set -e
23
24 cp "$testsrcdir/../lib/ar-lib" .
25 # Use a dummy lib, since lib isn't readily available on all systems.
26 cat >lib <<'END'
27 #! /bin/sh
28 if test x"$2" = x-LIST && test x"$3" = xfake.lib; then
29   echo fake.obj
30 elif test x"$2" = x-LIST && test x"$3" = xfake2.lib; then
31   printf "%s\n" "dir\\fake2.obj"
32 else
33   printf "%s\n" "lib $*"
34 fi
35 END
36
37 chmod +x ./lib
38
39 # Check if ar-lib can create an archive with "cr"
40 opts=`./ar-lib ./lib cr foo.lib foo.obj`
41 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.obj"
42
43 # Check if ar-lib can update an existing archive with "r"
44 touch foo.lib
45 opts=`./ar-lib ./lib r foo.lib foo.obj`
46 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
47
48 # Check if ar-lib can update an existing archive with "q".
49 opts=`./ar-lib ./lib q foo.lib foo.obj`
50 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
51
52 # Check if ar-lib accepts "u" as a modifier.
53 # NOTE: "u" should have an effect, but currently doesn't.
54 opts=`./ar-lib ./lib ru foo.lib foo.obj`
55 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
56
57 # Check if ar-lib accepts "s" as a modifier.
58 opts=`./ar-lib ./lib rs foo.lib foo.obj`
59 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
60
61 # Check if ar-lib accepts "S" as a modifier.
62 opts=`./ar-lib ./lib rS foo.lib foo.obj`
63 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib foo.obj"
64
65 # Check if ar-lib passes on @FILE with "r"
66 opts=`./ar-lib ./lib r foo.lib @list`
67 test x"$opts" = x"lib -NOLOGO -OUT:foo.lib foo.lib @list"
68
69 # Check if ar-lib can delete a member from an archive with "d"
70 opts=`./ar-lib ./lib d foo.lib foo.obj`
71 test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
72
73 # Check if ar-lib can delete members in an @FILE
74 echo foo.obj > foolist
75 opts=`./ar-lib ./lib d foo.lib @foolist`
76 test x"$opts" = x"lib -NOLOGO -REMOVE:foo.obj foo.lib"
77
78 # Check if ar-lib can list archive members with "t"
79 opts=`./ar-lib ./lib t foo.lib`
80 test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
81
82 # Check if ar-lib accepts "v" as a modifier.
83 # NOTE: "v" should have an effect, but currently doesn't.
84 opts=`./ar-lib ./lib tv foo.lib`
85 test x"$opts" = x"lib -NOLOGO -LIST foo.lib"
86
87 # Check if ar-lib can extract archive members with "x"
88 touch fake.lib
89 opts=`./ar-lib ./lib x fake.lib`
90 test x"$opts" = x"lib -NOLOGO -EXTRACT:fake.obj fake.lib"
91
92 # Check if ar-lib can extract specified archive members with "x"
93 opts=`./ar-lib ./lib x foo.lib foo.obj`
94 test x"$opts" = x"lib -NOLOGO -EXTRACT:foo.obj foo.lib"
95
96 # Check if ar-lib can extract members in an @FILE
97 opts=`./ar-lib ./lib x foo.lib @foolist`
98 test x"$opts" = x"lib -NOLOGO -EXTRACT:foo.obj foo.lib"
99
100 # Check if ar-lib passes -lib and -LTCG through to the wrappee
101 opts=`./ar-lib ./lib -lib -LTCG x foo.lib foo.obj`
102 test x"$opts" = x"lib -lib -LTCG -NOLOGO -EXTRACT:foo.obj foo.lib"
103
104 # Check if ar-lib can extract backslashed members
105 touch fake2.lib
106 opts=`./ar-lib ./lib x fake2.lib`
107 test x"$opts" = x"lib -NOLOGO -EXTRACT:dir\\fake2.obj fake2.lib"
108
109 # Check if ar-lib accepts "s" as an action.
110 opts=`./ar-lib ./lib s foo.lib`
111 test x"$opts" = x
112
113 :