File: test7.5

package info (click to toggle)
slurm-wlm 22.05.8-4%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 48,492 kB
  • sloc: ansic: 475,246; exp: 69,020; sh: 8,862; javascript: 6,528; python: 6,444; makefile: 4,185; perl: 4,069; pascal: 131
file content (148 lines) | stat: -rwxr-xr-x 4,492 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env expect
############################################################################
# Purpose: Test of TotalView termination logic for srun.
#
# Note:    This script generates and then deletes files in the working directory
#          named test7.5.prog
############################################################################
# Copyright (C) 2002-2007 The Regents of the University of California.
# Copyright (C) 2008-2009 Lawrence Livermore National Security.
# Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
# Written by Morris Jette <jette1@llnl.gov>
# CODE-OCEC-09-009. All rights reserved.
#
# This file is part of Slurm, a resource management program.
# For details, see <https://slurm.schedmd.com/>.
# Please also read the included file: DISCLAIMER.
#
# Slurm is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Slurm is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with Slurm; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
############################################################################
source ./globals

set file_prog   "$test_name.prog"
set matches     0
set fini_cnt    0
set usr1cnt     0
set usr2cnt     0

proc cleanup {} {
	global bin_rm file_prog

	exec $bin_rm -f $file_prog
}

#
# Delete left-over program and rebuild it
#
exec $bin_cc -O ${file_prog}.c -o $file_prog
exec $bin_chmod 700 $file_prog

#
# Get uid
#
set uid [get_my_uid]


#
# Spawn initial program via srun and terminate with SIGTERM
# Note: For systems supporting proper pthreads, instead use
#       exec $bin_kill -TERM $srun_pid, otherwise we need pkill
#       and can get multiple signals delivered
# Note: We send the signal right after task startup rather than
#	interspersed with messages because some versions of
#	Expect have difficulties handling unbuffered srun output
#
set timeout $max_job_delay
set srun_pid [spawn $srun -N1 -t1 --debugger-test --unbuffered ./$file_prog]
expect {
	-re "task:.*, host:.*, pid:.*, executable:.*" {
		incr matches
		# sleep to make sure the process is actually running
		exec $bin_sleep 1
		exec $bin_kill -TERM $srun_pid
		log_debug "Sent SIGTERM"
		exp_continue
	}
	-re "Received signal" {
		fail "Unexpected signal processed after sent SIGTERM"
	}
	-re "WAITING" {
		fail "Job not stopped in debugger mode after sent SIGTERM"
	}
	-re "TIME LIMIT" {
		fail "Job not terminated with SIGTERM"
	}
	-re "error.*not running" {
		log_debug "Don't worry about the error.."
		exp_continue
	}
	-re "FINI" {
		incr fini_cnt
		exp_continue
	}
	timeout {
		fail "srun not responding"
	}
	eof {
		log_debug "EOF"
		wait
	}
}
subtest {$matches == 1} "Verify proper initialization for srun with SIGTERM" "srun failed to initialize properly ($matches != 1)"
subtest {$fini_cnt <= 0} "Verify proper termination for srun with SIGTERM" "srun failed to terminate properly ($fini_cnt > 0)"

#
# Spawn initial program via srun and terminate with SIGINT * 3
#
set matches  0
set fini_cnt 0
set srun_pid [spawn $srun -N1 -t1 --debugger-test --unbuffered ./$file_prog]
expect {
	-re "task:.*, host:.*, pid:.*, executable:.*" {
		incr matches
		# sleep to make sure the process is actually running
		exec $bin_sleep 1
		exec $bin_kill -INT $srun_pid
		exec $bin_kill -INT $srun_pid
		log_debug "Sent SIGINT * 2"
		exp_continue
	}
	-re "Received signal" {
		fail "Unexpected signal processed after SIGINT"
	}
	-re "WAITING" {
		fail "Job not stopped in debugger mode after SIGINT"
	}
	-re "TIME LIMIT" {
		fail "Job not terminated with SIGINT"
	}
	-re "error.*not running" {
		log_debug "Don't worry about the error.."
		exp_continue
	}
	-re "FINI" {
		incr fini_cnt
		exp_continue
	}
	timeout {
		fail "srun not responding"
	}
	eof {
		log_debug "EOF"
		wait
	}
}
subtest {$matches == 1} "Verify proper initialization for srun with SIGINT" "srun failed to initialize properly ($matches != 1)"
subtest {$fini_cnt <= 0} "Verify proper termination for srun with SIGINT" "srun failed to terminate properly ($fini_cnt > 0)"