mirror of
https://git.kernel.org/pub/scm/libs/libcap/libcap.git
synced 2026-01-27 18:04:43 +00:00
I occasionally test libcap against a custom kernel using QEMU. Now I have a simple exit binary for exiting with status. From the top level, one can use: make ktest However, for more control: cd kdebug make test If you want to look around after the tests run: make shell Exit the shell & QEMU with ctrl-D (or exit). Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
37 lines
842 B
C
37 lines
842 B
C
/*
|
|
* See https://stackoverflow.com/questions/42208228/how-to-automatically-close-the-execution-of-the-qemu-after-end-of-process
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/io.h>
|
|
#include <unistd.h>
|
|
|
|
#define SHUTDOWN_PORT 0x604
|
|
#define EXIT_PORT 0x501
|
|
|
|
static void clean_exit(void) {
|
|
ioperm(SHUTDOWN_PORT, 16, 1);
|
|
outw(0x2000, SHUTDOWN_PORT);
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
int status;
|
|
if (argc != 2) {
|
|
clean_exit();
|
|
}
|
|
status = atoi(argv[1]);
|
|
printf("exiting with status %d (in three seconds)\n", status);
|
|
sleep(3);
|
|
if (!status) {
|
|
clean_exit();
|
|
}
|
|
ioperm(EXIT_PORT, 8, 1);
|
|
/*
|
|
* status returned is 1+(2*orig_status)
|
|
*/
|
|
outb(status-1, EXIT_PORT);
|
|
printf("didn't exit.. did you include '-device isa-debug-exit'"
|
|
" in qemu command?\n");
|
|
exit(1);
|
|
}
|