├── errno.map ├── netbsd_init.h ├── extra.map ├── readwrite.map ├── netbsd.map ├── host.map ├── .gitignore ├── .gitmodules ├── AUTHORS ├── halt.c ├── specs.in ├── rumpclient.c ├── cc.in ├── LICENSE ├── README.md ├── netbsd_init.c ├── emul.map ├── remoteinit.c ├── readwrite.c ├── .travis.yml ├── mkremote.sh ├── rumpctrl.sh.in ├── ld.in ├── tests ├── master.cfg └── test.sh ├── Makefile └── emul.c /errno.map: -------------------------------------------------------------------------------- 1 | __errno emul__errno 2 | -------------------------------------------------------------------------------- /netbsd_init.h: -------------------------------------------------------------------------------- 1 | void _netbsd_init(int); 2 | -------------------------------------------------------------------------------- /extra.map: -------------------------------------------------------------------------------- 1 | # h_errno may clash 2 | h_errno netbsd_h_errno 3 | -------------------------------------------------------------------------------- /readwrite.map: -------------------------------------------------------------------------------- 1 | rump___sysimpl_read rumprun_read_wrapper 2 | rump___sysimpl_write rumprun_write_wrapper 3 | -------------------------------------------------------------------------------- /netbsd.map: -------------------------------------------------------------------------------- 1 | main _netbsd_main 2 | exit _netbsd_exit 3 | environ _netbsd_environ 4 | __progname _netbsd__progname 5 | -------------------------------------------------------------------------------- /host.map: -------------------------------------------------------------------------------- 1 | # note several modified names... 2 | getenv emul_getenv 3 | __putenv50 emul_putenv 4 | setenv emul_setenv 5 | __unsetenv13 emul_unsetenv 6 | getenv_r emul_getenv_r 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # misc temp files 2 | tmp/* 3 | *~ 4 | *.core 5 | ktrace.out 6 | *.o 7 | rump.map 8 | rump/ 9 | rumpdyn/ 10 | rumpdynobj/ 11 | rumpobj/ 12 | rumptools/ 13 | rumprun 14 | rumpremote 15 | bin/ 16 | bin-rr/ 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "buildrump.sh"] 2 | path = buildrump.sh 3 | url = https://github.com/rumpkernel/buildrump.sh.git 4 | [submodule "rumpsrc"] 5 | path = src-netbsd 6 | url = https://github.com/rumpkernel/src-netbsd.git 7 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The following people have contributed to this repository: 2 | 3 | Justin Cormack 4 | Antti Kantee 5 | Stephan Renatus 6 | Stefan Grundmann 7 | -------------------------------------------------------------------------------- /halt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int 6 | main(int argc, char **argv) 7 | { 8 | 9 | (void)getprogname(); /* hack to get reference to __progname */ 10 | reboot(0, NULL); 11 | exit(0); /* hack to get reference */ 12 | } 13 | -------------------------------------------------------------------------------- /specs.in: -------------------------------------------------------------------------------- 1 | %rename cpp_options old_cpp_options 2 | 3 | *cpp_options: 4 | @BUILDRUMP_TOOL_CFLAGS@ @BUILDRUMP_TOOL_CPPFLAGS@ -isystem include%s %(old_cpp_options) 5 | 6 | *cc1: 7 | %(cc1_cpu) @BUILDRUMP_TOOL_CFLAGS@ @BUILDRUMP_TOOL_CPPFLAGS@ 8 | 9 | *linker: 10 | @PATH@/rump/lib/ld.rump --stunt-intermediate %g.link1 %g.link2 11 | 12 | *link: 13 | -nostdlib %s 14 | -------------------------------------------------------------------------------- /rumpclient.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int 4 | emul__fork(void) 5 | { 6 | return rumpclient_fork(); 7 | } 8 | 9 | int 10 | emul__vfork14(void) 11 | { 12 | return rumpclient_fork(); 13 | } 14 | 15 | extern char **environ; 16 | 17 | int 18 | emul_execve(const char *filename, char *const argv[], char *const envp[]) 19 | { 20 | 21 | return rumpclient_exec(filename, argv, environ); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /cc.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | case " $* " in 4 | *" -v "*) set -x ;; 5 | esac 6 | if ! ${REALCC:-cc} --version | grep -q 'Free Software Foundation'; then 7 | export PATH=@PATH@/rump/lib:$PATH 8 | exec "${REALCC:-cc}" \ 9 | @BUILDRUMP_TOOL_CFLAGS@ \ 10 | @BUILDRUMP_TOOL_CPPFLAGS@ \ 11 | -fuse-ld=rump -nostdlib "$@" 12 | else 13 | exec "${REALCC:-cc}" "$@" -specs "@PATH@/rump/lib/rump-cc.specs" 14 | fi 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | (c) 2013, 2014 Justin Cormack, Antti Kantee 2 | 3 | Licensed under CC0 4 | 5 | The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. 6 | 7 | You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission. 8 | 9 | For full license text see http://creativecommons.org/publicdomain/zero/1.0/legalcode 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/rumpkernel/rumpctrl.png?branch=master)](https://travis-ci.org/rumpkernel/rumpctrl) 2 | 3 | Rumpctrl provides configuration, control and diagnostic utilities for 4 | rump kernels. These utilities can be run on a POSIX-type 5 | userspace platform to remotely inspect and adjust the status of rump 6 | kernels via the _sysproxy_ remote system call facility. This repository 7 | provides both the build framework and a selection of familiar utilities 8 | such as `ifconfig`, `mount`, `sysctl`, and more. 9 | 10 | See [the wiki](http://wiki.rumpkernel.org/Repo:-rumpctrl) for more 11 | information and instructions. 12 | -------------------------------------------------------------------------------- /netbsd_init.c: -------------------------------------------------------------------------------- 1 | /* init routines for NetBSD namespace */ 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | /* this whole thing is a bit XXX */ 12 | static struct ps_strings thestrings; 13 | AuxInfo myaux[2]; 14 | 15 | #include "netbsd_init.h" 16 | 17 | void 18 | _netbsd_init(int stdouttty) 19 | { 20 | extern struct ps_strings *__ps_strings; 21 | 22 | memset(&thestrings, 0, sizeof(thestrings)); 23 | thestrings.ps_argvstr = (void *)((char *)&myaux - 2); /* well, uuuuh? */ 24 | __ps_strings = &thestrings; 25 | 26 | if (stdouttty) 27 | setlinebuf(stdout); 28 | } 29 | -------------------------------------------------------------------------------- /emul.map: -------------------------------------------------------------------------------- 1 | mmap emul_mmap 2 | munmap emul_munmap 3 | madvise emul_madvise 4 | minherit emul_minherit 5 | setpriority emul_setpriority 6 | execve emul_execve 7 | __getrusage50 emul__getrusage50 8 | __vfork14 emul__vfork14 9 | __fork emul__fork 10 | _exit emul__exit 11 | __sigaction14 emul___sigaction14 12 | __sigprocmask14 emul___sigprocmask14 13 | __sigsuspend14 emul___sigsuspend14 14 | __sigaction_sigtramp emul___sigaction_sigtramp 15 | __wait450 emul___wait450 16 | kill emul_kill 17 | undelete emul_undelete 18 | uuidgen emul_uuidgen 19 | sigqueueinfo emul_sigqueueinfo 20 | _lwp_kill emul__lwp_kill 21 | _lwp_self emul__lwp_self 22 | _setcontext emul__setcontext 23 | __libc_static_tls_setup emul___libc_static_tls_setup 24 | -------------------------------------------------------------------------------- /remoteinit.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #include "netbsd_init.h" 13 | 14 | /* we are not supposed to use values below 100 but NetBSD libc does */ 15 | void rumprun_init (void) __attribute__((constructor (1))); 16 | 17 | static void 18 | die(const char *fmt, ...) 19 | { 20 | va_list va; 21 | 22 | va_start(va, fmt); 23 | vfprintf(stderr, fmt, va); 24 | va_end(va); 25 | fputs("\n", stderr); 26 | exit(1); 27 | } 28 | 29 | void 30 | rumprun_init() 31 | { 32 | int ret; 33 | 34 | ret = rumpclient_init(); 35 | if (ret != 0) 36 | die("rumpclient init failed"); 37 | _netbsd_init(isatty(STDOUT_FILENO)); 38 | } 39 | -------------------------------------------------------------------------------- /readwrite.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | /* 6 | * _Very_ cheap trick (for purposes of remote clients): assume fd<=2 is 7 | * for stdio/stdout/stderr, so send it the console. All other file 8 | * descriptors go to the rump kernel. This of course should be 9 | * better tracked using something like rumphijack, but the cheap trick 10 | * allows to use most utils via sysproxy now. 11 | */ 12 | 13 | int rump___sysimpl_read(int, void *, size_t); 14 | int rump___sysimpl_write(int, const void *, size_t); 15 | 16 | int 17 | rumprun_read_wrapper(int fd, void *buf, size_t blen) 18 | { 19 | 20 | if (fd <= 2) 21 | return read(fd, buf, blen); 22 | else 23 | return rump___sysimpl_read(fd, buf, blen); 24 | } 25 | 26 | int 27 | rumprun_write_wrapper(int fd, const void *buf, size_t blen) 28 | { 29 | 30 | if (fd <= 2) 31 | return write(fd, buf, blen); 32 | else 33 | return rump___sysimpl_write(fd, buf, blen); 34 | } 35 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | os: linux 3 | sudo: false 4 | 5 | before_install: 6 | - git submodule update --init --recursive 7 | 8 | matrix: 9 | include: 10 | - env: ZFS= CC=gcc 11 | compiler: gcc 12 | - env: ZFS= CC=clang-3.6 13 | compiler: clang-3.6 14 | addons: &clang36 15 | apt: 16 | packages: 17 | - clang-3.6 18 | sources: 19 | - ubuntu-toolchain-r-test 20 | - llvm-toolchain-precise-3.6 21 | 22 | script: 23 | - ( cd buildrump.sh && ./buildrump.sh -s ../src-netbsd -V MKSTATICLIB=no -qq fullbuild ) 24 | - ./buildnb.sh -qq ${ZFS} tests ./buildrump.sh/rump 25 | 26 | notifications: 27 | irc: 28 | channels: 29 | - "chat.freenode.net#rumpkernel-builds" 30 | template: 31 | - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}' 32 | skip_join: true 33 | use_notice: true 34 | email: 35 | recipients: 36 | - rumpkernel-builds@freelists.org 37 | on_success: always 38 | on_failure: always 39 | -------------------------------------------------------------------------------- /mkremote.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | . ./config.sh 6 | 7 | NAME=$1 8 | 9 | shift 10 | 11 | LINK=$* 12 | 13 | BINDIR="bin" 14 | OBJDIR="obj-rr" 15 | 16 | mkdir -p ${BINDIR} ${OBJDIR} 17 | 18 | UNAME=$(uname -s) 19 | 20 | # -lrt not always needed 21 | [ ${UNAME} = Linux ] && DLFLAG="-ldl -lrt" 22 | 23 | RUMPCLIENT="-L${LIBRARY_PATH} -Wl,-R${LIBRARY_PATH} -lrumpclient" 24 | 25 | CC=${CC-cc} 26 | 27 | ${CC} ${LDFLAGS} -Wl,-r -nostdlib $LINK -o ${OBJDIR}/${NAME}.o 28 | objcopy --redefine-syms=host.map ${OBJDIR}/${NAME}.o ${OBJDIR}/tmp0_${NAME}.o 29 | ${CC} ${LDFLAGS} -Wl,-r ${OBJDIR}/tmp0_${NAME}.o netbsd_init.o -nostdlib rump/lib/libc.a -o ${OBJDIR}/tmp1_${NAME}.o 2>/dev/null 30 | objcopy --redefine-syms=namespace.map ${OBJDIR}/tmp1_${NAME}.o 31 | objcopy --redefine-syms=extra.map ${OBJDIR}/tmp1_${NAME}.o 32 | objcopy --redefine-syms=rump.map ${OBJDIR}/tmp1_${NAME}.o 33 | objcopy --redefine-syms=weakasm.map ${OBJDIR}/tmp1_${NAME}.o 34 | objcopy --redefine-syms=readwrite.map ${OBJDIR}/tmp1_${NAME}.o 35 | objcopy --redefine-syms=emul.map ${OBJDIR}/tmp1_${NAME}.o 36 | objcopy --redefine-syms=netbsd.map ${OBJDIR}/tmp1_${NAME}.o 37 | ${CC} ${LDFLAGS} -Wl,-r -nostdlib -Wl,-dc ${OBJDIR}/tmp1_${NAME}.o readwrite.o -o ${OBJDIR}/tmp2_${NAME}.o 2>/dev/null 38 | objcopy --redefine-syms=errno.map ${OBJDIR}/tmp2_${NAME}.o 39 | objcopy -w --localize-symbol='*' ${OBJDIR}/tmp2_${NAME}.o 40 | objcopy -w --globalize-symbol='_netbsd_*' ${OBJDIR}/tmp2_${NAME}.o 41 | 42 | ${CC} ${CFLAGS} ${OBJDIR}/tmp2_${NAME}.o emul.o rumpclient.o remoteinit.o ${RUMPCLIENT} ${DLFLAG} -o ${BINDIR}/${NAME} 43 | 44 | -------------------------------------------------------------------------------- /rumpctrl.sh.in: -------------------------------------------------------------------------------- 1 | rrCANDO=true 2 | [ -z "${RUMPCTRL_LOADED}" ] \ 3 | || { echo "rumpctrl env already loaded!"; rrCANDO=false; } 4 | 5 | # technically bash commands (PS1), but should mostly work with /bin/sh 6 | #[ "${SHELL}" != "${SHELL%bash}" ] \ 7 | # || { echo "environment requires bash"; rrCANDO=false; } 8 | 9 | # enable parameters expansion in the prompt 10 | [ "${SHELL}" = "${SHELL%/zsh}" ] \ 11 | || set -o PROMPT_SUBST 12 | 13 | # sed replacement is not run with /g ... 14 | [ "XXXPATHXXX" = "XXXPATHXXX" ] && { echo "not preprocessed"; rrCANDO=false; } 15 | 16 | rumpctrl_hascmd () 17 | { 18 | [ -z "${1}" ] && { echo '#f'; false; return; } 19 | PATH=${RRPATH}/bin type $1 > /dev/null 2>&1 20 | if [ $? -eq 0 ]; then 21 | echo '#t' 22 | else 23 | echo '#f' 24 | false 25 | fi 26 | } 27 | 28 | rumpctrl_hostcmd () 29 | { 30 | 31 | PATH="${rrPATH}" "$@" 32 | } 33 | 34 | if ${rrCANDO}; then 35 | RRPATH=XXXPATHXXX 36 | RUMPCTRL_LOADED=yes 37 | 38 | # parse args to see if we should set RUMP_SERVER 39 | # (yes, this is another bash'ism) 40 | # 41 | # if the first parameter is -u, set path to unix://${2} 42 | # (this way you can tab-complete an existing sucket) 43 | if [ ! -z "$*" ]; then 44 | case "$1" in 45 | -u) 46 | export RUMP_SERVER=unix://${2} 47 | ;; 48 | *) 49 | export RUMP_SERVER=${1} 50 | ;; 51 | esac 52 | fi 53 | 54 | # clear things like "alias ls=---weird-color-stuffs" 55 | # XXX: not restored 56 | unalias -a 57 | 58 | alias rumpctrl_listcmds='for x in $(echo ${RRPATH}/bin/*); 59 | do echo ${x##*/};done | column' 60 | alias cd='echo ERROR: cd not available in rumpctrl mode' 61 | 62 | # save current values 63 | rrPATH="${PATH}" 64 | rrPS1="${PS1}" 65 | 66 | # replace env variables 67 | PS1='rumpctrl (${RUMP_SERVER:-NULL})$ ' 68 | export PS1 69 | 70 | PATH="${RRPATH}/bin:${PATH}" 71 | export PATH 72 | 73 | alias rumpctrl_unload=' 74 | PS1="${rrPS1}" 75 | PATH="${rrPATH}" 76 | unset RUMPCTRL_LOADED 77 | unset rrPS1 78 | unset rrPATH 79 | unalias rumpctrl_listcmds 80 | unalias rumpctrl_unload 81 | unalias cd 82 | unset -f rumpctrl_hascmd 83 | unset -f rumpctrl_hostcmd 84 | ' 85 | elif [ ! -z "${RUMPCTRL_LOADED}" ]; then 86 | unset -f rumpctrl_hascmd 87 | unset -f rumpctrl_hostcmd 88 | fi 89 | -------------------------------------------------------------------------------- /ld.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | fail () { echo >&2 "stunt ld: $*"; exit 127; } 6 | 7 | noshift () { fail "no arg for $a"; } 8 | 9 | ALLARGS=$* 10 | 11 | CC=${REALCC:-cc} 12 | LD=${LD:-ld} 13 | OBJCOPY=${OBJCOPY:-objcopy} 14 | 15 | LIBC=false 16 | 17 | while [ $# != 0 ]; do 18 | a=$1; shift 19 | case "$a" in 20 | -m) 21 | march="$1"; shift || noshift 22 | outargs="$outargs $a $march" 23 | ;; 24 | -o) 25 | outfile="$1"; shift || noshift 26 | ;; 27 | --as-needed|--no-as-needed) 28 | ;; 29 | --stunt-intermediate) 30 | inter1="$1"; shift || noshift 31 | inter2="$1"; shift || noshift 32 | ;; 33 | -lgcc|-lgcc_s) 34 | # added later 35 | ;; 36 | -L*|-l*|-*|--whole-archive|--no-whole-archive) 37 | outargs="$outargs $a" 38 | ;; 39 | *crt1.o|*crti.o|*crtbegin.o) 40 | CRTS="${CRTS} $a" 41 | ;; 42 | *crtend.o|*crtn.o) 43 | CRTE="${CRTE} $a" 44 | ;; 45 | *.o|*.ro|*.a) 46 | INFILES="${INFILES} $a" 47 | ;; 48 | *) 49 | outargs="$outargs $a" 50 | ;; 51 | esac 52 | done 53 | 54 | if [ x"$outfile" = x ]; then outfile=a.out; fi 55 | 56 | # -lrt not always needed TODO work out at build time 57 | UNAME=$(uname -s) 58 | [ ${UNAME} = Linux ] && DLFLAG="-ldl -lrt" 59 | LIBRARY_PATH=@PATH@/hostlib/lib 60 | RUMPCLIENT="-L${LIBRARY_PATH} -Wl,-R${LIBRARY_PATH} -lrumpclient ${DLFLAG}" 61 | LIBC=@PATH@/rump/lib/libc.a 62 | 63 | TMPFILE1=$(mktemp /tmp/XXXXXXXXXXX).o 64 | TMPFILE2=$(mktemp /tmp/XXXXXXXXXXX).o 65 | TMPFILE3=$(mktemp /tmp/XXXXXXXXXXX).o 66 | TMPFILE4=$(mktemp /tmp/XXXXXXXXXXX).o 67 | 68 | ${CC} ${LDFLAGS} -Wl,-r -nostdlib ${INFILES} -o ${TMPFILE1} 69 | ${OBJCOPY} --redefine-syms=@PATH@/host.map ${TMPFILE1} ${TMPFILE2} 70 | ${CC} ${LDFLAGS} -Wl,-r ${TMPFILE2} @PATH@/netbsd_init.o -nostdlib ${LIBC} -o ${TMPFILE3} 2>/dev/null 71 | ${OBJCOPY} --redefine-syms=@PATH@/namespace.map ${TMPFILE3} 72 | ${OBJCOPY} --redefine-syms=@PATH@/extra.map ${TMPFILE3} 73 | ${OBJCOPY} --redefine-syms=@PATH@/rump.map ${TMPFILE3} 74 | ${OBJCOPY} --redefine-syms=@PATH@/weakasm.map ${TMPFILE3} 75 | ${OBJCOPY} --redefine-syms=@PATH@/readwrite.map ${TMPFILE3} 76 | ${OBJCOPY} --redefine-syms=@PATH@/emul.map ${TMPFILE3} 77 | ${OBJCOPY} --redefine-syms=@PATH@/netbsd.map ${TMPFILE3} 78 | ${CC} ${LDFLAGS} -Wl,-r -nostdlib -Wl,-dc ${TMPFILE3} @PATH@/readwrite.o -o ${TMPFILE4} 2>/dev/null 79 | ${OBJCOPY} --redefine-syms=@PATH@/errno.map ${TMPFILE4} 80 | ${OBJCOPY} -w --localize-symbol='*' ${TMPFILE4} 81 | ${OBJCOPY} -w --globalize-symbol='_netbsd_*' ${TMPFILE4} 82 | ${CC} ${LDFLAGS} ${TMPFILE4} @PATH@/emul.o @PATH@/rumpclient.o @PATH@/remoteinit.o ${RUMPCLIENT} -o ${outfile} 83 | 84 | rm ${TMPFILE1} ${TMPFILE2} ${TMPFILE3} ${TMPFILE4} 85 | -------------------------------------------------------------------------------- /tests/master.cfg: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | # ex: set syntax=python: 3 | 4 | # This is a sample buildmaster config file. It must be installed as 5 | # 'master.cfg' in your buildmaster's base directory. 6 | 7 | # This is the dictionary that the buildmaster pays attention to. We also use 8 | # a shorter alias to save typing. 9 | c = BuildmasterConfig = {} 10 | 11 | ####### BUILDSLAVES 12 | 13 | # The 'slaves' list defines the set of recognized buildslaves. Each element is 14 | # a BuildSlave object, specifying a unique slave name and password. The same 15 | # slave name and password must be configured on the slave. 16 | from buildbot.buildslave import BuildSlave 17 | from slaves import slaves 18 | def slmap(p): return BuildSlave(p[0], p[1]) 19 | c['slaves'] = map(slmap, slaves) 20 | 21 | # 'slavePortnum' defines the TCP port to listen on for connections from slaves. 22 | # This must match the value configured into the buildslaves (with their 23 | # --master option) 24 | c['slavePortnum'] = 9992 25 | 26 | ####### CHANGESOURCES 27 | 28 | # the 'change_source' setting tells the buildmaster how it should find out 29 | # about source code changes. Here we point to the buildbot clone of pyflakes. 30 | 31 | from buildbot.changes.gitpoller import GitPoller 32 | c['change_source'] = [] 33 | c['change_source'].append(GitPoller( 34 | 'https://github.com/rumpkernel/rumprun-posix.git', 35 | workdir='gitpoller-workdir', branch='master', 36 | pollinterval=60)) 37 | 38 | ####### SCHEDULERS 39 | 40 | # Configure the Schedulers, which decide how to react to incoming changes. In this 41 | # case, just kick off a 'runtests' build 42 | 43 | from buildbot.schedulers.basic import SingleBranchScheduler 44 | from buildbot.schedulers.forcesched import ForceScheduler 45 | from buildbot.changes import filter 46 | c['schedulers'] = [] 47 | c['schedulers'].append(SingleBranchScheduler( 48 | name="all", 49 | change_filter=filter.ChangeFilter(branch='master'), 50 | treeStableTimer=None, 51 | builderNames=["ubuntu64", "netbsd32"])) 52 | #c['schedulers'].append(ForceScheduler( 53 | # name="force", 54 | # builderNames=["runtests"])) 55 | 56 | ####### BUILDERS 57 | 58 | # The 'builders' list defines the Builders, which tell Buildbot how to perform a build: 59 | # what steps, and which slaves can execute them. Note that any particular build will 60 | # only take place on one slave. 61 | 62 | from buildbot.process.factory import BuildFactory 63 | from buildbot.steps.source.git import Git 64 | from buildbot.steps.shell import ShellCommand 65 | 66 | factory = BuildFactory() 67 | # check out the source 68 | factory.addStep(Git(repourl='https://github.com/rumpkernel/rumprun-posix.git', mode='incremental')) 69 | factory.addStep(ShellCommand(command=["git", "submodule", "update", "--init", "--recursive"])) 70 | factory.addStep(ShellCommand(command=["rm", "-rf", "rumpsrc"])) 71 | factory.addStep(ShellCommand(command=["./buildnb.sh", "buildrump", "tests"])) 72 | 73 | from buildbot.config import BuilderConfig 74 | 75 | c['builders'] = [] 76 | c['builders'].append( 77 | BuilderConfig(name="ubuntu64", 78 | slavenames=["ubuntu64"], 79 | factory=factory)) 80 | c['builders'].append( 81 | BuilderConfig(name="netbsd32", 82 | slavenames=["netbsd32"], 83 | factory=factory)) 84 | 85 | ####### STATUS TARGETS 86 | 87 | # 'status' is a list of Status Targets. The results of each build will be 88 | # pushed to these targets. buildbot/status/*.py has a variety to choose from, 89 | # including web pages, email senders, and IRC bots. 90 | 91 | c['status'] = [] 92 | 93 | from buildbot.status import html 94 | from buildbot.status.web import authz, auth 95 | 96 | authz_cfg=authz.Authz( 97 | # change any of these to True to enable; see the manual for more 98 | # options 99 | #auth=auth.BasicAuth([("pyflakes","pyflakes")]), 100 | gracefulShutdown = False, 101 | forceBuild = False, 102 | forceAllBuilds = False, 103 | pingBuilder = False, 104 | stopBuild = False, 105 | stopAllBuilds = False, 106 | cancelPendingBuild = False, 107 | ) 108 | c['status'].append(html.WebStatus(http_port=8013)) 109 | 110 | ####### PROJECT IDENTITY 111 | 112 | # the 'title' string will appear at the top of this buildbot 113 | # installation's html.WebStatus home page (linked to the 114 | # 'titleURL') and is embedded in the title of the waterfall HTML page. 115 | 116 | c['title'] = "Rumprun" 117 | c['titleURL'] = "https://github.com/rumpkernel/rumprun-posix" 118 | 119 | # the 'buildbotURL' string should point to the location where the buildbot's 120 | # internal web server (usually the html.WebStatus page) is visible. This 121 | # typically uses the port number set in the Waterfall 'status' entry, but 122 | # with an externally-visible host name which the buildbot cannot figure out 123 | # without some help. 124 | 125 | c['buildbotURL'] = "http://localhost:8013/" 126 | 127 | ####### DB URL 128 | 129 | c['db'] = { 130 | # This specifies what database buildbot uses to store its state. You can leave 131 | # this at its default for all but the largest installations. 132 | 'db_url' : "sqlite:///state.sqlite", 133 | } 134 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include config.mk 2 | include rumptools/toolchain-conf.mk 3 | 4 | BINDIR=bin 5 | 6 | NBCFLAGS=${CFLAGS} -O2 -g -Wall 7 | HOSTCFLAGS=${CFLAGS} -O2 -g -Wall -Ihostlib/include 8 | 9 | NBUTILS+= bin/cat 10 | NBUTILS+= bin/chmod 11 | NBUTILS+= bin/cp 12 | NBUTILS+= bin/dd 13 | NBUTILS+= bin/df 14 | NBUTILS+= bin/ed 15 | NBUTILS+= bin/ln 16 | NBUTILS+= bin/ls 17 | NBUTILS+= bin/mkdir 18 | NBUTILS+= bin/mv 19 | NBUTILS+= bin/pax 20 | NBUTILS+= bin/rm 21 | NBUTILS+= bin/rmdir 22 | 23 | NBUTILS+= sbin/cgdconfig 24 | NBUTILS+= sbin/chown 25 | NBUTILS+= sbin/disklabel 26 | NBUTILS+= sbin/dump 27 | NBUTILS+= sbin/fsck 28 | NBUTILS+= sbin/fsck_ext2fs 29 | NBUTILS+= sbin/fsck_ffs 30 | NBUTILS+= sbin/fsck_msdos 31 | NBUTILS+= sbin/ifconfig 32 | NBUTILS+= sbin/mknod 33 | NBUTILS+= sbin/modstat 34 | NBUTILS+= sbin/mount 35 | NBUTILS+= sbin/mount_ext2fs 36 | NBUTILS+= sbin/mount_ffs 37 | NBUTILS+= sbin/mount_msdos 38 | NBUTILS+= sbin/mount_tmpfs 39 | NBUTILS+= sbin/newfs 40 | NBUTILS+= sbin/newfs_ext2fs 41 | NBUTILS+= sbin/newfs_msdos 42 | NBUTILS+= sbin/ping 43 | NBUTILS+= sbin/ping6 44 | NBUTILS+= sbin/raidctl 45 | NBUTILS+= sbin/reboot 46 | NBUTILS+= sbin/rndctl 47 | NBUTILS+= sbin/route 48 | NBUTILS+= sbin/sysctl 49 | NBUTILS+= sbin/umount 50 | 51 | NBUTILS+= usr.sbin/arp 52 | NBUTILS+= usr.sbin/dumpfs 53 | NBUTILS+= usr.sbin/ndp 54 | NBUTILS+= usr.sbin/npf/npfctl 55 | NBUTILS+= usr.sbin/pcictl 56 | NBUTILS+= usr.sbin/rtadvd 57 | NBUTILS+= usr.sbin/vnconfig 58 | NBUTILS+= usr.sbin/wlanctl 59 | 60 | #NBUTILS+= usr.bin/kdump 61 | NBUTILS+= usr.bin/ktrace 62 | NBUTILS+= usr.bin/mixerctl 63 | 64 | NBUTILS+= external/bsd/wpa/bin/wpa_passphrase 65 | NBUTILS+= external/bsd/wpa/bin/wpa_supplicant 66 | 67 | ifeq (${BUILDZFS},true) 68 | NBUTILS+= external/cddl/osnet/sbin/zfs 69 | NBUTILS+= external/cddl/osnet/sbin/zpool 70 | NBUTILS+= external/cddl/osnet/usr.bin/ztest 71 | endif 72 | 73 | CPPFLAGS.umount= -DSMALL 74 | 75 | NBUTILS_BASE= $(notdir ${NBUTILS}) 76 | 77 | NBCC=./rump/bin/rump-cc 78 | 79 | all: ${NBUTILS_BASE} bin/halt rumpctrl.sh 80 | 81 | rumpctrl.sh: rumpctrl.sh.in 82 | sed 's,XXXPATHXXX,$(PWD),' $< > $@ 83 | 84 | emul.o: emul.c 85 | ${CC} ${HOSTCFLAGS} -c $< -o $@ 86 | 87 | rumpclient.o: rumpclient.c 88 | ${CC} ${HOSTCFLAGS} -c $< -o $@ 89 | 90 | readwrite.o: readwrite.c 91 | ${CC} ${HOSTCFLAGS} -c $< -o $@ 92 | 93 | remoteinit.o: remoteinit.c 94 | ${CC} ${HOSTCFLAGS} -c $< -o $@ 95 | 96 | netbsd_init.o: netbsd_init.c ${NBCC} 97 | ${NBCC} ${NBCFLAGS} -c $< -o $@ 98 | 99 | halt.o: halt.c ${NBCC} 100 | ${NBCC} ${NBCFLAGS} -c $< -o $@ 101 | 102 | MAPS=rump.map namespace.map host.map netbsd.map readwrite.map emul.map weakasm.map 103 | 104 | ${BINDIR}/halt: halt.o emul.o rumpclient.o readwrite.o remoteinit.o ${MAPS} 105 | ${NBCC} ${NBCFLAGS} -o ${BINDIR}/halt halt.o 106 | 107 | rump.map: ${RUMPSRC}/sys/rump/rump.sysmap 108 | awk '{printf("%s\t%s\n",$$3,$$4)}' $< > $@ 109 | 110 | namespace.map: ${RUMPSRC}/lib/libc/include/namespace.h rump.map emul.map 111 | grep '#define' $< | grep -v NAMESPACE_H | awk '{printf("%s\t%s\n",$$2,$$3)}' > fns.map 112 | cat rump.map emul.map > all.map 113 | awk 'NR==FNR{a[$$1]=$$1;next}a[$$1]' all.map fns.map | awk '{printf("%s\t%s\n",$$2,$$1)}' > $@ 114 | 115 | weakasm.map: ${RUMPSRC}/lib/libc/sys/Makefile.inc ${RUMPMAKE} 116 | ${RUMPMAKE} -f $< RUMPRUN=no -V '$${WEAKASM}' | xargs -n 1 echo | awk '{sub("\\..*", ""); printf("_sys_%s _%s\n", $$1, $$1);}' > $@ 117 | 118 | define NBUTIL_templ 119 | rumpobj/${1}/${2}.ro: 120 | ( cd ${RUMPSRC}/${1} && ${RUMPMAKE} obj && \ 121 | ${RUMPMAKE} LDFLAGS=-Wl,-r LIBCRT0= BUILDRUMP_CFLAGS="-fPIC -std=gnu99 -D__NetBSD__ ${CPPFLAGS.${2}}" ${2}.ro ) 122 | 123 | NBLIBS.${2}:= $(shell cd ${RUMPSRC}/${1} && ${RUMPMAKE} -V '$${LDADD}' | sed 's/-L\S*//g') 124 | LIBS.${2}=$${NBLIBS.${2}:-l%=rump/lib/lib%.a} 125 | ${BINDIR}/${2}: rumpobj/${1}/${2}.ro emul.o rumpclient.o readwrite.o remoteinit.o netbsd_init.o ${MAPS} $${LIBS.${2}} 126 | ${NBCC} ${NBCFLAGS} -o ${BINDIR}/${2} rumpobj/${1}/${2}.ro $${LIBS.${2}} 127 | 128 | ${2}: ${BINDIR}/${2} 129 | 130 | clean_${2}: 131 | ( [ ! -d ${RUMPSRC}/${1} ] || ( cd ${RUMPSRC}/${1} && ${RUMPMAKE} cleandir && rm -f ${2}.ro ) ) 132 | endef 133 | $(foreach util,${NBUTILS},$(eval $(call NBUTIL_templ,${util},$(notdir ${util})))) 134 | 135 | INSTALL_PATH=${PWD} 136 | 137 | ${NBCC}: cc.in rump/lib/rump-cc.specs rump/lib/ld.rump 138 | sed -e "s|@PATH@|${INSTALL_PATH}|g" \ 139 | -e "s|@BUILDRUMP_TOOL_CPPFLAGS@|${BUILDRUMP_TOOL_CPPFLAGS}|g" \ 140 | -e "s|@BUILDRUMP_TOOL_CFLAGS@|${BUILDRUMP_TOOL_CFLAGS}|g" $< > $@ 141 | chmod +x $@ 142 | 143 | rump/lib/ld.rump: ld.in 144 | sed "s|@PATH@|${INSTALL_PATH}|g" $< > $@ 145 | chmod +x $@ 146 | 147 | rump/lib/rump-cc.specs: specs.in 148 | sed -e "s|@BUILDRUMP_TOOL_CPPFLAGS@|${BUILDRUMP_TOOL_CPPFLAGS}|g" \ 149 | -e "s|@BUILDRUMP_TOOL_CFLAGS@|${BUILDRUMP_TOOL_CFLAGS}|g" \ 150 | -e "s|@PATH@|${INSTALL_PATH}|g" $< > $@ 151 | 152 | clean: $(foreach util,${NBUTILS_BASE},clean_${util}) 153 | rm -f *.o *~ rump.map namespace.map fns.map all.map weakasm.map ${PROGS} ${BINDIR}/* rumpctrl.sh 154 | rm -f test_disk-* test_busmem* disk1-* disk2-* csock-* csock1-* csock2-* raid.conf-* 155 | rm -f ${NBCC} rump/lib/rump-cc.specs 156 | 157 | cleanrump: clean 158 | rm -rf rump rumpobj rumptools hostlib hosttools hostobj 159 | rm -f config.mk config.sh 160 | 161 | distcleanrump: clean cleanrump 162 | -------------------------------------------------------------------------------- /emul.c: -------------------------------------------------------------------------------- 1 | /* convert to host format as necessary */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | /* TODO map errors better, and generally better error handling */ 17 | #define _NETBSD_ENOENT 2 18 | #define _NETBSD_EINVAL 22 19 | #define _NETBSD_ENOSYS 78 20 | #define _NETBSD_ENOTSUP 86 21 | 22 | static jmp_buf buf; 23 | 24 | extern char *_netbsd__progname; 25 | extern char **_netbsd_environ; 26 | int _netbsd_main(int argc, char **argv); 27 | void _netbsd_exit(int status); 28 | 29 | static int ret = 0; 30 | 31 | /* this will be the entry point, original one renamed to _netbsd_main */ 32 | int 33 | main(int argc, char **argv) 34 | { 35 | int jret; 36 | 37 | _netbsd__progname = argv[0]; 38 | 39 | if (! (jret = setjmp(buf))) { 40 | /* exit has not been called, so stdio may not be flushed etc */ 41 | _netbsd_exit(_netbsd_main(argc, argv)); 42 | /* will call _exit so will not reach here */ 43 | } 44 | return ret; 45 | } 46 | 47 | void 48 | emul__exit(int status) 49 | { 50 | 51 | ret = status; 52 | longjmp(buf, status); 53 | } 54 | 55 | /* this is the NetBSD initial environ array; when we fully just use host environ this can go away */ 56 | /* it is not quite clear why it is not being initialised properly, we should call the initialiser... */ 57 | static char *the_env[1] = { NULL } ; 58 | 59 | void nullenv_init (void) __attribute__((constructor (102))); 60 | 61 | void 62 | nullenv_init() 63 | { 64 | _netbsd_environ = the_env; 65 | } 66 | 67 | int * 68 | emul__errno(void) 69 | { 70 | return &errno; 71 | } 72 | 73 | typedef int64_t _netbsd_time_t; 74 | typedef int _netbsd_suseconds_t; 75 | typedef int64_t _netbsd_off_t; 76 | typedef int _netbsd_clockid_t; 77 | 78 | struct _netbsd_timeval { 79 | _netbsd_time_t tv_sec; 80 | _netbsd_suseconds_t tv_usec; 81 | }; 82 | 83 | struct _netbsd_rusage { 84 | struct _netbsd_timeval ru_utime; 85 | struct _netbsd_timeval ru_stime; 86 | long ru_maxrss; 87 | long ru_ixrss; 88 | long ru_idrss; 89 | long ru_isrss; 90 | long ru_minflt; 91 | long ru_majflt; 92 | long ru_nswap; 93 | long ru_inblock; 94 | long ru_oublock; 95 | long ru_msgsnd; 96 | long ru_msgrcv; 97 | long ru_nsignals; 98 | long ru_nvcsw; 99 | long ru_nivcsw; 100 | }; 101 | 102 | #define _NETBSD_MAP_SHARED 0x0001 103 | #define _NETBSD_MAP_PRIVATE 0x0002 104 | #define _NETBSD_MAP_FILE 0x0000 105 | #define _NETBSD_MAP_FIXED 0x0010 106 | #define _NETBSD_MAP_RENAME 0x0020 107 | #define _NETBSD_MAP_NORESERVE 0x0040 108 | #define _NETBSD_MAP_INHERIT 0x0080 109 | #define _NETBSD_MAP_HASSEMAPHORE 0x0200 110 | #define _NETBSD_MAP_TRYFIXED 0x0400 111 | #define _NETBSD_MAP_WIRED 0x0800 112 | #define _NETBSD_MAP_ANON 0x1000 113 | #define _NETBSD_MAP_STACK 0x2000 114 | 115 | void * 116 | emul_mmap(void *addr, size_t length, int prot, int nflags, int fd, _netbsd_off_t offset) 117 | { 118 | void *memp; 119 | 120 | if (! (fd == -1 && nflags & _NETBSD_MAP_ANON)) { 121 | errno = _NETBSD_ENOSYS; 122 | return (void *) -1; 123 | } 124 | 125 | memp = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); 126 | if (memp == MAP_FAILED) { 127 | errno = _NETBSD_EINVAL; 128 | return (void *) -1; 129 | } 130 | 131 | return memp; 132 | } 133 | 134 | int 135 | emul_munmap(void *addr, size_t len) 136 | { 137 | munmap(addr, len); 138 | return 0; 139 | } 140 | 141 | int 142 | emul_madvise(void *addr, size_t length, int advice) 143 | { 144 | /* thanks for the advice TODO can add */ 145 | return 0; 146 | } 147 | 148 | int 149 | emul_setpriority(int which, int who, int prio) { 150 | /* don't prioritise TODO can add */ 151 | return 0; 152 | } 153 | 154 | static int rusage_map[2] = { 155 | RUSAGE_SELF, 156 | RUSAGE_CHILDREN, 157 | }; 158 | 159 | int 160 | emul__getrusage50(int who, struct _netbsd_rusage *nrusage) 161 | { 162 | struct rusage rusage; 163 | int ok; 164 | if (who < 0 || who >= 2) { 165 | errno = _NETBSD_EINVAL; 166 | return -1; 167 | } 168 | who = rusage_map[who]; 169 | ok = getrusage(who, &rusage); 170 | memset(nrusage, 0, sizeof(struct _netbsd_rusage)); 171 | nrusage->ru_utime.tv_sec = rusage.ru_utime.tv_sec; 172 | nrusage->ru_utime.tv_usec = rusage.ru_utime.tv_usec; 173 | nrusage->ru_stime.tv_sec = rusage.ru_stime.tv_sec; 174 | nrusage->ru_stime.tv_usec = rusage.ru_stime.tv_usec; 175 | /* TODO add rest of fields */ 176 | return ok; 177 | } 178 | 179 | /* use host environment */ 180 | char * 181 | emul_getenv(const char *name) 182 | { 183 | 184 | return getenv(name); 185 | } 186 | 187 | int 188 | emul_putenv(char *string) 189 | { 190 | 191 | return putenv(string); 192 | } 193 | 194 | int 195 | emul_setenv(const char *name, const char *value, int overwrite) 196 | { 197 | 198 | return setenv(name, value, overwrite); 199 | } 200 | 201 | int 202 | emul_unsetenv(const char *name) 203 | { 204 | 205 | return unsetenv(name); 206 | } 207 | 208 | /* TODO, just lie for now */ 209 | int 210 | emul_getenv_r(const char *name, char *buf, size_t len) 211 | { 212 | 213 | errno = _NETBSD_ENOENT; 214 | return -1; 215 | } 216 | 217 | /* 218 | * BEGIN stubs 219 | */ 220 | 221 | #define STUB(name) \ 222 | int name(void); int name(void) { \ 223 | static int done = 0; \ 224 | errno = _NETBSD_ENOTSUP; \ 225 | if (done) return errno; done = 1; \ 226 | /*printk("STUB ``%s'' called\n", #name);*/\ 227 | return errno;} 228 | 229 | #define STUB_ABORT(name) void name(void); void name(void) { abort(); } 230 | 231 | STUB(emul___sigaction14); 232 | STUB(emul___sigprocmask14); 233 | STUB(emul___sigsuspend14); 234 | STUB(emul___sigaction_sigtramp); 235 | 236 | STUB(emul___wait450); 237 | STUB(emul_kill); 238 | STUB(emul_uuidgen); 239 | 240 | STUB(emul_minherit); 241 | 242 | STUB(emul__lwp_self); 243 | STUB(emul___libc_static_tls_setup); 244 | 245 | STUB_ABORT(emul_undelete); 246 | STUB_ABORT(emul_sigqueueinfo); 247 | STUB_ABORT(emul__setcontext); 248 | STUB_ABORT(emul__lwp_kill); 249 | -------------------------------------------------------------------------------- /tests/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Initial test script to sanity check 4 | 5 | # set up environment 6 | ERRORCOUNT=0 7 | 8 | SOCKFILE="unix://csock-$$" 9 | SOCKFILE1="unix://csock1-$$" 10 | SOCKFILE2="unix://csock2-$$" 11 | SOCKFILE_CGD="unix://csock2-cgd-$$" 12 | SOCKFILE_RAID="unix://csock-rf-$$" 13 | SOCKFILE_VND="unix://csock-vnd-$$" 14 | 15 | # create file system test image 16 | FSIMG=test.ffs.img 17 | FSIMGSIZE=$(( 16*1024*1024 )) 18 | 19 | rump_server -lrumpvfs -lrumpfs_kernfs -lrumpfs_ffs -lrumpdev_disk -lrumpdev -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpnet_netinet6 -lrumpnet_shmif -d key=/fsimg,hostpath=${FSIMG},size=${FSIMGSIZE} -d key=/rfsimg,hostpath=${FSIMG},size=${FSIMGSIZE},type=chr -r 2m $SOCKFILE 20 | SOCKFILE_LIST="${SOCKFILE}" 21 | export RUMP_SERVER="$SOCKFILE" 22 | . ./rumpctrl.sh 23 | 24 | TESTS='' 25 | definetest () 26 | { 27 | 28 | test=$1 29 | shift 30 | TESTS="${TESTS} ${test}" 31 | [ $# -gt 0 ] && SOCKFILE_LIST="${SOCKFILE_LIST} $*" 32 | } 33 | 34 | runtest () 35 | { 36 | 37 | printf "$1 ... " 38 | ( set -e ; $1 ) 39 | if [ $? -ne 0 ] 40 | then 41 | echo "ERROR" 42 | ERRORCOUNT=$((${ERRORCOUNT} + 1)) 43 | else 44 | echo "passed" 45 | fi 46 | } 47 | 48 | # tests 49 | 50 | Test_ifconfig() 51 | { 52 | 53 | ifconfig | grep lo0 > /dev/null 54 | } 55 | definetest Test_ifconfig 56 | 57 | Test_sysctl() 58 | { 59 | 60 | sysctl kern.hostname | grep 'kern.hostname = rump-' > /dev/null 61 | } 62 | definetest Test_sysctl 63 | 64 | Test_df() 65 | { 66 | 67 | df | grep rumpfs > /dev/null 68 | } 69 | definetest Test_df 70 | 71 | Test_cat() 72 | { 73 | 74 | cat /dev/null > /dev/null 75 | } 76 | definetest Test_cat 77 | 78 | Test_ping() 79 | { 80 | 81 | ping -o 127.0.0.1 \ 82 | | grep '64 bytes from 127.0.0.1: icmp_seq=0' > /dev/null 83 | } 84 | definetest Test_ping 85 | 86 | Test_ping6() 87 | { 88 | 89 | ping6 -c 1 ::1 | grep '16 bytes from ::1, icmp_seq=0' > /dev/null 90 | } 91 | definetest Test_ping6 92 | 93 | Test_directories() 94 | { 95 | 96 | dirname=definitely_nonexisting_directory 97 | mkdir /${dirname} > /dev/null 98 | ls / | grep ${dirname} > /dev/null 99 | rmdir /${dirname} > /dev/null 100 | ls / | grep -v ${dirname} > /dev/null 101 | } 102 | definetest Test_directories 103 | 104 | Test_ktrace() 105 | { 106 | 107 | # no kdump support yet so does not test output is sane 108 | ktrace ./bin/ls > /dev/null 109 | ls / | grep ktrace.out > /dev/null 110 | rm ktrace.out > /dev/null 111 | } 112 | definetest Test_ktrace 113 | 114 | Test_shmif() 115 | { 116 | BM="test_busmem-$$" 117 | ifconfig shmif0 create > /dev/null 118 | ifconfig shmif0 linkstr $BM > /dev/null 119 | ifconfig shmif0 inet 1.2.3.4 netmask 0xffffff00 > /dev/null 120 | ifconfig shmif0 \ 121 | | grep 'shmif0: flags=0x8843'\ 122 | > /dev/null 123 | rumpctrl_hostcmd rm $BM 124 | } 125 | definetest Test_shmif 126 | 127 | Test_ffs() 128 | { 129 | 130 | newfs /rfsimg > /dev/null 131 | mkdir /mnt 132 | mount_ffs /fsimg /mnt >/dev/null 133 | cat /dev/zero | dd of=/mnt/file 2>&1 | grep -q 'No space left on device' 134 | umount /mnt 135 | } 136 | definetest Test_ffs 137 | 138 | Test_npf() 139 | { 140 | # create servers 141 | BM="test_busmem2-$$" 142 | rump_server -lrumpnet_shmif -lrumpnet_netinet -lrumpnet_net -lrumpnet $SOCKFILE1 143 | rump_server -lrumpnet_shmif -lrumpnet_netinet -lrumpnet_net -lrumpnet -lrumpnet_npf -lrumpdev_bpf -lrumpdev -lrumpvfs $SOCKFILE2 144 | 145 | # configure network 146 | export RUMP_SERVER="$SOCKFILE1" 147 | ifconfig shmif0 create 148 | ifconfig shmif0 linkstr $BM 149 | ifconfig shmif0 inet 1.2.3.1 150 | 151 | export RUMP_SERVER="$SOCKFILE2" 152 | ifconfig shmif0 create 153 | ifconfig shmif0 linkstr $BM 154 | ifconfig shmif0 inet 1.2.3.2 155 | 156 | ping -c 1 1.2.3.1 > /dev/null 157 | 158 | echo 'group default { 159 | ruleset "test-set" 160 | pass all 161 | } 162 | set bpf.jit off' | dd of=/npf.conf 2> /dev/null 163 | npfctl reload /npf.conf 164 | npfctl rule "test-set" add block proto icmp from 1.2.3.1 > /dev/null 165 | 166 | ping -oq 1.2.3.1 | grep '1 packets received' > /dev/null 167 | 168 | npfctl start 169 | ping -oq -w 2 1.2.3.1 | grep '0 packets received' > /dev/null 170 | 171 | npfctl stop 172 | ping -oq -w 2 1.2.3.1 | grep '1 packets received' > /dev/null 173 | rumpctrl_hostcmd rm $BM 174 | } 175 | definetest Test_npf ${SOCKFILE1} ${SOCKFILE2} 176 | 177 | Test_cgd() 178 | { 179 | export RUMP_SERVER="${SOCKFILE_CGD}" 180 | DISK="test_disk-$$" 181 | rump_server -lrumpfs_ffs -lrumpdev -lrumpdev_disk -lrumpvfs -lrumpdev_cgd -lrumpkern_crypto -lrumpdev_rnd -d "key=/disk1,hostpath=$DISK,size=$((1000*512))" "${RUMP_SERVER}" 182 | 183 | cgdconfig -g -o /cgd.conf -k storedkey aes-cbc 192 184 | cgdconfig cgd0 /disk1 /cgd.conf 185 | newfs cgd0a > /dev/null 186 | 187 | mkdir /mnt 188 | mount_ffs /dev/cgd0a /mnt 189 | mount | grep -q cgd0a 190 | rumpctrl_hostcmd rm $DISK 191 | } 192 | definetest Test_cgd ${SOCKFILE_CGD} 193 | 194 | Test_raidframe() 195 | { 196 | D1="disk1-$$" 197 | D2="disk2-$$" 198 | RC="raid.conf-$$" 199 | echo "START array 200 | 1 2 0 201 | 202 | START disks 203 | /disk1 204 | /disk2 205 | 206 | START layout 207 | 32 1 1 0 208 | 209 | START queue 210 | fifo 100" > ${RC} 211 | rump_server -lrumpdev -lrumpdev_disk -lrumpvfs -lrumpdev_raidframe -lrumpfs_ffs -d "key=/disk1,hostpath=${D1},size=16777216" -d "key=/disk2,hostpath=${D2},size=16777216" -d "key=/raid.conf,hostpath=${RC},size=host,type=reg" $SOCKFILE_RAID 212 | export RUMP_SERVER="${SOCKFILE_RAID}" 213 | 214 | # create raid device 215 | raidctl -C /raid.conf raid0 216 | raidctl -I 24816 raid0 217 | 218 | ls /dev | grep raid0a > /dev/null 219 | 220 | # make a file system 221 | newfs raid0a | grep 'super-block backups' > /dev/null 222 | 223 | # check it 224 | fsck_ffs -f /dev/rraid0a \ 225 | | grep 'File system is already clean' > /dev/null 226 | 227 | # mount 228 | mkdir /mnt 229 | mount_ffs /dev/raid0a /mnt 230 | mount | grep raid0a > /dev/null 231 | 232 | umount /mnt 233 | 234 | rumpctrl_hostcmd rm $D1 $D2 $RC 235 | } 236 | definetest Test_raidframe ${SOCKFILE_RAID} 237 | 238 | Test_vnd() 239 | { 240 | export RUMP_SERVER="${SOCKFILE_VND}" 241 | rump_server -lrumpfs_ffs -lrumpdev -lrumpdev_disk -lrumpvfs -lrumpdev_vnd "${RUMP_SERVER}" 242 | 243 | newfs -F -s 1m /ffs.img > /dev/null 244 | vnconfig vnd0 /ffs.img 245 | mkdir /mnt 246 | mount_ffs /dev/vnd0a /mnt 247 | mount | grep vnd0a > /dev/null 248 | umount /mnt 249 | vnconfig -u vnd0 250 | } 251 | definetest Test_vnd ${SOCKFILE_VND} 252 | 253 | Test_zfs() 254 | { 255 | 256 | ZFSSOCK=unix://zfssock 257 | if ! rump_server -lrumpvfs -lrumpkern_solaris -lrumpfs_zfs -lrumpdev_disk -lrumpdev ${ZFSSOCK} > /dev/null 2>&1; then 258 | # eh eh. FIXME 259 | printf 'SKIPPED and ' 260 | else 261 | RUMP_SERVER=${ZFSSOCK} halt 262 | fi 263 | } 264 | definetest Test_zfs 265 | 266 | # actually run the tests 267 | for test in ${TESTS}; do 268 | runtest ${test} 269 | done 270 | for serv in ${SOCKFILE_LIST}; do 271 | RUMP_SERVER=${serv} halt 272 | done 273 | rumpctrl_hostcmd rm ${FSIMG} 274 | 275 | # show if passed 276 | 277 | if [ ${ERRORCOUNT} -ne 0 ] 278 | then 279 | echo "FAIL: ${ERRORCOUNT} test(s) failed" 280 | exit 1 281 | else 282 | echo "PASSED" 283 | exit 0 284 | fi 285 | --------------------------------------------------------------------------------