minix/tests/fs/ffs/h_ffs_server.c
Lionel Sambuc 11be35a165 Importing NetBSD "Kyua" test framework
To do so, a few dependencies have been imported:

 * external/bsd/lutok
 * external/mit/lua
 * external/public-domain/sqlite
 * external/public-domain/xz

The Kyua framework is the new generation of ATF (Automated Test
Framework), it is composed of:

 * external/bsd/atf
 * external/bsd/kyua-atf-compat
 * external/bsd/kyua-cli
 * external/bsd/kyua-tester
 * tests

Kyua/ATF being written in C++, it depends on libstdc++ which is
provided by GCC. As this is not part of the sources, Kyua is only
compiled when the native GCC utils are installed.

To install Kyua do the following:

 * In a cross-build enviromnent, add the following to the build.sh
   commandline: -V MKBINUTILS=yes -V MKGCCCMDS=yes

WARNING:
  At this point the import is still experimental, and not supported
  on native builds (a.k.a make build).

Change-Id: I26aee23c5bbd2d64adcb7c1beb98fe0d479d7ada
2013-07-23 20:43:41 +02:00

113 lines
1.9 KiB
C

/* $NetBSD: h_ffs_server.c,v 1.2 2012/08/24 20:25:50 jmmv Exp $ */
/*
* rump server for advanced quota tests
*/
#include "../common/h_fsmacros.h"
#include <err.h>
#include <semaphore.h>
#include <sys/types.h>
#include <sys/mount.h>
#include <stdlib.h>
#include <unistd.h>
#include <ufs/ufs/ufsmount.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
int background = 0;
static void
usage(void)
{
fprintf(stderr, "usage: %s [-b] [-l] diskimage bindurl\n",
getprogname());
exit(1);
}
static void
die(const char *reason, int error)
{
warnx("%s: %s", reason, strerror(error));
if (background)
rump_daemonize_done(error);
exit(1);
}
static sem_t sigsem;
static void
sigreboot(int sig)
{
sem_post(&sigsem);
}
int
main(int argc, char **argv)
{
int error;
struct ufs_args uargs;
const char *filename;
const char *serverurl;
int log = 0;
int ch;
while ((ch = getopt(argc, argv, "bl")) != -1) {
switch(ch) {
case 'b':
background = 1;
break;
case 'l':
log = 1;
break;
default:
usage();
}
}
argc -= optind;
argv += optind;
if (argc != 2)
usage();
filename = argv[0];
serverurl = argv[1];
if (background) {
error = rump_daemonize_begin();
if (error)
errx(1, "rump daemonize: %s", strerror(error));
}
error = rump_init();
if (error)
die("rump init failed", error);
if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1)
die("mount point create", errno);
rump_pub_etfs_register("/diskdev", filename, RUMP_ETFS_BLK);
uargs.fspec = __UNCONST("/diskdev");
if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, (log) ? MNT_LOG : 0,
&uargs, sizeof(uargs)) == -1)
die("mount ffs", errno);
error = rump_init_server(serverurl);
if (error)
die("rump server init failed", error);
if (background)
rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS);
sem_init(&sigsem, 0, 0);
signal(SIGTERM, sigreboot);
signal(SIGINT, sigreboot);
sem_wait(&sigsem);
rump_sys_reboot(0, NULL);
/*NOTREACHED*/
return 0;
}