diff --git a/tools/labs/Makefile b/tools/labs/Makefile index 62b91192db7885..9539a425487cda 100644 --- a/tools/labs/Makefile +++ b/tools/labs/Makefile @@ -27,6 +27,7 @@ copy: $(YOCTO_IMAGE) mkdir $(TEMPDIR) sudo mount -t ext4 -o loop $(YOCTO_IMAGE) $(TEMPDIR) find skels -type f \( -name *.ko -or -executable \) | xargs sudo cp --parents -t $(TEMPDIR)/home/root || true + find skels -type d \( -name checker \) | xargs sudo cp -r --parents -t $(TEMPDIR)/home/root || true sudo umount $(TEMPDIR) rmdir $(TEMPDIR) diff --git a/tools/labs/templates/hello_assignment/checker/hello-world-checker b/tools/labs/templates/hello_assignment/checker/hello-world-checker new file mode 100755 index 00000000000000..b641ac23c4085f --- /dev/null +++ b/tools/labs/templates/hello_assignment/checker/hello-world-checker @@ -0,0 +1,14 @@ +#!/bin/sh + +[ $# -ne 1 ] && { echo "Usage: $0 path-hello-world.ko"; exit 1; } + +/bin/dmesg -c > /dev/null 2>&1 +/sbin/rmmod hello-world > /dev/null 2>&1 +/sbin/insmod $1 +/bin/dmesg | grep 'Hello, World!' > /dev/null 2>&1 +if test $? -eq 0; then + echo "Test PASSED." +else + echo "Test FAILED." +fi +/sbin/rmmod hello-world > /dev/null 2>&1 diff --git a/tools/labs/templates/hello_assignment/hello-world/Kbuild b/tools/labs/templates/hello_assignment/hello-world/Kbuild new file mode 100644 index 00000000000000..9de37409e9e7c6 --- /dev/null +++ b/tools/labs/templates/hello_assignment/hello-world/Kbuild @@ -0,0 +1,3 @@ +EXTRA_CFLAGS = -Wall -g -m32 + +obj-m = hello-world.o diff --git a/tools/labs/templates/hello_assignment/hello-world/hello-world.c b/tools/labs/templates/hello_assignment/hello-world/hello-world.c new file mode 100644 index 00000000000000..c8c067b1ddf0ad --- /dev/null +++ b/tools/labs/templates/hello_assignment/hello-world/hello-world.c @@ -0,0 +1,23 @@ +#include +#include +#include + +MODULE_DESCRIPTION("Hello World"); +MODULE_AUTHOR("Psoru Lesfo Rever"); +MODULE_LICENSE("GPL"); + + +static int hello_init(void) +{ + /* TODO: Print "Hello, World!" */ + pr_info("Hello, World!\n"); + + return 0; +} + +static void hello_exit(void) +{ +} + +module_init(hello_init); +module_exit(hello_exit);