Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
COMP(2041|9044) 25T2: Software Construction
Assignment 1: MyGive
BETA RELEASE - SPECIFICATION STILL BEING UPDATED
Minor updates to specification and reference implementation still occurring
Aims
This assignment aims to give you
practice in Shell programming generally
Introduction
You are going to implement a simple but functional assignment submission, testing & marking system.
Your task in this assignment is to write 8 shell scripts named mygive-add mygive-submit mygive-summary mygive-status mygive-fetch mygive-test mygive-mark mygive-rm .
Reference implementation
Many aspects of this assignment are not fully specified in this document; instead, you must match the behaviour of a reference implementation.
For example, your script mygive-add should match the behaviour of 2041 mygive-add exactly, including producing the same error messages.
A reference implementation is a common method to provide an operational specification, and it's something you will likely encounter after you leave UNSW.
Discovering and matching the reference implementation's behaviour is deliberately part of the assignment.
While the code in the reference implementation is fairly straightforward, reverse-engineering its behaviour is obviously not so simple, and is a nice example of how coming to grips with the precise semantics of an apparently obvious task can still be challenging.
If you discover what you believe to be a bug in the reference implementation, report it in the class forum. We may fix the bug, or indicate that you do not need to match the reference implementation's behaviour in this case.
Storing information in .mygive
Your MyGive commands will need to store information.
They should do this by creating a directory in the current directory named .mygive and creating files and/or sub-directories with it as needed. They should not store information elsewhere.
You can choose what information you store in .mygive and you can choose how to store it.
The reference implementation also stores information in .mygive in a subdirectory named .reference. Do not change anything in this directory or store files in this directory. You do not have to create the same file or directories as the reference implementation.
Note, normally a system like this would store this information in a separate directory owned by another user, e.g it might be stored in /home/cs2041/work and owned by cs2041 . For the purposes of this assignment, we are storing it in .mygive.
Note, also some of the commands below would normally be run by the course lecturer (mygive-add, mygive-summary, mygive-mark, mygive-rm) and some by students (mygive-submit, mygive-status, mygive-fetch, mygive-test). For the purposes of this assignment, you are running all of them.
MyGive Commands
mygive-add
mygive-add command creates a new MyGive assignment.
Its first argument should be the name of the assignment. Assignment names must start with a lowercase letter ([a-z]) and be followed only by letters, number and underscore ([a-zA-Z0-9_]).
Its second argument should be the pathname of a file containing tests for the assignment. The pathname should only contain letters ([a-zA-Z]), numbers ([0-9]), underscore ('_'), dash ('-'), dot ('.') and slash ('/').
The format of the test file is described below.
HINT:
mygive-add should create .mygive if it doesn't exist and copy the files supplied to a suitable place.
mygive-submit
mygive-submit makes a submission for the assignment by a student.
Its first argument should be the name of the assignment.
Its second argument should be the zid of the student.
Its third argument should be the pathname of the file containing the submission. The pathname should only contain letters ([a-zA-Z]), numbers ([0-9]), underscore ('_'), dash ('-'), dot ('.') and slash ('/').
A student zid should be a 'z' followed by 7 digits.
Students can make multiple submissions. Only their last submission is marked but all submissions can be retrieved (see below).
mygive-summary
mygive-summary lists all assignments, with a count of how many students have made submissions. It takes no arguments.
mygive-status
mygive-status lists all submissions a student has made.
Its first argument should be the zid of the student.
mygive-fetch [n]
mygive-fetch outputs the contents of a submission the student has made.
Its first argument should be the name of the assignment.
Its second argument should be the zid of the student.
Its optional third argument is the number of the submission to print. It should be an integer. If the third argument is omitted, the last submission should be printed.
Non-positive integers specify submissions relative to the last submission. Zero specifies the last submission, -1 the second-last submission, -2 the third-last submission, and so on.
mygive-test
mygive-test runs the tests supplied to students for an assignment on a program.
Its first argument should be the name of the assignment.
Its second argument should be the name of the file containing the program to be tested. The filename should only contain letters ([a-zA-Z]), numbers ([0-9]), underscore ('_'), dash ('-'), dot ('.') and slash ('/').
Note, only tests without marks specified should be run.
HINT:
The reference implementation describes a failed test differently when the program being tested produces no output when output is expected or vice-versa.
The reference implementation describes a failed test differently if there is an extra newline or a missing newline.
You will need to use the reference implementation to determine the exact behavior for test options.
WARNING:
Trailing newlines (empty lines) are not captured in shell command substitution, e.g. after running variable="$(command)" , $variable will not contain any trailing empty lines.
You may wish instead to use temporary files to capture stdout and stderr.
The reference implementation describes a failed test differently if there is an extra newline or a missing newline.
You will need to use the reference implementation to determine the exact behavior for options
mygive-mark
mygive-mark runs the marking tests for an assignment on the last submission of each student.
Its first argument should be the name of the assignment.
Note, only tests with marks specified should be run.
mygive-rm
mygive-rm removes an assignment.
Its first argument should be the name of the assignment.
Examples
Here are some simple examples of how your 8 shell scripts should behave.
You will need to use the reference implementation to discover much more about exactly how your scripts should behave.
Tests file format
A tests file is a tar file containing one directory for each test. When a new assignment is created, mygive-add is supplied a tar file. This tar file contains a directory for each test that can be run for the assignment.
Directory names must start with a lowercase letter ([a-z]) and be followed only by letters, numbers and underscore ([a-zA-Z0-9_]). MyGive uses the directory name as the name of the individual test.
Each directory will contain 0-7 files and nothing else.
The files will only have these names: arguments, stdin, options, stdout, stderr, exit_status, marks.
All of these files may or may not be present in a directory.
No other files will be present.
The arguments file will contain a single line specifying the arguments, if any, for the test. Arguments should only contain the characters [a-zA-Z0-9_.-]. Multiple arguments should be separated by spaces.
If the arguments file is not present, the test should be run with no arguments.
The stdin file should contain the stdin for the test. It will contain 0 or more ASCII bytes.
If the stdin file is not present, the test should be run with no bytes on stdin. This is equivalent to the stdin file being empty (containing zero bytes).
The options file will contain a single line with zero or more of the characters [bcdw]. This should be zero or more of the characters [bcdw] in any order. Options apply when comparing both stdout and stderr to the correct output.
If the option b is specified, differences regarding empty lines should be ignored.
If the option c is specified, differences in case (uppercase versus lowercase) should be ignored.
If the option d is specified, differences regarding characters other than [0-9] and '\n' should be ignored.
If the option w is specified, differences in space (' ') and tab ('\t') characters should be ignored.
The stdout file will contain the expected stdout for the test. It will contain only ASCII bytes. If the stdout file is not present, no output on stdout is expected.
The stderr file will contain the expected stderr for the test. It will contain only ASCII bytes. If the stderr file is not present, no output on stderr is expected.
The exit_status file should contain a single line with an integer 0-127 specifying the expected exit status for the test. If the exit_status file is not present, the expected exit status is 0.
The marks file should contain a single line with a positive integer specifying the marks for the test.
If the marks file is not present, the test should be run by mygive-test but not by mygive-mark.
If the marks file is present, the test should be run by mygive-mark but not by mygive-test.
HINT:
To run tests, you will need to use the directories and files archived in the test files. The test files are tar files.
A tar file is an archive of multiple files. The tar command can be used to extract, list contents and create tar files.
Consider the example below. grep.tests is an example of a test file. It contains directories label1 , label2 , label1_marking , and label2_marking . These directories contain files containing information needed to run each test.
Test Scripts
You should submit ten Shell scripts, named test0.sh to test9.sh , which runs mygive-* commands to test an aspect of MyGive.
The test?.sh scripts do not have to be examples that your program implements successfully.
You may share your test examples with your friends, but the ones you submit must be your own creation.
The test scripts should show how you've thought about testing carefully.
You are only expected to write test scripts testing parts of MyGive you have attempted to implement. For example, if you have not implemented mygive-test you are not expected to write test scripts testing mygive-test .
We won't actually execute your test scripts.
The marking of test scripts will focus on the testing they do rather than their style.
We are expecting test script of 20-100 lines in size.
HINT:
Your test script might run a series of mygive commands, checking the output after each one. If any output is incorrect, it might stop and indicate which command failed; otherwise, it might print a message saying all tests passed.