Commit 5d115d1f authored by Alexandre Leblanc's avatar Alexandre Leblanc
Browse files

clean up and start doing a full project

parent ea7be9c5
GEM
remote: https://rubygems.org/
specs:
builder (3.2.2)
cucumber (2.4.0)
builder (>= 2.1.2)
cucumber-core (~> 1.5.0)
cucumber-wire (~> 0.0.1)
diff-lcs (>= 1.1.3)
gherkin (~> 4.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (1.5.0)
gherkin (~> 4.0)
cucumber-wire (0.0.1)
diff-lcs (1.2.5)
gherkin (4.0.0)
multi_json (1.12.1)
multi_test (0.1.2)
power_assert (0.2.6)
rake (11.3.0)
ruby_expect (1.7.4)
test-unit (3.2.3)
power_assert
PLATFORMS
ruby
DEPENDENCIES
cucumber
rake
ruby_expect
test-unit
BUNDLED WITH
1.13.6
bundle exec rake cucumber
require 'cucumber/rake/task'
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = %w{--format pretty}
end
\ No newline at end of file
project(LibBasicModel)
include_directories(/home/macmata/sfl/cucumber-cpp/include src)
add_library(LibBasicModel STATIC src/MyModel)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(${GTEST_DIR}/include ${GTEST_DIR}/src)
add_executable(GTestSfl step_definitions/Gtest_Basic_test.cpp)
target_link_libraries(GTestSfl LibBasicModel ${CUKE_LIBRARIES} ${CUKE_GTEST_LIBRARIES})
# language: en
Feature: Hello World
This is only a small hello world
That tap into a model Api
@wire
Scenario: Add two numbers
Given MyModel set 3
Then The result set is 3
@wire
Scenario: Add two numbers
Given MyModel set 4
Then The result set is 4
@wire
Scenario: This is my new supper test
Given I check for this service toto_service
Then It should be up
@wire
Scenario: This is my new supper test
Given I check for this service toto_service
And I check for this service nono_service
When Bob is not there
Then It should be up
But Jack is not eating
@wire
Scenario: This is my new new super test
Given I check for this variable JAVA_HOME
When Bob is not there
//
// Created by macmata on 22/11/16.
//
#include "MyModel.h"
void MyModel::set(double x) {
value = x;
}
double MyModel::get() {
return value;
}
//
// Created by macmata on 22/11/16.
//
#ifndef CUCUMBER_CPP_MYMODEL_H
#define CUCUMBER_CPP_MYMODEL_H
class MyModel {
double value;
public:
void set(double x);
double get();
};
#endif //CUCUMBER_CPP_MYMODEL_H
#include <gtest/gtest.h>
#include <cucumber-cpp/autodetect.hpp>
#include <MyModel.h>
using cucumber::ScenarioScope;
struct MyModelStruct {
MyModel model;
double result;
};
GIVEN("^MyModel set (\\d+)$") {
REGEX_PARAM(double, n);
ScenarioScope<MyModelStruct> context;
context->model.set(n);
}
THEN("^The result set is (\\d+)$") {
REGEX_PARAM(double, expected);
ScenarioScope<MyModelStruct> context;
context->result = context->model.get();
EXPECT_EQ(expected, context->result);
}
THEN("^This is not implemented for value (\\d+)$") {
REGEX_PARAM(double, expected);
ScenarioScope<MyModelStruct> context;
context->result = context->model.get();
EXPECT_EQ(expected, context->result);
}
BEFORE("@wire") {
}
AROUND_STEP("@wire") {
}
AFTER_STEP('@wire') {
}
AFTER('@wire') {
}
\ No newline at end of file
require 'ruby_expect'
require 'pry'
class Chatter
attr_reader :conn
attr_reader :cond
attr_accessor :mutex
PROMPT = Regexp.compile('\=\>.*')
AUTOLOAD = Regexp.compile('Hit any key to stop autoboot:.*$')
def initialize
@conn = RubyExpect::Expect.spawn("~/sfl/buildroot/launchQemu.sh")
@conn.timeout = 6
@conn.debug = true
@cond = ConditionVariable.new
@cond2 = ConditionVariable.new
@mutex = Mutex.new
@container = {}
@container[:run] = true
@container[:test] = []
@container[:test] = {}
end
def connect
@conn.expect /Hit any key to stop autoboot:.*$/ do
send ' '
puts 'autoload'
end
def connect(app, timeout, debug)
connector = RubyExpect::Expect.spawn(app) # or RubyExpect::Expect.connect
connector.timeout = timeout
connector.debug = debug
connector.expect AUTOLOAD do
send ' '
puts 'autoload' if debug
end
Thread.new do
Thread.new do
while @container[:run] do
@mutex.synchronize do
@cond2.wait(@mutex) while @container[:test].empty? or not @container[:test][3].nil?
@cond.wait(@mutex) while @container[:test].empty? or not @container[:test][:result].nil?
puts 'not empty'
puts 'not empty' if debug
cmd =@container[:test][1]
cmd = @container[:test][:cmd]
@conn.expect /\=\>.*/ do
connector.expect PROMPT do
send cmd
puts "send command #{cmd}"
puts "send command #{cmd}" if debug
end
result = 'failed'
@conn.expect @container[:test][2] do
puts 'catch regex'
connector.expect @container[:test][:regex] do
puts 'catch regex' if debug
result = 'ok'
send ' ' #clear line
end
@container[:test][3]=result
puts "my containter tests #{@container[:test]}"
@container[:test][:result]=result
puts "my containter tests #{@container[:test]}" if debug
end
end
end
end
def factory(debug, **karg)
connector = if karg[:socket]
RubyExpect::Expect.connect(karg[:socket])
else
RubyExpect::Expect.spawn(karg[:command])
end
connector.debug = debug
connector.timeout = karg[:timeout]
connector
end
def addTests(test)
@mutex.synchronize do
@container[:test] = test
puts "my containner added #{@container[:test]}"
end
@cond2.signal
@cond.signal
end
def getTest
while @container[:test][3] == nil
while @container[:test][:result] == nil
end
@container[:test]
end
......
require_relative '../step_definitions/Chatter'
require 'test/unit/assertions'
include Test::Unit::Assertions
require_relative '../src/ruby/Chatter'
require 'rubygems'
require 'test/unit'
Given(/^Uboot is booting$/) do
@chatter = Chatter.new
@chatter.connect
@chatter.connect('~/sfl/buildroot/launchQemu.sh', 4, false)
end
When(/^Sending command (.*)$/) do |arg|
@test = Array.new
@test[0] = 1
@test[1] = arg
When(/^Sending command (.*)$/) do |cmd|
@test = {}
@test[:cmd] = cmd
end
Then(/^Uboot should reply (.*)$/) do |arg|
@test[2] = Regexp.new(arg)
@test[:regex] = Regexp.new(arg)
@chatter.addTests @test
test = @chatter.getTest
assert_not_nil(test, "nit for test is #{test}")
assert_equal('ok', test[3], "#{test}")
assert_equal('ok', test[:result], "#{test}")
end
Given(/^Uboot prompt is present$/) do
@test = Array.new
@test[1] = ' '
@test[2] = Regexp.new('\=\>.*')
@test = {}
@test[:regex] = Regexp.new('\=\>.*')
@chatter.addTests @test
test = @chatter.getTest
assert_not_nil(test, "test is #{test}")
assert_not_nil(test, 'dic is nil')
assert_equal('ok', test[3], "#{test}")
assert_equal('ok', test[:result], "#{test}")
end
......@@ -3,6 +3,15 @@ Feature:
As a boot
I want to check it is running
Scenario: Uboot boot tests are failing and its ok
Given Uboot is booting
And Uboot prompt is present
When Sending command mii info 1
Then Uboot should reply PHY 0x02: OUI = 0x01F0, Model = 0x0D, Rev = 0x01, 100baseT, FDX
And Uboot prompt is present
When Sending command mii info 2
Then Uboot should reply PHY 0x01: OUI = 0x01F0, Model = 0x0D, Rev = 0x01, 100baseT, FDX
Scenario: Uboot boot
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment