SlideShare a Scribd company logo
Introduction

Overview

Static devices

Dynamic behaviour

Capture and Replay Hardware behaviour
for Regression Testing and Useful Bug Reports

Martin Pitt
<martin.pitt@ubuntu.com>

Linux Plumbers Conference, September 2013

Conclusion
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”?
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
Introduction

Overview

Static devices

Dynamic behaviour

How does it look like?

Live demo, brace for impact!

Conclusion
Introduction

Overview

Static devices

Dynamic behaviour

Device detection only

• only sysfs, udev props, uevents
• no /dev access
• power supply devices (upower), lsusb, DMI, rfkill,

/sys/class/drm/

Conclusion
Introduction

Overview

Static devices

Dynamic behaviour

Conclusion

API usage: create device

1
2
3
4
5
6
7
8
9
10
11
12
13

UMockdevTestbed ∗ t e s t b e d = u m o c k d e v t e s t b e d n e w ( ) ;
const char ∗ sys bat = umockdev testbed add device ( testbed ,
” p o w e r s u p p l y ” , ” fakeBAT0 ” , NULL ,
/∗ a t t r i b u t e s ∗/
” type ” , ” Battery ” ,
” status ” , ” Discharging ” ,
” e n e r g y f u l l ” , ” 60000000 ” ,
” e n e r g y n o w ” , ” 48000000 ” ,
NULL ,
/∗ p r o p e r t i e s ∗/
”POWER SUPPLY ONLINE” , ” 1 ” ,
NULL ) ;
);

14
15
16

/∗ s t a r t GTestDBus and upowerd ∗/
/∗ c a l l upower −−dump o r q u e r y o v e r D−BUS ∗/
Introduction

Overview

Static devices

Dynamic behaviour

API usage: load device

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

from g i . r e p o s i t o r y i m p o r t UMockdev
t e s t b e d = UMockdev . T e s t b e d . new ( )
t e s t b e d . a d d f r o m f i l e ( t e s t b e d , ’ b a t 0 . umockdev ’ )

Conclusion
Introduction

Overview

Static devices

Dynamic behaviour

API usage: change device

1
2
3
4
5

/∗ c h a n g e b a t t e r y c h a r g e ∗/
umockdev testbed set attribute ( testbed , sys bat ,
” e n e r g y n o w ” , ” 1500000 ” ) ;
/∗ s e n d u e v e n t t o n o t i f y upowerd ∗/
u m o c k d e v t e s t b e d u e v e n t ( t e s t b e d , s y s b a t , ” change ” ) ;

6
7

/∗ c a l l upower −−dump o r q u e r y o v e r D−BUS ∗/

Conclusion
Introduction

Overview

Static devices

Dynamic behaviour

Implementation: preload library

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

Conclusion
Introduction

Overview

Static devices

Dynamic behaviour

/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

Conclusion
Introduction

Overview

Static devices

Dynamic behaviour

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
2
3

G E r r o r ∗ e r r o r = NULL ;
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 ( t e s t b e d , ” / d e v / ttyUSB0 ” ,
” h u a w e i . s c r i p t ” , &e r r o r ) ;

Conclusion
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
2
3

G E r r o r ∗ e r r o r = NULL ;
u m o c k d e v t e s t b e d l o a d i o c t l ( t e s t b e d , ” / d e v / b u s / u s b /001/013 ” ,
”cam−i m p o r t . i o c t l ” , &e r r o r ) ;
Introduction

Overview

Static devices

Dynamic behaviour

Conclusion

Summary

• successful for several packages
• 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
• testing against D-BUS services: python-dbusmock, Bendy Bus
Introduction

Overview

Static devices

Dynamic behaviour

EOF

Q & A, other use cases, discussion

https://github.com/martinpitt/umockdev/
pitti on Freenode, martin.pitt@ubuntu.com

Slides license: CC-BY-SA 3.0

Conclusion

More Related Content

PPTX
Os Practical Assignment 1
PDF
The true story_of_hello_world
PDF
YCAM Workshop Part 3
PDF
DDAA FPGA - Multiplexor De Numeros en Display 7 Segmentos En Tiempo
PDF
Web-based visualisation and monitoring of smart meters using CQELS
PPT
13 exception handling
PPTX
C++ Optimization Tips
PDF
One page app with AngularJS
Os Practical Assignment 1
The true story_of_hello_world
YCAM Workshop Part 3
DDAA FPGA - Multiplexor De Numeros en Display 7 Segmentos En Tiempo
Web-based visualisation and monitoring of smart meters using CQELS
13 exception handling
C++ Optimization Tips
One page app with AngularJS

