From ad429d6f476d2355c6c3618c35d228730a0b24e9 Mon Sep 17 00:00:00 2001 From: Dan Walkes Date: Sat, 21 May 2022 13:53:07 -0600 Subject: [PATCH 1/4] Add assignment 3 part 1 changes --- .github/workflows/github-actions.yml | 9 --- CMakeLists.txt | 2 + conf/assignment.txt | 2 +- examples/systemcalls/systemcalls.c | 99 ++++++++++++++++++++++++++++ examples/systemcalls/systemcalls.h | 9 +++ finder-app/autorun-qemu.sh | 12 ++++ finder-app/dependencies.sh | 8 +++ finder-app/manual-linux.sh | 80 ++++++++++++++++++++++ finder-app/start-qemu-app.sh | 38 +++++++++++ finder-app/start-qemu-terminal.sh | 32 +++++++++ 10 files changed, 281 insertions(+), 10 deletions(-) create mode 100644 examples/systemcalls/systemcalls.c create mode 100644 examples/systemcalls/systemcalls.h create mode 100755 finder-app/autorun-qemu.sh create mode 100755 finder-app/dependencies.sh create mode 100755 finder-app/manual-linux.sh create mode 100755 finder-app/start-qemu-app.sh create mode 100755 finder-app/start-qemu-terminal.sh diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index e5339c2..94a5373 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -10,12 +10,3 @@ jobs: run : git submodule update --init --recursive - name: Run unit test run: ./unit-test.sh - full-test: - container: cuaesd/aesd-autotest:assignment2 - runs-on: self-hosted - steps: - - uses: actions/checkout@v2 - - name: Checkout submodules - run : git submodule update --init --recursive - - name: Run full test - run: ./full-test.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 0252a21..a3d8066 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,9 +7,11 @@ project(aesd-assignments) set(AUTOTEST_SOURCES test/assignment1/Test_hello.c test/assignment1/Test_assignment_validate.c + test/assignment3/Test_systemcalls.c ) # A list of all files containing test code that is used for assignment validation set(TESTED_SOURCE ../examples/autotest-validate/autotest-validate.c + ../examples/systemcalls/systemcalls.c ) add_subdirectory(assignment-autotest) diff --git a/conf/assignment.txt b/conf/assignment.txt index 3d46716..62cc2d1 100644 --- a/conf/assignment.txt +++ b/conf/assignment.txt @@ -1 +1 @@ -assignment2 +assignment3 diff --git a/examples/systemcalls/systemcalls.c b/examples/systemcalls/systemcalls.c new file mode 100644 index 0000000..6793970 --- /dev/null +++ b/examples/systemcalls/systemcalls.c @@ -0,0 +1,99 @@ +#include "systemcalls.h" + +/** + * @param cmd the command to execute with system() + * @return true if the command in @param cmd was executed + * successfully using the system() call, false if an error occurred, + * either in invocation of the system() call, or if a non-zero return + * value was returned by the command issued in @param cmd. +*/ +bool do_system(const char *cmd) +{ + +/* + * TODO add your code here + * Call the system() function with the command set in the cmd + * and return a boolean true if the system() call completed with success + * or false() if it returned a failure +*/ + + return true; +} + +/** +* @param count -The numbers of variables passed to the function. The variables are command to execute. +* followed by arguments to pass to the command +* Since exec() does not perform path expansion, the command to execute needs +* to be an absolute path. +* @param ... - A list of 1 or more arguments after the @param count argument. +* The first is always the full path to the command to execute with execv() +* The remaining arguments are a list of arguments to pass to the command in execv() +* @return true if the command @param ... with arguments @param arguments were executed successfully +* using the execv() call, false if an error occurred, either in invocation of the +* fork, waitpid, or execv() command, or if a non-zero return value was returned +* by the command issued in @param arguments with the specified arguments. +*/ + +bool do_exec(int count, ...) +{ + va_list args; + va_start(args, count); + char * command[count+1]; + int i; + for(i=0; i +#include +#include + +bool do_system(const char *command); + +bool do_exec(int count, ...); + +bool do_exec_redirect(const char *outputfile, int count, ...); diff --git a/finder-app/autorun-qemu.sh b/finder-app/autorun-qemu.sh new file mode 100755 index 0000000..2fbc8f8 --- /dev/null +++ b/finder-app/autorun-qemu.sh @@ -0,0 +1,12 @@ +#!/bin/sh +cd $(dirname $0) +echo "Running test script" +./finder-test.sh +rc=$? +if [ ${rc} -eq 0 ]; then + echo "Completed with success!!" +else + echo "Completed with failure, failed with rc=${rc}" +fi +echo "finder-app execution complete, dropping to terminal" +/bin/sh diff --git a/finder-app/dependencies.sh b/finder-app/dependencies.sh new file mode 100755 index 0000000..5727068 --- /dev/null +++ b/finder-app/dependencies.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Dependency installation script for kernel build. +# Author: Siddhant Jajoo. + + +sudo apt-get install -y libssl-dev +sudo apt-get install -y u-boot-tools +sudo apt-get install -y qemu diff --git a/finder-app/manual-linux.sh b/finder-app/manual-linux.sh new file mode 100755 index 0000000..a2dd5ee --- /dev/null +++ b/finder-app/manual-linux.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# Script outline to install and build kernel. +# Author: Siddhant Jajoo. + +set -e +set -u + +OUTDIR=/tmp/aeld +KERNEL_REPO=git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git +KERNEL_VERSION=v5.1.10 +BUSYBOX_VERSION=1_33_1 +FINDER_APP_DIR=$(realpath $(dirname $0)) +ARCH=arm64 +CROSS_COMPILE=aarch64-none-linux-gnu- + +if [ $# -lt 1 ] +then + echo "Using default directory ${OUTDIR} for output" +else + OUTDIR=$1 + echo "Using passed directory ${OUTDIR} for output" +fi + +mkdir -p ${OUTDIR} + +cd "$OUTDIR" +if [ ! -d "${OUTDIR}/linux-stable" ]; then + #Clone only if the repository does not exist. + echo "CLONING GIT LINUX STABLE VERSION ${KERNEL_VERSION} IN ${OUTDIR}" + git clone ${KERNEL_REPO} --depth 1 --single-branch --branch ${KERNEL_VERSION} +fi +if [ ! -e ${OUTDIR}/linux-stable/arch/${ARCH}/boot/Image ]; then + cd linux-stable + echo "Checking out version ${KERNEL_VERSION}" + git checkout ${KERNEL_VERSION} + + # TODO: Add your kernel build steps here +fi + +echo "Adding the Image in outdir" + +echo "Creating the staging directory for the root filesystem" +cd "$OUTDIR" +if [ -d "${OUTDIR}/rootfs" ] +then + echo "Deleting rootfs directory at ${OUTDIR}/rootfs and starting over" + sudo rm -rf ${OUTDIR}/rootfs +fi + +# TODO: Create necessary base directories + +cd "$OUTDIR" +if [ ! -d "${OUTDIR}/busybox" ] +then +git clone git://busybox.net/busybox.git + cd busybox + git checkout ${BUSYBOX_VERSION} + # TODO: Configure busybox +else + cd busybox +fi + +# TODO: Make and install busybox + +echo "Library dependencies" +${CROSS_COMPILE}readelf -a bin/busybox | grep "program interpreter" +${CROSS_COMPILE}readelf -a bin/busybox | grep "Shared library" + +# TODO: Add library dependencies to rootfs + +# TODO: Make device nodes + +# TODO: Clean and build the writer utility + +# TODO: Copy the finder related scripts and executables to the /home directory +# on the target rootfs + +# TODO: Chown the root directory + +# TODO: Create initramfs.cpio.gz diff --git a/finder-app/start-qemu-app.sh b/finder-app/start-qemu-app.sh new file mode 100755 index 0000000..8354bcb --- /dev/null +++ b/finder-app/start-qemu-app.sh @@ -0,0 +1,38 @@ +# !/bin/bash +# Script to open qemu terminal. +# Author: Siddhant Jajoo. + +set -e + +OUTDIR=$1 + +if [ -z "${OUTDIR}" ]; then + OUTDIR=/tmp/aeld + echo "No outdir specified, using ${OUTDIR}" +fi + +KERNEL_IMAGE=${OUTDIR}/Image +INITRD_IMAGE=${OUTDIR}/initramfs.cpio.gz + +if [ ! -e ${KERNEL_IMAGE} ]; then + echo "Missing kernel image at ${KERNEL_IMAGE}" + exit 1 +fi +if [ ! -e ${INITRD_IMAGE} ]; then + echo "Missing initrd image at ${INITRD_IMAGE}" + exit 1 +fi + + +echo "Booting the kernel" +# See trick at https://superuser.com/a/1412150 to route serial port output to file +qemu-system-aarch64 \ + -m 256M \ + -M virt \ + -cpu cortex-a53 \ + -nographic \ + -smp 1 \ + -kernel ${KERNEL_IMAGE} \ + -chardev stdio,id=char0,mux=on,logfile=${OUTDIR}/serial.log,signal=off \ + -serial chardev:char0 -mon chardev=char0 \ + -append "rdinit=/home/autorun-qemu.sh console=ttyAMA0" -initrd ${INITRD_IMAGE} diff --git a/finder-app/start-qemu-terminal.sh b/finder-app/start-qemu-terminal.sh new file mode 100755 index 0000000..f1a133f --- /dev/null +++ b/finder-app/start-qemu-terminal.sh @@ -0,0 +1,32 @@ +# !/bin/bash +# Script to open qemu terminal. +# Author: Siddhant Jajoo. + +set -e + +OUTDIR=$1 + +if [ -z "${OUTDIR}" ]; then + OUTDIR=/tmp/aeld + echo "No outdir specified, using ${OUTDIR}" +fi + +KERNEL_IMAGE=${OUTDIR}/Image +INITRD_IMAGE=${OUTDIR}/initramfs.cpio.gz + +if [ ! -e ${KERNEL_IMAGE} ]; then + echo "Missing kernel image at ${KERNEL_IMAGE}" + exit 1 +fi +if [ ! -e ${INITRD_IMAGE} ]; then + echo "Missing initrd image at ${INITRD_IMAGE}" + exit 1 +fi + + +echo "Booting the kernel" +# See trick at https://superuser.com/a/1412150 to route serial port output to file +qemu-system-aarch64 -m 256M -M virt -cpu cortex-a53 -nographic -smp 1 -kernel ${KERNEL_IMAGE} \ + -chardev stdio,id=char0,mux=on,logfile=${OUTDIR}/serial.log,signal=off \ + -serial chardev:char0 -mon chardev=char0\ + -append "rdinit=/bin/sh" -initrd ${INITRD_IMAGE} From 3bf587a7305adae4ed8144fd274c425531a2617d Mon Sep 17 00:00:00 2001 From: Hemanth Nandish Date: Sat, 8 Oct 2022 23:17:13 -0600 Subject: [PATCH 2/4] yaml changes for a3p1 --- .github/workflows/github-actions.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 94a5373..1d4d860 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -1,5 +1,10 @@ name: assignment-test -on: [push] +on: + push: + tags-ignore: + - '*' + branches: + - '*' jobs: unit-test: container: cuaesd/aesd-autotest:unit-test From c5419eddd81b3ca90308d2b5c7452dfda625b2cd Mon Sep 17 00:00:00 2001 From: Hemanth Nandish Date: Sat, 8 Oct 2022 23:17:59 -0600 Subject: [PATCH 3/4] Revert "yaml changes for a3p1" This reverts commit 3bf587a7305adae4ed8144fd274c425531a2617d. --- .github/workflows/github-actions.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 1d4d860..94a5373 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -1,10 +1,5 @@ name: assignment-test -on: - push: - tags-ignore: - - '*' - branches: - - '*' +on: [push] jobs: unit-test: container: cuaesd/aesd-autotest:unit-test From b5be209dec7e1f3034a375ec2e7ff10e7f1d2489 Mon Sep 17 00:00:00 2001 From: Dan Walkes Date: Sun, 26 Jan 2025 00:00:39 +0000 Subject: [PATCH 4/4] assignment-autotest: update to latest With fix for assignment 3 successful completion check. --- assignment-autotest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assignment-autotest b/assignment-autotest index 6072c48..a421651 160000 --- a/assignment-autotest +++ b/assignment-autotest @@ -1 +1 @@ -Subproject commit 6072c480bfb75881d6a5b1f8d5c622d2243e8879 +Subproject commit a421651f00a585e488572e9db94d896d364cfc5f