Dash:
[t2-trunk.git] / package / x86 / cpuburn / cpuburn.sh
blobeb1181e69ef94d7ffe025c025df7f1f3d381f8fc
1 #!/bin/sh
3 # --- T2-COPYRIGHT-NOTE-BEGIN ---
4 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 #
6 # T2 SDE: package/.../cpuburn/cpuburn.sh
7 # Copyright (C) 2004 - 2005 The T2 SDE Project
8 # Copyright (C) 1998 - 2003 ROCK Linux Project
9 #
10 # More information can be found in the files COPYING and README.
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; version 2 of the License. A copy of the
15 # GNU General Public License can be found in the file COPYING.
16 # --- T2-COPYRIGHT-NOTE-END ---
18 errors=`mktemp -t cpuburn.XXXX`
19 start=`date "+%s"` ; command="" ; jobs=1
21 help() {
22 cat << 'EOT'
24 Usage: $0 [ -j Jobs ] { -k6 | -k7 | -p5 | -p6 | -bx | -mmx } [ -mem Mem ]
26 The -mem option is only available for the bx and mmx tests. Possible values
27 for Mem are: 2kb, 4kb, 8kb, 16kb, 32kb, 64kb, 128kb, 256kb, 512kb, 1MB, 2MB,
28 4MB, 8MB, 16MB, 32MB and 64MB.
30 EOT
31 rm $errors
32 exit 1
35 while [ "$#" != 0 ]
37 case "$1" in
38 -j)
39 jobs=$2 ; shift ;;
41 -bx)
42 command="burnBX" ;;
43 -k6)
44 command="burnK6" ;;
45 -k7)
46 command="burnK7" ;;
47 -mmx)
48 command="burnMMX" ;;
49 -p5)
50 command="burnP5" ;;
51 -p6)
52 command="burnP6" ;;
54 -mem)
55 [ "$command" != burnBX -a "$command" != burnMMX ] && help
57 case "$2" in
58 2kb)
59 command="$command A" ;;
60 4kb)
61 command="$command B" ;;
62 8kb)
63 command="$command C" ;;
64 16kb)
65 command="$command D" ;;
66 32kb)
67 command="$command E" ;;
68 64kb)
69 command="$command F" ;;
70 128kb)
71 command="$command G" ;;
72 256kb)
73 command="$command H" ;;
74 512kb)
75 command="$command I" ;;
76 1MB)
77 command="$command J" ;;
78 2MB)
79 command="$command K" ;;
80 4MB)
81 command="$command L" ;;
82 8MB)
83 command="$command M" ;;
84 16MB)
85 command="$command N" ;;
86 32MB)
87 command="$command O" ;;
88 64MB)
89 command="$command P" ;;
91 help ;;
92 esac
93 shift
97 help ;;
98 esac
99 shift
100 done
102 [ "$command" = "" ] && help
103 desc="${jobs}x ${command#burn}"
105 while [ $jobs -gt 0 ] ; do
107 PATH=".:$PATH"
108 while true ; do
109 eval "$command"
110 date "+%T - $?" >> $errors
111 done
113 jobs=$(( $jobs - 1 ))
114 done &> /dev/null
116 trap "fuser -9 -k $errors > /dev/null ; rm $errors ; exit 0" INT TERM
117 echo "Using temp file $errors ..."
119 while true
121 tm=$(( `date +%s` - $start ))
122 tm=$( printf '%02d:%02d:%02d:%02d' \
123 $(( ($tm / (60*60*24)) )) \
124 $(( ($tm / (60*60)) % 24 )) \
125 $(( ($tm / 60) % 60 )) \
126 $(( $tm % 60 )) )
127 echo `date "+%T ($tm)"` " [$desc] " Load average: \
128 `uptime | sed "s,.*average: ,,"`, "" `wc -l < $errors` Errors.
129 sleep 5
130 done