Summary
The lab assumes that you are already have the class' VM setup and that you are comfortable with working in the terminal.
The lab covers
-
Donwload and install PintOS
-
Run PintOS tests
Download and install PintOS
You will want to install the PintOS source code inside the repository that the class staff has created
for your team. The instructions below are for the project called vm. You will have to follow these instructions
for later projects. In later projects you will have to import the source code from your previous projects as some features
will depend on your previous project’s solution.
| You are now working in teams. You are free to choose any pattern you prefer for managing your repository. Be warned however that is your responsibility to deal with that process. The staff will not accept excuses like "my partner messed up the merge" or "my partner pushed some code that broke the tests, it was working fine a minute ago". We treat you as a team. The whole team is responsible for the repository and the quality of the code. |
-
Download the pintos archive
wget https://course.ccs.neu.edu/cs5600f17/pintos/pintos-src.tgz
wgetwill store the file in the same directory that you runwget. We will refer to this directory asPINTOS_DOWNLOAD_PATHin the rest of this document. -
Navigate to the folder (repo) that you would like to extract the PintOS source. We will refer to this folder as
PINTOS_HOMEin the rest of this document. Run the following command to extract the archivetar xvzf PINTOS_DOWNLOAD_PATH/pintos-src.tgz
-
We need to add certain PintOS programs to our
PATH. Open your shells initialization file (.bashrcif you are using bash) and add the$PINTOS_HOME/pintos/src/utilsto yourPATHvariable. Here is what it should look like once you are donePATH=/usr/local/bin:$PATH:/home/therapon/cs5600-pintos-project1/pintos/src/utils
In my case
PINTOS_HOME = /home/therapon/cs5600-pintos-project1/ -
In order to use
gdbwith PintOS we need to configure somegdbmacros. The gdb macros are stored in the file$PINTOS_HOME/pintos/src/utils/pintos-gdb.-
Go to the folder
$PINTOS_HOME/pintos/src/utilsand using an editor open the filepintos-gdb. -
Find the string
GDBMACROSand change its definition to point to the full path of the filegdb-macros. For exampleGDBMACROS=$PINTOS_HOME/pintos/src/misc/gdb-macros
where in my case
PINTOS_HOME = /home/therapon/cs5600-pintos-project1/.
-
-
Navigate to the folder
$PINTOS_HOME/pintos/src/utilsand build the remaining PintOS utilities by runningmake
-
PintOS can use different emulators in order to run your code. We need to tell PintOS that we want to use
qemu. Navigate to$PINTOS_HOME/pintos/src/vmand use an editor to open the file calledMake.vars. Search for the line that contains the following textSIMULATOR = --bochs
and change it to say
SIMULATOR = --qemu
Running PintOS tests
The PintOS source code comes with a list of tests. The class staff will use these tests to grade your assignments. You cannot change these tests. The graders have a clean copy of the tests included in the PintOS and will run those against your submission.
You are however encouraged to add new tests of your own.
Each project contains it’s own tests folder that contains individual tests. Some of the tests are the same across projects and some vary.
The tests are located inside your build folder under tests/<project_name>/<test_name>.
The execution of a test generates 3 files in the same folder as the test’s source. The files have the same name as the test but have a different extension
-
output- a text file with all of the console output created during the run of this test -
errors- a text file with all of the error output created during the run of this test -
result- a text file with the final outcome of the test’s run, should be one of two wordsPASSif the test succeeded andFAILif the test failed.
Running a single test
-
Open a terminal and navigate to a project folder i.e.,
$PINTOS_HOME/pintos/src/vm. -
Build the vm project using
makemake
-
Building the project will generate a new folder called
build. -
Tests for each project are locate in the folder
$PINTOS_HOME/pintos/src/tests/. Each project has a sub-folder that contains all its tests, for example,$PINTOS_HOME/pintos/src/tests/vmcontains all the tests for this project. After building a project, all of its tests are copied over into thebuildfolder. -
Using your terminal, navigate to the
vmbuildfolder and run the following commandmake tests/vm/mmap-clean.result
The command will run the tests
mmap-cleanand will generate the following files-
$PINTOS_HOME/pintos/src/vm/build/tests/vm/mmap-clean.outputcontains anything that the test outputs during its run -
$PINTOS_HOME/pintos/src/vm/build/tests/vm/mmap-clean.errorscontains any errors that occurred during the tests' run -
$PINTOS_HOME/pintos/src/vm/build/tests/vm/mmap-clean.resultcontains the test’s result, typically the wordFAILorPASSIf you would like to run the tests and see the output on your terminal, as well as store it in the
.outputfile run your tests by passingVERBOSE=1, e.g.make VERBOSE=1 tests/vm/mmap-clean.result
Here is what the output on my screen looks like when I run the test
mmap-cleanin verbose mode.make VERBOSE=1 tests/vm/mmap-clean.result perl -I../.. ../../tests/vm/mmap-clean.ck tests/vm/mmap-clean tests/vm/mmap-clean.result FAIL tests/vm/mmap-clean Test output failed to match any acceptable form. Acceptable output: (mmap-clean) begin (mmap-clean) open "sample.txt" (mmap-clean) mmap "sample.txt" (mmap-clean) write "sample.txt" (mmap-clean) munmap "sample.txt" (mmap-clean) seek "sample.txt" (mmap-clean) read "sample.txt" (mmap-clean) file change was retained after munmap (mmap-clean) end Differences in `diff -u' format: (mmap-clean) begin (mmap-clean) open "sample.txt" (mmap-clean) mmap "sample.txt" - (mmap-clean) write "sample.txt" - (mmap-clean) munmap "sample.txt" - (mmap-clean) seek "sample.txt" - (mmap-clean) read "sample.txt" - (mmap-clean) file change was retained after munmap - (mmap-clean) end
The testing scripts try to be clever and only run tests if the test’s 3 output files are not present. So if you want to run the tests again you should remove the 3 output files.
Alternatively, if you just want to run a test without generating any files or checks,
pintos --qemu -k -T 60 -- -q run mmap-clean
The
pintosprogram takes a lot of options. Usepintos --helpto see all the possible options. -
Everything after the word
pintosand before the double-dash--are the arguments to thepintosprogram, i.e.,--qemu -k -T 60in our example above. -
Everything after the double-dash
--are the arguments passed to the PintOS kernel, i.e.,-q run alarm-singlein our example above.
-
Running all the tests
| Even before you add any code to the project, some of the existing test will pass and some will fail. Your goal is to make all the tests pass. Ensure that your code makes failing tests pass and makes passing test still pass. |
To run all the tests for a project
Running all the tests for the project thread will take time.
|
-
Navigate to the projects folder
cd $PINTOS_HOME/pintos/src/vm
-
Build the project
make
-
Navigate to the newly created
buildfoldercd build
-
Build all the test with the target
checkmake check
If you want to see the output on your terminal pass in the
VERBOSE=1argument tomake, i.e.make VERBOSE=1 check
Note that the tests take some time to complete depending on how fast your machine is.