[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH] Support for "hardware burn-in" stage



Otavio Salvador wrote:

> >> - I wonder if the CPU type could not be determined based
> >> on /proc/cpuinfo
> 
> I think it's useful to avoid questions to users and then or we're
> conservative and choose one generic flavour or we try to detect it.

Thinking about it more, I guess I would prefer it detect it when run. That
way:

 * There are no complicated questions ("What's a K7 chip?" "Won't it
   explode if I don't have a K7 chip?")

 * It's easier to extend (and replace!) the actual 'burn' program.

 * No need to preseed the CPU type and maintain different lists - it's
   just detected.

> > I agree with and have applied your
> <...>
> >  * XB-Installer-Menu-Item > 90000 suggestion
> <...>
> 
> While I agree with Frans on that, in some ways, I also think that some
> people would like to preseed its run and maybe it could be done
> just before finish install.

Not being able to preseed would be a shame, in my opinion.

> It would be nice if you could send a new patch so we could build it
> and give it a try easily.

I have attached a new third part to be combined with the previous two. Let
me know if I can make this easier.


Regards,

-- 
Chris Lamb, UK                                       chris@chris-lamb.co.uk
                                                            GPG: 0x634F9A20
diff --git a/debian/control b/debian/control
index 65f46e4..5ab0a88 100644
--- a/debian/control
+++ b/debian/control
@@ -18,3 +18,12 @@ Description: a collection of programs to put heavy load on CPU
  putting stress on the CPU itself, cooling system, motherboard. This
  may cause data loss (filesystem corruption) and possibly permanent 
  damage to electronic components. Use at your own risk.
+
+Package: cpuburn-udeb
+XC-Package-Type: udeb
+XB-Installer-Menu-Item: 95000
+Priority: optional
+Section: debian-installer
+Architecture: amd64 i386 hurd-i386 kfreebsd-i386 kfreebsd-amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: perform CPU stress test (burn in) - expert use only
diff --git a/debian/cpuburn-udeb.dirs b/debian/cpuburn-udeb.dirs
new file mode 100644
index 0000000..e772481
--- /dev/null
+++ b/debian/cpuburn-udeb.dirs
@@ -0,0 +1 @@
+usr/bin
diff --git a/debian/cpuburn-udeb.postinst b/debian/cpuburn-udeb.postinst
new file mode 100644
index 0000000..2a94430
--- /dev/null
+++ b/debian/cpuburn-udeb.postinst
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+#DEBHELPER#
+
+. /usr/share/debconf/confmodule
+
+db_capb backup progresscancel
+
+set -eu
+
+TEMPLATE_ROOT=cpuburn-udeb
+
+STATE=1
+
+while [ "$STATE" -ge 1 -a "$STATE" -le 4 ]; do
+	case "$STATE" in
+	    1)
+		db_input critical $TEMPLATE_ROOT/confirm || true
+		;;
+	    2)
+		# Check confirmation before continuing
+		db_get $TEMPLATE_ROOT/confirm
+		test "$RET" = "true" || exit 0
+
+		db_input critical $TEMPLATE_ROOT/type || true
+		;;
+	    3)
+		db_input critical $TEMPLATE_ROOT/duration || true
+		;;
+	    4)
+		db_get $TEMPLATE_ROOT/type
+		BURN_TYPE="$RET"
+
+		db_get $TEMPLATE_ROOT/duration
+		BURN_DURATION="$RET"
+
+		# Parse inputs
+		case "$BURN_TYPE" in
+		    BX|K7|K6|MMX|P5|P6)	;;
+		    *)
+			echo "Error parsing burn type '$BURN_DURATION'"
+			exit 1
+			;;
+		esac
+
+		QUANTITY=$(echo $BURN_DURATION | sed -e 's/^\([0-9]*\).*/\1/')
+		case "$QUANTITY" in
+		    [0-9]*) ;;
+		    *)
+			echo "Error parsing duration '$BURN_DURATION'"
+			exit 1
+			;;
+		esac
+
+		UNIT=$(echo $BURN_DURATION | sed -e 's/.*\([sSmMhHdD]\)$/\1/g' | tr A-Z a-z)
+		case "$UNIT" in
+		    s) SECONDS=$QUANTITY ;;
+		    m) SECONDS=$(($QUANTITY * 60)) ;;
+		    h) SECONDS=$(($QUANTITY * 60 * 60)) ;;
+		    d) SECONDS=$(($QUANTITY * 60 * 60 * 24)) ;;
+		    *)
+			echo "Error parsing duration '$BURN_DURATION'"
+			exit 1
+			;;
+		esac
+
+		db_progress START 0 $SECONDS $TEMPLATE_ROOT/progress/title
+
+		# Start a burn process for each core/processor, keeping
+		# track of their pids.
+		NUM_CPUS=$(grep -c "^processor" /proc/cpuinfo)
+		PID_LIST=""
+		while [ $NUM_CPUS -gt 0 ]; do
+			burn$BURN_TYPE &
+			PID_LIST="$PID_LIST $!"
+			NUM_CPUS=$(($NUM_CPUS - 1))
+		done
+
+		# We need to augment the progress bar with something that will
+		# stop moving when our system locks. Using the progress bar would 
+		# not be effective for this during long burns.
+		#
+		# An alternative solution would be to display the amount of time
+		# left for the burn-in, which the user can see decrementing as a
+		# sign that their machine is still alive.
+		STEP=1
+		while [ $SECONDS -gt 0 ]; do
+			case $STEP in
+			    1) PROGRESS="/" ;;
+			    2) PROGRESS="-" ;;
+			    3) PROGRESS="\\" ;;
+			    4)
+			        PROGRESS="|"
+				STEP=0
+				;;
+			esac
+			STEP=$(($STEP + 1))
+
+			db_subst $TEMPLATE_ROOT/progress/step PROGRESS "${PROGRESS}"
+			db_progress INFO $TEMPLATE_ROOT/progress/step || break
+			db_progress STEP 1 || break
+
+			SECONDS=$(($SECONDS - 1))
+			sleep 1
+		done
+
+		for PID in $PID_LIST; do
+			kill $PID || true
+		done
+
+		db_progress STOP
+		;;
+	esac
+
+	if db_go; then
+		STATE=$(($STATE + 1))
+	else
+		STATE=$(($STATE - 1))
+	fi
+done
diff --git a/debian/cpuburn-udeb.templates b/debian/cpuburn-udeb.templates
new file mode 100644
index 0000000..b818b87
--- /dev/null
+++ b/debian/cpuburn-udeb.templates
@@ -0,0 +1,44 @@
+Template: debian-installer/cpuburn-udeb/title
+Type: text
+Description: Perform CPU stress test (burn in)
+
+Template: cpuburn-udeb/confirm
+Type: boolean
+Default: false
+_Description: Are you sure you want to perform a burn test?
+ This may be dangerous for your system.
+ .
+ This process is designed to heavily load CPU chips. Undercooled,
+ overclocked or otherwise weak systems may fail causing possibly
+ permanent damage to electronic components.
+ .
+ Users should read the cpuburn documentation carefully before use.
+
+Template: cpuburn-udeb/type
+Type: select
+Choices: P5, P6, K6, K7, MMX, BX
+_Description: Burn-in type:
+ You should select a burn-in type suitable to your system.
+ .
+ The 'P5' test type is optimized for Intel Pentium processors,
+ 'P6' for Intel Pentium Pro, Pentium II & III and Celeron CPUs,
+ 'K6' for AMD K6 processors, and 'K7' for AMD Athlon and Duron
+ processors.
+ .
+ The 'MMX' variant is to test cache and memory interfaces on all
+ CPUs with MMX, and 'BX' is an alternate cache and memory test for
+ Intel CPUs.
+
+Template: cpuburn-udeb/duration
+Type: select
+Default: 30m
+Choices: 10m, 30m, 1h, 6h, 24h
+_Description: Burn-in duration
+
+Template: cpuburn-udeb/progress/title
+Type: text
+Description: Performing hardware burn-in
+
+Template: cpuburn-udeb/progress/step
+Type: text
+Description: Performing hardware burn-in. This may take some time... ${PROGRESS}
diff --git a/debian/rules b/debian/rules
index 06f202e..df55cc8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -30,6 +30,7 @@ install: build
 
 	for i in burnP5 burnP6 burnK6 burnK7 burnBX burnMMX ; do \
 		cp $(CURDIR)/$$i $(CURDIR)/debian/cpuburn/usr/bin ; \
+		cp $(CURDIR)/$$i $(CURDIR)/debian/cpuburn-udeb/usr/bin ; \
 	done
 
 # Build architecture-independent files here.

Attachment: signature.asc
Description: PGP signature


Reply to: