Autotest v2 Filesystem

Autotest v2 runs Ubuntu 20.04 on a Virtual Machine (VM) and as such you should keep in mind the structure of the VM filesystem when designing your automatic assignment. While you can help yourself navigate the filesystem with basic bash commands such as pwd, ls or cd, this page sums up the basics you need to remember.

Setup

In the Setup tab one usually installs software via script blocks and upload fixtures to later run tests. Software can be installed, in case there is no builtin block for that, using a script block that allows you to run bash scripts. At the beginning of every block your current directory is /home/codegrade as you can verify by using the bash command pwd. Also keep in mind that in the Setup tab you have superuser permissions so you can prepend sudo to commands that require such permissions. It is also important to remark that during the Setup you have no access to the student submission folder, so this means that any operation that involves the student's files has to executed in the next Test Tab (see below). Fixtures can be uploaded using the upload file block. Fixtures will be then uploaded to the folder /home/codegrade/fixtures which can be easily accessed using the builtin bash variable UPLOADED_FILES. For instance, if you want to verify the correct uploading of your files, you can add a script block below the upload file block and type the following bash commands:

cd $UPLOADED_FILES # same as cd /home/codegrade/fixtures
ls

Test

In the Test tab, for all the blocks, the initial current directory is /home/codegrade/student. In this folder you can find the whole student's submission as you can check with the bash command ls.

In the Test tab you have no more superuser permission as you generally don't want the student's code to run with such permission. Say for example that you uploaded as a fixture a custom python script named my_tests.py that runs some tests on the student's submission. In order to run it you would then type, within the appropriate block type (script, IO test, custom test), something like:

python3 $UPLOADED_FILES/my_tests.py <STUDENT_SUBMISSION_FILE>

Alternatively you may decide, before running any test, to move all the uploaded fixtures into the student directory. This can be done by running the following command within a script block at the beginning of the Test tab:

mv $UPLOADED_FILES/* .

Then our custom script would be directly available in the student directory and we could use it as follows:

python my_tests.py <STUDENT_SUBMISSION_FILE>

Last updated