VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/utils/TestExecServ/linux/vboxtxs-runvm.sh@ 98477

Last change on this file since 98477 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1#!/bin/sh
2## @file
3# VirtualBox Test Execution Service Init Script.
4#
5
6#
7# Copyright (C) 2018-2023 Oracle and/or its affiliates.
8#
9# This file is part of VirtualBox base platform packages, as
10# available from https://www.virtualbox.org.
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the terms of the GNU General Public License
14# as published by the Free Software Foundation, in version 3 of the
15# License.
16#
17# This program is distributed in the hope that it will be useful, but
18# WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, see <https://www.gnu.org/licenses>.
24#
25# The contents of this file may alternatively be used under the terms
26# of the Common Development and Distribution License Version 1.0
27# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28# in the VirtualBox distribution, in which case the provisions of the
29# CDDL are applicable instead of those of the GPL.
30#
31# You may elect to license modified versions of this file under the
32# terms and conditions of either the GPL or the CDDL or both.
33#
34# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35#
36
37# chkconfig: 35 35 65
38# description: VirtualBox Test Execution Service
39#
40### BEGIN INIT INFO
41# Provides: vboxtxs-runvm
42# Required-Start: $ALL
43# Required-Stop:
44# Default-Start: 5
45# Default-Stop: 0 1 6
46# Description: VirtualBox Test Execution Service
47### END INIT INFO
48
49PATH=$PATH:/bin:/sbin:/usr/sbin
50SCRIPTNAME=vboxtxs-runvm.sh
51
52CDROM_PATH=/media/cdrom
53SCRATCH_PATH=/tmp/vboxtxs-scratch
54SMOKEOUTPUT_PATH=/tmp/vboxtxs-smoketestoutput
55DEVKMSG_PATH=/dev/kmsg
56
57PIDFILE="/var/run/vboxtxs"
58
59export TESTBOX_PATH_RESOURCES="/home/vbox/testrsrc"
60SMOKETEST_SCRIPT="/opt/validationkit/tests/smoketests/tdSmokeTest1.py"
61PYTHON_BINARY="python"
62
63# Preamble for Gentoo
64if [ "`which $0`" = "/sbin/rc" ]; then
65 shift
66fi
67
68kernlog_msg() {
69 test -n "$2" && echo "${SCRIPTNAME}: ${1}"
70 echo "${SCRIPTNAME}: ${1}" > $DEVKMSG_PATH
71}
72
73dumpfile_to_kernlog() {
74 if test -f "$1"; then
75 kernlog_msg "---------------------- DUMP BEGIN ----------------------"
76 cat "$1" | while read LINE
77 do
78 kernlog_msg "${LINE}"
79 done
80 kernlog_msg "---------------------- DUMP END ------------------------"
81 rm -f "$1"
82 else
83 kernlog_msg "${1}: file not found" console
84 fi
85}
86
87killproc()
88{
89 kp_binary="${1##*/}"
90 pkill "${kp_binary}" || return 0
91 sleep 1
92 pkill "${kp_binary}" || return 0
93 sleep 1
94 pkill -9 "${kp_binary}"
95 return 0
96}
97
98case "`uname -m`" in
99 AMD64|amd64|X86_64|x86_64)
100 binary=/opt/validationkit/linux/amd64/TestExecService
101 ;;
102
103 i386|x86|i486|i586|i686|i787)
104 binary=/opt/validationkit/linux/x86/TestExecService
105 ;;
106
107 *)
108 binary=/opt/validationkit/linux/x86/TestExecService
109 ;;
110esac
111
112fixAndTestBinary() {
113 chmod a+x "$binary" 2> /dev/null > /dev/null
114 test -x "$binary" || {
115 echo "Cannot run $binary"
116 exit 1
117 }
118}
119
120testRsrcPath() {
121 test -d "$TESTBOX_PATH_RESOURCES" || {
122 echo "TESTBOX_PATH_RESOURCES directory not found"
123 exit 1
124 }
125}
126
127start() {
128 if ! test -f $PIDFILE; then
129 kernlog_msg "Starting Nested Smoke Test" console
130 fixAndTestBinary
131 testRsrcPath
132 $PYTHON_BINARY $SMOKETEST_SCRIPT -v -v -d --vbox-session-type gui --nic-attachment nat --quick all 1> "${SMOKEOUTPUT_PATH}" 2>&1
133 RETVAL=$?
134 dumpfile_to_kernlog "${SMOKEOUTPUT_PATH}"
135 sync
136 sleep 15
137 if test $RETVAL -eq 0; then
138 kernlog_msg "Nested Smoke Test done; Starting Test Execution service" console
139 mkdir -p "${CDROM_PATH}"
140 mount -o ro /dev/cdrom "${CDROM_PATH}" 2> /dev/null > /dev/null
141 $binary --auto-upgrade --scratch="${SCRATCH_PATH}" --cdrom="${CDROM_PATH}" --no-display-output > /dev/null
142 RETVAL=$?
143 test $RETVAL -eq 0 && sleep 3 && echo `pidof TestExecService` > $PIDFILE
144 if ! test -s "${PIDFILE}"; then
145 RETVAL=5
146 fi
147 if test $RETVAL -eq 0; then
148 kernlog_msg "Test Execution service started" console
149 else
150 kernlog_msg "Test Execution service failed to start" console
151 RETVAL=6
152 fi
153 else
154 kernlog_msg "Smoke Test failed! error code ${RETVAL}" console
155 RETVAL=7
156 fi
157 else
158 kernlog_msg "Starting Nested Smoke Test failed! Pidfile ${PIDFILE} exists" console
159 RETVAL=9
160 fi
161 return $RETVAL
162}
163
164stop() {
165 if test -f $PIDFILE; then
166 kernlog_msg "Stopping Test Execution Service"
167 killproc $binary
168 rm -f $PIDFILE
169 fi
170}
171
172restart() {
173 stop && start
174}
175
176status() {
177 echo -n "Checking for vboxtxs"
178 if [ -f $PIDFILE ]; then
179 echo " ...running"
180 else
181 echo " ...not running"
182 fi
183}
184
185case "$1" in
186start)
187 start
188 ;;
189stop)
190 stop
191 ;;
192restart)
193 restart
194 ;;
195status)
196 status
197 ;;
198setup)
199 ;;
200cleanup)
201 ;;
202*)
203 echo "Usage: $0 {start|stop|restart|status}"
204 exit 1
205esac
206
207exit $RETVAL
208
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette