Skip to content

Commit 8e22f4e

Browse files
authored
Merge pull request #18 from NationalSecurityAgency/17-fedora-deny_map_access-test-fails-during-serde_json-parsing
Allow tests to run on fedora 42
2 parents 654c38a + 2a2a7b8 commit 8e22f4e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

tests/kmod_example/hello_world_kmod.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,23 @@
77
#include <linux/module.h> /* Needed by all modules */
88
#include <linux/kernel.h> /* Needed for KERN_INFO */
99

10-
int init_module(void)
10+
static int __init hello_init(void)
1111
{
12-
printk(KERN_INFO "Hello world 1.\n");
12+
printk(KERN_INFO "Hello world\n");
1313

1414
/*
1515
* A non 0 return means init_module failed; module can't be loaded.
1616
*/
1717
return 0;
1818
}
1919

20-
void cleanup_module(void)
20+
static void __exit hello_exit(void)
2121
{
22-
printk(KERN_INFO "Goodbye world 1.\n");
22+
printk(KERN_INFO "Goodbye world\n");
2323
}
2424

25+
module_init(hello_init);
26+
module_exit(hello_exit);
27+
2528
MODULE_LICENSE("GPL");
29+
MODULE_DESCRIPTION("A simple hello world kernel module for testing");

tests/kmod_test/test_kmod.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,5 @@ module_init(test_kmod_init);
107107
module_exit(test_kmod_exit);
108108

109109
MODULE_LICENSE("GPL");
110+
MODULE_DESCRIPTION(
111+
"This is a test kernel module that is sent a predefined command from userspace and executes it");

tests/src/policy/protect_tool.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ fn deny_map_access() -> Result<(), Failed> {
103103
let output = Command::new("bpftool")
104104
.args(["prog", "show", "name", TEST_PROG_NAME, "-p"])
105105
.output()?;
106-
let json_out: ProgInfo = serde_json::from_str(&String::from_utf8(output.stdout)?)?;
106+
let stdout = String::from_utf8(output.stdout)?;
107+
let stderr = String::from_utf8(output.stderr)?;
108+
let json_out: ProgInfo = serde_json::from_str(&stdout)
109+
.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}"))?;
107110

108111
let mut found_map = false;
109112
for id in json_out.map_ids {

0 commit comments

Comments
 (0)