What's hot (18)

PDF
Rich and Snappy Apps (No Scaling Required)
PDF
Star bed 2018.07.19
PDF
The Ring programming language version 1.8 book - Part 61 of 202
PPTX
Javascript Basics for Advertisers
PDF
সোলার প্যানেল [ বিস্তারিত ]
PDF
Interactive Music II ProcessingとSuperColliderの連携 -2
PDF
A little systemtap
PPTX
Javascript Common Mistakes
PDF
Default bootloader DFU + UART
TXT
Programação completa e perfeira
PDF
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator
PDF
The Death of a Mouse
PDF
Of tutorials v1806
PPTX
Azure Durable Funkiness - .NET Oxford June 2018
PDF
Verifikation - Metoder og Libraries
PDF
Of tutorials v1612+
PDF
Memory error-talk
Rich and Snappy Apps (No Scaling Required)
Star bed 2018.07.19
The Ring programming language version 1.8 book - Part 61 of 202
Javascript Basics for Advertisers
সোলার প্যানেল [ বিস্তারিত ]
Interactive Music II ProcessingとSuperColliderの連携 -2
A little systemtap
Javascript Common Mistakes
Default bootloader DFU + UART
Programação completa e perfeira
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator
The Death of a Mouse
Of tutorials v1806
Azure Durable Funkiness - .NET Oxford June 2018
Verifikation - Metoder og Libraries
Of tutorials v1612+
Memory error-talk
Ad

Similar to Capture and replay hardware behaviour for regression testing and bug reporting (20)

PDF
Bsides Puerto Rico-2017
PDF
Andy Davis' Black Hat USA Presentation Revealing embedded fingerprints
PDF
Develop Your Own Operating Systems using Cheap ARM Boards
PDF
BSides DFW2016-Hack Mode Enabled
PDF
DEF CON 27 - PHILIPPE LAULHERET - introduction to hardware hacking extended v...
PDF
BSides Indy 2017 - Hardware Hacking - Abusing the Things
PDF
LAS16-403: GDB Linux Kernel Awareness
PDF
LAS16-403 - GDB Linux Kernel Awareness
PDF
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
PDF
Insecure Obsolete and Trivial - The Real IOT
PDF
Userspace drivers-2016
PDF
ELC-E 2019 Device tree, past, present, future
PPTX
Adventures in USB land
PDF
Embedded Recipes 2019 - Introduction to JTAG debugging
PDF
Introduction of unit test on android kernel
PDF
Testing and HW Virtualization (7th White Rabbit Workshop)
PDF
USB: Undermining Security Barriers
PDF
BadUSB, and what you should do about it
PDF
Hardware hacking
PDF
Hardware-Hacking-101 By Asutosh Kumar.pdf
Bsides Puerto Rico-2017
Andy Davis' Black Hat USA Presentation Revealing embedded fingerprints
Develop Your Own Operating Systems using Cheap ARM Boards
BSides DFW2016-Hack Mode Enabled
DEF CON 27 - PHILIPPE LAULHERET - introduction to hardware hacking extended v...
BSides Indy 2017 - Hardware Hacking - Abusing the Things
LAS16-403: GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
Insecure Obsolete and Trivial - The Real IOT
Userspace drivers-2016
ELC-E 2019 Device tree, past, present, future
Adventures in USB land
Embedded Recipes 2019 - Introduction to JTAG debugging
Introduction of unit test on android kernel
Testing and HW Virtualization (7th White Rabbit Workshop)
USB: Undermining Security Barriers
BadUSB, and what you should do about it
Hardware hacking
Hardware-Hacking-101 By Asutosh Kumar.pdf
Ad

Recently uploaded (20)

PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
A Presentation on Artificial Intelligence
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Getting Started with Data Integration: FME Form 101
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
1. Introduction to Computer Programming.pptx
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Web App vs Mobile App What Should You Build First.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Chapter 5: Probability Theory and Statistics
A Presentation on Artificial Intelligence
Group 1 Presentation -Planning and Decision Making .pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
cloud_computing_Infrastucture_as_cloud_p
Encapsulation_ Review paper, used for researhc scholars
A comparative study of natural language inference in Swahili using monolingua...
Hindi spoken digit analysis for native and non-native speakers
Getting Started with Data Integration: FME Form 101
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
SOPHOS-XG Firewall Administrator PPT.pptx
1. Introduction to Computer Programming.pptx
OMC Textile Division Presentation 2021.pptx
Assigned Numbers - 2025 - Bluetooth® Document
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...

