Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added github actions CI. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
on: [push, pull_request]

name: CI

jobs:
build_and_test:
name: Rust project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: RUSTFLAGS="-D warnings" cargo build --verbose
- run: cargo test --verbose
- run: cargo doc --verbose

clippy_check:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features

format_check:
name: Rust Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt
- run: cargo fmt -- --check
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
fn main() {
#[cfg(feature = "bindgen")]
{
use bindgen::callbacks::ParseCallbacks;
use std::env;
use std::path::PathBuf;
use bindgen::callbacks::ParseCallbacks;


#[derive(Debug)]
struct Parse;
impl ParseCallbacks for Parse {
Expand Down
32 changes: 23 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#![allow(non_snake_case)]

pub mod types {
#![allow(clippy::all)]

#[cfg(feature = "bindgen")]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

Expand All @@ -11,8 +13,8 @@ pub mod types {
}

pub mod ioctl {
use nix::*;
use crate::types::*;
use nix::*;

// see
// - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/core/devio.c
Expand Down Expand Up @@ -44,11 +46,17 @@ pub mod ioctl {
///
/// Will fail with `EBUSY` if some other claim is already in place (e.g. there is a kernel
/// driver already attached).
claiminterface, 'U', 15, ::std::os::raw::c_uint
claiminterface,
'U',
15,
::std::os::raw::c_uint
);
ioctl_read!(
/// Release an interface previously claimed with `claiminterface()`.
releaseinterface, 'U', 16, ::std::os::raw::c_uint
releaseinterface,
'U',
16,
::std::os::raw::c_uint
);
ioctl_write_ptr!(connectinfo, 'U', 17, connectinfo);
ioctl_readwrite!(ioctl, 'U', 18, ioctl);
Expand All @@ -57,15 +65,20 @@ pub mod ioctl {
ioctl_none!(reset, 'U', 20);
ioctl_read!(clear_halt, 'U', 21, ::std::os::raw::c_uint);
// USBDEVFS_CONNECT and USBDEVFS_DISCONNECT are only used via USBDEVFS_IOCTL
pub unsafe fn disconnect(fd: ::std::os::raw::c_int, ifno: ::std::os::raw::c_int) -> Result<i32> {
#[allow(clippy::missing_safety_doc)]
pub unsafe fn disconnect(
fd: ::std::os::raw::c_int,
ifno: ::std::os::raw::c_int,
) -> Result<i32> {
let mut req = crate::types::ioctl {
ifno,
ioctl_code: request_code_none!('U', 22) as i32,
data: std::ptr::null_mut(),
};
ioctl(fd, &mut req)
}
pub unsafe fn connect(fd: ::std::os::raw::c_int, ifno: ::std::os::raw::c_int) -> Result<i32>{
#[allow(clippy::missing_safety_doc)]
pub unsafe fn connect(fd: ::std::os::raw::c_int, ifno: ::std::os::raw::c_int) -> Result<i32> {
let mut req = crate::types::ioctl {
ifno,
ioctl_code: request_code_none!('U', 23) as i32,
Expand All @@ -78,7 +91,10 @@ pub mod ioctl {
ioctl_read!(
/// returns a 32 bit mask describing the capabilities of this _usbdevfs_ device, as
/// described by the `CAP_*` constants.
get_capabilities, 'U', 26, __u32
get_capabilities,
'U',
26,
__u32
);
ioctl_read!(disconnect_claim, 'U', 27, disconnect_claim);
ioctl_read!(alloc_streams, 'U', 28, streams);
Expand All @@ -87,6 +103,4 @@ pub mod ioctl {
}

#[cfg(test)]
mod tests {

}
mod tests {}