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