Skip to content
Merged
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
12 changes: 8 additions & 4 deletions tests/kmod_example/hello_world_kmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */

int init_module(void)
static int __init hello_init(void)
{
printk(KERN_INFO "Hello world 1.\n");
printk(KERN_INFO "Hello world\n");

/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}

void cleanup_module(void)
static void __exit hello_exit(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
printk(KERN_INFO "Goodbye world\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("A simple hello world kernel module for testing");
2 changes: 2 additions & 0 deletions tests/kmod_test/test_kmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,5 @@ module_init(test_kmod_init);
module_exit(test_kmod_exit);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION(
"This is a test kernel module that is sent a predefined command from userspace and executes it");
5 changes: 4 additions & 1 deletion tests/src/policy/protect_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ fn deny_map_access() -> Result<(), Failed> {
let output = Command::new("bpftool")
.args(["prog", "show", "name", TEST_PROG_NAME, "-p"])
.output()?;
let json_out: ProgInfo = serde_json::from_str(&String::from_utf8(output.stdout)?)?;
let stdout = String::from_utf8(output.stdout)?;
let stderr = String::from_utf8(output.stderr)?;
let json_out: ProgInfo = serde_json::from_str(&stdout)
.map_err(|e| anyhow!("serde_json failed read output of 'bpftool prog show name {TEST_PROG_NAME} -p'\n{e}\nbpftool stdout: {stdout}\nbpftool stderr:{stderr}"))?;

let mut found_map = false;
for id in json_out.map_ids {
Expand Down