IRB shell tweaked for testing Ethernet devices
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
spec
.document
.gitignore
.project
.rspec
Gemfile
Gemfile.lock
LICENSE.txt
README.rdoc
Rakefile
VERSION
ether_shell.gemspec

README.rdoc

ether_shell

ether_shell installs an IRB session with a DSL for testing Ethernet devices.

Usage

Installing the gem will give you an ether_shell binary. The binary can be launched standalone to get to the IRB session, or it can be given a script that it will execute. Here is how I use it.

ether_shell < example.esh

Here is an example.esh that describes the DSL by example.

# All commands will log to standard output.
verbose
# IP's Ethernet II protocol number is 0x0800
connect 'eth0', 0x0800, '0x112233445566'
disconnect
# The device's Ethernet MAC can be specified in a number of ways.
connect 'eth0', 0x0800, 'BADMAC'
disconnect
connect 'eth0', 0x0800, '112233445566'
disconnect
# Sends a packet to the device.
out "This is short and will be padded"
# Again, multiple ways of specifying a packet are supported.
out "0xCAFEBABE"
out [0xDE, 0xAD, 0xBE, 0xAF]
# Receives a packet and compares it with a golden value.
# If the device echoed packets, these would be valid expectations. 
expect "This is short and will be padded"
expect "0xCAFEBABE000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
expect [0xDE, 0xAD, 0xBE, 0xAF] + [0x00] * 42
disconnect
exit

The code should have full RSpec coverage, and the RSpecs can be used for documetation. You're most likely interested in the spec for ShellDsl.

Contributing to ether_shell

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Author

Victor Costan victor@costan.us

Copyright

Copyright © 2011 Massachusetts Institute of Technology. See LICENSE.txt for further details.