diff --git a/README.md b/README.md index 54b4d2303137790756a9dbc0364740ddc3a8155c..cf37a47bc257865f0f6ffc6a067ecf2444106591 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,66 @@ # CS350 Container -This is the CS350 Docker container that assists students who wish to have an -isolated local environment for their os161 and userspace -assignments. This repo currently expects that you are running in a UNIX -environments that support docker (MacOS, Linux, or Windows WSL) +This is CS350 Docker container repository. It includes the CS350 Docker container and the tools to build, run, debug and test OS/161 and Linux based programming assignments for CS350. This repository currently expects that you are running in a UNIX or UNIX-like environment that supports docker, such as, MacOS, Linux or Windows WSL. -If you do not have access to this type of environment then you can use the -[older instructions](https://student.cs.uwaterloo.ca/~cs350/common/Install161.html) for the provided student environments. +If you have a Windows system without WSL, then start [here](https://git.uwaterloo.ca/krhancoc/cs350-container/-/edit/master/README.md#windows). +If you do not have access to a UNIX or UNIX-like environment then you can use the +[older instructions](https://student.cs.uwaterloo.ca/~cs350/common/Install161.html) to build, run, debug and test in University of Waterloo's linux student environment. -## Windows -* Before you can install docker, you must have [WSL](https://docs.microsoft.com/en-us/windows/wsl/install) installed. -* You can then [install docker](https://docs.docker.com/desktop/windows/install) for WSL +## Windows - Prerequistes to install a UNIX-like environment and Docker +* Install [WSL](https://docs.microsoft.com/en-us/windows/wsl/install). +* Install [docker](https://docs.docker.com/desktop/windows/install) for WSL. -## Requirements -* Docker [installed](https://docs.docker.com/engine/install/) -* Your own working copy of os161 (if you do not have one see the next section) +## UNIX and UNIX-like Environments - Prerequiste to install Docker +* Install [docker](https://docs.docker.com/engine/install/) -## Starting Fresh with OS161 -If you are starting fresh and do not currently have a working copy of os161, you can retrieve your own by copying the -`os161.tar.gz` file within `os161-container/dependencies` directory. +## Prerequiste - repository for OS/161 source code +* This repository assumes that you have a copy of the OS/161 source code on the local machine. +* You **should** have a remote repository to manage your OS/161 source code and move between the local and linux.student environments. + +* If you do not currently have a working copy of os161, you can retrieve your own by copying the +`os161.tar.gz` file within `os161-container/dependencies` directory in the cs350-container repository. ``` cp os161-container/dependencies/os161.tar.gz ~/ cd ~/ tar xzvf os161.tar.gz ``` -You should now have a folder called os161-1.99 in your home directory. Make this a git repo! +You should now have a folder called `os161-1.99` in your home directory. Make this a git repository! -## Setup -Once the above requirements are met, you run: +## Prerequiste complete - install CS350-container +Once the above requirements are met, you can clone this repository and install the cs350-container by typing: ``` sudo ./install.sh ``` +In a terminal from within the project directory. This script will pull the assignments reposiroty and build it into a local copy of the os161-runner image. -From within the project directory. This script will pull the assignments repo and build it into a local copy of the os161-runner image. - - -## Running OS161 -To start using the container you use the run.sh script, which takes one argument -- the directory of your working code repo. +## Running OS161 in the cs350-container +To start using the container you use the run.sh script, which takes one argument -- the directory of your working code repository. ``` sudo ./run.sh ~/os161-1.99 ``` -Once executed you will be within the context of the container itself (its like your own mini environment), you will have preloaded two -ease of use functions (found at /helpers.sh within the container), `build_kernel ASST#`, and `test_kernel ASST#`. Where the `#` signifies the -assignment number. - -Within the container you may run within the shell (these functions are preloaded in your shell): +Once executed you will be within the context of the container itself (its like your own mini environment), there are two functions (found at /helpers.sh within the container), `build_kernel ASST#`, and `test_kernel ASST#`. Where the `#` represents the +assignment number. You can run these commands from the shell container. These functions are preloaded in your shell. For example, to build and run ASST0: ``` # build_kernel ASST0 # test_kernel ASST0 ``` -To build and run within the context of ASST0. Finally you may evaluate your assignment based off public test cases (there could be hidden ones not found within -the repo) - +You can evaluate your assignment based on public test cases. There will be hidden test cases that are not avaiable in this repository. ``` # /evalaute /logs/test_public.log /assignments/ASST0 ``` ## Running GDB - -To run GDB, in a window with the container running and having built the kernel using the `build_kernel ASST0`: +* Make sure you have built the kernel using `build_kernel ASST0`. +* To run GDB, open a terminal with the cs350-container running, and enter the following commands: ``` # cd /os-compile/ # sys161 -w kernel ``` -Now in another terminal, move to this project directory and use the `./connect.sh` script to connect to the running container: +* Now in another terminal, move to the project directory and use the `./connect.sh` script to connect to the previosuly running container: ``` # cd /os-compile/ # cs350-gdb kernel @@ -81,19 +74,19 @@ Copyright (C) 2006 Free Software Foundation, Inc. ... ``` You will need to use the command `dir /kernel/kern/compile/ASST#` where `#` is the assignment number. This will make sure to load the symbols -of the kernel. Symbols are the names we have given functions and variables, this allows gdb to convey what you are looking at (this is because -the kernel has been compiled WITH these symbols in mind), otherwise gdb will show just bare assembly! +of the kernel. Symbols are the names we have given functions and variables. This allows gdb to correctly convey what you are looking at, since the kernel has been compiled WITH these symbols, otherwise gdb will show just bare assembly! -Note: If `./connect.sh` does not work it may be because you have multiple running containers of os161-runner. Use `docker ps` to figure this out. -This script is not a smart script just an ease of use script. +Note: If run.sh fails it means there is still a os161-runner container running. Use `docker kill os161` to kill it. ## Running other assignments -You may point the `run.sh` to any directory as all this does is makes sure that the directory is shared between the container and you. Allowing you to +You may point the `run.sh` in any directory, the script makes sure that the directory is shared between the container and you. Allowing you to continue to code and work on the files within the directoy and have the container running and seeing those changes. Further instructions will be given to the scripts used to run and evaluate userspace code. When mounting other directories that are not os161 note that the `build_kernel` and `test_kernel` functionality will not work. +## Running, building and testing userspace code +* ## Layout There are some noted directories within the container @@ -102,16 +95,10 @@ There are some noted directories within the container * `/os-compile` holds the compiled version of the code * `/assignments` holds testing and evaluation scripts used for each assignment -Within the `/assignments` directory there are subdirectories for each assignment, to see the test cases we pass and use, looks to the `public` file, -to see how we run and build your assignment, see the `run.sh` file. Finally, to see how we automatically evaluate the output of your assignment, -look at `verify.py` +Within the `/assignments` directory there are subdirectories for each assignment, which you can review: +* the `public` file - shows the test cases we pass and use, +* the `run.sh` file - how we run and build your assignment, +* the `verify.py` script - how we evaluate the output of your assignment. -If the assignments repo has changed, either due to assignments being changed or bugs found (found at `os161-container/assignments`) you will need to pull this repo -and rebuild. +If the assignments repo has changed, either due to assignments being changed or bugs found (found at `os161-container/assignments`) you will need to just run `sudo ./install.sh` again. -``` -cd os161-container/assignments -git pull origin master -cd ../.. -sudo docker build -t os161-runner os161-container -``` diff --git a/connect.sh b/connect.sh index 13addbb7be847e0645e5943bb7e3007a16db6bcd..d3a4b0748cf548d87fd498897c1412305d570d83 100755 --- a/connect.sh +++ b/connect.sh @@ -1,3 +1,2 @@ #/usr/bin/env bash -ID=`docker ps -aqf "ancestor=os161-runner"` -docker exec -it $ID /bin/bash +docker exec -it os161 /bin/bash diff --git a/install.sh b/install.sh index b078cf79b2361bba21d2df0427abc6ad5e932b20..96d672c7f91572c2cbbd1f3f3298e4553560ab59 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash -git clone https://git.uwaterloo.ca/krhancoc/cs350-assignments.git os161-container/assignments - +echo "Cloning/Updating assignment directory" +git clone https://git.uwaterloo.ca/krhancoc/cs350-assignments.git os161-container/assignments > /dev/null 2> /dev/null +cd os161-container/assignments > /dev/null +git pull origin master > /dev/null 2> /dev/null +cd - > /dev/null +echo "Building CS350 container" docker build -t os161-runner ./os161-container diff --git a/run.sh b/run.sh index 4dcb21c2a4ab5000a8393c12df0358e75e4ada69..6960cce9daf42a211b0ead2e3e36615d70f4cefd 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,8 @@ -#! /bin/sh +#!/usr/bin/env bash +realpath() { + [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" +} + rm -rf logs set -e @@ -7,6 +11,7 @@ if [ "$#" -ne 1 ];then exit 1 fi + mkdir -p logs KERNFILE=$1 @@ -15,4 +20,7 @@ docker run -it --rm \ -v `realpath os161-container/assignments`:/assignments \ -v `realpath logs`:/logs \ --entrypoint /bin/bash \ + --name os161 \ os161-runner + +docker kill os161 > /dev/null 2> /dev/null