[修改] 增加freeRTOS

1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
2023-05-06 16:43:01 +00:00
commit a345df017b
20944 changed files with 11094377 additions and 0 deletions

View File

@ -0,0 +1,9 @@
Manifest.txt
Rakefile
lib/behaviors.rb
lib/behaviors/reporttask.rb
test/behaviors_tasks_test.rb
test/behaviors_test.rb
test/tasks_test/lib/user.rb
test/tasks_test/Rakefile
test/tasks_test/test/user_test.rb

View File

@ -0,0 +1,19 @@
require 'rake'
require 'rubygems'
require 'hoe'
Hoe.new('behaviors','1.0.3') do |p|
p.author = "Atomic Object LLC"
p.email = "dev@atomicobject.com"
p.url = "http://behaviors.rubyforge.org"
p.summary = "behavior-driven unit test helper"
p.description = <<-EOS
Behaviors allows for Test::Unit test case methods to be defined as
human-readable descriptions of program behavior. It also provides
Rake tasks to list the behaviors of your project.
EOS
p.test_globs = ['test/*_test.rb']
p.changes = <<-EOS
EOS
end

View File

@ -0,0 +1,76 @@
=begin rdoc
= Usage
Behaviors provides a single method: should.
Instead of naming test methods like:
def test_something
end
You declare test methods like:
should "perform action" do
end
You may omit the body of a <tt>should</tt> method to describe unimplemented behavior.
should "perform other action"
When you run your unit tests, empty <tt>should</tt> methods will appear as an 'UNIMPLEMENTED CASE' along with the described behavior.
This is useful for sketching out planned behavior quickly.
Simply <tt>extend Behaviors</tt> in your <tt>TestCase</tt> to start using behaviors.
require 'test/unit'
require 'behaviors'
require 'user'
class UserTest < Test::Unit::TestCase
extend Behaviors
...
end
= Motivation
Test methods typically focus on the name of the method under test instead of its behavior.
Creating test methods with <tt>should</tt> statements focuses on the behavior of an object.
This helps you to think about the role of the object under test.
Using a behavior-driven approach prevents the danger in assuming a one-to-one mapping of method names to
test method names.
As always, you get the most value by writing the tests first.
For a more complete BDD framework, try RSpec http://rspec.rubyforge.org/
= Rake tasks
You can define a <tt>Behaviors::ReportTask</tt> in your <tt>Rakefile</tt> to generate rake tasks that
summarize the behavior of your project.
These tasks are named <tt>behaviors</tt> and <tt>behaviors_html</tt>. They will output to the
console or an html file in the <tt>doc</tt> directory with a list all of your <tt>should</tt> tests.
Behaviors::ReportTask.new do |t|
t.pattern = 'test/**/*_test.rb'
end
You may also initialize the <tt>ReportTask</tt> with a custom name to associate with a particular suite of tests.
Behaviors::ReportTask.new(:widget_subsystem) do |t|
t.pattern = 'test/widgets/*_test.rb'
end
The html report will be placed in the <tt>doc</tt> directory by default.
You can override this default by setting the <tt>html_dir</tt> in the <tt>ReportTask</tt>.
Behaviors::ReportTask.new do |t|
t.pattern = 'test/**/*_test.rb'
t.html_dir = 'behaviors_html_reports'
end
=end
module Behaviors
def should(behave,&block)
mname = "test_should_#{behave}"
if block
define_method mname, &block
else
puts ">>> UNIMPLEMENTED CASE: #{name.sub(/Test$/,'')} should #{behave}"
end
end
end

View File

