From 4335a620a364b70f06421b1698706a9dc3324a46 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 18 Apr 2024 17:34:51 +0200 Subject: start writing test applications --- 1/test/.gitignore | 1 + 1/test/main.c | 18 ++++++++++++++++++ 1/test/makefile | 2 ++ 1/test/test.sh | 14 ++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 1/test/.gitignore create mode 100644 1/test/main.c create mode 100644 1/test/makefile create mode 100755 1/test/test.sh (limited to '1') diff --git a/1/test/.gitignore b/1/test/.gitignore new file mode 100644 index 0000000..ba2906d --- /dev/null +++ b/1/test/.gitignore @@ -0,0 +1 @@ +main diff --git a/1/test/main.c b/1/test/main.c new file mode 100644 index 0000000..7329e16 --- /dev/null +++ b/1/test/main.c @@ -0,0 +1,18 @@ +#include +#include + +int main(int argc, char** argv) { + if (geteuid() != 0) { + fprintf(stderr, "run me as root!\n"); + return 1; + } + + argc--; // argv[0] is the program name + if (argc == 0) { + fprintf(stderr, "usage: %s /dev/lork\n", argv[0]); + return 1; + } + + return 0; +} + diff --git a/1/test/makefile b/1/test/makefile new file mode 100644 index 0000000..3491973 --- /dev/null +++ b/1/test/makefile @@ -0,0 +1,2 @@ +main: main.o + diff --git a/1/test/test.sh b/1/test/test.sh new file mode 100755 index 0000000..18263e6 --- /dev/null +++ b/1/test/test.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +if [ $(id -u) -ne 0 ] ; then + echo "run me as root!" >&2 + exit 1 +fi + +if [ $# -eq 0 ] ; then + echo "usage: $0 /dev/lork" >&2 + exit 1 +fi + + +exit 0 -- cgit v1.2.3