Capture and Replay Hardware behaviour for Regression Testing and - - PowerPoint PPT Presentation

capture and replay hardware behaviour
SMART_READER_LITE
LIVE PREVIEW

Capture and Replay Hardware behaviour for Regression Testing and - - PowerPoint PPT Presentation

Introduction Overview Static devices Dynamic behaviour Conclusion Capture and Replay Hardware behaviour for Regression Testing and Useful Bug Reports Martin Pitt <martin.pitt@ubuntu.com> Linux Plumbers Conference, September 2013


slide-1
SLIDE 1

Introduction Overview Static devices Dynamic behaviour Conclusion

Capture and Replay Hardware behaviour

for Regression Testing and Useful Bug Reports Martin Pitt <martin.pitt@ubuntu.com> Linux Plumbers Conference, September 2013

slide-2
SLIDE 2

Introduction Overview Static devices Dynamic behaviour Conclusion

Motivation

From: Joe User <joe@random.com> Subject: eye phone 17 doesn’t work after Ubuntu upgrade My eye phone 17 has worked fine in Ubuntu 12.04 LTS, but under 13.04 Rhythmbox doesn’t do anything any more when I plug it in. From: Jack Developer <hacker@freedesktop.org> Subject: Re: eye phone 17 doesn’t work after Ubuntu upgrade Sorry, I don’t have this device. It works fine with my phone and media

  • player. Can you please attach the output of ”rhythmbox –debug”?
slide-3
SLIDE 3

Introduction Overview Static devices Dynamic behaviour Conclusion

Structure

  • umockdev-record /dev/ttyUSB0
  • UMockdevTestbed GObject class API
  • umockdev-run --device 3g-usbstick.umockdev
  • -script /dev/ttyUSB0=connect.script ModemManager
slide-4
SLIDE 4

Introduction Overview Static devices Dynamic behaviour Conclusion

How does it look like?

Live demo, brace for impact!

slide-5
SLIDE 5

Introduction Overview Static devices Dynamic behaviour Conclusion

Device detection only

  • program only uses sysfs, udev properties, and uevents
  • no /dev access
  • power supply devices (upower), lsusb, DMI, rfkill,

/sys/class/drm/

slide-6
SLIDE 6

Introduction Overview Static devices Dynamic behaviour Conclusion

API usage: create device

1

UMockdevTestbed ∗ t e s t b e d = umockdev testbed new ( ) ;

2

const char ∗ s y s b a t = umockdev testbed add device ( testbed ,

3

” power supply ” , ”fakeBAT0” , NULL,

4

/∗ a t t r i b u t e s ∗/

5

” type ” , ” Battery ” ,

6

” s t a t u s ” , ” D i s c h a r g i n g ” ,

7

” e n e r g y f u l l ” , ”60000000” ,

8

” energy now ” , ”48000000” ,

9

NULL,

10

/∗ p r o p e r t i e s ∗/

11

”POWER SUPPLY ONLINE” , ”1” ,

12

NULL ) ;

13

) ;

14 15

/∗ s t a r t GTestDBus and upowerd ∗/

16

/∗ c a l l upower − −dump or query

  • ver D

−BUS ∗/

slide-7
SLIDE 7

Introduction Overview Static devices Dynamic behaviour Conclusion

API usage: load device

umockdev-record /sys/class/power supply/BAT0 > bat0.umockdev Load with:

1

from g i . r e p o s i t o r y import UMockdev

2

t e s t b e d = UMockdev . Testbed . new ( )

3

t e s t b e d . a d d f r o m f i l e ( testbed , ’ bat0 . umockdev ’ )

slide-8
SLIDE 8

Introduction Overview Static devices Dynamic behaviour Conclusion

API usage: change device

1

/∗ change b a t t e r y charge ∗/

2

u m o c k d e v t e s t b e d s e t a t t r i b u t e ( testbed , sys bat ,

3

” energy now ” , ”1500000” ) ;

4

/∗ send uevent to n o t i f y upowerd ∗/

5

umockdev testbed uevent ( testbed , sys bat , ” change ” ) ;

6 7

/∗ c a l l upower − −dump or query

  • ver D

−BUS ∗/

slide-9
SLIDE 9

Introduction Overview Static devices Dynamic behaviour Conclusion

Implementation: preload library

$ umockdev-wrapper ./my-test-suite

  • r

$ LD PRELOAD=libumockdev-preload.so ./my-test-suite

slide-10
SLIDE 10

Introduction Overview Static devices Dynamic behaviour Conclusion

/dev emulation

$UMOCKDEV DIR/dev/* Common cases:

  • char device (tty, ModemManager, evdev events): read(),

write()

  • socket (Android rild): send(), recv()
  • ioctl (usbdevfs, evdev properties)
  • block device
slide-11
SLIDE 11

Introduction Overview Static devices Dynamic behaviour Conclusion

read/write scripts

w 0 ATZ^J r 200 OK^J w 350 ATI0^J r 10 Huawei X1234^Jcaps:^I2G 3G 4G^J [...] f 5 - w 50 ^@jf9j#2j(*J^@^@^@

1

GError ∗ e r r o r = NULL ;

2

u m o c k d e v t e s t b e d l o a d s c r i p t ( testbed , ”/ dev /ttyUSB0” ,

3

” huawei . s c r i p t ” , &e r r o r ) ;

slide-12
SLIDE 12

Introduction Overview Static devices Dynamic behaviour Conclusion

ioctl emulation

USBDEVFS_CONNECTINFO 0 0B00000000000000 USBDEVFS_REAPURB 0 1 2 0 0 8 8 0 0001020304050607 USBDEVFS_REAPURB 0 1 129 0 0 15 6 0 DEADBEEF0042 USBDEVFS_REAPURB 0 1 129 0 0 15 7 0 10090807060504 USBDEVFS_REAPURB 0 1 129 -5 0 15 5 0 1010101010 EVIOCGBIT(3) 8 0300001100806002

1

GError ∗ e r r o r = NULL ;

2

u m o c k d e v t e s t b e d l o a d i o c t l ( testbed , ”/ dev / bus / usb /001/013” ,

3

”cam−import . i o c t l ” , &e r r o r ) ;

slide-13
SLIDE 13

Introduction Overview Static devices Dynamic behaviour Conclusion

Summary

  • Limited to recorded use cases, without much deviation
  • use case driven, especially ioctls
  • specific to /sys and /dev
  • other kinds of devices: scsi debug, veth, mac80211 hwsim
slide-14
SLIDE 14

Introduction Overview Static devices Dynamic behaviour Conclusion

EOF

Thank you for your attention! Q & A, other use cases, discussion https://github.com/martinpitt/umockdev/ pitti on Freenode, martin.pitt@ubuntu.com