@ -0,0 +1,158 @@
require 'rake'
require 'rake/tasklib'
module Behaviors
include Rake
class ReportTask < TaskLib
attr_accessor :pattern
attr_accessor :html_dir
def initialize(name=:behaviors)
@name = name
@html_dir = 'doc'
yield self if block_given?
define
end
def define
desc "List behavioral definitions for the classes specified (use for=<regexp> to further limit files included in report)"
task @name do
specifications.each do |spec|
puts "#{spec.name} should:\n"
spec.requirements.each do |req|
puts " - #{req}"
end
end
end
desc "Generate html report of behavioral definitions for the classes specified (use for=<regexp> to further limit files included in report)"
task "#{@name}_html" do
require 'erb'
txt =<<-EOS
<html>
<head>
<style>
div.title
{
width: 600px;
font: bold 14pt trebuchet ms;
}
div.specification
{
font: bold 12pt trebuchet ms;
border: solid 1px black;
width: 600px;
padding: 5px;
margin: 5px;
}
ul.requirements
{
font: normal 11pt verdana;
padding-left: 0;
margin-left: 0;
border-bottom: 1px solid gray;
width: 600px;
}
ul.requirements li
{
list-style: none;
margin: 0;
padding: 0.25em;
border-top: 1px solid gray;
}
</style>
</head>
<body>
<div class="title">Specifications</div>
<% specifications.each do |spec| %>
<div class="specification">
<%= spec.name %> should:
<ul class="requirements">
<% spec.requirements.each do |req| %>
<li><%= req %></li>
<% end %>
</ul>
</div>
<% end %>
</body>
</html>
EOS
output_dir = File.expand_path(@html_dir)
mkdir_p output_dir
output_filename = output_dir + "/behaviors.html"
File.open(output_filename,"w") do |f|
f.write ERB.new(txt).result(binding)
end
puts "(Wrote #{output_filename})"
end
end
private
def test_files
test_list = FileList[@pattern]
if ENV['for']
test_list = test_list.grep(/#{ENV['for']}/i)
end
test_list
end
def specifications
test_files.map do |file|
spec = OpenStruct.new
m = %r".*/([^/].*)_test.rb".match(file)
class_name = titleize(m[1]) if m[1]
spec.name = class_name
spec.requirements = []
File::readlines(file).each do |line|
if line =~ /^\s*should\s+\(?\s*["'](.*)["']/
spec.requirements << $1
end
end
spec
end
end
############################################################
# STOLEN FROM inflector.rb
############################################################
#--
# Copyright (c) 2005 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++
def titleize(word)
humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize }
end
def underscore(camel_cased_word) camel_cased_word.to_s.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
end
def humanize(lower_case_and_underscored_word)
lower_case_and_underscored_word.to_s.gsub(/_id$/, "").gsub(/_/, " ").capitalize
end
end
end

View File

@ -0,0 +1,73 @@
require 'test/unit'
require 'fileutils'
class BehaviorsTasksTest < Test::Unit::TestCase
include FileUtils
def setup
@here = File.expand_path(File.dirname(__FILE__))
@base_cmd = RUBY_PLATFORM[/mswin/] ? 'rake.cmd ' : 'rake '
end
#
# HELPERS
#
def run_behaviors_task
run_cmd "behaviors"
end
def run_behaviors_html_task
run_cmd "behaviors_html"
end
def run_cmd(cmd)
cd "#{@here}/tasks_test" do
@report = %x[ #{@base_cmd} #{cmd} ]
end
end
def see_html_task_output_message
@html_output_filename = "#{@here}/tasks_test/behaviors_doc/behaviors.html"
assert_match(/Wrote #{@html_output_filename}/, @report)
end
def see_that_html_report_file_exits
assert File.exists?(@html_output_filename), "html output file should exist"
end
def html_report_file_should_contain(user_behaviors)
file_contents = File.read(@html_output_filename)
user_behaviors.each do |line|
assert_match(/#{line}/, file_contents)
end
rm_rf File.dirname(@html_output_filename)
end
#
# TESTS
#
def test_that_behaviors_tasks_should_list_behavioral_definitions_for_the_classes_under_test
run_behaviors_task
user_behaviors = [
"User should:",
" - be able set user name and age during construction",
" - be able to get user name and age",
" - be able to ask if a user is an adult"
]
assert_match(/#{user_behaviors.join("\n")}/, @report)
end
def test_that_behaviors_tasks_should_list_behavioral_definitions_for_the_classes_under_test_in_html_output
run_behaviors_html_task
see_html_task_output_message
see_that_html_report_file_exits
user_behaviors = [
"User should:",
"be able set user name and age during construction",
"be able to get user name and age",
"be able to ask if a user is an adult"
]
html_report_file_should_contain user_behaviors
end
end

View File

@ -0,0 +1,50 @@
require 'test/unit'
require File.expand_path(File.dirname(__FILE__)) + '/../lib/behaviors'
require 'stringio'
loading_developer_test_class_stdout = StringIO.new
saved_stdout = $stdout.dup
$stdout = loading_developer_test_class_stdout
class DeveloperTest
extend Behaviors
attr_accessor :flunk_msg, :tested_code
should "test their code" do
@tested_code = true
end
should "go to meetings"
end
$stdout = saved_stdout
loading_developer_test_class_stdout.rewind
$loading_developer_test_class_output = loading_developer_test_class_stdout.read
class BehaviorsTest < Test::Unit::TestCase
def setup
@target = DeveloperTest.new
assert_nil @target.tested_code, "block called too early"
end
#
# TESTS
#
def test_should_called_with_a_block_defines_a_test
assert @target.methods.include?("test_should_test their code"), "Missing test method"
@target.send("test_should_test their code")
assert @target.tested_code, "block not called"
end
def test_should_called_without_a_block_does_not_create_a_test_method
assert !@target.methods.include?("test_should_go to meetings"), "Should not have method"
end
def test_should_called_without_a_block_will_give_unimplemented_output_when_class_loads
unimplemented_output = "UNIMPLEMENTED CASE: Developer should go to meetings"
assert_match(/#{unimplemented_output}/, $loading_developer_test_class_output)
end
end

View File

@ -0,0 +1,19 @@
require 'rake'
require 'rake/testtask'
here = File.expand_path(File.dirname(__FILE__))
require "#{here}/../../lib/behaviors/reporttask"
desc 'Default: run unit tests.'
task :default => :test
Rake::TestTask.new(:test) do |t|
t.libs << "#{here}/../../lib"
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
Behaviors::ReportTask.new(:behaviors) do |t|
t.pattern = 'test/**/*_test.rb'
t.html_dir = 'behaviors_doc'
end

View File

@ -0,0 +1,2 @@
class User
end

View File

@ -0,0 +1,17 @@
require 'test/unit'
require 'behaviors'
require 'user'
class UserTest < Test::Unit::TestCase
extend Behaviors
def setup
end
should "be able set user name and age during construction"
should "be able to get user name and age"
should "be able to ask if a user is an adult"
def test_DELETEME
end
end