Merge lp:~roadmr/checkbox/752881-remove-bad-scrpit into lp:checkbox

Proposed by Daniel Manrique
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 2540
Merged at revision: 2541
Proposed branch: lp:~roadmr/checkbox/752881-remove-bad-scrpit
Merge into: lp:checkbox
Diff against target: 630 lines (+4/-611)
2 files modified
checkbox-old/debian/changelog (+4/-0)
checkbox-old/scripts/suspend_test (+0/-611)
To merge this branch: bzr merge lp:~roadmr/checkbox/752881-remove-bad-scrpit
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+197982@code.launchpad.net

Commit message

Removes an old, unused and bitrotten script.

Description of the change

Removes an old, unused and bitrotten script.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Sounds good, we can always revert this to resurrect the script +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-old/debian/changelog'
2--- checkbox-old/debian/changelog 2013-12-03 15:46:07 +0000
3+++ checkbox-old/debian/changelog 2013-12-06 01:39:37 +0000
4@@ -4,6 +4,10 @@
5 * scripts/network Handle ZeroDivisionError better (LP: #1257308)
6
7
8+ [ Daniel Manrique ]
9+ * Removed suspend_test script which hasn't been touched in over 3 years
10+ and is not used in any jobs. (LP: #752881)
11+
12 -- Sylvain Pineau <sylvain.pineau@canonical.com> Fri, 29 Nov 2013 22:30:45 +0100
13
14 checkbox (0.17) trusty; urgency=low
15
16=== removed file 'checkbox-old/scripts/suspend_test'
17--- checkbox-old/scripts/suspend_test 2013-05-29 07:50:30 +0000
18+++ checkbox-old/scripts/suspend_test 1970-01-01 00:00:00 +0000
19@@ -1,611 +0,0 @@
20-#!/bin/bash
21-#
22-# Script to automate suspend / resume
23-#
24-# Copyright (C) 2008-2009 Canonical Ltd.
25-#
26-# Authors:
27-# Michael Frey <michael.frey@canonical.com>
28-# Andy Whitcroft <apw@canonical.com>
29-#
30-# This program is free software: you can redistribute it and/or modify
31-# it under the terms of the GNU General Public License version 2,
32-# as published by the Free Software Foundation.
33-#
34-# This program is distributed in the hope that it will be useful,
35-# but WITHOUT ANY WARRANTY; without even the implied warranty of
36-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37-# GNU General Public License for more details.
38-#
39-# You should have received a copy of the GNU General Public License
40-# along with this program. If not, see <http://www.gnu.org/licenses/>.
41-
42-#
43-# Script to automate suspend / resume
44-#
45-# We set a RTC alarm that wakes the system back up and then sleep
46-# for seconds before we go back to sleep.
47-#
48-# Changelog:
49-#
50-# V8:
51-# - add a new suspend battery drain test
52-# - track batteries disabling tests which require them automatically
53-# - disable dbus tests when we have no primary user
54-# - include the new power drain test in --full
55-# - handle AC transitions better
56-# - use minutes in messages where appropriate
57-# - report AC transition failures
58-# - only mention AC when we have batteries
59-# - report results at the bottom for easy posting
60-#
61-# V7:
62-# - add a --dry-run mode to simplify developement
63-# - add a automation mode for checkbox integration
64-# - add a new pm-suspend test
65-# - record and restore timer_delay around the variable time test.
66-#
67-# V6:
68-# - move an --enable/--disable interface for tests
69-# - add --set to allow setting of approved parameters
70-# - fix up prompting for interactive and non-interactive tests
71-# - supply a sensible default for testing on servers (apw, kirkland)
72-#
73-# V5:
74-# - send dbus messages as the original user
75-# - stop clearing the dmesg as we go
76-# - stop using trace generally as this affects the wakeups
77-# - do a single dbus test then move to pm-suspend to avoid screensaver
78-# - timeout waiting for a suspend to complete catching failure to go down
79-#
80-# V4:
81-# - update the help output
82-# - add --comprehensive to do AC related tests
83-# - add --extensive to do a range of time related tests
84-# - add --full to enable all harder tests
85-# - add fallback to pm-suspend for Kbuntu
86-# - collect dmesg output
87-# - remove hwclock update
88-#
89-# V3:
90-# - fix typo in fallback acpi interface
91-# - when recording the RTC clock do not go direct
92-# - pmi is now deprecated suspend using dbus
93-#
94-# V2:
95-# - support newer rtc sysfs wakealarm interface
96-# - move to using pmi action suspend
97-# - allow the user to specify the number of iterations
98-# - ensure we are running as root
99-# - report the iterations to the user
100-# - clean up the output and put it in a standard logfile
101-# - add a descriptive warning and allow user cancel
102-# - add tracing enable/disable
103-# - fix logfile location
104-# - add a failure cleanup mode
105-# - make time sleep time and delay time configurable
106-# - ensure the log directory exists
107-# - clock will be fixed automatically on network connect
108-# - default sleep before wakeup to 20s
109-# - do not use dates after we have corrupted the clock
110-# - sort out the copyright information
111-# - we do not have any failure cleanup currently
112-#
113-# V1:
114-# - add the suspend test scripts
115-#
116-P="test-suspend"
117-
118-LOGDIR='/var/lib/pm-utils'
119-LOGFILE="$LOGDIR/stress.log"
120-
121-setup_wakeup_timer ()
122-{
123- timeout="$1"
124-
125- #
126- # Request wakeup from the RTC or ACPI alarm timers. Set the timeout
127- # at 'now' + $timeout seconds.
128- #
129- ctl='/sys/class/rtc/rtc0/wakealarm'
130- if [ -f "$ctl" ]; then
131- # Cancel any outstanding timers.
132- echo "0" >"$ctl"
133- # rtcN/wakealarm can use relative time in seconds
134- echo "+$timeout" >"$ctl"
135- return 0
136- fi
137- ctl='/proc/acpi/alarm'
138- if [ -f "$ctl" ]; then
139- echo `date '+%F %H:%M:%S' -d '+ '$timeout' seconds'` >"$ctl"
140- return 0
141- fi
142-
143- echo "no method to awaken machine automatically" 1>&2
144- exit 1
145-}
146-
147-suspend_system ()
148-{
149- if [ "$dry" -eq 1 ]; then
150- echo "DRY-RUN: suspend machine for $timer_sleep"
151- sleep 1
152- return
153- fi
154-
155- setup_wakeup_timer "$timer_sleep"
156-
157- dmesg >"$LOGFILE.dmesg.A"
158-
159- # Send a dbus message to initiate Suspend.
160- if [ "$suspend_dbus" -eq 1 ]; then
161- sudo -u $SUDO_USER dbus-send --session --type=method_call \
162- --dest=org.freedesktop.PowerManagement \
163- /org/freedesktop/PowerManagement \
164- org.freedesktop.PowerManagement.Suspend \
165- >> "$LOGFILE" || {
166- ECHO "FAILED: dbus suspend failed"
167- return
168- }
169- else
170- pm-suspend >> "$LOGFILE"
171- fi
172-
173- # Wait on the machine coming back up -- pulling the dmesg over.
174- echo "v---" >>"$LOGFILE"
175- retry=30
176- while [ "$retry" -gt 0 ]; do
177- let "retry=$retry-1"
178-
179- # Accumulate the dmesg delta.
180- dmesg >"$LOGFILE.dmesg.B"
181- diff "$LOGFILE.dmesg.A" "$LOGFILE.dmesg.B" | \
182- grep '^>' >"$LOGFILE.dmesg"
183- mv "$LOGFILE.dmesg.B" "$LOGFILE.dmesg.A"
184-
185- echo "Waiting for suspend to complete $retry to go ..." \
186- >> "$LOGFILE"
187- cat "$LOGFILE.dmesg" >> "$LOGFILE"
188-
189- if [ "`grep -c 'Back to C!' $LOGFILE.dmesg`" -ne 0 ]; then
190- break;
191- fi
192- sleep 1
193- done
194- echo "^---" >>"$LOGFILE"
195- rm -f "$LOGFILE.dmesg"*
196- if [ "$retry" -eq 0 ]; then
197- ECHO "SUSPEND FAILED, did not go to sleep"
198- fi
199-}
200-
201-delay_system ()
202-{
203- if [ "$dry" -eq 1 ]; then
204- echo "DRY-RUN: stay awake for $timer_delay"
205- sleep 1
206- return
207- fi
208-
209- #
210- # wait for $timer_delay seconds after system resume from S3
211- #
212- ECHO "wait for $timer_delay seconds"
213- sleep $timer_delay
214-}
215-
216-ECHO ()
217-{
218- echo "$@" | tee -a "$LOGFILE"
219-}
220-
221-run_suspend ()
222-{
223- CNT=1
224- TOTAL=$1
225- ECHO "Suspend Test starting on $(date '+%F %H:%M:%S') ($TOTAL cycles)"
226- while [ "$CNT" -le "$TOTAL" ]
227- do
228- ECHO "Suspend iteration $CNT of $TOTAL"
229-
230- suspend_system "$START"
231- delay_system
232-
233- (( CNT++ ))
234- done
235- ECHO "Suspend Test completed"
236-}
237-
238-enable_trace()
239-{
240- echo 1 > '/sys/power/pm_trace'
241-}
242-
243-disable_trace()
244-{
245- echo 0 > '/sys/power/pm_trace'
246-}
247-
248-# Battery
249-battery_count()
250-{
251- cat /proc/acpi/battery/*/state 2>/dev/null | \
252- awk '
253- BEGIN { total = 0 }
254- /present:.*yes/ { total += 1 }
255- END { print total }
256- '
257-}
258-battery_capacity()
259-{
260- cat /proc/acpi/battery/*/state 2>/dev/null | \
261- awk '
262- BEGIN { total = 0 }
263- /remaining capacity:/ { total += $3 }
264- END { print total }
265- '
266-}
267-
268-#
269-# MAIN
270-#
271-usage() {
272- cat - 1>&2 <<EOM
273-Usage: $P [<options>]
274-Options:
275- --sleep <seconds> - how long the machine wait before waking
276- --delay <seconds> - default delay between iterations
277-
278- --enable <test> - enable a specific test
279- --disable <test> - disable a specific test
280- --set <test>.<var>=<val> - set a test specific variable
281- dbus - perform a suspend via dbus
282- ac - perform tests involving removing ac power
283- timed - perform a variable timing test
284- repeat - perform a longer repeat test
285- .iterations - the number of iterations in the repeat
286- power - perform a battery consumption test
287- .sleep - how long to sleep
288-
289- --full - run a basic set of tests
290- --server - run those test appropriate for a server
291-EOM
292-}
293-
294-# We need TEMP as the `eval set --' would nuke the return value of getopt.
295-TEMP=`getopt -o '' -l dry-run,auto,,sleep:,delay:,enable:,disable:,set:,full,desktop,server -n "$P" -- "$@"`
296-if [ $? != 0 ] ; then
297- usage
298- exit 1
299-fi
300-
301-# Note the quotes around `$TEMP': they are essential!
302-eval set -- "$TEMP"
303-
304-# Options helpers.
305-chk_test ()
306-{
307- if ! declare -p "test_$1" 2>/dev/null 1>&2; then
308- echo "$P: $1: test unknown" 1>&2
309- exit 1
310- fi
311-}
312-handle_set ()
313-{
314- stmt=`echo "$1" | sed -e 's/\./_/g'`
315-
316- test="${stmt%%_*}"
317- var="${stmt%%=*}"
318-
319- chk_test "$test"
320- if ! declare -p "args_$var" 2>/dev/null 1>&2; then
321- echo "$P: $var: test variable unknown" 1>&2
322- exit 1
323- fi
324-
325- RET="args_$stmt"
326-}
327-chk_number() {
328- eval "val=\"\$$1\""
329- let num="0+$val"
330- if [ "$val" != "$num" ]; then
331- name=`echo "$1" | sed -e 's/args_//' -e 's/_/./'`
332- echo "$P: $name: $val: non-numeric value" 1>&2
333- exit 1
334- fi
335-}
336-
337-# Options handling.
338-dry=0
339-auto=0
340-timer_sleep=20
341-timer_delay=10
342-
343-test_dbus=0
344-test_pmsuspend=0
345-test_ac=0
346-test_timed=0
347-test_repeat=0
348-args_repeat_iterations=10
349-test_power=0
350-args_power_sleep=1200
351-
352-while :
353-do
354- case "$1" in
355- --dry-run) dry=1; shift 1 ;;
356- --auto) auto=1; shift 1 ;;
357- --sleep) timer_sleep="$2"; shift 2 ;;
358- --delay) timer_delay="$2"; shift 2 ;;
359- --disable) chk_test "$2"; declare "test_$1=0"; shift 2 ;;
360- --enable) chk_test "$2"; declare "test_$2=1"; shift 2 ;;
361- --set) handle_set "$2"; declare "$RET"; shift 2 ;;
362- --desktop|--full) test_dbus=1; test_ac=1; test_timed=1;
363- test_power=1; shift 1 ;;
364- --server) test_timed=1; shift 1 ;;
365- --) shift; break ;;
366- *) echo "$1: ERROR"; exit 1 ;;
367- esac
368-done
369-
370-chk_number "args_repeat_iterations"
371-chk_number "args_power_sleep"
372-
373-tests=`set | grep ^test_ | grep -c =1`
374-
375-if [ "$#" -gt 1 ]; then
376- usage
377- exit 1
378-fi
379-if [ "$tests" -eq 0 ]; then
380- usage
381- echo "$P: no tests selected" 1>&2
382- exit 1
383-fi
384-
385-battery_count=`battery_count`
386-
387-report_battery=''
388-
389-suspend_dbus=0
390-
391-# Check we are running as root as we are going to fiddle with the clock
392-# and use the rtc wakeups.
393-id=`id -u`
394-if [ "$id" -ne 0 ]; then
395- echo "ERROR: must be run as root to perform this test, use sudo:" 1>&2
396- echo " sudo $0 $@" 1>&2
397- exit 1
398-fi
399-
400-ac_needed=-1
401-ac_is=-1
402-ac_becomes=-1
403-ac_required()
404-{
405- ac_check
406-
407- ac_needed="$1"
408- ac_becomes="$1"
409-}
410-ac_transitions()
411-{
412- ac_check
413-
414- ac_needed="$1"
415- ac_becomes="$2"
416-}
417-ac_online()
418-{
419- cat /proc/acpi/ac_adapter/*/state 2>/dev/null | \
420- awk '
421- BEGIN { online = 0; offline = 0 }
422- /on-line/ { online = 1 }
423- /off-line/ { offline = 1 }
424- END {
425- if (online) {
426- print "1"
427- } else if (offline) {
428- print "0"
429- } else {
430- print "-1"
431- }
432- }
433- '
434-}
435-ac_check()
436-{
437- typeset ac_current=`ac_online`
438-
439- if [ "$ac_becomes" -ne -1 -a "$ac_current" -ne -1 -a \
440- "$ac_current" -ne "$ac_becomes" ]; then
441- ECHO "*** WARNING: AC power not in expected state" \
442- "($ac_becomes) after test"
443- fi
444- ac_is="$ac_becomes"
445-}
446-
447-phase=0
448-phase_first=1
449-phase_interactive=1
450-phase()
451-{
452- typeset sleep
453-
454- let phase="$phase+1"
455-
456- echo ""
457- echo "*** TEST $phase -- $1"
458- shift 1
459- for line in "$@"
460- do
461- echo "*** $line"
462- done
463- if [ "$battery_count" -ne 0 -a "$ac_needed" -ne "$ac_is" ]; then
464- case "$ac_needed" in
465- 0) echo "*** please ensure your AC cord is detached" ;;
466- 1) echo "*** please ensure your AC cord is attached" ;;
467- esac
468- ac_is="$ac_needed"
469- fi
470-
471- if [ "$timer_sleep" -gt 60 ]; then
472- let sleep="$timer_sleep / 60"
473- sleep="$sleep minutes"
474- else
475- sleep="$timer_sleep seconds"
476- fi
477- echo "*** machine will suspend for $sleep"
478-
479- if [ "$auto" -eq 1 ]; then
480- :
481-
482- elif [ "$phase_interactive" -eq 1 ]; then
483- echo "*** press return when ready"
484- read x
485-
486- elif [ "$phase_first" -eq 1 ]; then
487- echo "*** NOTE: there will be no further user interaction from this point"
488- echo "*** press return when ready"
489- phase_first=0
490- read x
491- fi
492- echo ""
493-}
494-
495-[ "$auto" -eq 0 ] && cat - <<EOM
496-This script will attempt to suspend and resume your computer a number of times.
497-Should the machine fail to resume, first attempt to manually resume it. If
498-that fails power your system off and on which will generate an apport bug
499-report automatically.
500-
501-Press CTRL-C now to abort testing ...
502-EOM
503-
504-# Ensure the log directory exists.
505-mkdir -p "$LOGDIR"
506-
507-phase_interactive=1
508-if [ "$test_dbus" -eq 1 -a \
509- \( "$SUDO_USER" = "" -o "$SUDO_USER" = "root" \) ]; then
510- ECHO "*** no primary user (via sudo) dbus tests skipped ..."
511-elif [ "$test_dbus" -eq 1 ]; then
512- ac_required 1
513- suspend_dbus=1
514- phase "suspend triggered via dbus message"
515- suspend_system
516- suspend_dbus=0
517-fi
518-if [ "$test_pmsuspend" -eq 1 ]; then
519- ac_required 1
520- phase "suspend triggered via pm-suspend"
521- suspend_system
522-fi
523-if [ "$test_ac" -eq 1 -a "$battery_count" -eq 0 ]; then
524- ECHO "*** no BATTERY detected ac tests skipped ..."
525-elif [ "$test_ac" -eq 1 ]; then
526- ac_required 0
527- phase "suspend with AC disconnected"
528- suspend_system
529-
530- ac_required 1
531- phase "suspend with AC connected"
532- suspend_system
533-
534- ac_transitions 1 0
535- phase "loss of AC while suspended" \
536- "please remove the AC cord while the machine is suspended"
537- suspend_system
538-
539- ac_transitions 0 1
540- phase "return of AC while suspended" \
541- "please insert the AC cord while the machine is suspended"
542- suspend_system
543-fi
544-if [ "$test_power" -eq 1 -a "$battery_count" -eq 0 ]; then
545- ECHO "*** no BATTERY detected power test skipped ..."
546-elif [ "$test_power" -eq 1 ]; then
547- save_timer_sleep="$timer_sleep"
548- let timer_sleep="$args_power_sleep"
549-
550- ac_required 0
551- phase "battery drain during suspend" \
552- "calculates overall power drain during a long-term suspend"
553-
554- # get start values
555- date_before=`date +%s`
556- bat_before=`battery_capacity`
557-
558- # Suspend
559- suspend_system
560-
561- # get end values
562- date_after=`date +%s`
563- bat_after=`battery_capacity`
564-
565- # do the calculations
566- let consumed="$bat_before - $bat_after"
567- let elapsed="$date_after - $date_before"
568- let usage="($consumed * 60*60) / $elapsed"
569-
570- # output the results
571- ECHO "before: $bat_before mWh"
572- ECHO "after: $bat_after mWh"
573- ECHO "consumed: $consumed mW"
574- ECHO "sleep seconds: $elapsed sec"
575- ECHO "overall usage: $usage mW"
576-
577- report_battery="$usage mW"
578-
579- if [ $elapsed -lt 1200 ]
580- then
581- ECHO "WARNING: the suspend was less than 20 minutes"
582- ECHO " to get reliable numbers increase the sleep time"
583- report_battery="$report_battery (unreliable)"
584- fi
585-
586- timer_sleep="$save_timer_sleep"
587-fi
588-
589-phase_interactive=0
590-if [ "$test_timed" -eq 1 ]; then
591- save_timer_delay="$timer_delay"
592- timer_delay=60
593-
594- ac_required 1
595- phase "30 iteration variable delay suspend/resume stress test"
596- while [ "$timer_delay" -gt 0 ]; do
597- echo "delay $timer_delay ..."
598- suspend_system
599- delay_system
600- let timer_delay="$timer_delay - 2"
601- done
602- timer_delay="$save_timer_delay"
603-fi
604-if [ "$test_repeat" -eq 1 ]; then
605- ac_required 1
606- phase "basic $args_repeat_iterations iteration suspend/resume stress test"
607- run_suspend "$args_repeat_iterations"
608-fi
609-
610-ac_check
611-
612-#
613-# REPORT: final report stage.
614-#
615-report_this()
616-{
617- if [ "$2" != "" ]; then
618- echo " $1 $2"
619- fi
620-}
621-if [ "$auto" -eq 0 ]; then
622- echo ""
623- echo "*** Please report your results on the Ubuntu WIKI:"
624- echo " https://wiki.ubuntu.com/KernelTeam/SuspendResumeTesting"
625- echo ""
626- report_this "Battery Consumption:" "$report_battery"
627-fi
628-
629-# All suceessful, clean up.
630-rm -f "$LOGFILE"

Subscribers

People subscribed via source and target branches