1#!/bin/bash
2#
3# adp.sh -- run ADP's stress test on /proc/[0-9]*/cmdline
4#
5#
6
7usage()
8{
9  cat << EOF
10  usage: $0 options
11
12  This script runs ADP's stress test on /proc/[0-0]*/cmdline.
13
14  OPTIONS
15    -h    display this message and exit
16    -d    delay for top, in seconds
17    -n    number of iterations for top
18EOF
19}
20
21
22checkvar()
23{
24  VAR=$1
25  eval VALUE='$'$VAR
26  if [ "x$VALUE" = "x" ]; then
27      echo "`basename $0`: $VAR is not set."
28      return 1
29	else
30      return 0
31  fi
32}
33
34
35while getopts hd:n: OPTION
36do
37  case $OPTION in
38    h)
39      usage
40      exit 1
41      ;;
42    d)
43      delay=$OPTARG
44      ;;
45    n)
46      iterations=$OPTARG
47      ;;
48    ?)
49      usage
50      exit 1
51      ;;
52  esac
53done
54
55
56#check all vars
57checkvar delay && checkvar iterations || {
58  usage
59  exit 2
60}
61
62echo "-------------------------------------------------------------------------"
63date
64echo "Starting tests..."
65
66for i in 1 2 3 4 5
67do
68	./adp_children.sh &
69done
70
71echo "Stressing /proc/[0-9]*/cmdline..."
72
73for i in 1 2 3 4 5
74do
75	./adp_test.sh &
76done
77
78echo "Starting 'top', redirecting output to 'adp.log'..."
79top -b -d $delay -n $iterations > adp.log &
80
81echo "LTP ADP Test done. Killing processes..."
82killall adp_test.sh
83killall adp_children.sh
84
85echo "Done. Please check adp.log."
86date
87
88echo "-------------------------------------------------------------------------"
89
90