-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntest.ps1
More file actions
154 lines (132 loc) · 3.45 KB
/
runtest.ps1
File metadata and controls
154 lines (132 loc) · 3.45 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
$BAMS = @("bam1.exe", "bam2.exe", "bam3.exe", "bam4.exe", "bam5.exe");
$TEST_IMAGES = @(
"doom.jpg",
"degraded.png",
"newspaper.jpg",
"perf.jpg",
"truth.jpg",
"newspaper2.jpg",
"test3.jpg",
"test4.jpg",
"test5.jpg",
"test6.jpg",
"test7.jpg"
);
$OUT_IMAGES = @(
"doom",
"degraded",
"newspaper",
"perf",
"truth",
"newspaper2",
"test3",
"test4",
"test5",
"test6",
"test7"
);
##------------------------------------------------------------------------------
## Select running mode
echo "";
echo "Select mode:";
echo " 0) RUN VBAM";
echo " 1) RUN BAM";
echo " 2) TEST (TESSERACT)";
echo " 3) Copy-Debug";
echo " 4) Copy-Release";
echo " 5) CLEAN";
echo "";
[int]$mode = read-host "Running mode";
##------------------------------------------------------------------------------
## Copy
if ($mode -eq 3) {
Copy-Item .\src\Debug\* -include bam*.exe, *.dll `
-destination .\bam\
Remove-Item -Recurse -Force .\bam\vbam\
New-Item .\bam\vbam\ -itemtype directory
Copy-Item .\src\Debug\* -include vbam.exe, FreeImage.dll `
-destination .\bam\vbam\
EXIT;
}
if ($mode -eq 4) {
Copy-Item .\src\Release\* -include bam*.exe, *.dll `
-destination .\bam\
Remove-Item -Recurse -Force .\bam\vbam\
New-Item .\bam\vbam\ -itemtype directory
Copy-Item .\src\Release\* -include vbam.exe, FreeImage.dll `
-destination .\bam\vbam\
EXIT;
}
##------------------------------------------------------------------------------
## CLEAN
if ($mode -eq 5) {
Remove-Item .\bam\* -include *.tif, *.tiff
Remove-Item .\output\*
Remove-Item .\* -include *.tif, *.tiff
EXIT;
}
##------------------------------------------------------------------------------
## Get BAM ID if running mode is BAM
if ($mode -eq 1) {
[int]$bam_id = read-host "Insert BAM ID: ";
}
##------------------------------------------------------------------------------
## Select test number
echo "";
echo "Select test:";
echo " 0) All";
for ($i=1; $i -le $OUT_IMAGES.length; $i++) {
$option = " " + $i + ") " + $OUT_IMAGES[$i - 1];
echo "$option";
}
echo "";
[int]$test = read-host "Test number";
echo "";
##------------------------------------------------------------------------------
## Functions
function getBAMCommand($IMAGE_ID){
$command = ".\bam\" + $BAMS[$bam_id - 1] + " .\images\" + $TEST_IMAGES[$IMAGE_ID] + " .\output\" + $OUT_IMAGES[$IMAGE_ID] + ".tiff .\output\" + $OUT_IMAGES[$IMAGE_ID] + "_conf.tiff";
return $command;
}
function getVBAMCommand($IMAGE_ID) {
$command = ".\bam\vbam\vbam.exe 100 1000 .\bam .\images\" + $TEST_IMAGES[$IMAGE_ID] + " .\output\ " + ".\output\" + $OUT_IMAGES[$IMAGE_ID];
return $command;
}
function RunCommand($image_id) {
if ($mode -eq 0) {
echo ("RUNNING VBAM on " + $TEST_IMAGES[$image_id]);
$command = getVBAMCommand($image_id);
iex $command;
}
if ($mode -eq 1) {
echo ("RUNNING BAM on " + $TEST_IMAGES[$image_id]);
$command = getBAMCommand($image_id);
iex $command;
return;
}
if ($mode -eq 2) {
return;
}
}
function RunTest($test_id) {
$command = ".\src\Debug\test.exe " + $OUT_IMAGES[$test_id];
iex $command;
}
##------------------------------------------------------------------------------
## Run BAM tests
if ($test -eq 0) {
for ($i=0; $i -lt $TEST_IMAGES.length; $i++) {
RunCommand($i);
}
for ($i=0; $i -lt $OUT_IMAGES.length; $i++) {
RunTest($i);
}
}
elseif ($test -le $TEST_IMAGES.length) {
RunCommand($test - 1);
RunTest($test - 1);
}
else {
echo ("Incorrect test number: " + $test);
echo "";
}