Skip to content

Commit

Permalink
Add bors + buildbot support, and legal stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
0152la committed Feb 11, 2022
1 parent 9f4758c commit 6a2c543
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 2 deletions.
40 changes: 40 additions & 0 deletions .buildbot.sh
Original file line number Diff line number Diff line change
@@ -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[@]}"
34 changes: 34 additions & 0 deletions .run_cheri_qemu_and_test.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE>
<http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT>
<http://opensource.org/licenses/MIT>, 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 <[email protected]>:
copyright retained by Arm Limited
Laurence Tratt <[email protected]>:
copyright retained by King's College London
10 changes: 10 additions & 0 deletions LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -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.
10 changes: 10 additions & 0 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -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 = ""
4 changes: 2 additions & 2 deletions tests/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6a2c543

Please sign in to comment.