tdc2016sp - trilha embarcados
TRANSCRIPT
Globalcode – Open4education
Trilha – EmbarcadosEuripedes Rocha Filho
Engenheiro Eletricista
Globalcode – Open4education
Agenda
Por que estamos aqui?
E o que eu ganho com isso?
Resultados das primeiras experiências
Let the carnage begin!
Globalcode – Open4education
Objetivos:
Porque gastar meu tempo com testes?
Resultados com os primeiros experimentos
Proposição de um fluxo
Um exemplo aplicado
Globalcode – Open4education
Quanto custa 1 bug?
DEPENDE
Globalcode – Open4education
Mars Climate Orbiter
"People sometimes make errors," said Dr. Edward Weiler, NASA's Associate Administrator for Space Science. "The problem here was not the error, it was the failure of NASA's systems engineering, and the checks and balances in our processes to detect the error. That's why we lost the spacecraft." http://mars.nasa.gov/msp98/news/mco990930.html
https://upload.wikimedia.org/wikipedia/commons/8/83/Mars_Climate_Orbiter_-_mishap_diagram.png
Globalcode – Open4education
Toyota
“The standard gcc compiler version 4″ generated a redacted number of warnings (probably larger than 100) about the code, in 11 different warning categories. (p. 25)
“Coverity version 4.2″ generated a redacted number of warnings (probably larger than 154) about the code, in 10 different warning categories. (p. 27)
“Codesonar version 3.6p1″ generated a redacted number of warnings (probably larger than 136) about the code, in 10 different warning categories.
“Uno version 2.12″ generated a redacted number of warnings (probably larger than 72) about the code, in 9 different warning categories.
The code contained at least 347 deviations from a subset of 14 of the MISRA-C rules.
Fonte: http://embeddedgurus.com/barr-code/2011/03/unintended-acceleration-and-other-embedded-software-bugs/
Globalcode – Open4education
Coin
Globalcode – Open4education
Minha balança
https://commons.wikimedia.org/wiki/File:Sourdough_miche_%26_boule.jpg
Globalcode – Open4education
Motivações
Time to Market Sólido
Testes de regressão
Release early and often
Diversão com falhou/passou
Curva de velocidade
Globalcode – Open4education
Caso 1: Rádio Enlace
Camada física de um modem Banda Larga
FPGA/VHDL
py.test→MyHDL →Modelsim(Verilog→VHDL)
Globalcode – Open4education
Resultados
Reduzimos os problemas de integração
Detectamos e validamos mais cedo alguns problemas
Testar em python facilitou implementação de modelos
Globalcode – Open4education
SAT
Especificação bem definida
Acceptance driven
1 semana de testes em 2 horas. Com 2,5 semanas de implementação de testes
Globalcode – Open4education
Ferramentas
The robotframework – Acceptance Testing
Atualizar estatiscas de execucaoPlugmini esta ligado a USBRequisitamos arquivo de dados de execucaoPlugmini envia arquivoDados devem seguir formatoAnd Tamanho deve corresponder ao exercicio
Globalcode – Open4education
Fluxo de trabalho
Estabelecer as coisas da perspectiva do cliente
Estabelecer uma maneira de validar o sistema. Comportamento Aceitável.
Abrace o refatoramento.
Inclua as ferramentas adequadas para cada tipo de desafio
Prazo derrota todos os argumentos, teste as seções críticas primeiro
Globalcode – Open4education
Plugfects
Por mais música no mundo.
https://commons.wikimedia.org/wiki/File:Open-source-hardware-logo.svg
Globalcode – Open4education
Plugmini
Globalcode – Open4education
Arquitetura
Globalcode – Open4education
Codec
http://www.ti.com/lit/ds/symlink/tlv320aic3120.pdf
Globalcode – Open4education
Criando o projeto
$ceedling new nome_do_projeto
Projeto
build/project.ymlrakefile.rbsrc/test/vendor/
Globalcode – Open4education
Novo módulo
$rake module:create[bsp/bsp_codec]Projeto
src/
test/
bsp/
bsp_codec.h
bsp_codec.c
bsp/
test_bsp_codec.c
Globalcode – Open4education
test_bsp_codec.c
#include "unity.h"#include "bsp_codec.h"
void setUp(void){}
void tearDown(void){}
void test_module_generator_needs_to_be_implemented(void){
TEST_IGNORE_MESSAGE("Implement me!");}
Globalcode – Open4education
Lista de testesvoid test_set_intensity(void){ TEST_FAIL_MESSAGE("Implement me!");}
void test_set_intensity_greater_than_100(void){ TEST_FAIL_MESSAGE("Implement me!");}
void test_set_intensity_negative(void){ TEST_FAIL_MESSAGE("Implement me!");}
Globalcode – Open4education
void test_set_intensity(void){ TEST_FAIL_MESSAGE("Definida intensidade arbitrária 0-100%"); TEST_FAIL_MESSAGE("Chamada a função set_intensity com o valor"); TEST_FAIL_MESSAGE("Retorno deve ser OK");}
Globalcode – Open4education
Teste
void test_set_intensity(void){ uint_fast8_t intensity = 40; bsp_codec_err_t ret_codec; ret_codec = bsp_codec_intensity(&hnd_codec, intensity); TEST_ASSERT_EQUAL(ret_codec, OK);}
Globalcode – Open4education
#ifndef bsp_codec_H#define bsp_codec_H#include <stdint.h>
typedef enum {OK=0, ERR } bsp_codec_err_t;
typedef struct{codec_route_t route; uint_fast16_t ctrl_addr;} codec_handler;
bsp_codec_err_t init(codec_handler * handler);
bsp_codec_err_t bsp_codec_intensity(codec_handler * handler, uint_fast8_t intensity);#endif
Globalcode – Open4education
bsp_codec.c
#include "bsp_codec.h"
bsp_codec_err_t bsp_codec_intensity(codec_handler * handler, uint_fast8_t intensity){ return ERR;};
Globalcode – Open4education
MOCK
Globalcode – Open4education
Integração Contínua?
Globalcode – Open4education
Livros
Globalcode – Open4education
github.com/plugfects signup.plugfects.org
Ceedling, Unity e Cmock - http://www.throwtheswitch.org/
The robotframework - http://robotframework.org/
Globalcode – Open4education
@rochaeuripedes [email protected]
https://www.facebook.com/rocha.euripedes
Obrigado!