SlideShare uma empresa Scribd logo
1 de 42
Baixar para ler offline
EMBEDDED SOFTWARE 
DEVELOPMENT USING BDD 
Itamar Hassin 
September 2014
THIS TALK COVERS 
•Embedded development challenges 
! 
•The case for BDD 
! 
•Simulating the target 
! 
•Accessing the target remotely/in-situ 
! 
•Orchestrating access to multiple targets
EMBEDDED DEVELOPMENT CHALLENGES 
•A simulator rarely available or not fully functional 
! 
•Remote device verification 
! 
•Complex state-machines 
! 
•Test coverage often limited to unit testing
THE CASE FOR CUCUMBER 
•Direct mapping from user story acceptance 
criteria 
! 
•Living documentation, unified view of the product 
! 
•Helps defines ‘done’: Code is tested and validated 
! 
•BDD promotes lean code & emergent design 
! 
•Authored by the team: BAs/QA/Devs
CLOSER TO THE SOURCE
PREMISE FOR AUTOMATION 
Programatically validate that code solves the 
problem by articulating behaviour in 
machine-readable form.
CUCUMBER FOR EMBEDDED!
WRITE ONCE, USE THRICE 
Feature: Alarm assured to appear in quiet mode 
! 
Scenario: Pressure alarm 
Given device is in quiet mode 
When pressure sensor is disconnected 
Then a silent alarm will appear
IMPLEMENT STEPS 
Given(/Given device is in quiet mode $/) do 
@device.set_quiet_mode(1) 
end
IMPLEMENT A SIMULATOR 
class Device 
def set_quiet_mode(flag) 
if (flag) 
mode |= QUIET_MODE 
else 
mode &= ~QUIET_MODE 
end 
update_driver(mode) 
end 
end
VALIDATE UNDER SIMULATOR 
Scenario: Pressure alarm 
Given device is in quiet mode 
When pressure sensor is disconnected 
Then a silent alarm will appear 
! 
5 scenarios (5 passed) 
26 steps (26 passed) 
0m0.052s
WHEN SIMULATION IS NOT 
ENOUGH
THE “WIRE” 
•When your system does not have native support 
•When you want a lean, portable implementation
SIMPLIFIED WIRE PROTOCOL
WIRE IMPLEMENTATION 
BLUEPRINT 
•TCP/IP loop managing Cucumber protocol 
•Function table for API invocation 
•API implementation returning status to Cucumber
HOOKING CUCUMBER TO 
LISTENER 
features/step_definitions/cucumber.wire 
host: device 
port: 3901
LISTENER TCP/IP LOOP 
while(fgets(buff, sizeof(buff), rStream)) 
{ 
respond_to_cucumber(wStream, buff); 
}
WIRE HANDLER 
void respond_to_cucumber(FILE* stream, char* msg) 
{ 
if (MSG_TYPE_IS(msg, "step_matches")) 
respond_to_step_matches(stream, msg); 
else if (MSG_TYPE_IS(msg, "invoke")) 
respond_to_invoke(stream, msg); 
else if (MSG_TYPE_IS(msg, "begin_scenario")) 
respond_to_begin(stream, msg); 
else if (MSG_TYPE_IS(msg, "end_scenario")) 
respond_to_end(stream, msg); 
else 
respond_success(stream); 
}
FUNCTION TABLE 
stepdef_t stepdefs[] = { 
{ "device is in quiet mode”, set_quiet_mode } 
};
INVOKING API FUNCTIONS 
void respond_to_invoke(…) 
{ 
int id = get_function_id(msg); 
! 
stepdefs[id].callback(arg_val) ? 
failure(stream) : success(stream); 
}
TARGET API 
int set_quiet_mode(const char *arg) 
{ 
context->requested_mode = atoi(arg); 
context->quiet_mode |= context->requested_mode; 
return(update_driver(context)); 
}
IMPLEMENTATION STACK
WORKING WITH CUCUMBER 
•Decide on a strategy (off-board, on-board) 
•Get appropriate toolchain (cross compiler, linker) 
•Implement and port Wire to target 
•Run the feature files 
•fail/implement/pass/refactor/repeat
USAGE PATTERNS 
Off-Board 
• Framework on PC 
• Listener on PC 
• Proxy API on PC 
• Network calls to Target API 
! 
In-Situ 
• Framework on PC 
• Listener on Target 
• API calls on Target Progression
WORKING AT A SAFE 
DISTANCE
OFF-BOARD 
Cucumber 
running on 
PC 
Wire running 
on PC 
Target API 
running on 
PC 
C-implementation Network 
Target 
• + Target untouched 
• - All API’s must be exposed; 
low-fidelity; many moving 
parts;
UP CLOSE AND PERSONAL
IN-SITU 
Framework 
running on 
PC 
Cucumber- 
Wire running 
on Target 
Target API 
Network C-implementation 
• + high-fidelity, API’s not exposed 
• - Server part of codebase
COLLABORATIVE 
ENVIRONMENT
GATEWAY 
! 
•Acts as an end-to-end test orchestrator 
! 
•Switchboard events across heterogeneous devices
COLLABORATIVE 
END-TO-END TESTING 
Framework 
running on 
PC 
Cucumber- 
Wire running 
on Target 
C-implementation 
Targets 
Native 
Wire 
Collaboration
GATEWAY ARCHITECTURE 
SpecFlow 
Target B 
Proxies 
A1 
B1 
Hardware 
Serial 
Wire 
Cucumber Target A 
Behave
END-TO-END FEATURES 
Feature: Alarm assured to appear in quiet mode 
! 
Scenario: Pressure alarm 
Given device is in quiet mode 
When pressure sensor is disconnected 
Then a silent alarm will appear
GATEWAY STEPS 
public class QuietModeSteps 
{ 
SignalSimulator signalSimulator = new SignalSimulator(); 
MedicalDevice medicalDevice = new MedicalDevice(“192.168.1.1”, 3901); 
! 
[Given(@"device is quiet mode")] 
public void GivenDeviceIsQuietMode() 
{ 
NUnit.Framework.Assert.IsTrue(medicalDevice.SetQuietMode()); 
} 
! 
[When(@“pressure sensor is disconnected")] 
public void GivenPressureSensorIsDisconnected() 
{ 
NUnit.Framework.Assert.IsTrue(signalSimulator.SetPressure(off)); 
} 
}
GATEWAY PROXIES 
class MedicalDevice 
{ 
protected Wire wire; 
! 
public MedicalDevice(string ipAddress, int port) 
{ 
myAddress = ipAddress; 
wire = new Wire(myAddress, port); 
wire.Open(); 
} 
! 
public bool SetQuietMode() 
{ 
wire.Send("["step_matches",{"name_to_match":"set quiet mode on"}]n"); 
wire.Send("["invoke",{"id":"7","args":["on"]}]n"); 
return(wire.Ack()); 
} 
}
EMULATING WIRE 
public class Wire 
{ 
public int Open() 
{ 
client = new TcpClient(myAddress, myPort); 
stream = client.GetStream(); 
return(Send(“[”begin_scenario"]n")); 
} 
! 
public int Close() 
{ 
stream = client.GetStream(); 
Send("["end_scenario"]n"); 
return(client.Close()); 
} 
}
SPECFLOW TO WIRE 
SpecFlow 
int SetQuietMode(“on”) {} 
Wire 
Proxies 
A1 
Target 
TCP 
Given … quiet mode 
Wire 
Match: 
“set quiet’(on|off)’” 
Invoke: 
idx:0, params: “on” 
A 
int set_quiet(char* state){}
MAINTENANCE 
CONSIDERATIONS 
Exists in proxy? Write wrappers 
Exists in Wire? 
No 
No 
Yes 
Function table entry 
Yes 
API Exists? No Implement API 
Yes 
Use in feature/step files
COMPLIANCE 
CONSIDERATIONS 
•Security - Anyone can connect to Wire! 
•Regulation may not allow non-application code on 
a production system 
Shut down the wire thread in production
LESSONS LEARNED 
Threads & Target Dual Vocabulary 
Architecture 
Threading
REFERENCES 
•Specification by example 
•The Cucumber Book 
•Cucumber Recipes 
Photo Credits: 
@history_pics/@historyinpics 
Jim Reese#Wikipedia 
National Library of Australia 
•SpecFlow
THANK YOU! 
@itababy 
www.in-context.com

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Ready player 2 Multiplayer Red Teaming Against macOS
Ready player 2  Multiplayer Red Teaming Against macOSReady player 2  Multiplayer Red Teaming Against macOS
Ready player 2 Multiplayer Red Teaming Against macOS
 
Ansible Automation to Rule Them All
Ansible Automation to Rule Them AllAnsible Automation to Rule Them All
Ansible Automation to Rule Them All
 
FreeSWITCH on Docker
FreeSWITCH on DockerFreeSWITCH on Docker
FreeSWITCH on Docker
 
White Paper: Saml as an SSO Standard for Customer Identity Management
White Paper: Saml as an SSO Standard for Customer Identity ManagementWhite Paper: Saml as an SSO Standard for Customer Identity Management
White Paper: Saml as an SSO Standard for Customer Identity Management
 
Introduction To Appium With Robotframework
Introduction To Appium With RobotframeworkIntroduction To Appium With Robotframework
Introduction To Appium With Robotframework
 
Penetration testing web application web application (in) security
Penetration testing web application web application (in) securityPenetration testing web application web application (in) security
Penetration testing web application web application (in) security
 
Mule expression language
Mule expression languageMule expression language
Mule expression language
 
JavaFest. Nanne Baars. Web application security for developers
JavaFest. Nanne Baars. Web application security for developersJavaFest. Nanne Baars. Web application security for developers
JavaFest. Nanne Baars. Web application security for developers
 
Nmap tutorial
Nmap tutorialNmap tutorial
Nmap tutorial
 
Single Sign On 101
Single Sign On 101Single Sign On 101
Single Sign On 101
 
Getting started with Test Driven Development
Getting started with Test Driven DevelopmentGetting started with Test Driven Development
Getting started with Test Driven Development
 
Building CI/CD Pipelines with Jenkins and Kubernetes
Building CI/CD Pipelines with Jenkins and KubernetesBuilding CI/CD Pipelines with Jenkins and Kubernetes
Building CI/CD Pipelines with Jenkins and Kubernetes
 
Kotlin Crash Course
Kotlin Crash CourseKotlin Crash Course
Kotlin Crash Course
 
Ansible
AnsibleAnsible
Ansible
 
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
MuleSoft Surat Virtual Meetup#21 - MuleSoft API and RAML Design Best Practice...
 
Sql Server Security
Sql Server SecuritySql Server Security
Sql Server Security
 
Network Protocol Testing Using Robot Framework
Network Protocol Testing Using Robot FrameworkNetwork Protocol Testing Using Robot Framework
Network Protocol Testing Using Robot Framework
 
Token, token... From SAML to OIDC
Token, token... From SAML to OIDCToken, token... From SAML to OIDC
Token, token... From SAML to OIDC
 
Indroduction to SIP
Indroduction to SIPIndroduction to SIP
Indroduction to SIP
 
Google mock training
Google mock trainingGoogle mock training
Google mock training
 

Destaque

Scenario Testing and Sensitivity Analysis for 3-D Kinematic Models and Geophy...
Scenario Testing and Sensitivity Analysis for 3-D Kinematic Models and Geophy...Scenario Testing and Sensitivity Analysis for 3-D Kinematic Models and Geophy...
Scenario Testing and Sensitivity Analysis for 3-D Kinematic Models and Geophy...
The University of Western Australia
 
Writing good test plan and writing good tests
Writing good test plan and writing good testsWriting good test plan and writing good tests
Writing good test plan and writing good tests
Qingsong Yao
 
Test Case Design
Test Case DesignTest Case Design
Test Case Design
acatalin
 
REAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEMREAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEM
prakrutijsh
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
vivek223
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
Mahesh Bhalerao
 

Destaque (20)

Embedded Software Development
Embedded Software DevelopmentEmbedded Software Development
Embedded Software Development
 
Automated Acceptance Testing from Scratch
Automated Acceptance Testing from ScratchAutomated Acceptance Testing from Scratch
Automated Acceptance Testing from Scratch
 
Mattias Ratert - Incremental Scenario Testing
Mattias Ratert - Incremental Scenario TestingMattias Ratert - Incremental Scenario Testing
Mattias Ratert - Incremental Scenario Testing
 
Scenario Testing and Sensitivity Analysis for 3-D Kinematic Models and Geophy...
Scenario Testing and Sensitivity Analysis for 3-D Kinematic Models and Geophy...Scenario Testing and Sensitivity Analysis for 3-D Kinematic Models and Geophy...
Scenario Testing and Sensitivity Analysis for 3-D Kinematic Models and Geophy...
 
Writing good test plan and writing good tests
Writing good test plan and writing good testsWriting good test plan and writing good tests
Writing good test plan and writing good tests
 
Role+Of+Testing+In+Sdlc
Role+Of+Testing+In+SdlcRole+Of+Testing+In+Sdlc
Role+Of+Testing+In+Sdlc
 
Intoduction to uml
Intoduction to umlIntoduction to uml
Intoduction to uml
 
Acceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot FrameworkAcceptance Test Driven Development and Robot Framework
Acceptance Test Driven Development and Robot Framework
 
Real Time Operating Systems
Real Time Operating SystemsReal Time Operating Systems
Real Time Operating Systems
 
Test Case Design
Test Case DesignTest Case Design
Test Case Design
 
Embedded systems ppt
Embedded systems pptEmbedded systems ppt
Embedded systems ppt
 
Test Case, Use Case and Test Scenario
Test Case, Use Case and Test ScenarioTest Case, Use Case and Test Scenario
Test Case, Use Case and Test Scenario
 
Writing Test Cases 20110808
Writing Test Cases 20110808Writing Test Cases 20110808
Writing Test Cases 20110808
 
Real-Time Scheduling Algorithms
Real-Time Scheduling AlgorithmsReal-Time Scheduling Algorithms
Real-Time Scheduling Algorithms
 
REAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEMREAL TIME OPERATING SYSTEM
REAL TIME OPERATING SYSTEM
 
E.s unit 6
E.s unit 6E.s unit 6
E.s unit 6
 
Real Time Operating System
Real Time Operating SystemReal Time Operating System
Real Time Operating System
 
Rtos Concepts
Rtos ConceptsRtos Concepts
Rtos Concepts
 
Specification by Example
Specification by ExampleSpecification by Example
Specification by Example
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 

Semelhante a Embedded software development using BDD

arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
ssusere5db05
 
Dolphin: Regression Test System for Latitude
Dolphin: Regression Test System for LatitudeDolphin: Regression Test System for Latitude
Dolphin: Regression Test System for Latitude
Tao Jiang
 
ADCSS 2022
ADCSS 2022ADCSS 2022

Semelhante a Embedded software development using BDD (20)

Android Things in action
Android Things in actionAndroid Things in action
Android Things in action
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
Architectural Patterns in IoT Cloud Platforms
Architectural Patterns in IoT Cloud PlatformsArchitectural Patterns in IoT Cloud Platforms
Architectural Patterns in IoT Cloud Platforms
 
Ntcip Device Tester
Ntcip Device TesterNtcip Device Tester
Ntcip Device Tester
 
Introduction to Node MCU
Introduction to Node MCUIntroduction to Node MCU
Introduction to Node MCU
 
Arduino course
Arduino courseArduino course
Arduino course
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
 
Dolphin: Regression Test System for Latitude
Dolphin: Regression Test System for LatitudeDolphin: Regression Test System for Latitude
Dolphin: Regression Test System for Latitude
 
Arduino and c programming
Arduino and c programmingArduino and c programming
Arduino and c programming
 
Introduction to Industrial Control Systems : Pentesting PLCs 101 (BlackHat Eu...
Introduction to Industrial Control Systems : Pentesting PLCs 101 (BlackHat Eu...Introduction to Industrial Control Systems : Pentesting PLCs 101 (BlackHat Eu...
Introduction to Industrial Control Systems : Pentesting PLCs 101 (BlackHat Eu...
 
Iot for smart agriculture
Iot for smart agricultureIot for smart agriculture
Iot for smart agriculture
 
Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014Sensu and Sensibility - Puppetconf 2014
Sensu and Sensibility - Puppetconf 2014
 
IOT beginnners
IOT beginnnersIOT beginnners
IOT beginnners
 
IOT beginnners
IOT beginnnersIOT beginnners
IOT beginnners
 
Arduino Workshop @ MSA University
Arduino Workshop @ MSA UniversityArduino Workshop @ MSA University
Arduino Workshop @ MSA University
 
Android 4.2 Internals - Bluetooth and Network
Android 4.2 Internals - Bluetooth and NetworkAndroid 4.2 Internals - Bluetooth and Network
Android 4.2 Internals - Bluetooth and Network
 
ADCSS 2022
ADCSS 2022ADCSS 2022
ADCSS 2022
 
iOS Bluetooth Low Energy (BLE) Remote Robot Interface
iOS Bluetooth Low Energy (BLE) Remote Robot InterfaceiOS Bluetooth Low Energy (BLE) Remote Robot Interface
iOS Bluetooth Low Energy (BLE) Remote Robot Interface
 
KazooCon 2014 - Playing Kazoo Dudka Style
KazooCon 2014 - Playing Kazoo Dudka StyleKazooCon 2014 - Playing Kazoo Dudka Style
KazooCon 2014 - Playing Kazoo Dudka Style
 
Cafè Terminal
Cafè TerminalCafè Terminal
Cafè Terminal
 

Último

%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 

Último (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 

Embedded software development using BDD

  • 1. EMBEDDED SOFTWARE DEVELOPMENT USING BDD Itamar Hassin September 2014
  • 2. THIS TALK COVERS •Embedded development challenges ! •The case for BDD ! •Simulating the target ! •Accessing the target remotely/in-situ ! •Orchestrating access to multiple targets
  • 3. EMBEDDED DEVELOPMENT CHALLENGES •A simulator rarely available or not fully functional ! •Remote device verification ! •Complex state-machines ! •Test coverage often limited to unit testing
  • 4. THE CASE FOR CUCUMBER •Direct mapping from user story acceptance criteria ! •Living documentation, unified view of the product ! •Helps defines ‘done’: Code is tested and validated ! •BDD promotes lean code & emergent design ! •Authored by the team: BAs/QA/Devs
  • 5. CLOSER TO THE SOURCE
  • 6. PREMISE FOR AUTOMATION Programatically validate that code solves the problem by articulating behaviour in machine-readable form.
  • 8. WRITE ONCE, USE THRICE Feature: Alarm assured to appear in quiet mode ! Scenario: Pressure alarm Given device is in quiet mode When pressure sensor is disconnected Then a silent alarm will appear
  • 9. IMPLEMENT STEPS Given(/Given device is in quiet mode $/) do @device.set_quiet_mode(1) end
  • 10. IMPLEMENT A SIMULATOR class Device def set_quiet_mode(flag) if (flag) mode |= QUIET_MODE else mode &= ~QUIET_MODE end update_driver(mode) end end
  • 11. VALIDATE UNDER SIMULATOR Scenario: Pressure alarm Given device is in quiet mode When pressure sensor is disconnected Then a silent alarm will appear ! 5 scenarios (5 passed) 26 steps (26 passed) 0m0.052s
  • 12. WHEN SIMULATION IS NOT ENOUGH
  • 13. THE “WIRE” •When your system does not have native support •When you want a lean, portable implementation
  • 15. WIRE IMPLEMENTATION BLUEPRINT •TCP/IP loop managing Cucumber protocol •Function table for API invocation •API implementation returning status to Cucumber
  • 16. HOOKING CUCUMBER TO LISTENER features/step_definitions/cucumber.wire host: device port: 3901
  • 17. LISTENER TCP/IP LOOP while(fgets(buff, sizeof(buff), rStream)) { respond_to_cucumber(wStream, buff); }
  • 18. WIRE HANDLER void respond_to_cucumber(FILE* stream, char* msg) { if (MSG_TYPE_IS(msg, "step_matches")) respond_to_step_matches(stream, msg); else if (MSG_TYPE_IS(msg, "invoke")) respond_to_invoke(stream, msg); else if (MSG_TYPE_IS(msg, "begin_scenario")) respond_to_begin(stream, msg); else if (MSG_TYPE_IS(msg, "end_scenario")) respond_to_end(stream, msg); else respond_success(stream); }
  • 19. FUNCTION TABLE stepdef_t stepdefs[] = { { "device is in quiet mode”, set_quiet_mode } };
  • 20. INVOKING API FUNCTIONS void respond_to_invoke(…) { int id = get_function_id(msg); ! stepdefs[id].callback(arg_val) ? failure(stream) : success(stream); }
  • 21. TARGET API int set_quiet_mode(const char *arg) { context->requested_mode = atoi(arg); context->quiet_mode |= context->requested_mode; return(update_driver(context)); }
  • 23. WORKING WITH CUCUMBER •Decide on a strategy (off-board, on-board) •Get appropriate toolchain (cross compiler, linker) •Implement and port Wire to target •Run the feature files •fail/implement/pass/refactor/repeat
  • 24. USAGE PATTERNS Off-Board • Framework on PC • Listener on PC • Proxy API on PC • Network calls to Target API ! In-Situ • Framework on PC • Listener on Target • API calls on Target Progression
  • 25. WORKING AT A SAFE DISTANCE
  • 26. OFF-BOARD Cucumber running on PC Wire running on PC Target API running on PC C-implementation Network Target • + Target untouched • - All API’s must be exposed; low-fidelity; many moving parts;
  • 27. UP CLOSE AND PERSONAL
  • 28. IN-SITU Framework running on PC Cucumber- Wire running on Target Target API Network C-implementation • + high-fidelity, API’s not exposed • - Server part of codebase
  • 30. GATEWAY ! •Acts as an end-to-end test orchestrator ! •Switchboard events across heterogeneous devices
  • 31. COLLABORATIVE END-TO-END TESTING Framework running on PC Cucumber- Wire running on Target C-implementation Targets Native Wire Collaboration
  • 32. GATEWAY ARCHITECTURE SpecFlow Target B Proxies A1 B1 Hardware Serial Wire Cucumber Target A Behave
  • 33. END-TO-END FEATURES Feature: Alarm assured to appear in quiet mode ! Scenario: Pressure alarm Given device is in quiet mode When pressure sensor is disconnected Then a silent alarm will appear
  • 34. GATEWAY STEPS public class QuietModeSteps { SignalSimulator signalSimulator = new SignalSimulator(); MedicalDevice medicalDevice = new MedicalDevice(“192.168.1.1”, 3901); ! [Given(@"device is quiet mode")] public void GivenDeviceIsQuietMode() { NUnit.Framework.Assert.IsTrue(medicalDevice.SetQuietMode()); } ! [When(@“pressure sensor is disconnected")] public void GivenPressureSensorIsDisconnected() { NUnit.Framework.Assert.IsTrue(signalSimulator.SetPressure(off)); } }
  • 35. GATEWAY PROXIES class MedicalDevice { protected Wire wire; ! public MedicalDevice(string ipAddress, int port) { myAddress = ipAddress; wire = new Wire(myAddress, port); wire.Open(); } ! public bool SetQuietMode() { wire.Send("["step_matches",{"name_to_match":"set quiet mode on"}]n"); wire.Send("["invoke",{"id":"7","args":["on"]}]n"); return(wire.Ack()); } }
  • 36. EMULATING WIRE public class Wire { public int Open() { client = new TcpClient(myAddress, myPort); stream = client.GetStream(); return(Send(“[”begin_scenario"]n")); } ! public int Close() { stream = client.GetStream(); Send("["end_scenario"]n"); return(client.Close()); } }
  • 37. SPECFLOW TO WIRE SpecFlow int SetQuietMode(“on”) {} Wire Proxies A1 Target TCP Given … quiet mode Wire Match: “set quiet’(on|off)’” Invoke: idx:0, params: “on” A int set_quiet(char* state){}
  • 38. MAINTENANCE CONSIDERATIONS Exists in proxy? Write wrappers Exists in Wire? No No Yes Function table entry Yes API Exists? No Implement API Yes Use in feature/step files
  • 39. COMPLIANCE CONSIDERATIONS •Security - Anyone can connect to Wire! •Regulation may not allow non-application code on a production system Shut down the wire thread in production
  • 40. LESSONS LEARNED Threads & Target Dual Vocabulary Architecture Threading
  • 41. REFERENCES •Specification by example •The Cucumber Book •Cucumber Recipes Photo Credits: @history_pics/@historyinpics Jim Reese#Wikipedia National Library of Australia •SpecFlow
  • 42. THANK YOU! @itababy www.in-context.com