diff --git a/.buildbot.sh b/.buildbot.sh new file mode 100644 index 0000000..33a79dd --- /dev/null +++ b/.buildbot.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +set -e + +build_dir="$(pwd)/build" +src_dir="$(pwd)" +cheri_dir="/home/buildbot/cheri/output" + +# Build project locally +export CC=$cheri_dir/morello-sdk/bin/clang +export CFLAGS="--config cheribsd-morello-hybrid.cfg" +export ASMFLAGS="--config cheribsd-morello-hybrid.cfg" + +cmake \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=DEBUG \ + -DLLVM_DIR=$cheri_dir/morello-sdk/lib/cmake/llvm \ + -DClang_DIR=$cheri_dir/morello-sdk/lib/cmake/clang \ + -B $build_dir \ + -S $src_dir +cmake --build $build_dir + +# Set arguments for Morello hybrid instance +export SSHPORT=10086 +export PYTHONPATH="/home/buildbot/build/test-scripts" + +args=( + --architecture morello-hybrid + # Qemu System to use + --qemu-cmd $cheri_dir/morello-sdk/bin/qemu-system-morello + --bios edk2-aarch64-code.fd + --disk-image $cheri_dir/cheribsd-morello-hybrid.img + # Required build-dir in CheriBSD + --build-dir . + --ssh-port $SSHPORT + --ssh-key $HOME/.ssh/id_ed25519.pub + ) + +# Spawn CHERI QEMU instance, then execute `ctest` +python3 $src_dir/.run_cheri_qemu_and_test.py "${args[@]}" diff --git a/.run_cheri_qemu_and_test.py b/.run_cheri_qemu_and_test.py new file mode 100644 index 0000000..e56a2bc --- /dev/null +++ b/.run_cheri_qemu_and_test.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +# Adapted from +# https://github.com/capablevms/cheri-examples/blob/master/tests/run_cheri_examples.py + +import argparse +import importlib.util +import os +import subprocess +import sys + +from pathlib import Path + +# Emulate `sys.path` from path of module `run_tests_common` (found via +# environment variable `PYTHONPATH`), as required by the CHERI testing +# infrastructure which we are using to simplify booting a QEMU instance +test_scripts_dir = str(Path(importlib.util.find_spec("run_tests_common").origin).parent.absolute()) +sys.path = sys.path[sys.path.index(test_scripts_dir):] + +from run_tests_common import boot_cheribsd, run_tests_main + +def run_tests(qemu: boot_cheribsd.QemuCheriBSDInstance, args: argparse.Namespace) -> bool: + if args.sysroot_dir is not None: + boot_cheribsd.set_ld_library_path_with_sysroot(qemu) + boot_cheribsd.info("Running tests for cheri-morello-compartmentalisation") + + # Run command on host to test the executed client + os.chdir(f"{args.build_dir}/build") + subprocess.run(["/usr/bin/ctest", "-V"], check=True) + return True + +if __name__ == '__main__': + # This call has the side-effect of booting a QEMU instance + run_tests_main(test_function=run_tests, need_ssh=True, should_mount_builddir=False) diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..8b2ad70 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,17 @@ +Except as otherwise noted (below and/or in individual files), this project is +licensed under the Apache License, Version 2.0 + or the MIT license +, at your option. + +Copyright is retained by contributors and/or the organisations they +represent(ed) -- this project does not require copyright assignment. Please see +version control history for a full list of contributors. Note that some files +may include explicit copyright and/or licensing notices. + +The following contributors wish to explicitly make it known that the copyright +of their contributions is retained by an organisation: + + Jacob Bramley : + copyright retained by Arm Limited + Laurence Tratt : + copyright retained by King's College London diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..3d127b7 --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,10 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..410e04e --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,17 @@ +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/bors.toml b/bors.toml new file mode 100644 index 0000000..db1bdaa --- /dev/null +++ b/bors.toml @@ -0,0 +1,10 @@ +# Sourced from +# https://github.com/capablevms/cheri-examples/blob/master/bors.toml +status = ["buildbot/capablevms-test-script"] + +timeout_sec = 600 # 10 minutes + +# Have bors delete auto-merged branches +delete_merged_branches = true + +cut_body_after = "" diff --git a/tests/run_test.sh b/tests/run_test.sh index 1a774df..06a8039 100755 --- a/tests/run_test.sh +++ b/tests/run_test.sh @@ -13,5 +13,5 @@ CHERIBSD_PORT=10086 CHERIBSD_USER=root CHERIBSD_HOST=localhost -scp -P $CHERIBSD_PORT $1 $CHERIBSD_USER@$CHERIBSD_HOST: -ssh -p $CHERIBSD_PORT $CHERIBSD_USER@$CHERIBSD_HOST -t ./$(basename $1) +scp -o "StrictHostKeyChecking no" -P $CHERIBSD_PORT $1 $CHERIBSD_USER@$CHERIBSD_HOST: +ssh -o "StrictHostKeyChecking no" -p $CHERIBSD_PORT $CHERIBSD_USER@$CHERIBSD_HOST -t ./$(basename $1)