summaryrefslogtreecommitdiff
path: root/tests/rpmquery.at
blob: 5a7470f7e5a282326cf756e40cac7a63bcfe67f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#    rpmquery.at: test rpmquery
#
#    Copyright (C) 2007  Ralf Corsépius <corsepiu@fedoraproject.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program 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 General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

AT_BANNER([RPM queries])

# ------------------------------
AT_SETUP([rpm --qf -p *.i386.rpm])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  -q --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" \
  -p /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[hello-1.0-1.i386
],
[ignore])
AT_CLEANUP

# ------------------------------
AT_SETUP([rpm --qf -p *.src.rpm])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  -q --qf "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n" \
  -p /data/SRPMS/hello-1.0-1.src.rpm
],
[0],
[hello-1.0-1.i386
],
[ignore])
AT_CLEANUP

# ------------------------------
AT_SETUP([rpm -ql -p *.src.rpm])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  -ql \
  -p /data/SRPMS/hello-1.0-1.src.rpm
],
[0],
[hello-1.0.tar.gz
hello.spec
],
[ignore])
AT_CLEANUP

# ------------------------------
AT_SETUP([rpmspec -q])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpmspec \
  -q --qf "%{name}" /data/SPECS/hello.spec
],
[0],
[hello],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([rpm -ql -p *.i386.rpm])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  -ql \
  -p /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[/usr/local/bin/hello
/usr/share/doc/hello-1.0
/usr/share/doc/hello-1.0/FAQ
],
[ignore])
AT_CLEANUP

# ------------------------------
# Test query on manifest
AT_SETUP([rpm -qp <manifest>])
AT_KEYWORDS([query])
AT_CHECK([
cat << EOF > ${RPMTEST}/query.mft
/data/RPMS/hello-1.0-1.i386.rpm
/data/RPMS/hello-1.0-1.ppc64.rpm
/data/RPMS/foo-1.0-1.noarch.rpm
EOF
runroot rpm -qp --qf "%{nvr}\n" /query.mft
],
[0],
[hello-1.0-1
hello-1.0-1
foo-1.0-1
],
[])
AT_CLEANUP

# ------------------------------
# Try to check "scripts"
# * Gets rpmpopt-$(VERSION) involved
AT_SETUP([rpm -q --scripts -p *.i386.rpm])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  -q --scripts \
  -p /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[preinstall program: /bin/sh
postinstall program: /bin/sh
preuninstall program: /bin/sh
postuninstall program: /bin/sh
],
[ignore])
AT_CLEANUP


# ------------------------------
# install a package into a local rpmdb
# * Shall only work with relocation
# * Use --ignorearch because we don't know the arch
AT_SETUP([rpm -q on installed package])
AT_KEYWORDS([rpmdb install query])

AT_CHECK([
RPMDB_CLEAR
RPMDB_INIT

runroot rpm \
  --noscripts --nodeps --ignorearch --relocate=/usr=/check \
  -i /data/RPMS/hello-1.0-1.ppc64.rpm
],
[0])

# check common NVRA combinations
AT_CHECK([
runroot rpm \
  -q hello hello-1.0 hello-1.0-1 \
     hello.ppc64 hello-1.0.ppc64 hello-1.0-1.ppc64 
],
[0],
[hello-1.0-1.ppc64
hello-1.0-1.ppc64
hello-1.0-1.ppc64
hello-1.0-1.ppc64
hello-1.0-1.ppc64
hello-1.0-1.ppc64
],
[ignore])


AT_CHECK([
runroot rpm \
  -ql hello
],
[0],
[/check/local/bin/hello
/check/share/doc/hello-1.0
/check/share/doc/hello-1.0/FAQ
],
[ignore])

AT_CLEANUP

# ------------------------------
AT_SETUP([integer array query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="[[%{filemodes}\n]]" \
  -qp /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[33257
16877
33188
],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([formatted filesbypkg query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="[[%-10{=NAME} %{FILENAMES}\n]]" \
  -qp /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[hello      /usr/local/bin/hello
hello      /usr/share/doc/hello-1.0
hello      /usr/share/doc/hello-1.0/FAQ
],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([hex formatted integer array extension query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="[[%5{longfilesizes:hex}\n]]" \
  -qp /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[  b40
 1000
   24
],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([base64 extension query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="%{pkgid:base64}" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[qt8W635v5FKy1pILrW+0uw==
],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([integer array perms format query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="[[%{filemodes:perms}\n]]" \
  -qp /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[-rwxr-x--x
drwxr-xr-x
-rw-r--r--
],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([string array query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="[[%{basenames} ]]" \
  -qp /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[hello hello-1.0 FAQ ],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([empty string array query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="[[%{basenames}]]" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([empty string array extension array format])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="[[%{filenames}]]" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([empty string array extension query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="%{filenames}" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[(none)],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([different sizes arrays query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="[[%{basenames} %{changelogname}]]" \
  -qp /data/RPMS/hello-1.0-1.i386.rpm
],
[0],
[],
[error: incorrect format: array iterator used with different sized arrays
])
AT_CLEANUP

# ------------------------------
AT_SETUP([non-existent string tag])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="%{vendor}" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[(none)],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([non-existent integer tag query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="%{installcolor}" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[(none)],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([conditional queryformat])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="%|name?{%{name}}:{no}| %|installtime?{%{installtime}}:{(not installed)}|" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[foo (not installed)],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([invalid tag query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="%{notag}" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[],
[error: incorrect format: unknown tag
])
AT_CLEANUP

# ------------------------------
AT_SETUP([invalid data for format query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="%{name:depflags}" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[(not a number)],
[])
AT_CLEANUP

# ------------------------------
AT_SETUP([invalid format width query])
AT_KEYWORDS([query])
AT_CHECK([
runroot rpm \
  --queryformat="%ss{size}" \
  -qp /data/RPMS/foo-1.0-1.noarch.rpm
],
[0],
[],
[error: incorrect format: invalid field width
])
AT_CLEANUP