1*49cdfc7eSAndroid Build Coastguard Worker#!/bin/sh 2*49cdfc7eSAndroid Build Coastguard Worker# SPDX-License-Identifier: GPL-2.0-or-later 3*49cdfc7eSAndroid Build Coastguard Worker# Copyright (c) 2021 Petr Vorel <[email protected]> 4*49cdfc7eSAndroid Build Coastguard Worker 5*49cdfc7eSAndroid Build Coastguard Worker# testing shell timeout handling in tst_timeout_kill 6*49cdfc7eSAndroid Build Coastguard Worker# expected output: 7*49cdfc7eSAndroid Build Coastguard Worker# timeout03 1 TINFO: timeout per run is 0h 0m 1s 8*49cdfc7eSAndroid Build Coastguard Worker# timeout03 1 TINFO: testing killing test after TST_TIMEOUT 9*49cdfc7eSAndroid Build Coastguard Worker# Test timed out, sending SIGTERM! 10*49cdfc7eSAndroid Build Coastguard Worker# If you are running on slow machine, try exporting LTP_TIMEOUT_MUL > 1 11*49cdfc7eSAndroid Build Coastguard Worker# Terminated 12*49cdfc7eSAndroid Build Coastguard Worker# timeout03 1 TBROK: test terminated 13*49cdfc7eSAndroid Build Coastguard Worker# timeout03 1 TPASS: test run cleanup after timeout 14*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 10 15*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 9 16*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 8 17*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 7 18*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 6 19*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 5 20*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 4 21*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 3 22*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 2 23*49cdfc7eSAndroid Build Coastguard Worker# Test is still running... 1 24*49cdfc7eSAndroid Build Coastguard Worker# Test is still running, sending SIGKILL 25*49cdfc7eSAndroid Build Coastguard Worker# Killed 26*49cdfc7eSAndroid Build Coastguard Worker 27*49cdfc7eSAndroid Build Coastguard WorkerTST_TESTFUNC=do_test 28*49cdfc7eSAndroid Build Coastguard WorkerTST_CLEANUP=cleanup 29*49cdfc7eSAndroid Build Coastguard Worker 30*49cdfc7eSAndroid Build Coastguard WorkerTST_TIMEOUT=1 31*49cdfc7eSAndroid Build Coastguard Worker 32*49cdfc7eSAndroid Build Coastguard Workerdo_test() 33*49cdfc7eSAndroid Build Coastguard Worker{ 34*49cdfc7eSAndroid Build Coastguard Worker tst_res TINFO "testing killing test after TST_TIMEOUT" 35*49cdfc7eSAndroid Build Coastguard Worker 36*49cdfc7eSAndroid Build Coastguard Worker sleep 2 37*49cdfc7eSAndroid Build Coastguard Worker tst_res TFAIL "test: running after TST_TIMEOUT" 38*49cdfc7eSAndroid Build Coastguard Worker} 39*49cdfc7eSAndroid Build Coastguard Worker 40*49cdfc7eSAndroid Build Coastguard Workercleanup() 41*49cdfc7eSAndroid Build Coastguard Worker{ 42*49cdfc7eSAndroid Build Coastguard Worker tst_res TPASS "test run cleanup after timeout" 43*49cdfc7eSAndroid Build Coastguard Worker 44*49cdfc7eSAndroid Build Coastguard Worker sleep 15 # must be higher than wait time in _tst_kill_test 45*49cdfc7eSAndroid Build Coastguard Worker tst_res TFAIL "cleanup: running after TST_TIMEOUT" 46*49cdfc7eSAndroid Build Coastguard Worker} 47*49cdfc7eSAndroid Build Coastguard Worker 48*49cdfc7eSAndroid Build Coastguard Worker. tst_test.sh 49*49cdfc7eSAndroid Build Coastguard Workertst_run 50