forked from AlphaPixel/3DNature
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·751 lines (639 loc) · 30.9 KB
/
pre-commit
File metadata and controls
executable file
·751 lines (639 loc) · 30.9 KB
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
#!/bin/bash
# rejects commits of UTF-8 text files.
# copy this file to .git/hooks
set -e # Abort on Errors
#set -x # show commands
################################################
# Checks, if called from git (env-variable set) or from shell (emv-variable empty)
function is_called_by_git() {
if [ -n "$GIT_PREFIX" ]; then
return 0 # yes!
else
return 1 # no
fi
}
function set_color {
local color=$1
case $color in
"brown")
echo -e '\033[0;33m'
;;
"red")
echo -e '\033[0;31m'
;;
"green")
echo -e '\033[0;32m'
;;
"reset")
echo -e '\033[0m'
;;
*)
echo -e '\033[0m' # Standardmaessig zuruecksetzen
;;
esac
}
function print_frame {
local func_name=$1
local length=${#func_name}
local border=$(printf -- '-%.0s' $(seq 1 $((length + 4))))
local color=$(set_color "brown")
local reset=$(set_color "reset")
echo -e "${color}${border}${reset}"
echo -e "${color}# $func_name #${reset}"
echo -e "${color}${border}${reset}"
}
function print_error {
local color=$(set_color "red")
local reset=$(set_color "reset")
echo -e "${color}$1${reset}"
}
function print_ok {
local color=$(set_color "green")
local reset=$(set_color "reset")
echo -e "${color}$1${reset}"
}
#################################################
# You should have an ENV-Variable LINUX_WCS_DIR=/home/developer/Desktop/WCS/
if [ -z $LINUX_WCS_DIR ]; then
echo "You should have an ENV-Variable \"export LINUX_WCS_DIR=/home/developer/Desktop/WCS/\" (points to an Amiga-WCS Installationi Dir. Will be copied into AROS.)"
print_error "Commit refused."
exit 1
fi
# You should have an ENV-Variable AROS_ALT_ABI_V0=~/Desktop/SelcoGit/alt-abiv0-linux-i386-d/
if [ -z $AROS_ALT_ABI_V0 ]; then
echo "You should have an ENV-Variable \"export AROS_ALT_ABI_V0=~/Desktop/SelcoGit/alt-abiv0-linux-i386-d/\" (points to an AROS alt-abiv0)"
print_error "Commit refused."
exit 1
fi
# You should have an ENV-Variable AROS_CORE_LINUX_X86_64=~/Desktop/SelcoGit/core-linux-x86_64-d/
if [ -z $AROS_CORE_LINUX_X86_64 ]; then
echo "You should have an ENV-Variable \"export AROS_CORE_LINUX_X86_64=~/Desktop/SelcoGit/core-linux-x86_64-d/\" (points to an AROS core-linux-x86_64-d)"
print_error "Commit refused."
exit 1
fi
# You should have an ENV-Variable AROS_CORE_LINUX_X86_64=~/Desktop/SelcoGit/core-linux-x86_64-d/
if [ -z $NATURE3D_DIR ]; then
echo "You should have an ENV-Variable \"export NATURE3D_DIR=/home/developer/Desktop/SelcoGit/3DNature/\" (points to the 3DNature dir)"
print_error "Commit refused."
exit 1
fi
function CheckTools {
# Checks, if all the used tools are available
print_frame "${FUNCNAME[0]}"
TOOLS="git grep netstat awk sshpass ssh rsync montage eog compare m68k-amigaos-gcc i386-aros-gcc x86_64-aros-gcc ack lscpu gcovr gnuplot"
for TOOL in $TOOLS; do
which $TOOL 1>/dev/null || { # we did "set -e", therefore we cannot evaluate $? as the program is exited as soon a program (which) failes. Use || instead
echo "Tool $TOOL not installed. Please install!"
print_error "Commit refused."
exit 1
}
done
print_ok "Passed."
}
function CheckNoUTF8 {
print_frame "${FUNCNAME[0]}"
FILE_LIST="$(git diff --cached --name-only)"
for FILE in $FILE_LIST; do
if [ $(file "$FILE" | grep -c "UTF-8") -ne "0" ]; then
echo "Local pre-commit hook"
echo "Error: File $FILE is UTF-8 encoded. Change that to ISO 8859-1 for Amiga and try again!"
print_error "Commit refused."
exit 1
fi
done
print_ok "Passed."
}
function CheckSimpleCat {
# check WCS.cs (SimpleCat) is ISO-8859
print_frame "${FUNCNAME[0]}"
file $NATURE3D_DIR/Amiga/WCS.cs | grep "ISO-8859"
if [ $? -ne 0 ]; then
echo "Local pre-commit hook"
echo "Error: File $FILE is not ISO-8859 encoded. Change that to ISO 8859-1 for Amiga and try again!"
print_error "Commit refused."
exit 1
fi
print_ok "Passed."
}
function CheckSshWinUAE {
#check if we can ssh to WinUAE
#We want to run test on WinUAE later below in this script after building all. Check ssh to WinUAE now and abort before wasting time on building all configurations
print_frame "${FUNCNAME[0]}"
local success=false
# Liste der moeglichen IP-Adressen
# $(netstat -rn | awk '/^[0-9]+/{ if($2!="0.0.0.0") {print $2;exit(0);}}') # shows line starting with an IP Address and Gataway != 0.0.0.0 #(works on my Dell)
# 0.0.0.0 works for BF
# af-hp works for AF HP
IP_ADDRESSES=( "172.20.56.220" "$(netstat -rn | awk '/^[0-9]+/{ if($2!="0.0.0.0") {print $2;exit(0);}}')" "af-hp" "0.0.0.0" )
if [ -n "$WINUAEIP" ]; then
# Wenn die Environment-Variable WINUAEIP in der shell gesetzt ist, nur diese IP-Adresse verwenden
echo "trying $WINUAEIP..."
if timeout 3s sshpass -p amigarulez! ssh -p 22222 ich@"$WINUAEIP" 'Ram:'; then
success=true
fi
else
# Wenn die Environment-Variable WINUAEIP nicht gesetzt war, dann durch die List der moeglichen IP-Adressen iterieren
for WINUAEIP in "${IP_ADDRESSES[@]}"; do
echo "trying $WINUAEIP..."
if timeout 2s sshpass -p amigarulez! ssh -p 22222 ich@"$WINUAEIP" 'Ram:'; then
success=true
break
fi
done
fi
# Ueberpruefen, ob das Kommando erfolgreich ausgefuehrt wurde
if [ "$success" = false ]; then
echo "Cannot ssh to WinUAE!"
echo "amigasshd -p22222 started on the Amiga?"
echo "You may also try setting WINUAEIP=<xxx.xxx.xxx.xxx> or WINUAEIP=<WinUAE-hostname> on the shell..."
print_error "Commit refused."
exit 1
fi
echo "OK, WINUAEIP=$WINUAEIP"
print_ok "Passed."
}
function BuildSASC {
#check, if WCS is still compileable with SAS/C
print_frame "${FUNCNAME[0]}"
cd $NATURE3D_DIR/Amiga/
./build_wcs_sasc.sh
if [ $? -ne 0 ]; then
echo "Local pre-commit hook"
echo "build_wcs_sasc.sh failed!"
print_error "Commit refused."
exit 1
fi
print_ok "Passed."
}
function BuildAllEclipse {
#check if all eclipse build configurations can be build
print_frame "${FUNCNAME[0]}"
cd $NATURE3D_DIR/Amiga/
./make_all_configurations.sh
if [ $? -ne 0 ]; then
echo "Local pre-commit hook"
echo "make_all_configurations.sh"
print_error "Commit refused."
exit 1
fi
print_ok "Passed."
}
function TestConvertOnWinUAE68020_Coverage {
# Run tests on WinUAE
print_frame "${FUNCNAME[0]}"
if [ -z $WINUAEIP ]; then
CheckSshWinUAE
fi
# wcs_test_68020 is build with coverage enabled.
find test_68020/ -name "*.gcda" -exec rm -f {} \; # delete old Coverage Files first
if [ ! -e "test_68020/DataOps.gcno" ]; then # check for one the gcno-Files.
print_error "${FUNCNAME[0]} not built at all or not built for coverage!"
return 1
fi
# ack is like grep but with output
# we need grep (ack) "All tests passed." at the end to get a return code
# "list test_68020" seems to be necessary to make the wcs_test_68020 program visible to the Amiga!? WCS2-issue? Worked under virtualbox/Samba on Windows7/10 perfectly. Here we need test_68020/wcs_test_68020, otherwise we get a unknown command error from the WinUAE Amiga. AF, 1.Feb25
#sshpass -p amigarulez! ssh -p 22222 ich@"$WINUAEIP" "vbox:SelcoGit/3DNature/amiga && stack 100000 && list test_68020 >NIL: && test_68020/wcs_test_68020" | ack --passthru "All tests passed."
printf "vbox:SelcoGit/3DNature/amiga\nstack 100000\nlist test_68020 >NIL:\ntest_68020/wcs_test_68020\n" >amiga_commands
sshpass -p amigarulez! sftp -P 22222 ich@"$WINUAEIP":Ram:<<< $'put amiga_commands\nbye' # bring "amiga_commands" script to RAM: (Home dir for amigasshd)
# && for multiple commands needs AmigaOS 3.2. Execute a script on the Amiga instead to be compatible with older Amiga-OS versions
sshpass -p amigarulez! ssh -p 22222 ich@"$WINUAEIP" "execute amiga_commands" | ack --passthru "All tests passed."
if [ $? -ne 0 ]; then
echo "Local pre-commit hook"
echo "test_68020/wcs_test_68020 failed!"
print_error "Commit refused."
exit 1
fi
print_ok "Passed."
}
############################################################################################################################################
function TestConvertOnArosI386 {
#Run Tests on AROS i386
print_frame "${FUNCNAME[0]}"
# Samba does not work on AROS so far (first char of all names missing), so copy all files
# copy Amiga WCS-Install-Dir for automatic testing...
# You should have an ENV-Variable for that! LINUX_WCS_DIR=/home/developer/Desktop/WCS/
rsync -avz $LINUX_WCS_DIR $AROS_ALT_ABI_V0/bin/linux-i386/AROS/WCS
# copy Build/Test-Files
mkdir -p $AROS_ALT_ABI_V0/bin/linux-i386/AROS/VBox/SelcoGit/3DNature/Amiga
rsync -avz $NATURE3D_DIR/Amiga/ $AROS_ALT_ABI_V0/bin/linux-i386/AROS/VBox/SelcoGit/3DNature/Amiga/
# create an assign VBox: to be identical with WinUAE-Tests and create a user-startup that runs our tests and exits afterwards
echo "assign VBOX: Sys:VBox" > $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "; BEGIN WCS" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "assign WCS: Sys:WCS" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "assign WCSFrames: WCS:WCSFRAMES" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "assign WCSProjects: WCS:WCSProjects" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "assign locale: VBox:SelcoGit/3DNature/Amiga add" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "; END WCS" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo ";-------------------" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "; run test tests" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "stack 100000" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "cd VBox:SelcoGit/3DNature/Amiga" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
# all stuff written to Debug: goes to the Linux console (stderr, i.e. use 2>&1)
echo "test_i386-aros/WCS_test_i386-aros > Debug:" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo ";-------------------" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo ";exit AROS when done" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
echo "shutdown" >> $AROS_ALT_ABI_V0/bin/linux-i386/AROS/S/user-startup
# now fire up AROS and let it do the tests.
pushd .
cd $AROS_ALT_ABI_V0/bin/linux-i386/AROS
Arch/linux/AROSBootstrap 2>&1 | ack --passthru "All tests passed."
if [ $? -ne 0 ]; then
echo "Local pre-commit hook"
echo "test_i386-aros/WCS_test_i386-aros failed!"
print_error "Commit refused."
exit 1
fi
popd
print_ok "Passed."
}
############################################################################################################################################
function TestConvertOnArosX86_64 {
#Run Tests on AROS x86-64
print_frame "${FUNCNAME[0]}"
# Samba does not work on AROS x86-64 so far at all, so copy all files
# copy Amiga WCS-Install-Dir for automatic testing...
# You should have an ENV-Variable for that! LINUX_WCS_DIR=/home/developer/Desktop/WCS/
rsync -avz $LINUX_WCS_DIR $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/WCS
# copy Build/Test-Files
mkdir -p $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/VBox/SelcoGit/3DNature/Amiga
rsync -avz $NATURE3D_DIR/Amiga/ $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/VBox/SelcoGit/3DNature/Amiga
# create an assign VBox: to be identical with WinUAE-Tests and create a user-startup that runs our tests and exits afterwards
echo "assign VBOX: Sys:VBox" > $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "; BEGIN WCS" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "assign WCS: Sys:WCS" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "assign WCSFrames: WCS:WCSFRAMES" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "assign WCSProjects: WCS:WCSProjects" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "assign locale: VBox:SelcoGit/3DNature/Amiga add" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "; END WCS" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo ";-------------------" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "; run test tests" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "stack 100000" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "cd VBox:SelcoGit/3DNature/Amiga" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
# all stuff written to Debug: goes to the Linux console (stderr, i.e. use 2>&1)
echo "test_x86_64-aros/WCS_test_x86_64-aros > Debug:" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo ";-------------------" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo ";exit AROS when done" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
echo "shutdown" >> $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS/S/user-startup
# now fire up AROS and let it do the tests.
pushd .
cd $AROS_CORE_LINUX_X86_64/bin/linux-x86_64/AROS
boot/linux/AROSBootstrap --config-debug=mungwall 2>&1 | ack --passthru "All tests passed."
if [ $? -ne 0 ]; then
echo "Local pre-commit hook"
echo "test_x86_64-aros/WCS_test_x86_64-aros failed!"
print_error "Commit refused."
exit 1
fi
popd
print_ok "Passed."
}
################################################################
################################################################
function RenderTest_Generic {
local LABEL=$1
local SSH_COMMAND="$2 7462847623" # magic param
local BUILDDIR=$(dirname $2)
if [ "$BUILDDIR" == "." ]; then
BUILDDIR="" # SAS/C wird im Verzeichnis "." gebaut. Damit WinUAE list ausfuehren kann, muss das durch "" ersetzt werden.
fi
local IMAGE_PREFIX=$3
local MAX_PIXEL_DIFFER=$4
if [ -z $WINUAEIP ]; then
CheckSshWinUAE
fi
# Verzeichnis vorbereiten
rm -rf $NATURE3D_DIR/Amiga/RenderTestImages
mkdir -p $NATURE3D_DIR/Amiga/RenderTestImages
# Remote-Ausfuehrung
Error=0
ErrorString=""
# "list $BASENAME" seems to be necessary to make the executable visible to WinUAE???
#echo sshpass -p amigarulez! ssh -p 22222 ich@"$WINUAEIP" "vbox:SelcoGit/3DNature/amiga && stack 100000 && list $BUILDDIR >NIL: && $SSH_COMMAND"
#sshpass -p amigarulez! ssh -p 22222 ich@"$WINUAEIP" "vbox:SelcoGit/3DNature/amiga && stack 100000 && list $BUILDDIR >NIL: && $SSH_COMMAND"
#
# && for multiple commands needs AmigaOS 3.2. Execute a script on the Amiga instead to be compatible with older Amiga-OS versions
printf "vbox:SelcoGit/3DNature/amiga\nstack 100000\nlist $BUILDDIR >NIL:\n$SSH_COMMAND\n" >amiga_commands
sshpass -p amigarulez! sftp -P 22222 ich@"$WINUAEIP":Ram: <<< $'put amiga_commands\nbye' # bring "amiga_commands" script to RAM: (Home dir for amigasshd)
sshpass -p amigarulez! ssh -p 22222 ich@"$WINUAEIP" "execute amiga_commands"
#SAS/C" "WCS_68020_SASC" "BigSasC" "ref
# Montage der Bilder
montage \
-label $LABEL $NATURE3D_DIR/Amiga/RenderTestImages/$(basename $2)_CanyonSet000 \
-label $LABEL $NATURE3D_DIR/Amiga/RenderTestImages/$(basename $2)_RMNP000 \
-label $LABEL $NATURE3D_DIR/Amiga/RenderTestImages/$(basename $2)_DemoFrame001 \
-label $LABEL $NATURE3D_DIR/Amiga/RenderTestImages/$(basename $2)_WorldTest001 \
-geometry 752x480 -tile 2x2 $IMAGE_PREFIX.png
eog $IMAGE_PREFIX.png &
# # Fehlerueberpruefung fuer jede Datei
# for file in "RMNP000" "CanyonSet000" "DemoFrame001" "WorldTest001"
# do
#
# # Fuehre den compare-Befehl aus und speichere die Ausgabe in einer Variablen
##set -x
# difference=$(compare -metric AE -fuzz 6% test_files/reference/ref_wcs2.031_$file RenderTestImages/$file null: 2>&1)
#
# # Extrahiere die Differenz von der Ausgabe (da compare Fehlerausgaben als Rueckgabewerte sendet)
# # In diesem Fall wird die Differenz auf die Standardfehlerausgabe geschrieben, daher "2>&1".
# # Die Ausgabe ist eine Zahl (die Anzahl der unterschiedlichen Pixel).
# difference_value=$(echo "$difference" | awk '/^[0-9]+/{print $1}')
#echo "differenz_value=$difference_value"
# # Vergleiche, ob die Differenz groesser als 10 ist
# if [ "$(echo "$difference_value > 0" | bc -l)" -ne 0 ]; then
#echo "Diff zu gross"
# LastError=1
# Error=$(expr $Error + $LastError)
#
# if [ $LastError -ne 0 ]; then
# ErrorString="$ErrorString $file"
# fi
#else
#echo "Diff nicht groesser 10"
# fi
##set +x
# done
#
# # Fehlerbehandlung
# if [ $Error -ne 0 ]; then
# echo "Local pre-commit hook"
# echo "$SSH_COMMAND failed ($ErrorString)!"
## echo "Commit refused."
# echo "ignored for now, test will move later."
## exit 1
# fi
echo "Done." # no print_ok as we have no check here...
}
################################################################
function RenderTest_WinUAE_SASC {
print_frame "${FUNCNAME[0]}"
RenderTest_Generic "SAS/C" "WCS_68020_SASC" "BigSasC" "ref"
}
################################################################
function RenderTest_WinUAE_68020 {
print_frame "${FUNCNAME[0]}"
RenderTest_Generic "68020" "68020/WCS_68020.unstripped" "Big68020" "ref"
}
################################################################
function RenderTest_WinUAE_68020_60 {
print_frame "${FUNCNAME[0]}"
RenderTest_Generic "68020_60" "68020-60/WCS_68020-60" "Big68020_60" "ref"
}
################################################################
function RenderTest_WinUAE_68040 {
print_frame "${FUNCNAME[0]}"
RenderTest_Generic "68040" "68040/WCS_68040" "Big68040" "ref"
}
################################################################
function RenderTest_WinUAE_68060 {
print_frame "${FUNCNAME[0]}"
RenderTest_Generic "68060" "68060/WCS_68060" "Big68060" "ref"
}
################################################################
function RenderTest_WinUAE_68020_Coverage {
print_frame "${FUNCNAME[0]}"
echo "RenderTest gcc 68020 version with coverage"
find 68020_Coverage/ -name "*.gcda" -exec rm -f {} \; # delete old Coverage Files
find . -name "*.html" -exec rm -f {} \; # delete old HTML-Files
RenderTest_Generic "68020_Coverage" "68020_Coverage/WCS_68020_Coverage" "Big68020Coverage" "ref"
# Now we have *.gcda-files in directory 68020_Coverage
# following gcov command uses all gcda files is finds in any directory, i.e. including test_68020/ (convert-data-test)
gcovr --gcov-executable=m68k-amigaos-gcov --html --html-details -o coverage.html
xdg-open coverage.html &
# and also in text form for easy comparision
# There are several warnings if I do both gcovr calls !?
gcovr --gcov-executable=m68k-amigaos-gcov | awk '{print $1 " " $2 " " $3 " " $4}' # do not print all the lines
}
################################################################
# Generische Funktion zum Render-Test auf AROS
function RenderTest_Aros {
local arch=$1
local AROS_DIR=$2
local AROS_BOOT_DIR=$3 # Arch/linux (i386 or boot/linux (x86_64)
local LINUX_WCS_DIR=$4
local NATURE3D_DIR=$5
local LABEL=$6
echo "-------------------------------"
echo "| Render-Test on AROS $arch |"
echo "-------------------------------"
# Samba funktioniert nicht, also alle Dateien manuell kopieren
rsync -avz $LINUX_WCS_DIR $AROS_DIR/AROS/WCS
# Kopiere Build/Test-Files
mkdir -p $AROS_DIR/AROS/VBox/SelcoGit/3DNature/Amiga
rsync -avz $NATURE3D_DIR/Amiga/ $AROS_DIR/AROS/VBox/SelcoGit/3DNature/Amiga
# ev. noch vorhandene alte Bilder loeschen
rm -rf $AROS_DIR/AROS/VBox/SelcoGit/3DNature/Amiga/RenderTestImages
mkdir -p $AROS_DIR/AROS/VBox/SelcoGit/3DNature/Amiga/RenderTestImages
# Erstelle ein 'assign VBox:', identisch mit WinUAE-Tests, und eine user-startup fuer die Tests
echo "assign VBOX: Sys:VBox" > $AROS_DIR/AROS/S/user-startup
echo "; BEGIN WCS" >> $AROS_DIR/AROS/S/user-startup
echo "assign WCS: Sys:WCS" >> $AROS_DIR/AROS/S/user-startup
echo "assign WCSFrames: WCS:WCSFRAMES" >> $AROS_DIR/AROS/S/user-startup
echo "assign WCSProjects: WCS:WCSProjects" >> $AROS_DIR/AROS/S/user-startup
echo "assign locale: VBox:SelcoGit/3DNature/Amiga add" >> $AROS_DIR/AROS/S/user-startup
echo "; END WCS" >> $AROS_DIR/AROS/S/user-startup
echo ";-------------------" >> $AROS_DIR/AROS/S/user-startup
echo "; run test tests" >> $AROS_DIR/AROS/S/user-startup
echo "stack 100000" >> $AROS_DIR/AROS/S/user-startup
echo "cd VBox:SelcoGit/3DNature/Amiga" >> $AROS_DIR/AROS/S/user-startup
echo "$arch-aros/WCS_${arch}-aros 7462847623 > Debug:" >> $AROS_DIR/AROS/S/user-startup
echo ";-------------------" >> $AROS_DIR/AROS/S/user-startup
echo ";exit AROS when done" >> $AROS_DIR/AROS/S/user-startup
echo "shutdown" >> $AROS_DIR/AROS/S/user-startup
# Starte AROS und fuehre die Tests aus
pushd .
cd $AROS_DIR/AROS/
$AROS_BOOT_DIR/AROSBootstrap 2>&1
popd
rm -rf WCS_${arch}-aros.png # altes Montagebild loeschen
# Montage der Bilder
montage \
-label $LABEL $AROS_DIR/AROS/VBox/SelcoGit/3DNature/Amiga/RenderTestImages/WCS_${arch}-aros_CanyonSet000 \
-label $LABEL $AROS_DIR/AROS/VBox/SelcoGit/3DNature/Amiga/RenderTestImages/WCS_${arch}-aros_RMNP000 \
-label $LABEL $AROS_DIR/AROS/VBox/SelcoGit/3DNature/Amiga/RenderTestImages/WCS_${arch}-aros_DemoFrame001 \
-label $LABEL $AROS_DIR/AROS/VBox/SelcoGit/3DNature/Amiga/RenderTestImages/WCS_${arch}-aros_WorldTest001 \
-geometry 752x480 -tile 2x2 Big_${arch}-aros.png
eog Big_${arch}-aros.png &
echo "Done." # no print_ok as we have no check here...
}
################################################################
# Funktion fuer den i386-Render-Test
function RenderTest_Aros_I386 {
print_frame "${FUNCNAME[0]}"
RenderTest_Aros i386 $AROS_ALT_ABI_V0/bin/linux-i386 Arch/linux $LINUX_WCS_DIR $NATURE3D_DIR Aros_i386
}
################################################################
# Funktion fuer den x86_64-Render-Test
function RenderTest_Aros_X86_64 {
print_frame "${FUNCNAME[0]}"
RenderTest_Aros x86_64 $AROS_CORE_LINUX_X86_64/bin/linux-x86_64 boot/linux $LINUX_WCS_DIR $NATURE3D_DIR Aros_x86_64
}
################################################################
function CheckLocaleRedfinitions {
# Check some locale messages. On SAS/C only 31 characters of macro names are relevant. (Some have manually been shorztened therefore)
print_frame "${FUNCNAME[0]}"
echo "Checking some locale strings..."
rm -rf test_locale_redefinitions.o WCS_locale.o test_locale_gcc
m68k-amigaos-gcc -noixemul test_locale_redefinitions.c WCS_locale.c -o test_locale_gcc -I .
vamos test_locale_gcc
rm -rf test_locale_redefinitions.o WCS_locale.o test_locale_sasc
vamos -q sc NOGST NOOPT NODEBUG DATA=FAR test_locale_redefinitions.c WCS_locale.c IGNORE=51
vamos -q slink LIB:c.o test_locale_redefinitions.o WCS_locale.o WITH lib:utillib.with LIB LIB:sc.lib LIB:amiga.lib TO test_locale_sasc ND
vamos test_locale_sasc
print_ok "Passed."
}
################################################################
function MakeCoverageHistoryGraph() {
COVERAGE_HISTORY_FILE=coverage_history.txt
COVERAGE_TEXT_FILE=coverage_text.txt
if is_called_by_git; then
echo "Das Skript wurde von Git aufgerufen."
git reset HEAD $COVERAGE_HISTORY_FILE # remove from staging area
git checkout -- $COVERAGE_HISTORY_FILE # set to last committed gcovr history
# store text summary
date +"%Y-%m-%d %H:%M:%S" >>$COVERAGE_TEXT_FILE
gcovr --gcov-executable=m68k-amigaos-gcov --print-summary >$COVERAGE_TEXT_FILE
git add $COVERAGE_TEXT_FILE # mark history-file for check-in
#store total percentage of covarage for gnuplot-display (only with --print-summary we get decimals like "lines: 21.5% (10134 out of 47090)"
printf "$(date +"%Y-%m-%d %H:%M:%S") $(gcovr --gcov-executable=m68k-amigaos-gcov --print-summary | awk '/^lines/{print $2"%\\n"}')" >>$COVERAGE_HISTORY_FILE # print only tolal percentage >history-file
git add $COVERAGE_HISTORY_FILE # mark history-file for check-in
else
echo "Das Skript wurde direkt von der Shell aufgerufen."
# no checkout before. During development the "local" (not commited) history is intersting, too
date +"%Y-%m-%d %H:%M:%S" >$COVERAGE_TEXT_FILE
gcovr --gcov-executable=m68k-amigaos-gcov --print-summary >>$COVERAGE_TEXT_FILE
printf "$(date +"%Y-%m-%d %H:%M:%S") $(gcovr --gcov-executable=m68k-amigaos-gcov --print-summary | awk '/^lines/{print $2"%\\n"}')" >>$COVERAGE_HISTORY_FILE # print only tolal percentage >history-file
fi
echo starte gnuplot coverage.gnuplot
gnuplot coverage.gnuplot
}
################################################################
# Funktion zum Zaehlen der unterschiedlichen Pixel
count_diff_pixels() {
compare -metric AE "$1" "$2" null: 2>&1
}
# Funktion zum Test, ob sich die Anzahl unterschiedlicher Pixel erhoeht hat
function ChangedDiffPixelCount() {
local diff_image_name=$1
local diff_image_pixelcount=$2
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # Keine Farbe
PIXEL_DIFF_GROWN="ALEXANDER"
# Reference Values for different pixels
local DiffBig68020_Big68020Coverage_cnt=8857
local DiffBig68020_Big68020_60_cnt=508335
local DiffBig68020_Big68040_cnt=506940
local DiffBig68020_Big68060_cnt=837
local DiffBig68020_BigSasC_cnt=145953
local DiffBig68020_Big_i386_aros_cnt=138759
local DiffBig68020_Big_x86_64_aros_cnt=146891
local DiffBig68020Coverage_Big68020_60_cnt=509346
local DiffBig68020Coverage_Big68040_cnt=509177
local DiffBig68020Coverage_Big68060_cnt=9330
local DiffBig68020Coverage_BigSasC_cnt=150225
local DiffBig68020Coverage_Big_i386_aros_cnt=142634
local DiffBig68020Coverage_Big_x86_64_aros_cnt=150543
local DiffBig68020_60_Big68040_cnt=4959
local DiffBig68020_60_Big68060_cnt=508461
local DiffBig68020_60_BigSasC_cnt=585652
local DiffBig68020_60_Big_i386_aros_cnt=586139
local DiffBig68020_60_Big_x86_64_aros_cnt=585958
local DiffBig68040_Big68060_cnt=507010
local DiffBig68040_BigSasC_cnt=585195
local DiffBig68040_Big_i386_aros_cnt=586021
local DiffBig68040_Big_x86_64_aros_cnt=585830
local DiffBig68060_BigSasC_cnt=145794
local DiffBig68060_Big_i386_aros_cnt=138686
local DiffBig68060_Big_x86_64_aros_cnt=146822
local DiffBigSasC_Big_i386_aros_cnt=12779
local DiffBigSasC_Big_x86_64_aros_cnt=4308
local DiffBig_i386_aros_Big_x86_64_aros_cnt=14920
# make Reference variable name from parameter diff_image_name
diff_image_cnt_name=$(echo "$diff_image_name" | sed 's/\.png/_cnt/') # replace ".png" by "_cnt"
diff_image_cnt_name=$(echo "$diff_image_cnt_name" | sed 's/-/_/g') # replace all "-" by "_"
# "${!diff_image_cnt_name}" is indirect reference to for instance $DiffBig68020Coverage-BigSasC.cnt
# i.e. we made a variable name from a string
if [ "$diff_image_pixelcount" -gt "${!diff_image_cnt_name}" ]; then # "${!diff_image_cnt_name}" is indirect reference
printf "${RED}new:old %6d > %d worse!${NC}\n" "$diff_image_pixelcount" "${!diff_image_cnt_name}"
elif [ "$diff_image_pixelcount" -lt "${!diff_image_cnt_name}" ]; then
printf "${GREEN}new:old %6d < %d improved!${NC}\n" "$diff_image_pixelcount" "${!diff_image_cnt_name}"
else # equal
printf " %6d not changed.\n" "$diff_image_pixelcount"
fi
}
function MakeDiffImages() {
DiffImagesToisplay="DiffBig68020-BigSasC.png
DiffBig68020-Big68040.png
DiffBig68020-Big68060.png
DiffBig68020-Big68020_60.png
DiffBig68020-Big_i386-aros.png
DiffBig_i386-aros-Big_x86_64-aros.png
"
rm -f DiffBig*.png
# Big68020.png Big68020_60.png Big68040.png Big68060.png
#
#
local image_directory="."
local image_files=($(ls $image_directory/Big*.png))
# Vergleiche jedes Bild mit jedem anderen Bild
for ((i=0; i<${#image_files[@]}; i++)); do
for ((j=i+1; j<${#image_files[@]}; j++)); do
image1="${image_files[i]}"
image2="${image_files[j]}"
diff_image="Diff$(basename ${image1%.*})-$(basename ${image2%.*}).png"
# Vergleiche die Bilder und speichere das Differenzbild
compare "$image1" "$image2" "$diff_image" || true
# Zeige ausgewaehlte Differenzbilder an
if echo "$DiffImagesToisplay" | grep "$diff_image" >/dev/null; then
eog "$diff_image" &
fi
# Zaehle die unterschiedlichen Pixel und gib die Anzahl aus
diff_image_pixelcount=$(count_diff_pixels "$image1" "$image2") || true
ChangedDiffPixelCountText=$(ChangedDiffPixelCount $diff_image $diff_image_pixelcount)
Images="$(basename $image1) and $(basename $image2)"
printf "Differences between %-50s: %s\n" "$Images" "$ChangedDiffPixelCountText"
if echo "$ChangedDiffPixelCountText" | grep "worse" >/dev/null; then
PIXEL_DIFF_GROWN="YES"
fi
done
done
if [ "$PIXEL_DIFF_GROWN" = "YES" ]; then
echo "Pixel differences have grown! Aborted... (ALEXANDER: pass anyway)"
# exit $(false)
fi
}
################################################################
# Wenn Parameter uebergeben wurden, fuehre die angegebenen Funktionen aus
if [ "$#" -gt 0 ]; then
for func in "$@"; do
if type "$func" &>/dev/null; then
$func
else
echo "Funktion '$func' existiert nicht!"
fi
done
else
# Wenn keine Parameter uebergeben wurden, fuehre alle Funktionen aus
CheckTools
CheckNoUTF8
CheckSimpleCat
CheckSshWinUAE
BuildSASC
BuildAllEclipse
CheckLocaleRedfinitions
TestConvertOnWinUAE68020_Coverage
TestConvertOnArosI386
TestConvertOnArosX86_64
RenderTest_WinUAE_SASC
RenderTest_WinUAE_68020
RenderTest_WinUAE_68020_60
RenderTest_WinUAE_68040
RenderTest_WinUAE_68060
RenderTest_Aros_I386
RenderTest_Aros_X86_64
RenderTest_WinUAE_68020_Coverage
MakeCoverageHistoryGraph
MakeDiffImages
fi
print_ok "Everything passed."