-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add kunit framework Signed-off-by: atsushi421 <atsushi.yano.2@tier4.jp> * fix * fix Signed-off-by: sykwer <sykwer@gmail.com> --------- Signed-off-by: atsushi421 <atsushi.yano.2@tier4.jp> Signed-off-by: sykwer <sykwer@gmail.com>
- Loading branch information
1 parent
2ea7122
commit b238640
Showing
7 changed files
with
95 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ log | |
*.log | ||
coverage_report_agnocastlib | ||
.vscode | ||
agnocast_kmod_coverage_report |
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,22 @@ | ||
#include "agnocast.h" | ||
|
||
#include <kunit/test.h> | ||
|
||
MODULE_LICENSE("Dual BSD/GPL"); | ||
|
||
static void agnocast_sample_test_case(struct kunit * test) | ||
{ | ||
KUNIT_EXPECT_EQ(test, 1 + 1, 2); | ||
} | ||
|
||
struct kunit_case agnocast_test_cases[] = { | ||
KUNIT_CASE(agnocast_sample_test_case), | ||
{}, | ||
}; | ||
|
||
struct kunit_suite agnocast_test_suite = { | ||
.name = "agnocast_test_suite", | ||
.test_cases = agnocast_test_cases, | ||
}; | ||
|
||
kunit_test_suite(agnocast_test_suite); |
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,39 @@ | ||
#!/bin/bash | ||
|
||
### Validation | ||
if [ -f "/boot/config-$(uname -r)" ]; then | ||
CONFIG_FILE="/boot/config-$(uname -r)" | ||
elif [ -f "/proc/config.gz" ]; then | ||
zcat /proc/config.gz >/tmp/config-$(uname -r) | ||
CONFIG_FILE="/tmp/config-$(uname -r)" | ||
else | ||
echo "Kernel config file not found!" | ||
exit 1 | ||
fi | ||
|
||
if ! grep -q "CONFIG_KUNIT=y" $CONFIG_FILE; then | ||
echo "Skipping KUnit tests as CONFIG_KUNIT is not enabled." | ||
exit 0 | ||
fi | ||
|
||
### Run KUnit tests | ||
AGNOCAST_DIR=$(realpath "$(dirname $(readlink -f $0))/..") | ||
|
||
AGNOCAST_KMOD_PATH=$AGNOCAST_DIR/kmod | ||
|
||
if [ -z "$AGNOCAST_KMOD_PATH" ]; then | ||
echo "Usage: create_coverage_report <agnocast_kmod_path>" | ||
exit 1 | ||
fi | ||
|
||
cd $AGNOCAST_KMOD_PATH | ||
make clean | ||
make | ||
sudo insmod $AGNOCAST_KMOD_PATH/agnocast_kunit.ko | ||
sudo rmmod agnocast_kunit | ||
|
||
sudo lcov --capture --directory /sys/kernel/debug/gcov/$AGNOCAST_KMOD_PATH --output-file $AGNOCAST_DIR/coverage.info | ||
sudo lcov --remove $AGNOCAST_DIR/coverage.info "*linux*" "*kunit*" --output-file $AGNOCAST_DIR/coverage_filtered.info | ||
genhtml $AGNOCAST_DIR/coverage_filtered.info --output-directory $AGNOCAST_DIR/agnocast_kmod_coverage_report | ||
rm -f $AGNOCAST_DIR/coverage.info $AGNOCAST_DIR/coverage_filtered.info $AGNOCAST_KMOD_PATH/*.gcno | ||
echo "Please open agnocast_kmod_coverage_report/index.html in your web browser." |