Created
February 17, 2015 11:45
-
-
Save jschmid1/72f8aac2055620da0c76 to your computer and use it in GitHub Desktop.
s3 / s4 testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| dir=/var/tmp | |
| log=$dir/test_hib.log | |
| if [ x`id -u` != x0 ] ; then | |
| echo "call as root!" | |
| exit 1 | |
| fi | |
| # | |
| # Args analysis | |
| # | |
| method="$1" | |
| watchdog="$2 $3" | |
| maxnum="$4" | |
| if [ "x$1" = x ] ; then | |
| cat 1>&2 <<"EOUSAGE" | |
| Usage: $0 <s4|s4k|s3|s4hy|s3k|s4simdev|s4simcore|s3simdev|s3simplatform|s3simcore|s4simcpu> [watchdog port [maxnum]] | |
| Possible deductions: | |
| simdev fails -> no BIOS issue | |
| simcore passes AND s4k fails -> BIOS issue | |
| s4simcpu fails -> no BIOS issue + CPU hotplug bug | |
| Only use coresim on machines that switch off power to busses in ACPI. | |
| EOUSAGE | |
| exit 1 | |
| fi | |
| if [ "x$watchdog" = "x " ] ; then | |
| watchdog="" | |
| fi | |
| if [ "x$maxnum" = x ] ; then | |
| maxnum=9999999999 | |
| fi | |
| delay=10 | |
| resume="" | |
| simulation="none" | |
| case "x$method" in | |
| xs4) resume=60; ;; | |
| xs4k) resume=60; ;; | |
| xs4hy) resume=60; ;; | |
| xs3) resume=60; ;; | |
| xs3k) resume=60; ;; | |
| xs43) alternate=1; method="s4" resume=70 ;; | |
| xs43k) alternate=1; method="s4" resume=70 ;; | |
| xs4simdev) simulation="devices"; delay=5; ;; | |
| xs4simcore) simulation="core"; delay=5; ;; | |
| xs3simdev) simulation="devices"; delay=5; ;; | |
| xs3simplatform) simulation="platform"; delay=5; ;; | |
| xs3simcore) simulation="core"; delay=5; ;; | |
| xs4simcpu) simulation="processors";delay=0; ;; | |
| *) | |
| echo "unknown method $method" | |
| exit 1 | |
| esac | |
| # | |
| # Preparations | |
| # | |
| if [ "x$resume" != x ] ; then | |
| # Set hwclock as UTC to current clock | |
| . /etc/sysconfig/clock | |
| if [ "x$HWCLOCK" != x-u ] ; then | |
| echo "!!ATTENTION!! Setting up UTC hw clock" | |
| sed -i '/^HWCLOCK=/s/.*/HWCLOCK="-u"/' /etc/sysconfig/clock | |
| fi | |
| /sbin/hwclock --systohc -u | |
| fi | |
| # Deprecated because gconftool-2 was replaced by gsettings. screensaver is auto disabled when using root user | |
| # Disable auto suspend / blank | |
| #if [ x`gconftool-2 -g /apps/gnome-power-manager/timeout/sleep_computer_ac` != x0 ] ; then | |
| # echo "!!ATTENTION!! Disabling auto sleep and screen saver" | |
| # gconftool-2 -s /apps/gnome-power-manager/timeout/sleep_computer_ac --type int 0 | |
| # gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool false | |
| #fi | |
| echo "" | |
| #instruct the kernel | |
| echo $simulation > /sys/power/pm_test | |
| pmtrace=1 | |
| test "x$simulation" = xnone && pmtrace=0 | |
| test -e /sys/power/pm_trace && echo $pmtrace > /sys/power/pm_trace | |
| # | |
| # State dumper | |
| # | |
| dump_state() { | |
| echo "======================================" | |
| echo "PCI CONFIG SPACE" | |
| echo "--------------------------------------" | |
| /sbin/lspci -xxxvv | |
| echo "======================================" | |
| echo "DMI" | |
| echo "--------------------------------------" | |
| /usr/sbin/dmidecode | |
| echo "======================================" | |
| echo "dmesg" | |
| echo "--------------------------------------" | |
| dmesg | |
| } | |
| # | |
| # Other subroutines | |
| # | |
| set_alarm() { | |
| while true ; do | |
| echo 0 >/sys/class/rtc/rtc0/wakealarm && break | |
| sleep 1 | |
| done | |
| while true ; do | |
| echo $t >/sys/class/rtc/rtc0/wakealarm && break | |
| sleep 1 | |
| done | |
| sleep 1 | |
| } | |
| # | |
| # Main loop | |
| # | |
| echo "Logging to $log + $dir/test_hib.state.*" | |
| echo "" | |
| rm -f $log | |
| find $dir -name test_hib.state.\* -exec rm \{\} \+ | |
| :> $log | |
| c=0 | |
| nextsync=2 | |
| while [ $c -lt $maxnum ] ; do | |
| # Setup delay | |
| if [ "x$delay" != x0 ] ; then | |
| echo "Sleeping $delay secs..." | |
| sleep $delay | |
| fi | |
| # State dump | |
| c=$(($c+1)) | |
| dump_state >$dir/test_hib.state.$c 2>&1 | |
| gzip $dir/test_hib.state.$c | |
| # Setting info to watchdog | |
| # Do after sleep (so networkmanager has a chance) | |
| # TODO: send state shortcut | |
| if [ "x$watchdog" != x ] ; then | |
| echo "$method $c" | netcat $watchdog | |
| fi | |
| if [ "x$resume" != x ] ; then | |
| # Resync HW clock | |
| if [ $c -ge $nextsync ] ; then | |
| echo "resyncing clock..." | |
| /sbin/hwclock --hctosys -u | |
| nextsync=$(($nextsync+2)) | |
| fi | |
| # Resume time calc | |
| date=`date` | |
| t=`date --date "$date $resume sec" +%s` | |
| tt="`date -d @$t`" | |
| echo "$method sim $simulation $c: Wakeup at $tt" | |
| echo "$method sim $simulation $c: Wakeup at $tt" >>$log | |
| fi | |
| d="`date`" | |
| echo "$method sim $simulation $c: $d: suspending..." | |
| echo "$method sim $simulation $c: $d: suspending..." >>$log | |
| # Emergency sync | |
| sync | |
| # Suspend/Hibernate | |
| case "x$method" in | |
| xs4) | |
| set_alarm $t | |
| systemctl hibernate | |
| ;; | |
| xs4k) | |
| set_alarm $t | |
| echo disk >/sys/power/state | |
| ;; | |
| xs4hy) | |
| set_alarm $t | |
| systemctl hybrid-sleep | |
| ;; | |
| xs3) | |
| #NUM_SECONDS_TO_SLEEP=$resume pm-suspend | |
| set_alarm $t | |
| systemctl suspend | |
| ;; | |
| xs3k) | |
| set_alarm $t | |
| echo mem >/sys/power/state | |
| ;; | |
| xs4sim*) | |
| echo disk >/sys/power/state | |
| ;; | |
| xs3sim*) | |
| echo mem >/sys/power/state | |
| ;; | |
| *) | |
| exit 1; | |
| esac | |
| # Post-resume | |
| d="`date`" | |
| echo "$method sim $simulation $c: $d: resuming" >>$log | |
| sync | |
| echo "$method sim $simulation $c: $d: resuming" | |
| done | |
| # | |
| # EOT | |
| # | |
| echo "none" >/sys/power/pm_test | |
| echo "Maximum reached" | |
| echo "Maximum reached" >>$log | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment