This repository has been archived by the owner on Mar 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make modinfo work properly (fixes #80)
- Loading branch information
Showing
14 changed files
with
141 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "modinfo-tests" | ||
version = "0.1.0" | ||
authors = ["Alex Gaynor <alex.gaynor@gmail.com>", "Geoffrey Thomas <geofft@ldpreload.com>"] | ||
edition = "2018" | ||
|
||
[lib] | ||
crate-type = ["staticlib"] | ||
test = false | ||
|
||
[features] | ||
default = ["linux-kernel-module"] | ||
|
||
[dependencies] | ||
linux-kernel-module = { path = "../..", optional = true } | ||
|
||
[dev-dependencies] | ||
kernel-module-testlib = { path = "../../testlib" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![no_std] | ||
|
||
use linux_kernel_module; | ||
|
||
struct ModinfoTestModule; | ||
|
||
impl linux_kernel_module::KernelModule for ModinfoTestModule { | ||
fn init() -> linux_kernel_module::KernelResult<Self> { | ||
Ok(ModinfoTestModule) | ||
} | ||
} | ||
|
||
linux_kernel_module::kernel_module!( | ||
ModinfoTestModule, | ||
author: b"Fish in a Barrel Contributors", | ||
description: b"Empty module for testing modinfo", | ||
license: b"GPL" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::env; | ||
use std::fs; | ||
use std::path::Path; | ||
use std::process::Command; | ||
|
||
use kernel_module_testlib::with_kernel_module; | ||
|
||
#[test] | ||
fn test_modinfo() { | ||
let module = env::var("KERNEL_MODULE").unwrap(); | ||
|
||
for (key, value) in &[ | ||
("author", "Fish in a Barrel Contributors"), | ||
("description", "Empty module for testing modinfo"), | ||
("license", "GPL"), | ||
] { | ||
let modinfo = Command::new("modinfo") | ||
.arg("-F") | ||
.arg(key) | ||
.arg(&module) | ||
.output() | ||
.unwrap(); | ||
assert!(modinfo.status.success()); | ||
assert_eq!(&std::str::from_utf8(&modinfo.stdout).unwrap().trim(), value); | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_no_proprietary_taint() { | ||
let module = env::var("KERNEL_MODULE").unwrap(); | ||
let module_name = Path::new(&module).file_stem().unwrap(); | ||
let sysfs_path = Path::new("/sys/module").join(module_name).join("taint"); | ||
|
||
with_kernel_module(|| { | ||
let taints = fs::read_to_string(&sysfs_path).unwrap(); | ||
assert!(!taints.contains("P")); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters