Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/lang/management/OperatingSystemMXBean/TestSystemLoadAvg.sh
41153 views
1
#
2
# Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
#
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.
8
#
9
# This code is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
# version 2 for more details (a copy is included in the LICENSE file that
13
# accompanied this code).
14
#
15
# You should have received a copy of the GNU General Public License version
16
# 2 along with this work; if not, write to the Free Software Foundation,
17
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
#
19
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
# or visit www.oracle.com if you need additional information or have any
21
# questions.
22
#
23
24
#
25
# @test
26
# @bug 6336608 6367473 6511738
27
# @summary Tests OperatingSystemMXBean.getSystemLoadAverage() api.
28
# @author Mandy Chung
29
#
30
# @run build GetSystemLoadAverage
31
# @run shell/timeout=300 TestSystemLoadAvg.sh
32
#
33
34
#
35
# This test tests the system load average on linux and solaris.
36
# On windows tests if it returns -1.0 The verification is done
37
# by the GetSystemLoadAverage class. By default it takes no
38
# input argument which verifies the system load average with
39
# /usr/bin/uptime command. Or specify "-1.0" as the input argument
40
# indicatiing that the platform doesn't support the system load average.
41
42
#Set appropriate jdk
43
#
44
45
if [ ! -z "${TESTJAVA}" ] ; then
46
jdk="$TESTJAVA"
47
else
48
echo "--Error: TESTJAVA must be defined as the pathname of a jdk to test."
49
exit 1
50
fi
51
52
runOne()
53
{
54
echo "$TESTJAVA/bin/java -classpath $TESTCLASSES $@"
55
$TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES $@
56
}
57
58
# Retry 5 times to be more resilent to system load fluctation.
59
MAX=5
60
i=1
61
while true; do
62
echo "Run $i: TestSystemLoadAvg"
63
case `uname -s` in
64
Linux | Darwin | AIX )
65
runOne GetSystemLoadAverage
66
;;
67
* )
68
# On Windows -1.0 should be returned
69
runOne GetSystemLoadAverage "-1.0"
70
;;
71
esac
72
if [ $? -eq 0 ]; then
73
# exit if the test passes
74
echo "Run $i: TestSystemLoadAvg test passed"
75
exit 0
76
elif [ $i -eq $MAX ] ; then
77
echo "TEST FAILED: TestSystemLoadAvg test failed $i runs"
78
exit 1
79
fi
80
i=`expr $i + 1`
81
# sleep for 5 seconds
82
sleep 5
83
done
84
85