Blame tests/p_java-1.6.0-openjdk/10-test_java.sh

Christoph Galuschka e2cd20
#!/bin/sh
Christoph Galuschka e2cd20
# Author: Christoph Galuschka <christoph.galuschka@chello.at>
Christoph Galuschka e2cd20
Pablo Greco b2c079
if [ $centos_ver -ge 8 ]; then
Pablo Greco b2c079
  echo "Package not included in CentOS $centos_ver, skipping"
Pablo Greco b2c079
  exit 0
Pablo Greco b2c079
fi
b52398
if (t_GetArch | grep -qE 'aarch64|ppc64le')
07966e
  then
9a1e76
  echo "Package not included for current arch, skipping"
07966e
  exit 0
07966e
fi
07966e
Christoph Galuschka e2cd20
t_Log "Running $0 - javac can compile and java can print 'hello centos'"
Christoph Galuschka e2cd20
ad6e26
# selecting the right alternative
ad6e26
t_Select_Alternative java jre-1.6.0-openjdk
ad6e26
t_Select_Alternative javac java-1.6.0-openjdk
ad6e26
Christoph Galuschka e2cd20
# creating source file
Christoph Galuschka e2cd20
PATH2FILE='/var/tmp/'
Christoph Galuschka e2cd20
FILE='HelloWorld'
Christoph Galuschka e2cd20
FILE2=$PATH2FILE$FILE.java
Christoph Galuschka e2cd20
Christoph Galuschka e2cd20
cat > $FILE2 <
Christoph Galuschka e2cd20
public class HelloWorld {
Christoph Galuschka e2cd20
Christoph Galuschka e2cd20
  public static void main(String[] args) {
Christoph Galuschka e2cd20
    System.out.println("hello centos");
Christoph Galuschka e2cd20
  }
Christoph Galuschka e2cd20
}
Christoph Galuschka e2cd20
EOF
Christoph Galuschka e2cd20
Christoph Galuschka e2cd20
# Compiling
Christoph Galuschka e2cd20
javac $FILE2
Christoph Galuschka e2cd20
if [ $? == 1 ]
Christoph Galuschka e2cd20
  then
Christoph Galuschka e2cd20
  t_Log "Java-Compilation failed"
Christoph Galuschka e2cd20
  exit
Christoph Galuschka e2cd20
fi
Christoph Galuschka e2cd20
Christoph Galuschka e2cd20
# executing java
Christoph Galuschka e2cd20
workpath=$(pwd)
Christoph Galuschka e2cd20
cd $PATH2FILE
Christoph Galuschka d315fb
java $FILE |grep -q 'hello centos'
Christoph Galuschka e2cd20
Christoph Galuschka e2cd20
t_CheckExitStatus $?
Christoph Galuschka e2cd20
Christoph Galuschka e2cd20
cd $workpath
Christoph Galuschka e2cd20
# remove files
Christoph Galuschka e2cd20
/bin/rm $PATH2FILE$FILE.class $FILE2