/
winetricks-test
executable file
·830 lines (715 loc) · 27 KB
/
winetricks-test
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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
#!/bin/sh
# Regression test for winetricks
#
# Copyright (C) 2010-2014 Dan Kegel
# Copyright (C) 2011-2017 Austin English
# See also copyright notice in src/winetricks.
#
# This software comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the GNU Lesser
# Public License version 2.1 (or later), as published by the Free
# Software Foundation. Please see the file COPYING for details.
# Requires wine >= 2.8 (https://bugs.winehq.org/show_bug.cgi?id=37811)
# TODO:
# add selfupdate tests
# automate non -q verbs with autohotkey
# Override this if you want to put the work area on a different disk
WINE_PREFIXES=${WINE_PREFIXES:-$HOME/winetrickstest-prefixes}
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
cache="$XDG_CACHE_HOME/winetricks"
#set -e
set -x
if [ -f src/winetricks ] ; then
TOP="$PWD"
shwinetricks="${PWD}/src/winetricks"
elif [ -f ../src/winetricks ] ; then
# realpath isn't available on OSX, use a subshell instead:
TOP="$(cd .. && echo "$PWD")"
shwinetricks="${TOP}/src/winetricks"
elif [ -f ../../src/winetricks ] ; then
# realpath isn't available on OSX, use a subshell instead:
TOP="$(cd ../.. && echo "$PWD")"
shwinetricks="${TOP}/src/winetricks"
else
echo "Running from unknown directory. Exiting"
exit 1
fi
# Start with a fresh output dir each time:
outputdir="${TOP}/output"
rm -rf "${outputdir}"
mkdir -p "${outputdir}"
# Workaround for:
# kcov has trouble with forking shell scripts
# https://github.com/SimonKagstrom/kcov/issues/64
# https://github.com/SimonKagstrom/kcov/issues/165
# check-deps checks for time/cabextract, but doesn't invoke winetricks so we don't care about it for coverage
# If the below code runs, it creates an empty 'kcov-results' dir in the root directory. So, bail out here:
if [ "$1" = "check-deps" ] ; then
true
# Using an environmental variable rather than a CLI option
# so it doesn't need extra handling/targets in Makefile
elif [ -n "$WINETRICKS_ENABLE_KCOV" ] ; then
KCOV_RESULTS="${outputdir}/kcov-results"
rm -rf "$KCOV_RESULTS"
mkdir -p "$KCOV_RESULTS"
# kcov --kcov-options output-dir testscript --test-script-args
# I think kcov lets you append results, if not we may have to use separate for each invocation then combine at the end
# It seems to be capping out at 468 lines for me. Mentioned on their github here:
# https://github.com/SimonKagstrom/kcov/issues/165
# Previously, winetricks-test used `$WINETRICKS`. That fails for kcov, which
# then tracks bash itself and not winetricks. `${shwinetricks}` works fine.
WINETRICKS="kcov --configure=bash-use-basic-parser=1 $KCOV_RESULTS \"${shwinetricks}\""
#WINETRICKS="kcov --configure=bash-use-basic-parser=1 $KCOV_RESULTS-$(date +%k-%M-%S) \"${shwinetricks}\""
else
WINETRICKS="${shwinetricks}"
fi
# Disable winetricks update checks:
WINETRICKS_LATEST_VERSION_CHECK=disabled
export WINETRICKS_LATEST_VERSION_CHECK
# Disable some verbose output that makes parsing harder:
WINETRICKS_SUPER_QUIET=1
export WINETRICKS_SUPER_QUIET
# verbs known to not work in -q mode yet
BLACKLIST="dx8sdk|kde|psdk2003|psdkwin7"
# verbs that hang in -q because of simple problem we should work around soon
BLACKLIST="$BLACKLIST|vc2005trial"
# verbs that are too slow
BLACKLIST="$BLACKLIST|bfbc2|dxsdk_nov2006|dxsdk_jun2010"
# steam verbs I don't have
BLACKLIST="$BLACKLIST|borderlands|supermeatboy|trine"
# broken http://bugs.winehq.org/show_bug.cgi?id=26411:
BLACKLIST="$BLACKLIST|mfsxde|mfsx_demo"
# hang lately, probably ui changes in install process
BLACKLIST="$BLACKLIST|bioshock2"
# broken/flaky, http://bugs.winehq.org/show_bug.cgi?id=26016
BLACKLIST="$BLACKLIST|xmllite"
# redundant metaverbs
BLACKLIST="$BLACKLIST|allcodecs"
# https://bugs.winehq.org/show_bug.cgi?id=16876
BLACKLIST="$BLACKLIST|wmi"
# Travis CI is apparently blocking archive.org, which breaks several verbs:
# https://github.com/travis-ci/travis-ci/issues/6798
# Blacklist those verbs on those hosts:
# FIXME: setup another test target for torify, use it to d/l these?
ARCHIVE_ORG_BLACKLIST="atmlib|avifil32|cabinet|cmd|comctl32ocx|comdgl32ocx|gmdls|mdac27|mfc40|msflxgrd|mshflxgd"
ARCHIVE_ORG_BLACKLIST="$ARCHIVE_ORG_BLACKLIST|msls31ms|msmask|msscript|msxml3|pdh|pngfilt|riched30"
ARCHIVE_ORG_BLACKLIST="$ARCHIVE_ORG_BLACKLIST|richtx32|secur32|tabctl32|usp10|"
# See https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
if [ "$TRAVIS" = "true" ] ; then
BLACKLIST="$ARCHIVE_ORG_BLACKLIST|$BLACKLIST"
fi
# Tests that fail under Xvfb
XVFB_DOTNET_BLACKLIST="dotnet11|dotnet11sp1|dotnet20|dotnet20sdk|dotnet20sp1|dotnet30|dotnet40|dotnet46"
XVFB_BLACKLIST="$XVFB_DOTNET_BLACKLIST|adobeair|binkw32|dirac|directmusic|dxdiag|flash|gdiplus_winxp|gfw|ie6|ie7|ie8"
XVFB_BLACKLIST="$XVFB_BLACKLIST|jet40|nuget|quicktime72|vcrun2008|vcrun2010|vcrun2012|vcrun2013|vcrun2015"
XVFB_BLACKLIST="$XVFB_BLACKLIST|vjrun20|windowscodecs|wmi|wmp9|wmp10|wsh56js|wsh56vb|xmllite|xna31|xna40|xvid"
# Verbs known to update frequently
QUICKCHECK="flash steam"
failed_verbs=""
passes=0
errors=0
skips=0
# Check for programs this script (or winetricks) uses.
# Better to find out they're missing now than in the
# middle of a two day run.
check_deps() {
for tool in time cabextract; do
command -v "$tool"
ret=$?
if [ ! $ret -eq 0 ] ; then
echo "Please install $tool."
exit 1
fi
done
}
fail()
{
echo "FAIL: $*"
failed_verbs="${failed_verbs}|$*"
errors=$((errors + 1))
}
pass()
{
echo "PASS: $*"
passes=$((passes + 1))
}
skip()
{
echo "SKIP: $*"
skips=$((skips + 1))
was_skipped=1
}
w_die()
{
echo "$*"
exit 1
}
w_time()
{
# OSX time doesn't support -o, so try it first:
if ! /usr/bin/time -o "${outputdir}/test.log" echo test > /dev/null 2>&1; then
/usr/bin/time -p "$@"
else
/usr/bin/time -p -o "${outputdir}/time.log" "$@"
fi
}
case "$LANG" in
""|"C") echo "Some games won't install in the Posix locale; doing 'export LANG=en_US.UTF-8'" ; export LANG=en_US.UTF-8;;
esac
case "$OS" in
"Windows_NT")
# Mostly unimplemented...
# Cheezy fix for getting rid of double slashes when running cygwin in wine
case "$HOME" in
/) HOME="" ;;
esac
WINE=""
WINESERVER=true
#DRIVE_C="C:/"
;;
*)
export WINE=${WINE:-wine}
# Find wineserver. Some distros (Debian) don't have it on the path,
# on the mistaken understanding that user scripts never need it :-(
# If wineserver is from wine-development set WINE to wine-development.
# FIXME: get packagers to put wineserver on the path.
for x in \
"$WINESERVER" \
"${WINE}server" \
"$(command -v wineserver 2> /dev/null)" \
"$(dirname $WINE)/server/wineserver" \
/usr/lib/wine/wineserver \
/usr/lib/i386-kfreebsd-gnu/wine/wineserver \
/usr/lib/i386-linux-gnu/wine/wineserver \
/usr/lib/powerpc-linux-gnu/wine/wineserver \
/usr/lib/i386-kfreebsd-gnu/wine/bin/wineserver \
/usr/lib/i386-linux-gnu/wine/bin/wineserver \
/usr/lib/powerpc-linux-gnu/wine/bin/wineserver \
/usr/lib/x86_64-linux-gnu/wine/bin/wineserver \
/usr/lib/i386-kfreebsd-gnu/wine-development/wineserver \
/usr/lib/i386-linux-gnu/wine-development/wineserver \
/usr/lib/powerpc-linux-gnu/wine-development/wineserver \
/usr/lib/x86_64-linux-gnu/wine-development/wineserver \
file-not-found
do
if [ -x "$x" ] ; then
case "$x" in
/usr/lib/*/wine-development/wineserver)
if [ -x /usr/bin/wine-development ] ; then
WINE="/usr/bin/wine-development"
fi
;;
esac
break
fi
done
case "$x" in
file-not-found) w_die "wineserver not found!" ;;
*) WINESERVER="$x" ;;
esac
;;
esac
test_speed()
{
# shellcheck disable=SC2086
if ! w_time $XVFB $WINETRICKS nocrashdialog "$1" > "${outputdir}/foo.log"; then
fail "winetricks $1 returned status $?"
fi
# shellcheck disable=SC2046
if [ $(wc -l < "${outputdir}/foo.log") -lt 5 ] ; then
fail "winetricks $1 returned too few lines"
fi
if [ ! -f time.log ] ; then
# OSX, fake it:
seconds=0
else
seconds=$(awk '/real/ {print $2}' < "${outputdir}/time.log" | sed 's/\..*//')
fi
echo "test_speed: winetricks $1 took $seconds seconds"
# Longest runtime as of 11 Dec 2010 is 5 seconds on an e8400 with cygwin
# shellcheck disable=SC2086
if [ $seconds -gt 7 ] ; then
fail "test_speed: winetricks $1 took $seconds seconds"
fi
}
# test win32 7-zip fallback
test_7zip()
{
# 7z
WINETRICKS_FORCE_WIN_7Z=1 test_command --verify comctl32ocx
# ar
WINETRICKS_FORCE_WIN_7Z=1 test_command --verify opensymbol
# rar
# FIXME: protectionid requires a manual download, and the only other user is avatar_demo
#WINETRICKS_FORCE_WIN_7Z=1 test_command --verify protectionid
# zip
WINETRICKS_FORCE_WIN_7Z=1 test_command --verify vb2run
}
# Return the number of blocks available in the system
total_df()
{
df | grep -v /dev/loop | awk '/^\// { sum += $4 } END { print sum }'
}
# for single apps, wrapper around test_command:
test_app()
{
app=$1
was_skipped=0
# Watch transient disk space
DF_START=$(total_df)
if [ -d "$W_CACHE/$app" ] ; then
DU_CACHE_START=$(du -s "$W_CACHE/$app" | awk '{print $1}')
else
DU_CACHE_START=0
fi
touch "${outputdir}/df-daemon"
(set +x; while test -f "${outputdir}/df-daemon"; do total_df; sleep 1; done ) > "${outputdir}/df-during.log" &
test_command --verify "$app"
if [ $was_skipped = 1 ]; then
skip "post-install file check for skipped verb $app"
else
# Post install:
# Don't check whether metaverbs are installed
case "$app" in
allcodecs) ;;
*)
# if test was skipped because of wrong arch, don't check for it:
if [ "$archskip" = "1" ]; then
skip "$app was skipped because of wrong prefix arch!"
return
fi
# no xvfb needed
"${shwinetricks}" -q list-installed > "${outputdir}/list-installed.out"
if ! grep -w "$app" "${outputdir}/list-installed.out"; then
fail "test app $app not installed after install?"
fi
;;
esac
# Cleanup..
echo "rm ${outputdir}/df-daemon"
rm "${outputdir}/df-daemon"
# Total max disk usage = max df change plus any initial blocks in cache
DF_MIN=$(awk '{ if (min == "" || $1 < min) min=$1; } END {printf "%d\n", min}' < "${outputdir}/df-during.log" )
DF_DIFF=$((DF_START - DF_MIN))
TOTAL=$((DF_DIFF + DU_CACHE_START))
echo "test_app: ${app}: max_disk $TOTAL blocks."
TOTAL_MB=$((TOTAL / 1024))
mkdir -p "${outputdir}/measurements"
echo "${app}:size_MB=${TOTAL_MB},time_sec=${seconds}" >> "${outputdir}/measurements/$app.dat"
# Cleanup the prefix, unless $W_OPT_NOCLEAN is set to 1 (to match winetricks):
if [ "$W_OPT_NOCLEAN" = "1" ]; then
echo "W_OPT_NOCLEAN set to 1, not removing wineprefix $WINEPREFIX"
else
echo "Removing wineprefix $WINEPREFIX"
# FIXME: for some reason, steam doesn't clean up. $WINESERVER -k doesn't help either
rm -rf "$WINEPREFIX"
fi
fi
}
test_command()
{
archskip=0
command="$*"
# This previously changed spaces to hyphens. Going back to spaces so we test WINEPREFIXes
# with special characters, to prevent issues like https://github.com/Winetricks/winetricks/issues/995
export WINEPREFIX="$WINE_PREFIXES/${command}"
#DRIVE_C="$WINEPREFIX/dosdevices/c:"
# always use a clean $WINEPREFIX
if [ -d "$WINEPREFIX" ] ; then
rm -rf "$WINEPREFIX"
fi
# Isolate us from the user's home directory
# shellcheck disable=SC2086
$XVFB $WINETRICKS sandbox || fail "\'$XVFB $WINETRICKS sandbox\' failed"
echo "Installing $command"
# shellcheck disable=SC2086
$XVFB $WINETRICKS --no-isolate -q nocrashdialog "$@"
return=$?
if [ -d "$WINEPREFIX/drive_c/windows/syswow64" ]; then
WINEARCH="win64"
else
WINEARCH="win32"
fi
if [ "$return" = "32" ] && [ "$WINEARCH" != "win32" ]; then
skip "$command is not supported on $WINEARCH, requires win32"
archskip=1
return
elif [ "$return" = "64" ] && [ "$WINEARCH" != "win64" ]; then
skip "$command is not supported on $WINEARCH, requires win64"
archskip=1
return
fi
if [ "$EXPECT_FAIL" = "yes" ] ; then
# A success is failure:
if [ "$return" = "0" ] ; then
fail "$command succeeded, should have failed"
else
pass "test_command $command expected to fail, and did fail!"
fi
else
if [ "$return" = "0" ] ; then
pass "$@"
else
fail "$@"
fi
fi
if [ ! -f time.log ] ; then
seconds=0
else
seconds=$(awk '/real/ {print $2}' < time.log | sed 's/\..*//')
fi
echo "test_app: ${app}: install_time $seconds seconds."
echo "Checking for dangling processes!"
# shellcheck disable=SC2009
ps augxw | grep \\.exe
"$WINESERVER" -w
echo "Wineserver done."
}
test_custom_verbs()
{
# Custom .verb support isn't commonly used, and may break without notice for a while
# Also try with --isolate:
# https://github.com/Winetricks/winetricks/issues/599
# Test as apps first, then dll, since they take different codepaths
# First, a working 'app' as an app:
cat > "${outputdir}/true.verb" <<_EOF
w_metadata true apps
load_true()
{
echo "true should succeed"
/bin/true
}
_EOF
# Next, a broken 'app' as an app:
cat > "${outputdir}/false.verb" <<_EOF
w_metadata false apps
load_false()
{
echo "false should fail"
false
}
_EOF
# no xvfb needed
$WINETRICKS --no-isolate "${outputdir}/true.verb" ; ret=$?
case $ret in
0) pass "${outputdir}/true.verb not isolated, as apps passed" ;;
*) fail "${outputdir}/true.verb not isolated, as apps failed" ;;
esac
# no xvfb needed
$WINETRICKS --no-isolate "${outputdir}/false.verb" ; ret=$?
case $ret in
0) fail "false.verb not isolated, as apps worked, should have failed" ;;
1) pass "false.verb not isolated, as apps passed" ;;
*) fail "false.verb not isolated, as apps failed in unexpected way" ;;
esac
# no xvfb needed
$WINETRICKS --isolate "${outputdir}/true.verb" ; ret=$?
case $ret in
0) pass "${outputdir}/true.verb isolated, as apps passed" ;;
*) fail "${outputdir}/true.verb isolated, as apps failed" ;;
esac
# no xvfb needed
$WINETRICKS --isolate "${outputdir}/false.verb" ; ret=$?
case $ret in
0) fail "${outputdir}/false.verb isolated, as apps worked, should have failed" ;;
1) pass "${outputdir}/false.verb isolated, as apps passed" ;;
*) fail "${outputdir}/false.verb isolated, as apps failed in unexpected way" ;;
esac
# Repeat as dll:
# First, a working 'app' as a dll:
cat > "${outputdir}/true.verb" <<_EOF
w_metadata true dlls
load_true()
{
echo "true should succeed"
true
}
_EOF
# Next, a broken 'app' as a dll:
cat > "${outputdir}/false.verb" <<_EOF
w_metadata false dlls
load_false()
{
echo "false should fail"
false
}
_EOF
# no xvfb needed
$WINETRICKS --no-isolate "${outputdir}/true.verb" ; ret=$?
case $ret in
0) pass "true.verb isolated, as dlls passed" ;;
*) fail "true.verb isolated, as dlls failed" ;;
esac
# no xvfb needed
$WINETRICKS --no-isolate "${outputdir}/false.verb" ; ret=$?
case $ret in
0) fail "${outputdir}/false.verb isolated, as dlls worked, should have failed" ;;
1) pass "${outputdir}/false.verb isolated, as dlls passed" ;;
*) fail "${outputdir}/false.verb isolated, as dlls failed in unexpected way" ;;
esac
# no xvfb needed
$WINETRICKS --no-isolate "${outputdir}/true.verb" ; ret=$?
case $ret in
0) pass "${outputdir}/true.verb isolated, as dlls passed" ;;
*) fail "${outputdir}/true.verb isolated, as dlls failed" ;;
esac
# no xvfb needed
$WINETRICKS --no-isolate "${outputdir}/false.verb" ; ret=$?
case $ret in
0) fail "${outputdir}/false.verb isolated, as dlls worked, should have failed" ;;
1) pass "${outputdir}/false.verb isolated, as dlls passed" ;;
*) fail "${outputdir}/false.verb isolated, as dlls failed in unexpected way" ;;
esac
rm "${outputdir}/false.verb" "${outputdir}/true.verb"
pass
}
test_dlls()
{
# no xvfb needed, kcov breaks
"${shwinetricks}" list-manual-download > "${outputdir}/manual.log"
"${shwinetricks}" dlls list | awk '{print $1}' > "${outputdir}/dlls.log"
if grep .------------------- "${outputdir}/dlls.log" ; then
fail "output of dlls list contained garbage"
exit 1
fi
sort -u < "${outputdir}/dlls.log" | grep -F -w -v -f "${outputdir}/manual.log" | grep -E -v "$BLACKLIST" > "${outputdir}/dlls.verbs"
if [ ! -f "${outputdir}/dlls.verbs" ] ; then
w_die "${outputdir}/dlls.verbs doesn't exist? No verbs to test!"
elif [ -f "${outputdir}/dlls.verbs" ] && [ ! -s "${outputdir}/dlls.verbs" ] ; then
w_die "${outputdir}/dlls.verbs exists, but it is empty"
else
echo "Testing these verbs:"
cat "${outputdir}/dlls.verbs"
fi
while IFS= read -r line; do
test_app "$line"
done < "${outputdir}/dlls.verbs"
}
test_dotnet()
{
# verify that each individual installer works:
for x in dotnet11 dotnet11sp1 \
dotnet20 dotnet20sp1 dotnet20sp2 \
dotnet30 dotnet30sp1 dotnet35 dotnet35sp1 \
dotnet40 dotnet45 dotnet452 dotnet46 dotnet461 dotnet462 dotnet472; do
echo "testing $x"
test_command --verify $x
done
# FIXME: add other possible combinations
# combinations that should work:
for combo in "dotnet20 dotnet20sp2"; do
# shellcheck disable=SC2086
test_command --verify $combo
done
# combinations that should break:
for fail_combo in "dotnet11 dotnet20"; do
# shellcheck disable=SC2086
EXPECT_FAIL=yes test_command $fail_combo
done
}
test_install_cached_or_download()
{
# no xvfb needed, kcov breaks
"${shwinetricks}" list-cached list-download > "${outputdir}/ticd.log"
if grep .------------------- ticd.log ; then
fail "output of list-cached list-download contained garbage"
exit 1
fi
sort -u < ticd.log | grep -E -v "$BLACKLIST" > ticd.verbs
if true ; then
# Split into two, only do half
nverbs=$(wc -l < ticd.verbs )
firsthalf=$((nverbs / 2 + 1))
sed "${firsthalf}"',$d' < ticd.verbs > ticd-1.verbs
sed '1,'"${firsthalf}"d < ticd.verbs > ticd-2.verbs
VERBS=$(cat ticd-1.verbs)
else
VERBS=$(cat ticd.verbs)
fi
for a in $VERBS; do
test_app "$a"
done
# no xvfb needed, kcov breaks
"${shwinetricks}" list-cached | sort > cached.txt
# Verbs that are just wrappers around others don't detect cache/install state yet.
# Verbs that are just informative placeholders don't ever download (gecko).
# And some verbs (gecko110) don't usually install for other reasons.
BLACKLIST_CACHE="allfonts|cjkfonts|allcodecs|gecko|gecko110|fontfix"
grep -E -vw "$BLACKLIST_CACHE" ticd.verbs > download.txt
comm -23 download.txt cached.txt > download-but-not-cached.txt
echo "Supposedly downloadable"
cat download.txt
echo "Cached"
cat cached.txt
echo "Downloadable but not cached"
cat download-but-not-cached.txt
# shellcheck disable=SC2046
if [ $(wc -l < download-but-not-cached.txt) != 0 ] ; then
fail "test_install_cached_or_download: asked to install all downloadable apps, but some not listed as cached afterwards"
cat download-but-not-cached.txt
fi
}
test_quick()
{
echo "warning: quick test takes up around 20GB"
# Test the frequent download-changes-checksum offenders first
export W_CACHE="$cache"
for a in $QUICKCHECK; do
# shellcheck disable=SC2115
rm -rf "$WINE_PREFIXES/$a"
test_app "$a"
done
# And test all the automatically-downloadable dlls
test_dlls
# And win32 7zip fallback
test_7zip
}
test_full() {
test_quick
test_dotnet
test_speed list
test_speed list-download
#test_install_cached_or_download
test_speed list-cached
test_speed list-installed
test_custom_verbs
test_w_compare_wine_version
}
test_xvfb() {
if ! command -v xvfb-run 2>/dev/null; then
w_die "Please install xvfb-run for xvfb tests"
fi
BLACKLIST="$BLACKLIST|$XVFB_BLACKLIST"
export BLACKLIST
# Not test_quick() since flash fails without proper X, but test_quick() doesn't respect $BLACKLIST
# Also, we don't really want to duplicate those tests twice, as this is for TravisCI where time is limited..
test_dlls
}
helper_test_w_compare_wine_version()
{
version="$1" # version we're pretending to be (e.g., wine-2.0)
comparison="$2" # the comparison to make (e.g., ',1.8', '1.9,', or '1.8,1.9')
workaround_expected="$3" # should the workaround be executed (yes/no)
WINETRICKS_WINE_VERSION="$version"
export WINETRICKS_WINE_VERSION
if [ "${workaround_expected}" = "yes" ] ; then
cat > "${outputdir}/test_version.verb" <<_EOF
w_metadata test_version settings
load_test_version()
{
# FIXME: w_info/w_die aren't getting through b/c of QUIET? stop using quiet everywhere..
if w_workaround_wine_bug 99999 "test" "$comparison" ; then
w_info "Using w_workaround, expected, version: $WINETRICKS_WINE_VERSION"
else
w_die "Not using w_workaround, unexpected, version: $WINETRICKS_WINE_VERSION"
fi
}
_EOF
elif [ "${workaround_expected}" = "no" ] ; then
cat > "${outputdir}/test_version.verb" <<_EOF
w_metadata test_version settings
load_test_version()
{
if w_workaround_wine_bug 99999 "test" "$comparison" ; then
w_die "Using w_workaround, unexpected, version: $WINETRICKS_WINE_VERSION"
else
w_info "Not using w_workaround, expected, version: $WINETRICKS_WINE_VERSION"
fi
}
_EOF
else
w_die "unknown value ${workaround_expected}!"
fi
# no xvfb needed
$WINETRICKS -v --no-isolate "${outputdir}/test_version.verb" ; ret=$?
case $ret in
0) pass "test_version.verb (version: $version comparison: $comparison expected: $workaround_expected passed" ;;
*) fail "test_version.verb (version: $version comparison: $comparison expected: $workaround_expected failed" ;;
esac
}
test_w_compare_wine_version()
{
# Previous code was very fragile, and had no regression tests.
# Now that we can override reported Wine version with $WINETRICKS_WINE_VERSION, easier to test using some custom verbs
# val1, (for >= val1)
# ,val2 (for <= val2)
# val1,val2 (for >= val1 && <= val2)
# helper_test_w_compare_wine_version() {
# version="$1" # version we're pretending to be (e.g., wine-2.0)
# comparison="$2" # the comparison to make (e.g., ',1.8', '1.9,', or '1.8,1.9')
# workaround_expected="$3" # should the workaround be executed (yes/no)
helper_test_w_compare_wine_version "wine-2.0" ",1.6" "no"
helper_test_w_compare_wine_version "wine-2.0" ",1.4" "no"
helper_test_w_compare_wine_version "wine-2.0" "1.4,1.6" "no"
helper_test_w_compare_wine_version "wine-1.6" "1.4,2.0" "yes"
helper_test_w_compare_wine_version "wine-1.0" "1.8.0," "no"
helper_test_w_compare_wine_version "wine-1.0" ",1.8.0" "yes"
helper_test_w_compare_wine_version "wine-1.3" ",1.2" "no"
helper_test_w_compare_wine_version "wine-1.3" "1.2," "yes"
helper_test_w_compare_wine_version "wine-1.3.4" ",1.2" "no"
helper_test_w_compare_wine_version "wine-1.3.4" "1.2," "yes"
helper_test_w_compare_wine_version "wine-1.6" ",1.2" "no"
helper_test_w_compare_wine_version "wine-1.6" ",1.2" "no"
helper_test_w_compare_wine_version "wine-1.6" "1.2," "yes"
helper_test_w_compare_wine_version "wine-1.6-rc1" ",1.2" "no"
helper_test_w_compare_wine_version "wine-1.6-rc1" "1.2," "yes"
helper_test_w_compare_wine_version "wine-2.0.1" ",1.8.0" "no"
helper_test_w_compare_wine_version "wine-2.0.1" "1.8.0," "yes"
helper_test_w_compare_wine_version "wine-2.0.1" ",2.0" "no"
helper_test_w_compare_wine_version "wine-2.0.1" ",2.0" "no"
helper_test_w_compare_wine_version "wine-2.0.1" "2.0," "yes"
helper_test_w_compare_wine_version "wine-2.0" ",1.8.0" "no"
helper_test_w_compare_wine_version "wine-2.0" ",1.8.0" "no"
helper_test_w_compare_wine_version "wine-2.0" "1.8.0," "yes"
helper_test_w_compare_wine_version "wine-2.0" "1.8.0," "yes"
helper_test_w_compare_wine_version "wine-2.0" ",1.8.1" "no"
helper_test_w_compare_wine_version "wine-2.0" "1.8.1," "yes"
helper_test_w_compare_wine_version "wine-2.0" ",1.8" "no"
helper_test_w_compare_wine_version "wine-2.0" "1.8," "yes"
helper_test_w_compare_wine_version "wine-2.0" ",1.9" "no"
helper_test_w_compare_wine_version "wine-2.0.1 (debian 2.0.1-r1)" ",1.8.0" "no"
helper_test_w_compare_wine_version "wine-2.0.1 (debian 2.0.1-r1)" "1.8.0," "yes"
helper_test_w_compare_wine_version "wine-2.0.1 (staging)" ",1.8.0" "no"
helper_test_w_compare_wine_version "wine-2.0.1 (staging)" "1.8.0," "yes"
helper_test_w_compare_wine_version "wine-2.0-rc1" ",1.8.0" "no"
helper_test_w_compare_wine_version "wine-2.0-rc1" ",1.8.0" "no"
helper_test_w_compare_wine_version "wine-2.0-rc1" "1.8.0," "yes"
helper_test_w_compare_wine_version "wine-3.0" ",1.8.0" "no"
helper_test_w_compare_wine_version "wine-3.0" "1.8.0," "yes"
# FIXME: there's plenty of room for more tests..
}
case "$1" in
7zip) check_deps; test_7zip;;
check-deps) check_deps ; exit $? ;;
custom-verbs) test_custom_verbs ;;
dotnet) check_deps && test_dotnet ;;
full) check_deps && test_full ;;
quick) check_deps && test_quick ;;
w_compare_wine_version) check_deps && test_w_compare_wine_version ;;
xvfb-check) check_deps && XVFB=xvfb-run && export XVFB && test_xvfb ;;
*) echo "Usage: $0 quick|full" ; exit 1 ;;
esac
# Turn off set -x so the results are cleaner:
set +x
echo "==============================================================="
echo "Test over, $errors failures, $passes successes, $skips skipped."
if [ $errors = 0 ] && [ $passes -gt 0 ] ; then
echo PASS
echo "==============================================================="
exit 0
else
echo FAIL
echo "Test failures:"
oldifs="$IFS"
IFS="|"
for test_failure in $failed_verbs; do
if [ -z "$test_failure" ]; then
:
fi
echo "$test_failure"
done
IFS=$oldifs
echo "==============================================================="
exit 1
fi