diff options
| -rwxr-xr-x | bin/disk_smart | 18 | ||||
| -rwxr-xr-x | bin/hdd_parking | 6 | ||||
| -rwxr-xr-x | bin/memory_compare | 48 | ||||
| -rw-r--r-- | jobs/disk.txt.in | 4 | ||||
| -rw-r--r-- | jobs/stress.txt.in | 2 | ||||
| -rw-r--r-- | po/pl.po | 2 | 
6 files changed, 61 insertions, 19 deletions
| diff --git a/bin/disk_smart b/bin/disk_smart index 35457006..c7f58dfa 100755 --- a/bin/disk_smart +++ b/bin/disk_smart @@ -125,6 +125,7 @@ def get_smart_entries(disk, type='selftest'):  # Get lengths from header  line = stdout.readline().decode()  if not line.startswith('Num'): + entries.append('No entries found in log yet')  return entries  columns = ['number', 'description', 'status',  'remaining', 'lifetime', 'lba'] @@ -215,13 +216,16 @@ def main():  time.sleep(args.sleep)  current_entries = get_smart_entries(disk) - logging.debug('%s %s %s %s' % (current_entries[0]['number'], - current_entries[0]['description'], - current_entries[0]['status'], - current_entries[0]['remaining'])) - if current_entries != previous_entries \ - and current_entries[0]["status"] != 'Self-test routine in progress': - break + if isinstance(current_entries[0], str): + logging.debug(current_entries[0]) + else: + logging.debug('%s %s %s %s' % (current_entries[0]['number'], + current_entries[0]['description'], + current_entries[0]['status'], + current_entries[0]['remaining'])) + if current_entries != previous_entries \ + and current_entries[0]["status"] != 'Self-test routine in progress': + break  if args.timeout is not None:  if args.timeout <= 0: diff --git a/bin/hdd_parking b/bin/hdd_parking index ead27c01..18151b4f 100755 --- a/bin/hdd_parking +++ b/bin/hdd_parking @@ -43,8 +43,12 @@ from subprocess import Popen, PIPE  TIMEOUT = 15.0  def hdaps_test(run_time): - hdapsd = Popen(['/usr/sbin/hdapsd'], stdout=PIPE, stderr=PIPE, + try: + hdapsd = Popen(['/usr/sbin/hdapsd'], stdout=PIPE, stderr=PIPE,  universal_newlines=True) + except OSError as err: + print("Unable to start hdapsd: {}".format(err)) + return 1  time.sleep(float(run_time))  hdapsd.terminate()  # Look for parking message in hdapsd output. diff --git a/bin/memory_compare b/bin/memory_compare index 41436739..2c26f673 100755 --- a/bin/memory_compare +++ b/bin/memory_compare @@ -24,6 +24,7 @@  import os  import sys +from math import log, copysign  from subprocess import check_output, PIPE  from checkbox_support.parsers.lshwjson import LshwJsonParser @@ -81,6 +82,32 @@ def get_threshold(installed_memory):  return 10 +def bytes_to_human(my_bytes): + """ Convert my_bytes to a scaled representation with a + suffix + """ + if my_bytes == 0: + return "0 bytes" + + suffixes = ["bytes", "KiB", "MiB", "GiB", "TiB", + "PiB", "EiB", "ZiB", "YiB"] + + try: + sign = copysign(1, my_bytes) + except OverflowError as excp: + return "(Number too large: {})".format(excp) + my_bytes = abs(my_bytes) + # my_bytes' base-1024 logarithm. + exponent = log(my_bytes, 1024) + try: + suffix = suffixes[int(exponent)] + except IndexError: + return "(Number too large)" + scalar = my_bytes / (1024**int(exponent)) + + return "{:.2f} {}".format(sign * scalar, suffix) + +  def main():  if os.geteuid() != 0:  print("This script must be run as root.", file=sys.stderr) @@ -95,9 +122,11 @@ def main():  percentage = difference / installed_memory * 100  except ZeroDivisionError:  print("Results:") - print("\t/proc/meminfo reports:\t%s kB" % (visible_memory / 1024), + print("\t/proc/meminfo reports:\t{}".format( + bytes_to_human(visible_memory)),  file=sys.stderr) - print("\tlshw reports:\t%s kB" % (installed_memory / 1024), + print("\tlshw reports:\t{}".format( + bytes_to_human(installed_memory)),  file=sys.stderr)  print("\nFAIL: Either lshw or /proc/meminfo returned a memory size "  "of 0 kB", file=sys.stderr) @@ -105,17 +134,20 @@ def main():  if percentage <= threshold:  print("Results:") - print("\t/proc/meminfo reports:\t%s kB" % (visible_memory / 1024)) - print("\tlshw reports:\t%s kB" % (installed_memory / 1024)) - print("\nPASS: Meminfo reports %d bytes less than lshw, a " + print("\t/proc/meminfo reports:\t{}".format( + bytes_to_human(visible_memory))) + print("\tlshw reports:\t{}".format(bytes_to_human(installed_memory))) + print("\nPASS: Meminfo reports %s less than lshw, a "  "difference of %.2f%%. This is less than the " - "%d%% variance allowed." % (difference, percentage, threshold)) + "%d%% variance allowed." % (bytes_to_human(difference), + percentage, threshold))  return 0  else:  print("Results:", file=sys.stderr) - print("\t/proc/meminfo reports:\t%s kB" % (visible_memory / 1024), + print("\t/proc/meminfo reports:\t{}".format( + bytes_to_human(visible_memory)),  file=sys.stderr) - print("\tlshw reports:\t%s kB" % (installed_memory / 1024), + print("\tlshw reports:\t{}".format(bytes_to_human(installed_memory)),  file=sys.stderr)  print("\nFAIL: Meminfo reports %d bytes less than lshw, "  "a difference of %.2f%%. Only a variance of %d%% in " diff --git a/jobs/disk.txt.in b/jobs/disk.txt.in index c17746db..4dd440f1 100644 --- a/jobs/disk.txt.in +++ b/jobs/disk.txt.in @@ -123,7 +123,9 @@ _description:  plugin: user-interact  id: disk/hdd-parking  estimated_duration: 60.0 -requires: device.category == 'DISK' +requires: + device.category == 'DISK' + package.name == 'hdapsd'  depends: input/accelerometer  user: root  command: hdd_parking diff --git a/jobs/stress.txt.in b/jobs/stress.txt.in index 63a22e7f..0eb374ae 100644 --- a/jobs/stress.txt.in +++ b/jobs/stress.txt.in @@ -279,7 +279,7 @@ requires:  package.name == 'x11-apps'  user: root  environ: PLAINBOX_SESSION_SHARE -command: graphics_stress_test -b repeat -d -o $PLAINBOX_SESSION_SHARE/graphics-stress-results && echo "Graphics Stress Test completed successfully" || echo "Graphics Stress Test completed, but there are errors. Please see the log $PLAINBOX_SESSION_SHARE/graphics-stress-results for details" && false +command: graphics_stress_test --iterations 20 -b repeat -d -o $PLAINBOX_SESSION_SHARE/graphics-stress-results && echo "Graphics Stress Test completed successfully" || echo "Graphics Stress Test completed, but there are errors. Please see the log $PLAINBOX_SESSION_SHARE/graphics-stress-results for details" && false  _description:  Run the graphics stress test. This test can take a few minutes. @@ -14,7 +14,7 @@ msgstr ""  "MIME-Version: 1.0\n"  "Content-Type: text/plain; charset=UTF-8\n"  "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2014-09-03 05:49+0000\n" +"X-Launchpad-Export-Date: 2014-09-11 05:56+0000\n"  "X-Generator: Launchpad (build 17196)\n"  "Language: Polish\n" | 
