##
## @test @(#)test6941923.sh
## @bug 6941923
## @summary test new added flags for gc log rotation
## @author yqi
## @run shell test6941923.sh
##
## some tests require path to find test source dir
if [ "${TESTSRC}" = "" ]
then
fi
echo "TESTSRC=${TESTSRC}"
## Adding common setup Variables for running shell tests.
. ${TESTSRC}/../../test_env.sh
## skip on windows
echo "Test skipped for Windows"
exit 0
;;
esac
# create a small test case
testname="Test"
fi
import java.util.Vector;
public class Test implements Runnable
{
private boolean _should_stop = false;
public static void main(String[] args) throws Exception {
long limit = Long.parseLong(args[0]) * 60L * 1000L; // minutes
Test t = new Test();
t.set_stop(false);
Thread thr = new Thread(t);
thr.start();
long time1 = System.currentTimeMillis();
long time2 = System.currentTimeMillis();
while (time2 - time1 < limit) {
try {
Thread.sleep(2000); // 2 seconds
}
catch(Exception e) {}
time2 = System.currentTimeMillis();
System.out.print("\r... " + (time2 - time1)/1000 + " seconds");
}
System.out.println();
t.set_stop(true);
}
public void set_stop(boolean value) { _should_stop = value; }
public void run() {
int cap = 20000;
int fix_size = 2048;
int loop = 0;
Vector< byte[] > v = new Vector< byte[] >(cap);
while(!_should_stop) {
byte[] g = new byte[fix_size];
v.add(g);
loop++;
if (loop > cap) {
v = null;
cap *= 2;
if (cap > 80000) cap = 80000;
v = new Vector< byte[] >(cap);
}
}
}
}
__EOF__
msgsuccess="succeeded"
msgfail="failed"
gclogsize="16K"
if [ $? != 0 ]; then
exit -1
fi
# test for 2 minutes, it will complete circulation of gc log rotation
tts=2
if [ -e $logfile ]; then
fi
#also delete $hotspotlog if it exists
if [ -f $hotspotlog ]; then
fi
options="-Xloggc:$logfile -XX:+UseConcMarkSweepGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=$gclogsize"
echo "Test gc log rotation in same file, wait for $tts minutes ...."
if [ $? != 0 ]; then
echo "$msgfail"
exit -1
fi
# rotation file will be $logfile.0
if [ -f $logfile.0 ]; then
echo $msgsuccess
else
echo $msgfail
fi
else
echo $msgfail
exit -1
fi
# delete log file
if [ -f $hotspotlog ]; then
fi
#multiple log files
options="-Xloggc:$logfile -XX:+UseConcMarkSweepGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=$numoffiles -XX:GCLogFileSize=$gclogsize"
echo "Test gc log rotation in $numoffiles files, wait for $tts minutes ...."
if [ $? != 0 ]; then
echo "$msgfail"
exit -1
fi
tk=0
do
fi
fi
done
echo $msgsuccess
else
echo $msgfail
exit -1
fi