1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-01 19:02:31 +01:00

tests: moved out of wa package

Tests now reside in the root of the repo, rather than in wa package.
This means they will no longer packaged and installed in user
deployments (they're only useful for developers).
This commit is contained in:
Sergei Trofimov
2017-04-27 17:36:44 +01:00
parent 6a5dda9bfb
commit 2bbe300dc2
17 changed files with 0 additions and 0 deletions

0
tests/__init__.py Normal file
View File

View File

@@ -0,0 +1,49 @@
# Copyright 2013-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from wa import Plugin
class TestDevice(Plugin):
name = 'test-device'
kind = 'device'
def __init__(self, *args, **kwargs):
self.boot_called = 0
self.push_file_called = 0
self.pull_file_called = 0
self.execute_called = 0
self.set_sysfile_int_called = 0
self.close_called = 0
def boot(self):
self.boot_called += 1
def push_file(self, source, dest):
self.push_file_called += 1
def pull_file(self, source, dest):
self.pull_file_called += 1
def execute(self, command):
self.execute_called += 1
def set_sysfile_int(self, file, value):
self.set_sysfile_int_called += 1
def close(self, command):
self.close_called += 1

98
tests/data/interrupts/after Executable file
View File

@@ -0,0 +1,98 @@
CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
65: 0 0 0 0 0 0 0 0 GIC dma-pl330.2
66: 0 0 0 0 0 0 0 0 GIC dma-pl330.0
67: 0 0 0 0 0 0 0 0 GIC dma-pl330.1
74: 0 0 0 0 0 0 0 0 GIC s3c2410-wdt
85: 2 0 0 0 0 0 0 0 GIC exynos4210-uart
89: 368 0 0 0 0 0 0 0 GIC s3c2440-i2c.1
90: 0 0 0 0 0 0 0 0 GIC s3c2440-i2c.2
92: 1294 0 0 0 0 0 0 0 GIC exynos5-hs-i2c.0
95: 831 0 0 0 0 0 0 0 GIC exynos5-hs-i2c.3
103: 1 0 0 0 0 0 0 0 GIC ehci_hcd:usb1, ohci_hcd:usb2
104: 7304 0 0 0 0 0 0 0 GIC xhci_hcd:usb3, exynos-ss-udc.0
105: 0 0 0 0 0 0 0 0 GIC xhci_hcd:usb5
106: 0 0 0 0 0 0 0 0 GIC mali.0
107: 16429 0 0 0 0 0 0 0 GIC dw-mci
108: 1 0 0 0 0 0 0 0 GIC dw-mci
109: 0 0 0 0 0 0 0 0 GIC dw-mci
114: 28074 0 0 0 0 0 0 0 GIC mipi-dsi
117: 0 0 0 0 0 0 0 0 GIC exynos-gsc
118: 0 0 0 0 0 0 0 0 GIC exynos-gsc
121: 0 0 0 0 0 0 0 0 GIC exynos5-jpeg-hx
123: 7 0 0 0 0 0 0 0 GIC s5p-fimg2d
126: 0 0 0 0 0 0 0 0 GIC s5p-mixer
127: 0 0 0 0 0 0 0 0 GIC hdmi-int
128: 0 0 0 0 0 0 0 0 GIC s5p-mfc-v6
142: 0 0 0 0 0 0 0 0 GIC dma-pl330.3
146: 0 0 0 0 0 0 0 0 GIC s5p-tvout-cec
149: 1035 0 0 0 0 0 0 0 GIC mali.0
152: 26439 0 0 0 0 0 0 0 GIC mct_tick0
153: 0 2891 0 0 0 0 0 0 GIC mct_tick1
154: 0 0 3969 0 0 0 0 0 GIC mct_tick2
155: 0 0 0 2385 0 0 0 0 GIC mct_tick3
160: 0 0 0 0 8038 0 0 0 GIC mct_tick4
161: 0 0 0 0 0 8474 0 0 GIC mct_tick5
162: 0 0 0 0 0 0 7842 0 GIC mct_tick6
163: 0 0 0 0 0 0 0 7827 GIC mct_tick7
200: 0 0 0 0 0 0 0 0 GIC exynos5-jpeg-hx
201: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.29
218: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.25
220: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.27
224: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.19
251: 320 0 0 0 0 0 0 0 GIC mali.0
252: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
253: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
254: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
272: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.5
274: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.6
280: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.11
282: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.30
284: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.12
286: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.17
288: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.4
290: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.20
294: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
296: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
298: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
300: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
302: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
306: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.0
316: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.2
325: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.0
332: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
340: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
342: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
344: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
405: 327 0 0 0 0 0 0 0 combiner s3c_fb
409: 0 0 0 0 0 0 0 0 combiner mcuctl
414: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.28
434: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.22
436: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.23
438: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.26
443: 12 0 0 0 0 0 0 0 combiner mct_comp_irq
446: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.21
449: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.13
453: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.15
474: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.24
512: 0 0 0 0 0 0 0 0 exynos-eint gpio-keys: KEY_POWER
518: 0 0 0 0 0 0 0 0 exynos-eint drd_switch_vbus
524: 0 0 0 0 0 0 0 0 exynos-eint gpio-keys: KEY_HOMEPAGE
526: 1 0 0 0 0 0 0 0 exynos-eint HOST_DETECT
527: 1 0 0 0 0 0 0 0 exynos-eint drd_switch_id
531: 1 0 0 0 0 0 0 0 exynos-eint drd_switch_vbus
532: 1 0 0 0 0 0 0 0 exynos-eint drd_switch_id
537: 3 0 0 0 0 0 0 0 exynos-eint mxt540e_ts
538: 0 0 0 0 0 0 0 0 exynos-eint sec-pmic-irq
543: 1 0 0 0 0 0 0 0 exynos-eint hdmi-ext
544: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_VOLUMEDOWN
545: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_VOLUMEUP
546: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_MENU
547: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_BACK
655: 0 0 0 0 0 0 0 0 sec-pmic rtc-alarm0
IPI0: 0 0 0 0 0 0 0 0 Timer broadcast interrupts
IPI1: 8823 7185 4642 5652 2370 2069 1452 1351 Rescheduling interrupts
IPI2: 4 7 8 6 8 7 8 8 Function call interrupts
IPI3: 1 0 0 0 0 0 0 0 Single function call interrupts
IPI4: 0 0 0 0 0 0 0 0 CPU stop interrupts
IPI5: 0 0 0 0 0 0 0 0 CPU backtrace
Err: 0

97
tests/data/interrupts/before Executable file
View File

@@ -0,0 +1,97 @@
CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
65: 0 0 0 0 0 0 0 0 GIC dma-pl330.2
66: 0 0 0 0 0 0 0 0 GIC dma-pl330.0
67: 0 0 0 0 0 0 0 0 GIC dma-pl330.1
74: 0 0 0 0 0 0 0 0 GIC s3c2410-wdt
85: 2 0 0 0 0 0 0 0 GIC exynos4210-uart
89: 368 0 0 0 0 0 0 0 GIC s3c2440-i2c.1
90: 0 0 0 0 0 0 0 0 GIC s3c2440-i2c.2
92: 1204 0 0 0 0 0 0 0 GIC exynos5-hs-i2c.0
95: 831 0 0 0 0 0 0 0 GIC exynos5-hs-i2c.3
103: 1 0 0 0 0 0 0 0 GIC ehci_hcd:usb1, ohci_hcd:usb2
104: 7199 0 0 0 0 0 0 0 GIC xhci_hcd:usb3, exynos-ss-udc.0
105: 0 0 0 0 0 0 0 0 GIC xhci_hcd:usb5
106: 0 0 0 0 0 0 0 0 GIC mali.0
107: 16429 0 0 0 0 0 0 0 GIC dw-mci
108: 1 0 0 0 0 0 0 0 GIC dw-mci
109: 0 0 0 0 0 0 0 0 GIC dw-mci
114: 26209 0 0 0 0 0 0 0 GIC mipi-dsi
117: 0 0 0 0 0 0 0 0 GIC exynos-gsc
118: 0 0 0 0 0 0 0 0 GIC exynos-gsc
121: 0 0 0 0 0 0 0 0 GIC exynos5-jpeg-hx
123: 7 0 0 0 0 0 0 0 GIC s5p-fimg2d
126: 0 0 0 0 0 0 0 0 GIC s5p-mixer
127: 0 0 0 0 0 0 0 0 GIC hdmi-int
128: 0 0 0 0 0 0 0 0 GIC s5p-mfc-v6
142: 0 0 0 0 0 0 0 0 GIC dma-pl330.3
146: 0 0 0 0 0 0 0 0 GIC s5p-tvout-cec
149: 1004 0 0 0 0 0 0 0 GIC mali.0
152: 26235 0 0 0 0 0 0 0 GIC mct_tick0
153: 0 2579 0 0 0 0 0 0 GIC mct_tick1
154: 0 0 3726 0 0 0 0 0 GIC mct_tick2
155: 0 0 0 2262 0 0 0 0 GIC mct_tick3
161: 0 0 0 0 0 2554 0 0 GIC mct_tick5
162: 0 0 0 0 0 0 1911 0 GIC mct_tick6
163: 0 0 0 0 0 0 0 1928 GIC mct_tick7
200: 0 0 0 0 0 0 0 0 GIC exynos5-jpeg-hx
201: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.29
218: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.25
220: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.27
224: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.19
251: 312 0 0 0 0 0 0 0 GIC mali.0
252: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
253: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
254: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
272: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.5
274: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.6
280: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.11
282: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.30
284: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.12
286: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.17
288: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.4
290: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.20
294: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
296: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
298: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
300: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
302: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
306: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.0
316: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.2
325: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.0
332: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
340: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
342: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
344: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
405: 322 0 0 0 0 0 0 0 combiner s3c_fb
409: 0 0 0 0 0 0 0 0 combiner mcuctl
414: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.28
434: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.22
436: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.23
438: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.26
443: 12 0 0 0 0 0 0 0 combiner mct_comp_irq
446: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.21
449: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.13
453: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.15
474: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.24
512: 0 0 0 0 0 0 0 0 exynos-eint gpio-keys: KEY_POWER
518: 0 0 0 0 0 0 0 0 exynos-eint drd_switch_vbus
524: 0 0 0 0 0 0 0 0 exynos-eint gpio-keys: KEY_HOMEPAGE
526: 1 0 0 0 0 0 0 0 exynos-eint HOST_DETECT
527: 1 0 0 0 0 0 0 0 exynos-eint drd_switch_id
531: 1 0 0 0 0 0 0 0 exynos-eint drd_switch_vbus
532: 1 0 0 0 0 0 0 0 exynos-eint drd_switch_id
537: 3 0 0 0 0 0 0 0 exynos-eint mxt540e_ts
538: 0 0 0 0 0 0 0 0 exynos-eint sec-pmic-irq
543: 1 0 0 0 0 0 0 0 exynos-eint hdmi-ext
544: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_VOLUMEDOWN
545: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_VOLUMEUP
546: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_MENU
547: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_BACK
655: 0 0 0 0 0 0 0 0 sec-pmic rtc-alarm0
IPI0: 0 0 0 0 0 0 0 0 Timer broadcast interrupts
IPI1: 8751 7147 4615 5623 2334 2066 1449 1348 Rescheduling interrupts
IPI2: 3 6 7 6 7 6 7 7 Function call interrupts
IPI3: 1 0 0 0 0 0 0 0 Single function call interrupts
IPI4: 0 0 0 0 0 0 0 0 CPU stop interrupts
IPI5: 0 0 0 0 0 0 0 0 CPU backtrace
Err: 0

98
tests/data/interrupts/result Executable file
View File

@@ -0,0 +1,98 @@
CPU0 CPU1 CPU2 CPU3 CPU4 CPU5 CPU6 CPU7
65: 0 0 0 0 0 0 0 0 GIC dma-pl330.2
66: 0 0 0 0 0 0 0 0 GIC dma-pl330.0
67: 0 0 0 0 0 0 0 0 GIC dma-pl330.1
74: 0 0 0 0 0 0 0 0 GIC s3c2410-wdt
85: 0 0 0 0 0 0 0 0 GIC exynos4210-uart
89: 0 0 0 0 0 0 0 0 GIC s3c2440-i2c.1
90: 0 0 0 0 0 0 0 0 GIC s3c2440-i2c.2
92: 90 0 0 0 0 0 0 0 GIC exynos5-hs-i2c.0
95: 0 0 0 0 0 0 0 0 GIC exynos5-hs-i2c.3
103: 0 0 0 0 0 0 0 0 GIC ehci_hcd:usb1, ohci_hcd:usb2
104: 105 0 0 0 0 0 0 0 GIC xhci_hcd:usb3, exynos-ss-udc.0
105: 0 0 0 0 0 0 0 0 GIC xhci_hcd:usb5
106: 0 0 0 0 0 0 0 0 GIC mali.0
107: 0 0 0 0 0 0 0 0 GIC dw-mci
108: 0 0 0 0 0 0 0 0 GIC dw-mci
109: 0 0 0 0 0 0 0 0 GIC dw-mci
114: 1865 0 0 0 0 0 0 0 GIC mipi-dsi
117: 0 0 0 0 0 0 0 0 GIC exynos-gsc
118: 0 0 0 0 0 0 0 0 GIC exynos-gsc
121: 0 0 0 0 0 0 0 0 GIC exynos5-jpeg-hx
123: 0 0 0 0 0 0 0 0 GIC s5p-fimg2d
126: 0 0 0 0 0 0 0 0 GIC s5p-mixer
127: 0 0 0 0 0 0 0 0 GIC hdmi-int
128: 0 0 0 0 0 0 0 0 GIC s5p-mfc-v6
142: 0 0 0 0 0 0 0 0 GIC dma-pl330.3
146: 0 0 0 0 0 0 0 0 GIC s5p-tvout-cec
149: 31 0 0 0 0 0 0 0 GIC mali.0
152: 204 0 0 0 0 0 0 0 GIC mct_tick0
153: 0 312 0 0 0 0 0 0 GIC mct_tick1
154: 0 0 243 0 0 0 0 0 GIC mct_tick2
155: 0 0 0 123 0 0 0 0 GIC mct_tick3
> 160: 0 0 0 0 8038 0 0 0 GIC mct_tick4
161: 0 0 0 0 0 5920 0 0 GIC mct_tick5
162: 0 0 0 0 0 0 5931 0 GIC mct_tick6
163: 0 0 0 0 0 0 0 5899 GIC mct_tick7
200: 0 0 0 0 0 0 0 0 GIC exynos5-jpeg-hx
201: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.29
218: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.25
220: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.27
224: 0 0 0 0 0 0 0 0 GIC exynos-sysmmu.19
251: 8 0 0 0 0 0 0 0 GIC mali.0
252: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
253: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
254: 0 0 0 0 0 0 0 0 GIC exynos5-scaler
272: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.5
274: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.6
280: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.11
282: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.30
284: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.12
286: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.17
288: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.4
290: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.20
294: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
296: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
298: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
300: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
302: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
306: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.0
316: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.2
325: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.0
332: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
340: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
342: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.9
344: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.16
405: 5 0 0 0 0 0 0 0 combiner s3c_fb
409: 0 0 0 0 0 0 0 0 combiner mcuctl
414: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.28
434: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.22
436: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.23
438: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.26
443: 0 0 0 0 0 0 0 0 combiner mct_comp_irq
446: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.21
449: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.13
453: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.15
474: 0 0 0 0 0 0 0 0 combiner exynos-sysmmu.24
512: 0 0 0 0 0 0 0 0 exynos-eint gpio-keys: KEY_POWER
518: 0 0 0 0 0 0 0 0 exynos-eint drd_switch_vbus
524: 0 0 0 0 0 0 0 0 exynos-eint gpio-keys: KEY_HOMEPAGE
526: 0 0 0 0 0 0 0 0 exynos-eint HOST_DETECT
527: 0 0 0 0 0 0 0 0 exynos-eint drd_switch_id
531: 0 0 0 0 0 0 0 0 exynos-eint drd_switch_vbus
532: 0 0 0 0 0 0 0 0 exynos-eint drd_switch_id
537: 0 0 0 0 0 0 0 0 exynos-eint mxt540e_ts
538: 0 0 0 0 0 0 0 0 exynos-eint sec-pmic-irq
543: 0 0 0 0 0 0 0 0 exynos-eint hdmi-ext
544: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_VOLUMEDOWN
545: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_VOLUMEUP
546: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_MENU
547: 0 0 0 0 0 0 0 0 s5p_gpioint gpio-keys: KEY_BACK
655: 0 0 0 0 0 0 0 0 sec-pmic rtc-alarm0
IPI0: 0 0 0 0 0 0 0 0 Timer broadcast interrupts
IPI1: 72 38 27 29 36 3 3 3 Rescheduling interrupts
IPI2: 1 1 1 0 1 1 1 1 Function call interrupts
IPI3: 0 0 0 0 0 0 0 0 Single function call interrupts
IPI4: 0 0 0 0 0 0 0 0 CPU stop interrupts
IPI5: 0 0 0 0 0 0 0 0 CPU backtrace
Err: 0

14
tests/data/logcat.2.log Normal file
View File

@@ -0,0 +1,14 @@
--------- beginning of /dev/log/main
D/TextView( 2468): 7:07
D/TextView( 2468): 7:07
D/TextView( 2468): Thu, June 27
--------- beginning of /dev/log/system
D/TextView( 3099): CaffeineMark results
D/TextView( 3099): Overall score:
D/TextView( 3099): Rating
D/TextView( 3099): Rank
D/TextView( 3099): 0
D/TextView( 3099): Details
D/TextView( 3099): Publish
D/TextView( 3099): Top 10
D/TextView( 3099): 3672

10
tests/data/logcat.log Normal file
View File

@@ -0,0 +1,10 @@
--------- beginning of /dev/log/main
--------- beginning of /dev/log/system
D/TextView( 2462): 5:05
D/TextView( 2462): 5:05
D/TextView( 2462): Mon, June 24
D/TextView( 3072): Stop Test
D/TextView( 3072): Testing CPU and memory…
D/TextView( 3072): 0%
D/TextView( 3072): Testing CPU and memory…

View File

@@ -0,0 +1,25 @@
global:
iterations: 8
boot_parameters:
os_mode: mp_a15_bootcluster
runtime_parameters:
a7_governor: Interactive
a15_governor: Interactive2
a7_cores: 3
a15_cores: 2
workloads:
- id: 1c
workload_name: bbench_with_audio
- id: 1d
workload_name: Bbench_with_audio
runtime_parameters:
os_mode: mp_a7_only
a7_cores: 0
iterations: 4
- id: 1e
workload_name: audio
- id: 1f
workload_name: antutu
runtime_parameters:
a7_cores: 1
a15_cores: 1

17
tests/data/test-config.py Normal file
View File

@@ -0,0 +1,17 @@
# Copyright 2013-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
device = 'TEST'

195
tests/test_agenda.py Normal file
View File

@@ -0,0 +1,195 @@
# Copyright 2013-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=E0611
# pylint: disable=R0201
import os
from StringIO import StringIO
from unittest import TestCase
from nose.tools import assert_equal, assert_in, raises
from wa.framework.agenda import Agenda
from wa.framework.exception import ConfigError
YAML_TEST_FILE = os.path.join(os.path.dirname(__file__), 'data', 'test-agenda.yaml')
invalid_agenda_text = """
workloads:
- id: 1
workload_parameters:
test: 1
"""
invalid_agenda = StringIO(invalid_agenda_text)
invalid_agenda.name = 'invalid1'
duplicate_agenda_text = """
global:
iterations: 1
workloads:
- id: 1
workload_name: antutu
workload_parameters:
test: 1
- id: 1
workload_name: andebench
"""
duplicate_agenda = StringIO(duplicate_agenda_text)
duplicate_agenda.name = 'invalid2'
short_agenda_text = """
workloads: [antutu, linpack, andebench]
"""
short_agenda = StringIO(short_agenda_text)
short_agenda.name = 'short'
default_ids_agenda_text = """
workloads:
- antutu
- id: 1
name: linpack
- id: test
name: andebench
params:
number_of_threads: 1
- vellamo
"""
default_ids_agenda = StringIO(default_ids_agenda_text)
default_ids_agenda.name = 'default_ids'
sectioned_agenda_text = """
sections:
- id: sec1
runtime_params:
dp: one
workloads:
- antutu
- andebench
- name: linpack
runtime_params:
dp: two
- id: sec2
runtime_params:
dp: three
workloads:
- antutu
workloads:
- nenamark
"""
sectioned_agenda = StringIO(sectioned_agenda_text)
sectioned_agenda.name = 'sectioned'
dup_sectioned_agenda_text = """
sections:
- id: sec1
workloads:
- antutu
- id: sec1
workloads:
- andebench
workloads:
- nenamark
"""
dup_sectioned_agenda = StringIO(dup_sectioned_agenda_text)
dup_sectioned_agenda.name = 'dup-sectioned'
caps_agenda_text = """
config:
device: TC2
global:
runtime_parameters:
sysfile_values:
/sys/test/MyFile: 1
/sys/test/other file: 2
workloads:
- id: 1
name: linpack
"""
caps_agenda = StringIO(caps_agenda_text)
caps_agenda.name = 'caps'
bad_syntax_agenda_text = """
config:
# tab on the following line
reboot_policy: never
workloads:
- antutu
"""
bad_syntax_agenda = StringIO(bad_syntax_agenda_text)
bad_syntax_agenda.name = 'bad_syntax'
section_ids_test_text = """
config:
device: TC2
reboot_policy: never
workloads:
- name: bbench
id: bbench
- name: audio
sections:
- id: foo
- id: bar
"""
section_ids_agenda = StringIO(section_ids_test_text)
section_ids_agenda.name = 'section_ids'
class AgendaTest(TestCase):
def test_yaml_load(self):
agenda = Agenda(YAML_TEST_FILE)
assert_equal(len(agenda.workloads), 4)
def test_duplicate_id(self):
try:
Agenda(duplicate_agenda)
except ConfigError, e:
assert_in('duplicate', e.message.lower()) # pylint: disable=E1101
else:
raise Exception('ConfigError was not raised for an agenda with duplicate ids.')
def test_yaml_missing_field(self):
try:
Agenda(invalid_agenda_text)
except ConfigError, e:
assert_in('workload name', e.message)
else:
raise Exception('ConfigError was not raised for an invalid agenda.')
def test_defaults(self):
agenda = Agenda(short_agenda)
assert_equal(len(agenda.workloads), 3)
assert_equal(agenda.workloads[0].workload_name, 'antutu')
assert_equal(agenda.workloads[0].id, '1')
def test_default_id_assignment(self):
agenda = Agenda(default_ids_agenda)
assert_equal(agenda.workloads[0].id, '2')
assert_equal(agenda.workloads[3].id, '3')
def test_sections(self):
agenda = Agenda(sectioned_agenda)
assert_equal(agenda.sections[0].workloads[0].workload_name, 'antutu')
assert_equal(agenda.sections[1].runtime_parameters['dp'], 'three')
@raises(ConfigError)
def test_dup_sections(self):
Agenda(dup_sectioned_agenda)
@raises(ConfigError)
def test_bad_syntax(self):
Agenda(bad_syntax_agenda)

25
tests/test_config.py Normal file
View File

@@ -0,0 +1,25 @@
import unittest
from nose.tools import assert_equal
from wa.utils.misc import merge_config_values
class TestConfigUtils(unittest.TestCase):
def test_merge_values(self):
test_cases = [
# base, other, expected_result
('a', 3, 3),
('a', [1, 2], ['a', 1, 2]),
({1: 2}, [3, 4], [{1: 2}, 3, 4]),
(set([2]), [1, 2, 3], [2, 1, 3]),
([1, 2, 3], set([2]), set([1, 2, 3])),
([1, 2], None, [1, 2]),
(None, 'a', 'a'),
]
for v1, v2, expected in test_cases:
result = merge_config_values(v1, v2)
assert_equal(result, expected)
if v2 is not None:
assert_equal(type(result), type(v2))

44
tests/test_diff.py Normal file
View File

@@ -0,0 +1,44 @@
# Copyright 2013-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=E0611
# pylint: disable=R0201
import os
import tempfile
from unittest import TestCase
from nose.tools import assert_equal
from wa.instrumentation.misc import _diff_interrupt_files
class InterruptDiffTest(TestCase):
def test_interrupt_diff(self):
file_dir = os.path.join(os.path.dirname(__file__), 'data', 'interrupts')
before_file = os.path.join(file_dir, 'before')
after_file = os.path.join(file_dir, 'after')
expected_result_file = os.path.join(file_dir, 'result')
output_file = tempfile.mktemp()
_diff_interrupt_files(before_file, after_file, output_file)
with open(output_file) as fh:
output_diff = fh.read()
with open(expected_result_file) as fh:
expected_diff = fh.read()
assert_equal(output_diff, expected_diff)

269
tests/test_exec_control.py Normal file
View File

@@ -0,0 +1,269 @@
# Copyright 2013-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=W0231,W0613,E0611,W0603,R0201
from unittest import TestCase
from nose.tools import assert_equal, assert_raises
from wa.utils.exec_control import (init_environment, reset_environment,
activate_environment, once,
once_per_class, once_per_instance)
class TestClass(object):
def __init__(self):
self.count = 0
@once
def initilize_once(self):
self.count += 1
@once_per_class
def initilize_once_per_class(self):
self.count += 1
@once_per_instance
def initilize_once_per_instance(self):
self.count += 1
class SubClass(TestClass):
def __init__(self):
super(SubClass, self).__init__()
class SubSubClass(SubClass):
def __init__(self):
super(SubSubClass, self).__init__()
class AnotherClass(object):
def __init__(self):
self.count = 0
@once
def initilize_once(self):
self.count += 1
@once_per_class
def initilize_once_per_class(self):
self.count += 1
@once_per_instance
def initilize_once_per_instance(self):
self.count += 1
class EnvironmentManagementTest(TestCase):
def test_duplicate_environment(self):
init_environment('ENVIRONMENT')
assert_raises(ValueError, init_environment, 'ENVIRONMENT')
def test_reset_missing_environment(self):
assert_raises(ValueError, reset_environment, 'MISSING')
def test_reset_current_environment(self):
activate_environment('CURRENT_ENVIRONMENT')
t1 = TestClass()
t1.initilize_once()
assert_equal(t1.count, 1)
reset_environment()
t1.initilize_once()
assert_equal(t1.count, 2)
def test_switch_environment(self):
activate_environment('ENVIRONMENT1')
t1 = TestClass()
t1.initilize_once()
assert_equal(t1.count, 1)
activate_environment('ENVIRONMENT2')
t1.initilize_once()
assert_equal(t1.count, 2)
activate_environment('ENVIRONMENT1')
t1.initilize_once()
assert_equal(t1.count, 2)
def test_reset_environment_name(self):
activate_environment('ENVIRONMENT')
t1 = TestClass()
t1.initilize_once()
assert_equal(t1.count, 1)
reset_environment('ENVIRONMENT')
t1.initilize_once()
assert_equal(t1.count, 2)
class OnlyOnceEnvironmentTest(TestCase):
def setUp(self):
activate_environment('TEST_ENVIRONMENT')
def tearDown(self):
reset_environment('TEST_ENVIRONMENT')
def test_single_instance(self):
t1 = TestClass()
ac = AnotherClass()
t1.initilize_once()
assert_equal(t1.count, 1)
t1.initilize_once()
assert_equal(t1.count, 1)
ac.initilize_once()
assert_equal(ac.count, 1)
def test_mulitple_instances(self):
t1 = TestClass()
t2 = TestClass()
t1.initilize_once()
assert_equal(t1.count, 1)
t2.initilize_once()
assert_equal(t2.count, 0)
def test_sub_classes(self):
t1 = TestClass()
sc = SubClass()
ss = SubSubClass()
t1.initilize_once()
assert_equal(t1.count, 1)
sc.initilize_once()
sc.initilize_once()
assert_equal(sc.count, 0)
ss.initilize_once()
ss.initilize_once()
assert_equal(ss.count, 0)
class OncePerClassEnvironmentTest(TestCase):
def setUp(self):
activate_environment('TEST_ENVIRONMENT')
def tearDown(self):
reset_environment('TEST_ENVIRONMENT')
def test_single_instance(self):
t1 = TestClass()
ac = AnotherClass()
t1.initilize_once_per_class()
assert_equal(t1.count, 1)
t1.initilize_once_per_class()
assert_equal(t1.count, 1)
ac.initilize_once_per_class()
assert_equal(ac.count, 1)
def test_mulitple_instances(self):
t1 = TestClass()
t2 = TestClass()
t1.initilize_once_per_class()
assert_equal(t1.count, 1)
t2.initilize_once_per_class()
assert_equal(t2.count, 0)
def test_sub_classes(self):
t1 = TestClass()
sc1 = SubClass()
sc2 = SubClass()
ss1 = SubSubClass()
ss2 = SubSubClass()
t1.initilize_once_per_class()
assert_equal(t1.count, 1)
sc1.initilize_once_per_class()
sc2.initilize_once_per_class()
assert_equal(sc1.count, 1)
assert_equal(sc2.count, 0)
ss1.initilize_once_per_class()
ss2.initilize_once_per_class()
assert_equal(ss1.count, 1)
assert_equal(ss2.count, 0)
class OncePerInstanceEnvironmentTest(TestCase):
def setUp(self):
activate_environment('TEST_ENVIRONMENT')
def tearDown(self):
reset_environment('TEST_ENVIRONMENT')
def test_single_instance(self):
t1 = TestClass()
ac = AnotherClass()
t1.initilize_once_per_instance()
assert_equal(t1.count, 1)
t1.initilize_once_per_instance()
assert_equal(t1.count, 1)
ac.initilize_once_per_instance()
assert_equal(ac.count, 1)
def test_mulitple_instances(self):
t1 = TestClass()
t2 = TestClass()
t1.initilize_once_per_instance()
assert_equal(t1.count, 1)
t2.initilize_once_per_instance()
assert_equal(t2.count, 1)
def test_sub_classes(self):
t1 = TestClass()
sc = SubClass()
ss = SubSubClass()
t1.initilize_once_per_instance()
assert_equal(t1.count, 1)
sc.initilize_once_per_instance()
sc.initilize_once_per_instance()
assert_equal(sc.count, 1)
ss.initilize_once_per_instance()
ss.initilize_once_per_instance()
assert_equal(ss.count, 1)

204
tests/test_plugin.py Normal file
View File

@@ -0,0 +1,204 @@
# Copyright 2014-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=E0611,R0201,E1101
import os
from unittest import TestCase
from nose.tools import assert_equal, raises, assert_true
from wa.framework.plugin import Plugin, PluginMeta, PluginLoader, Parameter
from wa.utils.types import list_of_ints
from wa import ConfigError
EXTDIR = os.path.join(os.path.dirname(__file__), 'data', 'extensions')
class PluginLoaderTest(TestCase):
def setUp(self):
self.loader = PluginLoader(paths=[EXTDIR, ])
def test_load_device(self):
device = self.loader.get_device('test-device')
assert_equal(device.name, 'test-device')
def test_list_by_kind(self):
exts = self.loader.list_devices()
assert_equal(len(exts), 1)
assert_equal(exts[0].name, 'test-device')
class MyBasePlugin(Plugin):
name = 'base'
kind = 'test'
parameters = [
Parameter('base'),
]
def __init__(self, **kwargs):
super(MyBasePlugin, self).__init__(**kwargs)
self.v1 = 0
self.v2 = 0
self.v3 = ''
def virtual1(self):
self.v1 += 1
self.v3 = 'base'
def virtual2(self):
self.v2 += 1
class MyAcidPlugin(MyBasePlugin):
name = 'acid'
parameters = [
Parameter('hydrochloric', kind=list_of_ints, default=[1, 2]),
Parameter('citric'),
Parameter('carbonic', kind=int),
]
def __init__(self, **kwargs):
super(MyAcidPlugin, self).__init__(**kwargs)
self.vv1 = 0
self.vv2 = 0
def virtual1(self):
self.vv1 += 1
self.v3 = 'acid'
def virtual2(self):
self.vv2 += 1
class MyOtherPlugin(MyBasePlugin):
name = 'other'
parameters = [
Parameter('mandatory', mandatory=True),
Parameter('optional', allowed_values=['test', 'check']),
]
class MyOtherOtherPlugin(MyOtherPlugin):
name = 'otherother'
parameters = [
Parameter('mandatory', override=True),
]
class MyOverridingPlugin(MyAcidPlugin):
name = 'overriding'
parameters = [
Parameter('hydrochloric', override=True, default=[3, 4]),
]
class MyThirdTeerPlugin(MyOverridingPlugin):
name = 'thirdteer'
class MultiValueParamExt(Plugin):
name = 'multivalue'
kind = 'test'
parameters = [
Parameter('test', kind=list_of_ints, allowed_values=[42, 7, 73]),
]
class PluginMetaTest(TestCase):
def test_propagation(self):
acid_params = [p.name for p in MyAcidPlugin.parameters]
assert_equal(acid_params, ['base', 'hydrochloric', 'citric', 'carbonic'])
@raises(ValueError)
def test_duplicate_param_spec(self):
class BadPlugin(MyBasePlugin): # pylint: disable=W0612
parameters = [
Parameter('base'),
]
def test_param_override(self):
class OverridingPlugin(MyBasePlugin): # pylint: disable=W0612
parameters = [
Parameter('base', override=True, default='cheese'),
]
assert_equal(OverridingPlugin.parameters['base'].default, 'cheese')
@raises(ValueError)
def test_invalid_param_spec(self):
class BadPlugin(MyBasePlugin): # pylint: disable=W0612
parameters = [
7,
]
class ParametersTest(TestCase):
def test_setting(self):
myext = MyAcidPlugin(hydrochloric=[5, 6], citric=5, carbonic=42)
assert_equal(myext.hydrochloric, [5, 6])
assert_equal(myext.citric, '5')
assert_equal(myext.carbonic, 42)
def test_validation_ok(self):
myext = MyOtherPlugin(mandatory='check', optional='check')
myext.validate()
def test_default_override(self):
myext = MyOverridingPlugin()
assert_equal(myext.hydrochloric, [3, 4])
myotherext = MyThirdTeerPlugin()
assert_equal(myotherext.hydrochloric, [3, 4])
def test_multivalue_param(self):
myext = MultiValueParamExt(test=[7, 42])
myext.validate()
assert_equal(myext.test, [7, 42])
@raises(ConfigError)
def test_bad_multivalue_param(self):
myext = MultiValueParamExt(test=[5])
myext.validate()
@raises(ConfigError)
def test_validation_no_mandatory(self):
myext = MyOtherPlugin(optional='check')
myext.validate()
@raises(ConfigError)
def test_validation_no_mandatory_in_derived(self):
MyOtherOtherPlugin()
@raises(ConfigError)
def test_validation_bad_value(self):
myext = MyOtherPlugin(mandatory=1, optional='invalid')
myext.validate()

View File

@@ -0,0 +1,50 @@
import unittest
from nose.tools import assert_equal
from mock.mock import Mock
from wa.utils.misc import resolve_cpus, resolve_unique_domain_cpus
class TestRuntimeParameterUtils(unittest.TestCase):
def test_resolve_cpu(self):
# Set up a mock target
mock = Mock()
mock.big_core = "A72"
mock.little_core = "A53"
mock.core_names = ['A72', 'A72', 'A53', 'A53']
mock.number_of_cpus = 4
def mock_core_cpus(core):
return [i for i, c in enumerate(mock.core_names) if c == core]
def mock_online_cpus():
return [0, 1, 2]
def mock_offline_cpus():
return [3]
def mock_domain_cpus(core):
if core in [0, 1]:
return [0, 1]
elif core in [2, 3]:
return [2, 3]
mock.list_online_cpus = mock_online_cpus
mock.list_offline_cpus = mock_offline_cpus
mock.core_cpus = mock_core_cpus
mock.core_cpus = mock_core_cpus
mock.cpufreq.get_domain_cpus = mock_domain_cpus
# Check retrieving cpus from a given prefix
assert_equal(resolve_cpus('A72', mock), [0, 1])
assert_equal(resolve_cpus('A53', mock), [2, 3])
assert_equal(resolve_cpus('big', mock), [0, 1])
assert_equal(resolve_cpus('little', mock), [2, 3])
assert_equal(resolve_cpus('', mock), [0, 1, 2, 3])
assert_equal(resolve_cpus('cpu0', mock), [0])
assert_equal(resolve_cpus('cpu3', mock), [3])
# Check get unique domain cpus
assert_equal(resolve_unique_domain_cpus('A72', mock), [0])
assert_equal(resolve_unique_domain_cpus('A53', mock), [2])
assert_equal(resolve_unique_domain_cpus('big', mock), [0])
assert_equal(resolve_unique_domain_cpus('little', mock), [2])
assert_equal(resolve_unique_domain_cpus('', mock), [0, 2])
assert_equal(resolve_unique_domain_cpus('cpu0', mock), [0])
assert_equal(resolve_unique_domain_cpus('cpu3', mock), [2])

63
tests/test_signal.py Normal file
View File

@@ -0,0 +1,63 @@
import unittest
from nose.tools import assert_equal, assert_true, assert_false
import wa.framework.signal as signal
class Callable(object):
def __init__(self, val):
self.val = val
def __call__(self):
return self.val
class TestPriorityDispatcher(unittest.TestCase):
def test_ConnectNotify(self):
one = Callable(1)
two = Callable(2)
three = Callable(3)
signal.connect(
two,
'test',
priority=200
)
signal.connect(
one,
'test',
priority=100
)
signal.connect(
three,
'test',
priority=300
)
result = [i[1] for i in signal.send('test')]
assert_equal(result, [3, 2, 1])
def test_wrap_propagate(self):
d = {'before': False, 'after': False, 'success': False}
def before():
d['before'] = True
def after():
d['after'] = True
def success():
d['success'] = True
signal.connect(before, signal.BEFORE_WORKLOAD_SETUP)
signal.connect(after, signal.AFTER_WORKLOAD_SETUP)
signal.connect(success, signal.SUCCESSFUL_WORKLOAD_SETUP)
caught = False
try:
with signal.wrap('WORKLOAD_SETUP'):
raise RuntimeError()
except RuntimeError:
caught=True
assert_true(d['before'])
assert_true(d['after'])
assert_true(caught)
assert_false(d['success'])

93
tests/test_utils.py Normal file
View File

@@ -0,0 +1,93 @@
# Copyright 2013-2015 ARM Limited
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# pylint: disable=R0201
from unittest import TestCase
from nose.tools import raises, assert_equal, assert_not_equal, assert_in, assert_not_in
from nose.tools import assert_true, assert_false
from wa.utils.types import list_or_integer, list_or_bool, caseless_string, arguments, prioritylist
class TestPriorityList(TestCase):
def test_insert(self):
pl = prioritylist()
elements = {3: "element 3",
2: "element 2",
1: "element 1",
5: "element 5",
4: "element 4"
}
for key in elements:
pl.add(elements[key], priority=key)
match = zip(sorted(elements.values()), pl[:])
for pair in match:
assert(pair[0] == pair[1])
def test_delete(self):
pl = prioritylist()
elements = {2: "element 3",
1: "element 2",
0: "element 1",
4: "element 5",
3: "element 4"
}
for key in elements:
pl.add(elements[key], priority=key)
del elements[2]
del pl[2]
match = zip(sorted(elements.values()), pl[:])
for pair in match:
assert(pair[0] == pair[1])
def test_multiple(self):
pl = prioritylist()
pl.add('1', 1)
pl.add('2.1', 2)
pl.add('3', 3)
pl.add('2.2', 2)
it = iter(pl)
assert_equal(it.next(), '3')
assert_equal(it.next(), '2.1')
assert_equal(it.next(), '2.2')
assert_equal(it.next(), '1')
def test_iterator_break(self):
pl = prioritylist()
pl.add('1', 1)
pl.add('2.1', 2)
pl.add('3', 3)
pl.add('2.2', 2)
for i in pl:
if i == '2.1':
break
assert_equal(pl.index('3'), 3)
def test_add_before_after(self):
pl = prioritylist()
pl.add('m', 1)
pl.add('a', 2)
pl.add('n', 1)
pl.add('b', 2)
pl.add_before('x', 'm')
assert_equal(list(pl), ['a', 'b', 'x', 'm', 'n'])
pl.add_after('y', 'b')
assert_equal(list(pl), ['a', 'b','y', 'x', 'm', 'n'])
pl.add_after('z', 'm')
assert_equal(list(pl), ['a', 'b', 'y', 'x', 'm', 'z', 'n'])