1 #!/bin/bash
2
3 # Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 #
6 # This code is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License version 2 only, as
8 # published by the Free Software Foundation. Oracle designates this
9 # particular file as subject to the "Classpath" exception as provided
10 # by Oracle in the LICENSE file that accompanied this code.
11 #
12 # This code is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # version 2 for more details (a copy is included in the LICENSE file that
16 # accompanied this code).
17 #
18 # You should have received a copy of the GNU General Public License version
19 # 2 along with this work; if not, write to the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 #
22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 # or visit www.oracle.com if you need additional information or have any
24 # questions.
25
26 if [ "$#" -lt 3 ]; then
27 echo "Usage: test.sh <branch> <path> <backend...>" >&2
28 exit 1
29 fi
30
31 GREEN="\033[0;32m"
32 NC="\033[0m" # No Color (reset)
33
34 ## Run nvidia-smi if exists
35 if command -v nvidia-smi >/dev/null 2>&1; then
36 nvidia-smi
37 ## NVIDIA Env Variables
38 export CPLUS_INCLUDE_PATH=/usr/local/cuda/include
39 export LD_LIBRARY_PATH=/usr/local/cuda/lib64
40 export PATH=/usr/local/cuda/bin/:$PATH
41 fi
42
43 branch=$1
44 remote_path=$2
45 shift 2
46 backends=("$@")
47
48 cd $remote_path/hat/
49 source setup.sh > /dev/null
50
51 # HAT Env variables
52 export HAT=CHECK_SSA_LOWERING
53
54 # run the test suite per backend
55 for backend in "${backends[@]}"
56 do
57 echo -e "${GREEN}[running] java @.test-suite "$backend" ${NC}"
58 java @.test-suite "$backend" > "$backend".txt 2> "$backend"Errors.txt
59 done
60
61 # Print logs
62 for backend in "${backends[@]}"
63 do
64 cat "$backend".txt
65 done
66
67 ## Run violajones
68 for backend in "${backends[@]}"
69 do
70 echo -e "${GREEN}[running] java @."$backend"-example -Dheadless=true violajones.Main${NC}"
71 java @."$backend"-example -Dheadless=true violajones.Main > "$backend"Violajones.log
72 done
73
74 for backend in "${backends[@]}"
75 do
76 if grep -q "336faces found" "$backend"Violajones.log; then
77 echo "✅ ViolaJones for backend: $backend ....... [pass]"
78 else
79 echo "❌ ViolaJones for backend: $backend ....... [fail]"
80 fi
81 done