Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
Fix a unit test and add coveralls support
Browse files Browse the repository at this point in the history
  • Loading branch information
cholcombe973 committed Jan 13, 2016
1 parent 5464d3b commit 42de99c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 57 deletions.
33 changes: 15 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
language: rust

addons:
apt:
packages:
- libpcap-dev
- libcurl4-openssl-dev
- libelf-dev
- libdw-dev
language: rust
- libudev-dev
rust:
- nightly
- beta
Expand All @@ -20,24 +22,19 @@ matrix:
allow_failures:
- rust: beta
- rust: nightly
cache:
apt: true
rust-download: true
directories:
- $TRAVIS_BUILD_DIR/target
- ~/.cargo
notifications:
email:
on_success: never

# This requires the old travis
#after_success: |
# wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz &&
# tar xzf master.tar.gz &&
# mkdir kcov-master/build &&
# cd kcov-master/build &&
# cmake .. &&
# make &&
# sudo make install &&
# cd ../.. &&
# kcov --coveralls-id=$TRAVIS_JOB_ID --exclude-pattern=/.cargo target/kcov target/debug/decode_ceph--*;
before_script:
- pip install 'travis-cargo<0.2' --user && export PATH=$HOME/.local/bin:$PATH

script:
- |
travis-cargo build &&
travis-cargo test
after_success:
- travis-cargo coveralls --no-sudo

sudo: false
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 19 additions & 28 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ extern crate time;
extern crate users;

use ceph::sniffer::*;
// use ceph::sniffer::serial::*;
// use ceph::sniffer::crypto::*;
// use ceph::sniffer::mon_decode::*;
// use ceph::sniffer::common_decode::*;
// use ceph::sniffer::osd_decode::*;

use pcap::{Capture, Device};

Expand All @@ -32,40 +27,36 @@ use output_args::*;
mod tests{
extern crate output_args;
extern crate pcap;
extern crate log;

// use std::io::Cursor;
// use std::net::Ipv4Addr;
use std::path::Path;
use pcap::Capture;
// use output_args::*;
// use super::serial;
use super::ceph::sniffer::*;

#[test]
fn test_pcap_parsing(){
// let args = output_args::Args {
// carbon: None,
// elasticsearch: None,
// stdout: Some("stdout".to_string()),
// influx: None,
// outputs: vec!["elasticsearch".to_string(), "carbon".to_string(), "stdout".to_string()],
// config_path: "".to_string(),
// log_level: log::LogLevel::Info
// };
let args = output_args::Args {
carbon: None,
elasticsearch: None,
stdout: Some("stdout".to_string()),
influx: None,
outputs: vec!["stdout".to_string()],
config_path: "".to_string(),
log_level: log::LogLevel::Info
};
//Set the cursor so the parsing doesn't fail
let mut cap = Capture::from_file(Path::new("ceph.pcap")).unwrap();
/*
//We received a packet
while let Ok(packet) = cap.next() {
match serial::parse_ceph_packet(&packet.data) {
nom::IResult::Done(_, result) => {
println!("logging {:?}", result);
// let _ = super::process_packet(&result.header, &result.ceph_message, &args);
Some(result) => {
trace!("logging {:?}", result);
let _ = super::process_packet(&result.header, &result.ceph_message, &args);
},
nom::IResult::Incomplete(i) => println!("Incomplete: {:?}: {:?}", i, packet),
nom::IResult::Error(e) => println!("Error parsing; {:?}", e),
// _ => trace!("Error while parsing packet")
}
_ => {},
};
// break
}
*/
}
}

Expand Down Expand Up @@ -244,7 +235,7 @@ fn log_msg_to_influx(header: &serial::PacketHeader, msg: &serial::Message, outpu
let client = create_client(credentials, hosts);

let src_addr = header.src_addr.ip_address();

let dst_addr = header.dst_addr.ip_address();

let _ = match *msg{
Expand Down

0 comments on commit 42de99c

Please sign in to comment.