Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Adding new tests to Pintos

Pintos also comes with its own testing framework that allows you to design and run your own tests. For this project, you will also be required to extend the current suite of tests with a few tests of your own. All of the file system and userprog tests are “user program” tests, which means that they are only allowed to interact with the kernel via system calls.

Some things to keep in mind while writing your test cases:

  • User programs have access to a limited subset of the C standard library. You can find the user library in lib/.
  • User programs cannot directly access variables in the kernel.
  • User programs do not have access to malloc, since brk and sbrk are not implemented. User programs also have a limited stack size. If you need a large buffer, make it a static global variable.
  • Pintos starts with 4 MB of memory and the file system block device is 2 MB by default. Don’t use data structures or files that exceed these sizes.
  • Your test should use msg() instead of printf() (they have the same function signature).

You can add new test cases to the userprog suite by modifying these files:


Entry point for the userprog test suite. You need to add the name of your test to the tests/userprog_TESTS variable, in order for the test suite to find it. Additionally, you will need to define a variable named tests/userprog/my-test-1_SRC which contains all the files that need to be compiled into your test (see the other test definitions for examples). You can add other source files and resources to your tests, if you wish.


This is the test code for your test. Your test should define a function called test_main, which contains a user-level program. This is the main body of your test case, which should make syscalls and print output. Use the msg() function instead of printf.


Every test needs a .ck file, which is a Perl script that checks the output of the test program. If you are not familiar with Perl, don’t worry! You can probably get through this part with some educated guessing. Your check script should use the subroutines that are defined in tests/ At the end, call pass to print out the “PASS” message, which tells the Pintos test driver that your test passed.