From 1263399c0b985a517beb934125d5c9018adf4e1f Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Sun, 7 May 2017 19:32:55 +0200 Subject: [PATCH] qa: check devproc start/stop ctl msg --- qa/kern/build.json | 1 + qa/kern/stop_start.c | 41 +++++++++++++++++++++++++++++++++++++++ qa/kern/stop_start.runner | 29 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 qa/kern/stop_start.c create mode 100755 qa/kern/stop_start.runner diff --git a/qa/kern/build.json b/qa/kern/build.json index d5bec8c..2184803 100644 --- a/qa/kern/build.json +++ b/qa/kern/build.json @@ -36,6 +36,7 @@ "psx.c", "segattach.c", "sched0.c", + "stop_start.c", "syscall.c", "sysstatread.c", "tsemacquire.c", diff --git a/qa/kern/stop_start.c b/qa/kern/stop_start.c new file mode 100644 index 0000000..b921854 --- /dev/null +++ b/qa/kern/stop_start.c @@ -0,0 +1,41 @@ +/* + * This file is part of Jehanne. + * + * Copyright (C) 2017 Giacomo Tesio + * + * Jehanne is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * Jehanne is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jehanne. If not, see . + */ +#include +#include + +void +main(int argc, char**argv) +{ + int fd, n; + char *path; + + path = smprint("/proc/%d/ctl", getpid()); + fd = open(path, OWRITE); + if(fd < 0){ + print("FAIL: open"); + exits("FAIL"); + } + n = write(fd, "stop", 4); + if(n < 0){ + print("FAIL: write"); + exits("FAIL"); + } + close(fd); + print("PASS\n"); + exits("PASS"); +} diff --git a/qa/kern/stop_start.runner b/qa/kern/stop_start.runner new file mode 100755 index 0000000..1bed6cb --- /dev/null +++ b/qa/kern/stop_start.runner @@ -0,0 +1,29 @@ +#!/cmd/rc + +runner=$0 +test = `{echo $runner|sed 's/.runner//'} +test_output = /tmp/output-`{basename $test} + +if ( test -e $test_output) rm $test_output + +$test > $test_output & +testpid=$apid +sleep 5 + +if ( cat $test_output | grep 'PASS' > /dev/null ) { + cat $test_output + echo FAIL + exit FAIL +} + +echo start > /proc/$testpid/ctl +wait $testpid + +if ( cat $test_output | grep 'PASS' > /dev/null ) { + rm $test_output + echo PASS + exit PASS +} +cat $test_output +echo FAIL +exit FAIL