xref: /linux/tools/testing/selftests/arm64/fp/ssve-stress (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1*4126bde0SMark Brown#!/bin/bash
2*4126bde0SMark Brown# SPDX-License-Identifier: GPL-2.0-only
3*4126bde0SMark Brown# Copyright (C) 2015-2019 ARM Limited.
4*4126bde0SMark Brown# Original author: Dave Martin <Dave.Martin@arm.com>
5*4126bde0SMark Brown
6*4126bde0SMark Brownset -ue
7*4126bde0SMark Brown
8*4126bde0SMark BrownNR_CPUS=`nproc`
9*4126bde0SMark Brown
10*4126bde0SMark Brownpids=
11*4126bde0SMark Brownlogs=
12*4126bde0SMark Brown
13*4126bde0SMark Browncleanup () {
14*4126bde0SMark Brown	trap - INT TERM CHLD
15*4126bde0SMark Brown	set +e
16*4126bde0SMark Brown
17*4126bde0SMark Brown	if [ -n "$pids" ]; then
18*4126bde0SMark Brown		kill $pids
19*4126bde0SMark Brown		wait $pids
20*4126bde0SMark Brown		pids=
21*4126bde0SMark Brown	fi
22*4126bde0SMark Brown
23*4126bde0SMark Brown	if [ -n "$logs" ]; then
24*4126bde0SMark Brown		cat $logs
25*4126bde0SMark Brown		rm $logs
26*4126bde0SMark Brown		logs=
27*4126bde0SMark Brown	fi
28*4126bde0SMark Brown}
29*4126bde0SMark Brown
30*4126bde0SMark Browninterrupt () {
31*4126bde0SMark Brown	cleanup
32*4126bde0SMark Brown	exit 0
33*4126bde0SMark Brown}
34*4126bde0SMark Brown
35*4126bde0SMark Brownchild_died () {
36*4126bde0SMark Brown	cleanup
37*4126bde0SMark Brown	exit 1
38*4126bde0SMark Brown}
39*4126bde0SMark Brown
40*4126bde0SMark Browntrap interrupt INT TERM EXIT
41*4126bde0SMark Brown
42*4126bde0SMark Brownfor x in `seq 0 $((NR_CPUS * 4))`; do
43*4126bde0SMark Brown	log=`mktemp`
44*4126bde0SMark Brown	logs=$logs\ $log
45*4126bde0SMark Brown	./ssve-test >$log &
46*4126bde0SMark Brown	pids=$pids\ $!
47*4126bde0SMark Browndone
48*4126bde0SMark Brown
49*4126bde0SMark Brown# Wait for all child processes to be created:
50*4126bde0SMark Brownsleep 10
51*4126bde0SMark Brown
52*4126bde0SMark Brownwhile :; do
53*4126bde0SMark Brown	kill -USR1 $pids
54*4126bde0SMark Browndone &
55*4126bde0SMark Brownpids=$pids\ $!
56*4126bde0SMark Brown
57*4126bde0SMark Brownwait
58*4126bde0SMark Brown
59*4126bde0SMark Brownexit 1
60