Skip to content

Commit

Permalink
Add Jenkins-specific new_init script to run inside VM
Browse files Browse the repository at this point in the history
Currently it performs only two steps:
- inserts the Gramine testing device,
- runs `helloworld` and `device_ioctl` LibOS regression tests.

The old `new_init` script (useful for manual testing) is renamed to
`new_init_shell`.

Signed-off-by: Dmitrii Kuvaiskii <[email protected]>
  • Loading branch information
dimakuv committed Jan 17, 2023
1 parent 8a35c41 commit acd650a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
35 changes: 33 additions & 2 deletions initramfs_builder/new_init
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@
#!/bin/sh

set -e
set -ex

setsid /bin/bash -i
echo "PREP STARTING"

# QEMU appends `PWD_FOR_VM=<current Jenkins working dir>` to Linux command line
cd $PWD_FOR_VM
. "$PWD/envs"

# to find insmod and poweroff programs (default PATH doesn't have `/sbin`)
export PATH="/sbin:$PATH"

if test -n "$SGX"; then
GRAMINE=gramine-sgx
else
GRAMINE=gramine-direct
fi

(
cd device-testing-tools/gramine-device-testing-module
insmod gramine-testing-dev.ko
)
echo "PREP DONE"

(
# run only couple tests -- executing in a VM with virtio-9p-pci FS passthrough is very slow
cd libos/test/regression

gramine-test build helloworld
$GRAMINE helloworld

gramine-test build device_ioctl
$GRAMINE device_ioctl
)
echo "TESTS OK"

poweroff -n -f
9 changes: 9 additions & 0 deletions initramfs_builder/new_init_shell
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# this new_init with a Bash shell can be used for manual testing

set -e

setsid /bin/bash -i

poweroff -n -f
6 changes: 3 additions & 3 deletions initramfs_builder/run.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/sh

set -e
set -ex

exec qemu-system-x86_64 \
-enable-kvm \
-kernel /boot/vmlinuz-$(uname -r) \
-initrd initramfs.cpio.gz \
-initrd ${1:-initramfs.cpio.gz} \
-nographic \
-monitor /dev/null \
-cpu host \
-smp 2 \
-m 1G \
-append "console=ttyS0 loglevel=3 quiet oops=panic" \
-append "console=ttyS0 loglevel=3 quiet oops=panic PWD_FOR_VM=\"${2:-$PWD}\"" \
-device virtio-rng-pci \
-virtfs 'local,path=/,id=hostfs,mount_tag=hostfs,security_model=none,readonly=on' \
-device 'virtio-9p-pci,fsdev=hostfs,mount_tag=hostfs' \
Expand Down

0 comments on commit acd650a

Please sign in to comment.