summaryrefslogtreecommitdiff
diff options
-rwxr-xr-xbin/brightness_test82
-rwxr-xr-xbin/disk_stress_ng2
-rwxr-xr-xbin/pm_test10
-rwxr-xr-xbin/removable_storage_test16
-rw-r--r--units/graphics/jobs.pxu2
-rw-r--r--units/power-management/jobs.pxu4
-rw-r--r--units/stress/jobs.pxu10
-rw-r--r--units/wireless/jobs.pxu2
8 files changed, 59 insertions, 69 deletions
diff --git a/bin/brightness_test b/bin/brightness_test
index 818796e..af1de1b 100755
--- a/bin/brightness_test
+++ b/bin/brightness_test
@@ -5,9 +5,11 @@
#
# This file is part of Checkbox.
#
-# Copyright 2012 Canonical Ltd.
+# Copyright 2012-2018 Canonical Ltd.
#
-# Authors: Alberto Milone <alberto.milone@canonical.com>
+# Authors:
+# Alberto Milone <alberto.milone@canonical.com>
+# Sylvain Pineau <sylvain.pineau@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
@@ -33,7 +35,7 @@ from glob import glob
class Brightness(object):
def __init__(self, path='/sys/class/backlight'):
self.sysfs_path = path
- self._interfaces = self._get_interfaces_from_path()
+ self.interfaces = self._get_interfaces_from_path()
def read_value(self, path):
'''Read the value from a file'''
@@ -94,36 +96,6 @@ class Brightness(object):
return interfaces
- def get_best_interface(self):
- '''Get the best acpi interface'''
- # Follow the heuristic in https://www.kernel.org/doc/Documentation/
- #ABI/stable/sysfs-class-backlight
- if len(self._interfaces) == 0:
- return None
- else:
- interfaces = {}
- for interface in self._interfaces:
- try:
- with open(interface + '/type') as type_file:
- iface_type = type_file.read().strip()
- except IOError:
- continue
- interfaces[iface_type] = interface
-
- if interfaces.get('firmware'):
- return interfaces.get('firmware')
- elif interfaces.get('platform'):
- return interfaces.get('platform')
- elif interfaces.get('raw'):
- return interfaces.get('raw')
- else:
- fallback_type = sorted(interfaces.keys())[0]
- print("WARNING: no interface of type firmware/platform/raw "
- "found. Using {} of type {}".format(
- interfaces[fallback_type],
- fallback_type))
- return interfaces[fallback_type]
-
def was_brightness_applied(self, interface):
'''See if the selected brightness was applied
@@ -132,9 +104,9 @@ class Brightness(object):
'''
if (abs(self.get_actual_brightness(interface) -
self.get_last_set_brightness(interface)) > 1):
- return False
+ return 1
else:
- return True
+ return 0
def main():
@@ -146,33 +118,35 @@ def main():
file=sys.stderr)
exit(1)
- interface = brightness.get_best_interface()
# If no backlight interface can be found
- if not interface:
+ if len(brightness.interfaces) == 0:
exit(1)
- # Get the current brightness which we can restore later
- current_brightness = brightness.get_actual_brightness(interface)
+ exit_status = 0
+ for interface in brightness.interfaces:
+
+ # Get the current brightness which we can restore later
+ current_brightness = brightness.get_actual_brightness(interface)
- # Get the maximum value for brightness
- max_brightness = brightness.get_max_brightness(interface)
+ # Get the maximum value for brightness
+ max_brightness = brightness.get_max_brightness(interface)
- # Set the brightness to half the max value
- brightness.write_value(max_brightness / 2,
- os.path.join(interface,
- 'brightness'))
+ # Set the brightness to half the max value
+ brightness.write_value(max_brightness / 2,
+ os.path.join(interface,
+ 'brightness'))
- # Check that "actual_brightness" reports the same value we
- # set "brightness" to
- exit_status = not brightness.was_brightness_applied(interface)
+ # Check that "actual_brightness" reports the same value we
+ # set "brightness" to
+ exit_status += brightness.was_brightness_applied(interface)
- # Wait a little bit before going back to the original value
- time.sleep(2)
+ # Wait a little bit before going back to the original value
+ time.sleep(2)
- # Set the brightness back to its original value
- brightness.write_value(current_brightness,
- os.path.join(interface,
- 'brightness'))
+ # Set the brightness back to its original value
+ brightness.write_value(current_brightness,
+ os.path.join(interface,
+ 'brightness'))
exit(exit_status)
diff --git a/bin/disk_stress_ng b/bin/disk_stress_ng
index 0b5de83..df5694e 100755
--- a/bin/disk_stress_ng
+++ b/bin/disk_stress_ng
@@ -121,7 +121,7 @@ find_largest_partition() {
exit 1
fi
local blkid_info=$(blkid -s TYPE $part_location | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs\|LVM2_member)
- if [ "$part_size" > "$largest_size" ] && [ -n "$blkid_info" ] ; then
+ if [ "$part_size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then
if [[ "$blkid_info" =~ .*LVM2_member.* ]] ; then
find_largest_lv
else
diff --git a/bin/pm_test b/bin/pm_test
index 35cd215..481b566 100755
--- a/bin/pm_test
+++ b/bin/pm_test
@@ -637,7 +637,7 @@ class AutoStartFile(object):
[Desktop Entry]
Name={pm_operation} test
Comment=Verify {pm_operation} works properly
-Exec=sudo /usr/bin/python3 {script} -r {repetitions} -w {wakeup} --hardware-delay {hardware_delay} --pm-delay {pm_delay} --min-pm-time {min_pm_time} --max-pm-time {max_pm_time} --append --total {total} --start {start} --pm-timestamp {pm_timestamp} {silent} --log-level={log_level} --log-dir={log_dir} --suspends-before-reboot={suspend_cycles} --checkbox-respawn-cmd={checkbox_respawn} {fwts} {pm_operation}
+Exec=sudo {script} -r {repetitions} -w {wakeup} --hardware-delay {hardware_delay} --pm-delay {pm_delay} --min-pm-time {min_pm_time} --max-pm-time {max_pm_time} --append --total {total} --start {start} --pm-timestamp {pm_timestamp} {silent} --log-level={log_level} --log-dir={log_dir} --suspends-before-reboot={suspend_cycles} --checkbox-respawn-cmd={checkbox_respawn} {fwts} {pm_operation}
Type=Application
X-GNOME-Autostart-enabled=true
Hidden=false
@@ -673,9 +673,13 @@ Hidden=false
"""
logging.debug('Writing desktop file ({0!r})...'
.format(self.desktop_filename))
-
+ snap_name = os.getenv('SNAP_NAME')
+ if snap_name:
+ script = '/snap/bin/{}.pm-test'.format(snap_name)
+ else:
+ script = '/usr/bin/python3 {}'.format(os.path.realpath(__file__))
contents = (self.TEMPLATE
- .format(script=os.path.realpath(__file__),
+ .format(script=script,
repetitions=self.args.repetitions - 1,
wakeup=self.args.wakeup,
hardware_delay=self.args.hardware_delay,
diff --git a/bin/removable_storage_test b/bin/removable_storage_test
index ddd4e1b..42e197a 100755
--- a/bin/removable_storage_test
+++ b/bin/removable_storage_test
@@ -99,6 +99,20 @@ def md5_hash_file(path):
return md5.hexdigest()
+def on_ubuntucore():
+ """
+ Check if running from on ubuntu core
+ """
+ snap = os.getenv("SNAP")
+ if snap:
+ with open(os.path.join(snap, 'meta/snap.yaml')) as f:
+ for l in f.readlines():
+ if l == "confinement: classic\n":
+ return False
+ return True
+ return False
+
+
class DiskTest():
''' Class to contain various methods for testing removable disks '''
@@ -177,7 +191,7 @@ class DiskTest():
Indirectly sets:
self.rem_disks{,_nm,_memory_cards,_memory_cards_nm,_speed}
"""
- if "SNAP" in os.environ:
+ if on_ubuntucore():
self._probe_disks_udisks2_cli()
else:
bus, loop = connect_to_system_bus()
diff --git a/units/graphics/jobs.pxu b/units/graphics/jobs.pxu
index 80f509b..08bc7b3 100644
--- a/units/graphics/jobs.pxu
+++ b/units/graphics/jobs.pxu
@@ -240,7 +240,7 @@ id: graphics/{index}_rotation_{product_slug}
depends: graphics/xorg-version
command:
source graphics_env {driver} {index}
- rotation_test_using_dbus
+ rotation_test
estimated_duration: 20.000
_summary: Test rotation for {vendor} {product}
_description:
diff --git a/units/power-management/jobs.pxu b/units/power-management/jobs.pxu
index 976f814..be640c3 100644
--- a/units/power-management/jobs.pxu
+++ b/units/power-management/jobs.pxu
@@ -39,7 +39,7 @@ user: root
environ: PLAINBOX_SESSION_SHARE
requires: executable.name == 'fwts'
command: pm_test --silent --checkbox-respawn-cmd $PLAINBOX_SESSION_SHARE/__respawn_checkbox poweroff --log-level=debug --log-dir=$PLAINBOX_SESSION_SHARE
-flags: noreturn autorestart
+flags: noreturn
_description:
This test will check the system's ability to power-off and boot.
@@ -61,7 +61,7 @@ user: root
environ: PLAINBOX_SESSION_SHARE
requires: executable.name == 'fwts'
command: pm_test --silent --checkbox-respawn-cmd $PLAINBOX_SESSION_SHARE/__respawn_checkbox reboot --log-level=debug --log-dir=$PLAINBOX_SESSION_SHARE
-flags: noreturn autorestart
+flags: noreturn
_description:
This test will check the system's ability to reboot cleanly.
diff --git a/units/stress/jobs.pxu b/units/stress/jobs.pxu
index 42a79cc..8d25af9 100644
--- a/units/stress/jobs.pxu
+++ b/units/stress/jobs.pxu
@@ -74,7 +74,7 @@ depends:
suspend/suspend_advanced
requires:
executable.name == 'x-terminal-emulator'
-flags: noreturn autorestart
+flags: noreturn
user: root
command:
pm_test reboot --checkbox-respawn-cmd $PLAINBOX_SESSION_SHARE/__respawn_checkbox --fwts --log-level=debug --log-dir=$PLAINBOX_SESSION_SHARE --suspends-before-reboot=30 -r 3 --silent
@@ -224,7 +224,7 @@ id: stress/reboot
estimated_duration: 4500.0
requires: executable.name == 'fwts'
command: pm_test --checkbox-respawn-cmd $PLAINBOX_SESSION_SHARE/__respawn_checkbox -r 100 --silent --log-level=notset reboot --log-dir=$PLAINBOX_SESSION_SHARE
-flags: noreturn autorestart
+flags: noreturn
user: root
environ: PLAINBOX_SESSION_SHARE
_description:
@@ -245,7 +245,7 @@ id: stress/reboot_30
requires: executable.name == 'fwts'
executable.name == 'x-terminal-emulator'
command: pm_test --checkbox-respawn-cmd $PLAINBOX_SESSION_SHARE/__respawn_checkbox -r 30 --silent --log-level=notset reboot --log-dir=$PLAINBOX_SESSION_SHARE
-flags: noreturn autorestart
+flags: noreturn
estimated_duration: 2700
user: root
environ: PLAINBOX_SESSION_SHARE
@@ -268,7 +268,7 @@ requires:
executable.name == 'fwts'
executable.name == 'x-terminal-emulator'
command: pm_test --checkbox-respawn-cmd $PLAINBOX_SESSION_SHARE/__respawn_checkbox -r 100 --silent --log-level=notset poweroff --log-dir=$PLAINBOX_SESSION_SHARE
-flags: noreturn autorestart
+flags: noreturn
user: root
environ: PLAINBOX_SESSION_SHARE
_description:
@@ -290,7 +290,7 @@ requires:
executable.name == 'fwts'
executable.name == 'x-terminal-emulator'
command: pm_test --checkbox-respawn-cmd $PLAINBOX_SESSION_SHARE/__respawn_checkbox -r 30 --wakeup 150 --silent --log-level=notset poweroff --log-dir=$PLAINBOX_SESSION_SHARE
-flags: noreturn autorestart
+flags: noreturn
estimated_duration: 3600
user: root
environ: PLAINBOX_SESSION_SHARE
diff --git a/units/wireless/jobs.pxu b/units/wireless/jobs.pxu
index 68056e5..363984a 100644
--- a/units/wireless/jobs.pxu
+++ b/units/wireless/jobs.pxu
@@ -78,7 +78,6 @@ category_id: com.canonical.plainbox::wireless
estimated_duration: 30.0
flags: preserve-locale also-after-suspend also-after-suspend-manual
requires:
- wireless_sta_protocol.{{ interface }}_n == 'supported'
{%- if __on_ubuntucore__ %}
connections.slot == 'network-manager:service' and connections.plug == '{{ __system_env__["SNAP_NAME"] }}:network-manager'
{% endif -%}
@@ -100,7 +99,6 @@ category_id: com.canonical.plainbox::wireless
estimated_duration: 30.0
flags: preserve-locale also-after-suspend also-after-suspend-manual
requires:
- wireless_sta_protocol.{{ interface }}_n == 'supported'
{%- if __on_ubuntucore__ %}
connections.slot == 'network-manager:service' and connections.plug == '{{ __system_env__["SNAP_NAME"] }}:network-manager'
{% endif -%}