13ce53722SRobert Mustacchi#!/usr/bin/ksh 23ce53722SRobert Mustacchi# 33ce53722SRobert Mustacchi# 43ce53722SRobert Mustacchi# This file and its contents are supplied under the terms of the 53ce53722SRobert Mustacchi# Common Development and Distribution License ("CDDL"), version 1.0. 63ce53722SRobert Mustacchi# You may only use this file in accordance with the terms of version 73ce53722SRobert Mustacchi# 1.0 of the CDDL. 83ce53722SRobert Mustacchi# 93ce53722SRobert Mustacchi# A full copy of the text of the CDDL should have accompanied this 103ce53722SRobert Mustacchi# source. A copy of the CDDL is also available via the Internet at 113ce53722SRobert Mustacchi# http://www.illumos.org/license/CDDL. 123ce53722SRobert Mustacchi# 133ce53722SRobert Mustacchi 143ce53722SRobert Mustacchi# 153ce53722SRobert Mustacchi# Copyright 2020 Oxide Computer Company 163ce53722SRobert Mustacchi# 173ce53722SRobert Mustacchi 183ce53722SRobert Mustacchi# 193ce53722SRobert Mustacchi# This is a stress test that tries to just generate a bunch of ksensor 203ce53722SRobert Mustacchi# activity. It will run launching a number of threads that do different 213ce53722SRobert Mustacchi# activities. The goal here is to try and have the following: 223ce53722SRobert Mustacchi# 233ce53722SRobert Mustacchi# o Things trying to modunload the ksensor_test and ksensor driver 243ce53722SRobert Mustacchi# o things trying to actually use the various sensors from the 253ce53722SRobert Mustacchi# ksensor_test driver 263ce53722SRobert Mustacchi# 273ce53722SRobert Mustacchi# To make sure that everything cleans up when this exits, this script 283ce53722SRobert Mustacchi# wraps itself in a ctrun. The caller needs to ensure that the 293ce53722SRobert Mustacchi# ksensor_test driver is loaded to begin with. It may or may not be part 303ce53722SRobert Mustacchi# of the system when all is said and done. 313ce53722SRobert Mustacchi# 323ce53722SRobert Mustacchi 333ce53722SRobert Mustacchisensor_base="/dev/sensors/test" 343ce53722SRobert Mustacchi 353ce53722SRobert Mustacchi# 363ce53722SRobert Mustacchi# The number of instances that we expect to exist. 373ce53722SRobert Mustacchi# 383ce53722SRobert Mustacchisensor_inst=42 393ce53722SRobert Mustacchisensor_count=4 403ce53722SRobert Mustacchi 413ce53722SRobert Mustacchi# 423ce53722SRobert Mustacchi# Tunnables 433ce53722SRobert Mustacchi# 443ce53722SRobert Mustacchisensor_unloaders=50 453ce53722SRobert Mustacchisensor_readers=500 463ce53722SRobert Mustacchi 473ce53722SRobert Mustacchiif [[ ${@:$#} != "elbereth" ]]; then 483ce53722SRobert Mustacchi exec ctrun -o noorphan ksh $0 "elbereth" 493ce53722SRobert Mustacchifi 503ce53722SRobert Mustacchi 513ce53722SRobert Mustacchi 523ce53722SRobert Mustacchiif [[ ! -L "$sensor_base/test.temp.0.1" ]]; then 53*1045e13aSRobert Mustacchi printf "missing ksensor test data, ksensor_tstp driver loaded?\n" 2>&1 543ce53722SRobert Mustacchi exit 1 553ce53722SRobert Mustacchifi 563ce53722SRobert Mustacchi 573ce53722SRobert Mustacchicat << EOL 583ce53722SRobert MustacchiBeginning to run the ksensor stress test. This will launch processes 593ce53722SRobert Mustacchiwhich will: 603ce53722SRobert Mustacchi 613ce53722SRobert Mustacchi o Attempt to modunload 'ksensor' driver ($sensor_unloaders procs) 623ce53722SRobert Mustacchi o Attempt to modunload 'ksensor_test' driver ($sensor_unloaders procs) 633ce53722SRobert Mustacchi o Attempt to read test sensors ($sensor_readers procs) 643ce53722SRobert Mustacchi 653ce53722SRobert MustacchiTo stop things, simply kill this process. All dependent processes will 663ce53722SRobert Mustacchibe cleaned up. 673ce53722SRobert MustacchiEOL 683ce53722SRobert Mustacchi 693ce53722SRobert Mustacchifor ((i = 0; i < $sensor_unloaders; i++)); do 703ce53722SRobert Mustacchi ksh ./ksensor_unload.ksh ksensor_test & 713ce53722SRobert Mustacchi ksh ./ksensor_unload.ksh ksensor & 723ce53722SRobert Mustacchidone 733ce53722SRobert Mustacchi 743ce53722SRobert Mustacchifor ((i = 0; i < $sensor_readers; i++)); do 753ce53722SRobert Mustacchi if [[ $(( $i % 2 )) -eq 0 ]]; then 763ce53722SRobert Mustacchi ./ksensor_sread.32 $sensor_inst $sensor_count & 773ce53722SRobert Mustacchi else 783ce53722SRobert Mustacchi ./ksensor_sread.64 $sensor_inst $sensor_count & 793ce53722SRobert Mustacchi fi 803ce53722SRobert Mustacchidone 813ce53722SRobert Mustacchi 823ce53722SRobert Mustacchiwhile :; do 833ce53722SRobert Mustacchi wait 843ce53722SRobert Mustacchidone 853ce53722SRobert Mustacchi 863ce53722SRobert Mustacchiexit 0 87