Capture and replay hardware behaviour for regression testing and bug reporting

  • 1. Introduction Overview Static devices Dynamic behaviour Capture and Replay Hardware behaviour for Regression Testing and Useful Bug Reports Martin Pitt <martin.pitt@ubuntu.com> Linux Plumbers Conference, September 2013 Conclusion
  • 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”?
  • 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
  • 4. Introduction Overview Static devices Dynamic behaviour How does it look like? Live demo, brace for impact! Conclusion
  • 5. Introduction Overview Static devices Dynamic behaviour Device detection only • only sysfs, udev props, uevents • no /dev access • power supply devices (upower), lsusb, DMI, rfkill, /sys/class/drm/ Conclusion
  • 6. Introduction Overview Static devices Dynamic behaviour Conclusion API usage: create device 1 2 3 4 5 6 7 8 9 10 11 12 13 UMockdevTestbed ∗ t e s t b e d = u m o c k d e v t e s t b e d n e w ( ) ; const char ∗ sys bat = umockdev testbed add device ( testbed , ” p o w e r s u p p l y ” , ” fakeBAT0 ” , NULL , /∗ a t t r i b u t e s ∗/ ” type ” , ” Battery ” , ” status ” , ” Discharging ” , ” e n e r g y f u l l ” , ” 60000000 ” , ” e n e r g y n o w ” , ” 48000000 ” , NULL , /∗ p r o p e r t i e s ∗/ ”POWER SUPPLY ONLINE” , ” 1 ” , NULL ) ; ); 14 15 16 /∗ s t a r t GTestDBus and upowerd ∗/ /∗ c a l l upower −−dump o r q u e r y o v e r D−BUS ∗/
  • 7. Introduction Overview Static devices Dynamic behaviour API usage: load device umockdev-record /sys/class/power supply/BAT0 > bat0.umockdev Load with: 1 2 3 from g i . r e p o s i t o r y i m p o r t UMockdev t e s t b e d = UMockdev . T e s t b e d . new ( ) t e s t b e d . a d d f r o m f i l e ( t e s t b e d , ’ b a t 0 . umockdev ’ ) Conclusion
  • 8. Introduction Overview Static devices Dynamic behaviour API usage: change device 1 2 3 4 5 /∗ c h a n g e b a t t e r y c h a r g e ∗/ umockdev testbed set attribute ( testbed , sys bat , ” e n e r g y n o w ” , ” 1500000 ” ) ; /∗ s e n d u e v e n t t o n o t i f y upowerd ∗/ u m o c k d e v t e s t b e d u e v e n t ( t e s t b e d , s y s b a t , ” change ” ) ; 6 7 /∗ c a l l upower −−dump o r q u e r y o v e r D−BUS ∗/ Conclusion
  • 9. Introduction Overview Static devices Dynamic behaviour Implementation: preload library $ umockdev-wrapper ./my-test-suite or $ LD PRELOAD=libumockdev-preload.so ./my-test-suite Conclusion
  • 10. Introduction Overview Static devices Dynamic behaviour /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 Conclusion
  • 11. Introduction Overview Static devices Dynamic behaviour 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 2 3 G E r r o r ∗ e r r o r = NULL ; 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 ( t e s t b e d , ” / d e v / ttyUSB0 ” , ” h u a w e i . s c r i p t ” , &e r r o r ) ; Conclusion
  • 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 2 3 G E r r o r ∗ e r r o r = NULL ; u m o c k d e v t e s t b e d l o a d i o c t l ( t e s t b e d , ” / d e v / b u s / u s b /001/013 ” , ”cam−i m p o r t . i o c t l ” , &e r r o r ) ;
  • 13. Introduction Overview Static devices Dynamic behaviour Conclusion Summary • successful for several packages • 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 • testing against D-BUS services: python-dbusmock, Bendy Bus
  • 14. Introduction Overview Static devices Dynamic behaviour EOF Q & A, other use cases, discussion https://github.com/martinpitt/umockdev/ pitti on Freenode, martin.pitt@ubuntu.com Slides license: CC-BY-SA 3.0 Conclusion