首页 > > 详细

CSSE2310/CSSE7231 Assignment 3

 The University of Queensland

School of Information Technology and Electrical Engineering
CSSE2310/CSSE7231 — Semester 1, 2023
Assignment 3 (version 1.0)
Marks: 75 (for CSSE2310), 85 (for CSSE7231)
Weighting: 15%
Due: 4:00pm Friday 5th May, 2023
Introduction 1
The goal of this assignment is to demonstrate your skills and ability in fundamental process management and 2
communication concepts, and to further develop your C programming skills with a moderately complex program. 3
You are to create a program called testuqwordiply that creates and manages communicating collections 4
of processes that test a uqwordiply program (from assignment one) according to a job specification file that 5
lists tests to be run. For various test cases, your program will run both a test version of uqwordiply and the 6
assignment one solution (available as demo-uqwordiply) and compare their standard outputs, standard errors 7
and exit statuses and report the results. You will be provided with (and must use) a program named uqcmp 8
that will compare the input arriving on two file descriptors. The assignment will also test your ability to code 9
to a programming style guide and to use a revision control system appropriately. 10
CSSE7231 students will, in addition, write their own version of uqcmp. 11
Student Conduct 12
This is an individual assignment. You should feel free to discuss general aspects of C programming and 13
the assignment specification with fellow students, including on the discussion forum. In general, questions like 14
“How should the program behave if h this happensi ?” would be safe, if they are seeking clarification on the 15
specification. 16
You must not actively help (or seek help from) other students or other people with the actual design, structure 17
and/or coding of your assignment solution. It is cheating to look at another student’s assignment code 18
and it is cheating to allow your code to be seen or shared in printed or electronic form by others. 19
All submitted code will be subject to automated checks for plagiarism and collusion. If we detect plagiarism or 20
collusion, formal misconduct actions will be initiated against you, and those you cheated with. That’s right, if 21
you share your code with a friend, even inadvertently, then both of you are in trouble. Do not post your 22
code to a public place such as the course discussion forum or a public code repository. (Code in private posts 23
to the discussion forum is permitted.) You must assume that some students in the course may have very long 24
extensions so do not post your code to any public repository until at least three months after the result release 25
date for the course (or check with the course coordinator if you wish to post it sooner). Do not allow others to 26
access your computer – you must keep your code secure. Never leave your work unattended. 27
You must follow the following code referencing rules for all code committed to your SVN repository 28
(not just the version that you submit): 29
Code Origin Usage/Referencing
Code provided to you in writing this semester by
CSSE2310/7231 teaching staff (e.g. code hosted on Black￾board, found in /local/courses/csse2310/resources on
moss, posted on the discussion forum by teaching staff, pro￾vided in Ed Lessons, or shown in class).
May be used freely without reference. (You must be able
to point to the source if queried about it – so you may
find it easier to reference the code.)
Code you have personally written this semester for
CSSE2310/7231 (e.g. code written for A1 reused in A3)
– provided you have not shared or published it.
May be used freely without reference. (This assumes
that no reference was required for the original use.)
Code examples found in man pages on moss. May be used provided you understand the code AND
the source of the code is referenced in a comment
adjacent to that code (in the required format – see the
style guide). If such code is used without appropriate
referencing then this will be considered misconduct.
Code you have personally written in a previous enrolment
in this course or in another ITEE course and where that
code has not been shared or published.
Code (in any programming language) that you have taken
inspiration from but have not copied1
.
1Code you have taken inspiration from must not be directly copied or just converted from one programming language to another.
1
Code Origin Usage/Referencing
Code written by or obtained from, or based on code written
by or obtained from, a code generation tool (including any
artificial intelligence tool) that you personally have inter￾acted with, without the assistance of another person.
May be used provided you understand that code AND
the source of the code is referenced in a comment ad￾jacent to that code (in the required format) AND an
ASCII text file (named toolHistory.txt) is included in
your repository and with your submission that describes
in detail how the tool was used. If such code is used
without appropriate referencing and without inclusion
of the toolHistory.txt file then this will be considered
misconduct.
Other code – includes (but may not be limited to): code
provided by teaching staff only in a previous offering of this
course (e.g. previous assignment one solution); code from
public or private repositories; code from websites; code
from textbooks; any code written or partially written or
provided by or written with the assistance of someone else;
and any code you have written that is available to other
students.
May not be used. If the source of the code is referenced
adjacent to the code then this will be considered code
without academic merit (not misconduct) and will be
removed from your assignment prior to marking (which
may cause compilation to fail and zero marks to be
awarded). Copied code without adjacent referencing will
be considered misconduct and action will be taken.
Uploading or otherwise providing the assignment specification or part of it to a third party including online 30
tutorial and contract cheating websites is considered misconduct. The university is aware of these sites and 31
many cooperate with us in misconduct investigations. 32
The teaching staff will conduct interviews with a subset of students about their submissions, for the purposes 33
of establishing genuine authorship. If you write your own code, you have nothing to fear from this process. If 34
you legitimately use code from other sources (following the usage/referencing requirements in the table above) 35
then you are expected to understand that code. If you are not able to adequately explain the design of your 36
solution and/or adequately explain your submitted code (and/or earlier versions in your repository) and/or 37
be able to make simple modifications to it as requested at the interview, then your assignment mark will be 38
scaled down based on the level of understanding you are able to demonstrate and/or your submission may be 39
subject to a misconduct investigation where your interview responses form part of the evidence. Failure to 40
attend a scheduled interview will result in zero marks for the assignment. The use of referenced code in your 41
submission (particularly from artificial intelligence tools) is likely to increase the probability of your selection 42
for an interview. 43
In short - Don’t risk it! If you’re having trouble, seek help early from a member of the teaching staff. 44
Don’t be tempted to copy another student’s code or to use an online cheating service. Don’t help another 45
CSSE2310/7231 student with their code no matter how desperate they may be and no matter how close your 46
relationship. You should read and understand the statements on student misconduct in the course profile and 47
on the school website: https://www.itee.uq.edu.au/itee-student-misconduct-including-plagiarism. 48
Specification – testuqwordiply 49
testuqwordiply reads a set of test jobs from a file whose name is provided as a command line argument. (The 50
format of this file is specified below.) For each of these test jobs, testuqwordiply will run both a program to be 51
tested (whose name is given on the command line, e.g. your solution to assignment one) and demo-uqwordiply 52
and compare their outputs (stdout and stderr) and their exit statuses. If the stdout, stderr and exit statuses 53
match, then the test passes, otherwise it fails. The comparison of the programs’ outputs will require the use 54
of a provided comparison program called uqcmp which reads input on file descriptors 3 and 4 (e.g. piped from 55
stdout from each of the programs) and reports whether that data is the same or different. 56
Figure 1 illustrates the processes and pipes to be created by testuqwordiply for each test job. Four 57
processes will be created (labelled A, B, C and D in Figure 1): an instance of the program being tested (A), an 58
instance of demo-uqwordiply (B) and two instances of uqcmp – one for comparing the standard outputs of the 59
two programs (C) and one for comparing the standard errors (D). This will require the creation of four pipes 60
(labelled 1, 2, 3 and 4 in Figure 1). The standard input for the two programs being tested will come from a file 61
whose name is specified in the job file – this contains sample user input for that test. 62
Full details of the required behaviour are provided below. 63
2
Figure 1: Processes (A to D) and pipes (1 to 4) to be created by testuqwordiply for each test job.
Command Line Arguments 64
testuqwordiply has two mandatory arguments – the name of the program being tested, and the name of a 65
job specification file that specifies the tests to be run. There are two optional arguments which may appear in 66
either order if both are present (but must appear before the mandatory arguments). 67
Usage of the program and the meaning of the arguments are as follows: 68
./testuqwordiply [--quiet] [--parallel] testprogram jobfile 69
• --quiet – if present, the output (stdout and stderr) of the uqcmp processes is to be suppressed (i.e. not 70
shown), otherwise it should be output to testuqwordiply’s stdout and stderr respectively. This option 71
does not change testuqwordiply’s output – it will still send output to stdout and stderr as described 72
in this specification. This behaviour is described in more detail below. 73
• --parallel – if present, the test jobs are to be run in parallel, otherwise they should be run sequentially 74
(one after the other). This behaviour is explained in more detail below. 75
• testprogram – must be present and is the name of the program being tested against demo-uqwordiply. 76
The name can be a relative or absolute pathname or otherwise (if it doesn’t contain a slash ‘/’) is expected 77
to be found on the user’s PATH. The argument may not begin with --. (If a program’s name begins with 78
-- then the path to the program must be given, e.g. ./--prog.) 79
• jobfile – must be present (after the program name) and is the name of the file containing details of the 80
tests to be run (referred to in the remainder of this document as the job specification file). More details 81
on the format of this file are given below. The argument may not begin with --. (If a file’s name begins 82
with -- then the path to the file must be given, e.g. ./--jobfile.) 83
Prior to doing anything else, your testuqwordiply program must check the validity of the command line 84
arguments. If the program receives an invalid command line then it must print the message: 85
Usage: testuqwordiply [--quiet] [--parallel] testprogram jobfile 86
to standard error (with a following newline) and exit with an exit status of 2. 87
Invalid command lines include (but may not be limited to) any of the following: 88
• arguments that begin with -- that are not either --quiet or --parallel2
89
• either the --quiet or --parallel argument is specified more than once 90
• the program name and/or the job file name are not specified on the command line 91
• an unexpected argument is present 92
Checking whether the program name and/or the file name are valid is not part of usage checking. 93
2To allow for getopt() implementations of argument parsing (not required) we will not run any tests using the argument --
3
Job Specification File 94
If the command line arguments are valid then testuqwordiply reads the job specification file listed on the 95
command line. The whole file must be read and checked prior to any test jobs being run. 96
If testuqwordiply is unable to open the job specification file for reading then it must print the following 97
message to stderr (with a following newline) and exit with an exit status of 3: 98
testuqwordiply: Unable to open job file "filename " 99
where filename is replaced by the name of the file (as given on the command line). (The double quotes around 100
the filename must be present in the output message.) 101
File Format 102
The job specification file provided to testuqwordiply is a text file, with one line per job. The file may contain 103
any number of lines. 104
If testuqwordiply is able to open the job specification file for reading, then it should read and check all of 105
the test jobs in the file before starting any tests. 106
Lines in the job file beginning with the ‘#’ (hash) character are comments3
, and are to be ignored by 107
testuqwordiply. Similarly, empty lines (i.e. with no characters before the newline) are to be ignored. 108
All other lines are to be interpreted as job specifications, split over 2 separate fields delimited by the comma 109
(‘,’) character as follows: 110
input-file-name,[arg1 arg2 ...] 111
The input-file-name field is the name of a file to be used as the standard input to the the test program 112
and to demo-uqwordiply for that test. It may be an absolute pathname or relative to the current directory. It 113
must not be an empty field. 114
The second field is a space separated list of command line arguments to be provided to the test program 115
and to demo-uqwordiply when the test is run. This field may be empty. Arguments that contain spaces may 116
be enclosed by double quotes. Leading spaces and extra separating spaces are ignored. (A helper function is 117
provided to make processing this field easier, see the split_space_not_quote() function described on page 118
10.) 119
Note that individual job specifications are independent – a given test job will always be run in the same way 120
independent of any other test jobs described in the file. 121
The comma character has special meaning in job specification files and will only appear in job lines as a 122
separator. You do not need to consider, nor will we test for, job specification files that contain the comma 123
character as part of a file name or an argument. See the split_line() function described on page 10 for an 124
easy way to split the comma-delimited job specifications. 125
Checking the Jobs 126
Each job listed in the job specification file must be checked in turn. If a job line is not syntactically valid then 127
testuqwordiply must print the following message to stderr (with a following newline) and exit with an exit 128
status of 4: 129
testuqwordiply: syntax error on line linenum of "filename " 130
where linenum is replaced by the line number in the job specification file (where lines are counted from 1), and 131
filename is replaced by the name of the job specification file (as given on the command line). (The double 132
quotes around the filename must be present in the output message.) No further job lines are checked. 133
A syntactically valid line will contain exactly one comma with at least one character before the comma (i.e. 134
a non-empty input filename). 135
If the line is syntactically valid but the input file specified on the job line is unable to be opened for reading, 136
then testuqwordiply must print the following message to stderr (with a following newline) and exit with an 137
exit status of 5: 138
testuqwordiply: unable to open file "inputfile " specified on line linenum of "filename " 139
where inputfile is replaced by the name of the file specified on the job line (all characters before the comma), 140
linenum is replaced by the line number in the job specification file (where lines are counted from 1), and 141
3“beginning with” means the # character is in the leftmost position on the line – there are no preceding spaces or other characters
4
filename is replaced by the name of the job specification file (as given on the command line). (The double 142
quotes around both filenames must be present in the output message.) 143
If these checks are passed (the line is syntactically valid and the input file can be opened for reading) then 144
testuqwordiply can move on to the next line in the job file. 145
If testuqwordiply reaches the end of the file and doesn’t find any job specifications (i.e. the file is empty or 146
only contains blank lines and/or comments) then testuqwordiply must print the following message to stderr 147
(with a following newline) and exit with an exit status of 6: 148
testuqwordiply: no jobs found in "filename " 149
where filename is replaced by the name of the job specification file (as given on the command line). (The 150
double quotes around the filename must be present in the output message.) 151
The following are examples of valid jobfiles4
containing explanatory comments:
# Run a single test with no command line arguments and an immediate EOF on stdin
/dev/null,
# Run two tests - specifying the starter word in both cases
testfiles/cab,--start cab
input-file,--start PRO
# Run four tests - with various combinations of starter word and dictionary
# Also illustrates use of double quotes and additional spaces in arguments
input.1,--start art --dictionary testfiles/common-words
2.in,--dictionary "testfiles/simple dictionary" "--start" ion
3.in, --start xyz --dictionary /dev/null
# Blank line on the line above will be ignored
2.in,--dictionary /usr/share/dict/words --start def
Running Test Jobs and Reporting Results 152
If all of the test jobs in the job specification file are valid then testuqwordiply must run the jobs, either in 153
sequence (one after the other) or in parallel (if the --parallel argument is provided on the command line). 154
The behaviour of these two different modes is described below. 155
Running Test Jobs Sequentially 156
If testuqwordiply is running jobs sequentially, then it must perform the following sequence of operations: 157
For each job (in the order specified in the job specification file): 158
• Start the job (as described below in Running One Test Job) 159
• Sleep for 2 seconds 160
• Send a SIGKILL signal to all processes that make up that job. (It is likely they are already dead, but 161
testuqwordiply does not need to check this prior to attempting to send a signal.) 162
• Report the result of the job (as described below in Reporting the Result of One Test Job). 163
When one job is complete, the next job can be started. 164
Running Test Jobs In Parallel 165
If testuqwordiply is running jobs in parallel, then it must perform the following sequence of operations: 166
• Start all of the jobs specified in the job specification file (each individual job should be started as described 167
below in Running One Test Job) 168
• Sleep for 2 seconds 169
4This assumes that all of the listed input files are valid readable files in the current directory.
5
• Send a SIGKILL signal to all processes that make up all jobs. (It is likely they are already dead, but 170
testuqwordiply does not need to check this prior to attempting to send a signal.) 171
• Iterate over each job (in the order specified in the job specification file) and report the result of the job 172
(as described below in Reporting the Result of One Test Job). 173
Running One Test Job 174
Just before running a test job, testuqwordiply must output the following to standard output (followed by a 175
newline): 176
Starting job T 177
where T is replaced by the job number (1 to N, where N is the number of jobs in the job specification file). 178
For each individual test job, testuqwordiply must create four pipes and four processes as shown in Figure 1. 179
The four processes are: 180
• an instance of the program being tested (as specified on the command line). Standard input for this 181
process must come from the input file specified in the job. Standard output and standard error must be 182
sent to file descriptor 3 of two instances of uqcmp (see description of uqcmp instances below). 183
• an instance of demo-uqwordiply – which will be found in the user’s PATH. Standard input for this process 184
must come from the input file specified in the job. Standard output and standard error must be sent to 185
file descriptor 4 of the two instances of uqcmp. This is the expected output from the test program. 186
• an instance of uqcmp which compares standard outputs – which will receive the standard output of the 187
program being tested on file descriptor 3 and the standard output of demo-uqwordiply on file descriptor 188
4. uqcmp must be started with one command line argument: “Job T stdout” where T is replaced by the 189
job number. 190
• an instance of uqcmp which compares standard errors – which will receive the standard error of the 191
program being tested on file descriptor 3 and the standard error of demo-uqwordiply on file descriptor 192
4. uqcmp must be started with one command line argument: “Job T stderr” where T is replaced by the 193
job number. 194
If the --quiet option is provided on the testuqwordiply command line then the standard output and 195
standard error of the uqcmp instances must be redirected to /dev/null. If --quiet is not specified, then the 196
uqcmp instances must inherit standard output and standard error from testuqwordiply – i.e. send standard 197
output and standard error to wherever testuqwordiply’s standard output and standard error are being sent. 198
Reporting the Result of One Test Job 199
uqcmp will exit with an exit status of 0 if the data received on file descriptor 3 matches that received on file 200
descriptor 4, otherwise it will exit with a non-zero exit status. Full details on the behaviour of the uqcmp 201
program are given below. 202
If any of the programs were unable to be executed (demo-uqwordiply, uqcmp or the program under test) 203
then testuqwordiply must print the following to standard output (followed by a newline): 204
Job T : Unable to execute test 205
where T is replaced by the job number. This counts as a test failure. (If one test job fails then all test jobs are 206
likely to fail. A possible scenario is where one of the programs is not found in the user’s PATH.) 207
If the four programs run, then for one individual test (say job number T), testuqwordiply must report the 208
following – in this given order. (In all of the messages below, T is replaced by the job number. All messages 209
are sent to testuqwordiply’s standard output and are terminated by a single newline.) 210
• If the standard outputs of the two programs match (as determined by the exit status of that uqcmp 211
instance), then testuqwordiply must print the following: 212
Job T : Stdout matches 213
If the standard outputs do not match, then testuqwordiply must print the following: 214
Job T : Stdout differs 215
6
• If the standard errors of the two programs match (as determined by the exit status of that uqcmp instance), 216
then testuqwordiply must print the following: 217
Job T : Stderr matches 218
If the standard errors do not match, then testuqwordiply must print the following: 219
Job T : Stderr differs 220
• If both processes exit normally with the same exit status, then testuqwordiply must print the following: 221
Job T : Exit status matches 222
otherwise it must print: 223
Job T : Exit status differs 224
Reporting the Overall Result 225
A test passes if the standard output, standard error and exit statuses of the program being tested and 226
demo-uqwordiply all match each other. 227
For both sequential and parallel modes of operation, when all test jobs have been run and finished, then 228
testuqwordiply must output the following message to stdout (followed by a newline): 229
testuqwordiply: M out of N tests passed 230
where M is replaced by the number of tests that passed, and N is replaced by the number of tests that have been 231
run (which may be fewer than the number of the tests in the job specification file if the tests are interrupted – 232
see below). 233
If all tests that have been run passed then testuqwordiply must exit with exit status 0 (indicating success), 234
otherwise it must exit with exit status 1 (indicating failure). 235
Interrupting the Tests 236
If testuqwordiply receives a SIGINT (as usually sent by pressing Ctrl-C) then it should complete the test job(s) 237
in progress (including any sleeps), not commence any more test jobs, and report the overall result (as described 238
above) based on the tests that have been run. 239
In practical terms, this will only make a difference in sequential mode – tests that haven’t been started will 240
not be run. In parallel mode, all tests are started immediately, so all tests should be run to completion if a 241
SIGINT is received. 242
Specification – uqcmp 243
This section details the expected operation of uqcmp. Only CSSE7231 students are required to implement 244
uqcmp, but this section is useful to all students so as to understand how uqcmp behaves. The UQ provided version 245
of uqcmp will be used in testing testuqwordiply. uqcmp programs implemented by CSSE7231 students will be 246
tested independently of testuqwordiply. 247
uqcmp will read from file descriptors 3 and 4, compare the data read from both file descriptors, and determine 248
whether it is the same. The data read from file descriptor 4 is considered to be the “expected” (i.e. “correct”) 249
data, and is being compared with that received from file descriptor 3. 250
uqcmp Command Line Arguments 251
uqcmp takes one optional command line argument – a prefix that is to be emitted with messages that are output 252
(see below). 253
If more than one command line argument is provided, then uqcmp is to output the following message to 254
standard error (with a following newline) and then exit with exit status 1: 255
Usage: uqcmp [prefix] 256
If no prefix is specified on the command line then the prefix “uqcmp” is to be used (without the quotes). 257
uqcmp Operation 258
If file descriptor 3 is not open, then uqcmp must output the following message to standard error (with a following 259
newline) and then exit with status 2: 260
7
uqcmp: fd 3 is not open 261
If file descriptor 3 is open and file descriptor 4 is not open, then uqcmp must output the following message 262
to standard error (with a following newline) and then exit with status 2: 263
uqcmp: fd 4 is not open 264
If both file descriptors are open, then uqcmp will print a message (with a following newline) and exit as 265
described below. The text PREFIX is to be replaced by the prefix specified on the command line (or uqcmp if 266
no prefix is specified on the command line). 267
• If identical data is received from both file descriptors 3 and 4 (from commencement to EOF) then uqcmp 268
must print the following to stdout: 269
PREFIX : OK 270
and exit with status 0. 271
• If no data is received on file descriptor 3 but data is received on file descriptor 4 then uqcmp must print 272
the following to stderr: 273
PREFIX : Expected data but received nothing 274
and exit with status 3. 275
• If data is received on file descriptor 3 but no data is received on file descriptor 4 then uqcmp must print 276
the following to stderr: 277
PREFIX : Received data but expected nothing 278
and exit with status 4. 279
• If data is received on both file descriptors 3 and 4 but this data does not match then uqcmp must print 280
the following to stderr: 281
PREFIX : Received data does not match expected data 282
and exit with status 5. 283
uqcmp may exit at any point after it is able to make this determination – i.e. it does not have to wait for 284
EOF on both file descriptors in order to exit if it has identified differences – though it may wait until then if 285
desired. 286
uqcmp ignores its standard input. 287
Testing uqcmp 288
You can test uqcmp at the command line by getting the shell to redirect files or standard input to file descriptors 289
3 and/or 4, e.g. 290
./uqcmp 3<&1 4
will redirect file descriptor 3 from standard input and file descriptor 4 from /dev/null. 292
Other Functionality – uqcmp and testuqwordiply 293
It is not expected that uqcmp has any special signal handling capability. 294
It is expected that testuqwordiply frees all dynamically allocated memory before exiting. (This requirement 295
does not apply to child processes of testuqwordiply.) 296
It is expected that child processes created by testuqwordiply do not inherit unnecessary open file descrip- 297
tors. 298
Example testuqwordiply Output 299
In this section we give examples of expected testuqwordiply output for some given job specification files and 300
command lines. Note that two programs that call get_wordiply_starter_word() at about the same time will 301
receive the same starter word – the random number generator in this program is seeded by the current time (in 302
seconds). 303
Note that these examples, like provided test-cases, are not exhaustive. You need to implement the program 304
specification as it is written, and not just code for these few examples. 305
8
Example One 306
Consider a job specification file as follows (named job1): 307
1 # One job - no command line args, immediate EOF on stdin
2 /dev/null,
In the following runs of testuqwordiply, assume that ./uqwordiply is a fully functional program. 308
1 $ ./testuqwordiply ./uqwordiply job1
2 Starting job 1
3 Job 1 stdout: OK
4 Job 1 stderr: OK
5 Job 1: Stdout matches
6 Job 1: Stderr matches
7 Job 1: Exit status matches
8 testuqwordiply: 1 out of 1 tests passed
9 $ ./testuqwordiply --quiet ./uqwordiply job1
10 Starting job 1
11 Job 1: Stdout matches
12 Job 1: Stderr matches
13 Job 1: Exit status matches
14 testuqwordiply: 1 out of 1 tests passed
Note that in the first run of testuqwordiply, the first two lines of output (lines 3 and 4 in the listing) 309
are the standard output from the two instances of uqcmp. (These could be printed in either order.) The 310
remaining lines are printed about two seconds later – and will always be in the order shown. In the second run 311
of testuqwordiply, the output of uqcmp is suppressed by using the --quiet command line argument. 312
Example Two 313
In the following example, assume that ./buggy-uqwordiply works correctly except that it exits with a segmen- 314
tation fault when given an empty dictionary. The job specification file job2 has the following contents: 315
1 ./7.era.in, --start ERA
2 7.lay.in,--start LAY --dictionary /dev/null
3 6.1.in, --dictionary /usr/share/dict/words --start top
Assume that 7.lay.in, 7.era.in and 6.1.in are valid input files in the current directory (matching those 316
provided in the assignment one test files found in /local/courses/csse2310/resources/a1/testfiles.public 317
on moss). 318
1 $ time ./testuqwordiply --quiet ./buggy-uqwordiply job2
2 Starting job 1
3 Job 1: Stdout matches
4 Job 1: Stderr matches
5 Job 1: Exit status matches
6 Starting job 2
7 Job 2: Stdout differs
8 Job 2: Stderr matches
9 Job 2: Exit status differs
10 Starting job 3
11 Job 3: Stdout matches
12 Job 3: Stderr matches
13 Job 3: Exit status matches
14 testuqwordiply: 2 out of 3 tests passed
15
16 real 0m6.004s
17 user 0m0.165s
18 sys 0m0.014s
19 $ time ./testuqwordiply --parallel ./buggy-uqwordiply job2
20 Starting job 1
9
21 Starting job 2
22 Starting job 3
23 Job 2 stdout: Expected data but received nothing
24 Job 2 stderr: OK
25 Job 1 stderr: OK
26 Job 1 stdout: OK
27 Job 3 stderr: OK
28 Job 3 stdout: OK
29 Job 1: Stdout matches
30 Job 1: Stderr matches
31 Job 1: Exit status matches
32 Job 2: Stdout differs
33 Job 2: Stderr matches
34 Job 2: Exit status differs
35 Job 3: Stdout matches
36 Job 3: Stderr matches
37 Job 3: Exit status matches
38 testuqwordiply: 2 out of 3 tests passed
39
40 real 0m2.003s
41 user 0m0.165s
42 sys 0m0.012s
The lines shown in green (and the blank line prior to these) are the output of the time utility which reports 319
how much time is taken to run the program. You can see in the first run (sequential mode) that the three tests 320
take about six seconds total to run. In the second run (parallel mode), the three tests take about two seconds 321
total to run. 322
In this second run, the output lines from uqcmp (lines 23 to 28 inclusive) could have been printed in any 323
order. Note that test job 2 failed due to the exit status and standard output contents not matching. 324
Provided Library: libcsse2310a3 325
A library has been provided to you with the following functions which your program may use. See the man 326
pages on moss for more details on these library functions. 327
char* read_line(FILE *stream); 328
The function attempts to read a line of text from the specified stream, allocating memory for it, and returning 329
the buffer. 330
char **split_line(char* line, char delimiter); 331
This function will split a line into substrings based on a given delimiter character. 332
char** split_space_not_quote(char *input, int *numTokens); 333
This function takes an input string and tokenises it according to spaces, but will treat text within double quotes 334
as a single token. 335
To use the library, you will need to add #include to your code and use the compiler flag 336
-I/local/courses/csse2310/include when compiling your code so that the compiler can find the include 337
file. You will also need to link with the library containing this function. To do this, use the compiler arguments 338
-L/local/courses/csse2310/lib -lcsse2310a3. 339
Style 340
Your program must follow version 2.3.0 of the CSSE2310/CSSE7231 C programming style guide available on 341
the course Blackboard site. 342
Hints 343
1. Make sure you review the lecture/contact content and examples and the Ed Lessons exercises from weeks 344
6 and 7. These provide the necessary background for this assignment. 345
10
2. While not mandatory, the provided library functions will make your life a lot easier – use them! 346
3. You can examine the file descriptors associated with a process by running ls -l /proc/PID/fd where 347
PID is the process ID of the process. 348
4. If you implement the test interruption functionality, consider the use of nanosleep() to allow resumption 349
of interrupted sleeps. 350
5. uqcmp (CSSE7231): You can determine if a file descriptor is open by trying to use it in a function that 351
will report an error if it is not open, e.g. fdopen(), dup(), fcntl(), etc. 352
Suggested Approach 353
It is suggested that you write your program using the following steps. Test your program at each stage and 354
commit to your SVN repository frequently. Note that the specification text above is the definitive description 355
of the expected program behaviour. The list below does not cover all required functionality but will get you 356
started. 357
1. Write a program to parse the expected command line arguments and handle usage errors. 358
2. Write code to read and parse the job specification file and save it to a data structure (and output error 359
messages if problems are found). 360
3. Write code that correctly starts the four processes associated with one job (with the necessary command 361
line arguments). 362
4. Add code to redirect the standard input of the program under test and testuqwordiply. 363
5. Add code to create the four pipes and connect them as required to the four processes. 364
Forbidden Functions 365
You must not use any of the following C functions/statements. If you do so, you will get zero (0) marks for the 366
assignment. 367
• goto 368
• longjmp() and equivalent functions 369
• system() or popen() 370
• mkfifo() or mkfifoat() 371
Submission 372
Your submission must include all source and any other required files (in particular you must submit a Makefile). 373
Do not submit compiled files (e.g. .o files and compiled programs). 374
Your programs testuqwordiply and uqcmp (CSSE7231 only) must build on moss.labs.eait.uq.edu.au 375
with the command: 376
make 377
Your program must be compiled with gcc with at least the following options: 378
-pedantic -Wall -std=gnu99 379
You are not permitted to disable warnings or use pragmas to hide them. You may not use source files other 380
than .c and .h files as part of the build process – such files will be removed before building your program. 381
CSSE7231 only – the default target of your Makefile must cause both programs to be built5
. 382
If any errors result from the make command (i.e. no executable is created) then you will receive 0 marks 383
for functionality (see below). Any code without academic merit will be removed from your program before 384
compilation is attempted (and if compilation fails, you will receive 0 marks for functionality). 385
5
If you only submit an attempt at one program then it is acceptable for just that single program to be built when running make.
11
Your program must not invoke other programs or use non-standard headers/libraries other than those 386
explicity described in this specification. 387
Your assignment submission must be committed to your subversion repository under 388
https://source.eait.uq.edu.au/svn/csse2310-sem1-sXXXXXXX/trunk/a3 389
where sXXXXXXX is your moss/UQ login ID. Only files at this top level will be marked so do not put source 390
files in subdirectories. You may create subdirectories for other purposes (e.g. your own test files) but these 391
will not be considered in marking – they will not be checked out of your repository. 392
You must ensure that all files needed to compile and use your assignment (including a Makefile) are com- 393
mitted and within the trunk/a3 directory in your repository (and not within a subdirectory or some other part 394
of your repository) and not just sitting in your working directory. Do not commit compiled files or binaries. 395
You are strongly encouraged to check out a clean copy for testing purposes. 396
To submit your assignment, you must run the command 397
2310createzip a3 398
on moss and then submit the resulting zip file on Blackboard (a GradeScope submission link will be made 399
available in the Assessment area on the CSSE2310/7231 Blackboard site)6
. The zip file will be named 400
sXXXXXXX_csse2310_a3_timestamp.zip 401
where sXXXXXXX is replaced by your moss/UQ login ID and timestamp is replaced by a timestamp indicating 402
the time that the zip file was created. 403
The 2310createzip tool will check out the latest version of your assignment from the Subversion repository, 404
ensure it builds with the command ‘make’, and if so, will create a zip file that contains those files and your 405
Subversion commit history and a checksum of the zip file contents. You may be asked for your password as 406
part of this process in order to check out your submission from your repository. You will be asked to confirm 407
references in your code. 408
You must not create the zip file using some other mechanism and you must not modify the zip file prior 409
to submission. If you do so, you will receive zero marks. Your submission time will be the time that the file 410
is submitted via GradeScope on Blackboard, and not the time of your last repository commit nor the time of 411
creation of your submission zip file. 412
We will mark your last submission, even if that is after the deadline and you made submissions before the 413
deadline. Any submissions after the deadline7 will incur a late penalty – see the CSSE2310/7231 course profile 414
for details. 415
Note that Gradescope will run the test suite immediately after you submit. When complete8 you will be 416
able to see the results of the “public” tests. 417
Marks 418
Marks will be awarded for functionality, style and svn commit history messages. Marks may be reduced if you 419
are asked to attend an interview about your assignment and you do not attend or are unable to adequately 420
respond to questions – see the Student conduct section above. 421
Functionality (60 marks) 422
Provided your code compiles (see above) and does not use any prohibited statements/functions (see above), and 423
your zip file has been generated correctly and has not been modified prior to submission, then you will earn 424
functionality marks based on the number of features your program correctly implements, as outlined below. 425
Partial marks will be awarded for partially meeting the functionality requirements. Not all features are of equal 426
difficulty. If your program does not allow a feature to be tested then you will receive 0 marks 427
for that feature, even if you claim to have implemented it. For example, if your program can never create 428
a child process then we can not test pipe communication between the processes of that job, or your ability 429
to send it a termination signal. Memory-freeing tests require correct functionality also – a program that frees 430
allocated memory but doesn’t implement the required functionality can’t earn marks for this criteria. This is 431
not a complete list of all dependencies, other dependencies may also exist. If your program takes longer than 10 432
6You may need to use scp or a graphical equivalent such as WinSCP, Filezilla or Cyberduck in order to download the zip file to
your local computer and then upload it to the submission site.
7or your extended deadline if you are granted an extension.
8Gradescope marking may take only a few minutes or more than 30 minutes depending on the functionality/efficiency of your
code.
12
seconds to run any test9
, then it will be terminated and you will earn no marks for the functionality associated 433
with that test. The markers will make no alterations to your code (other than to remove code without academic 434
merit). 435
Functionality marks (out of 60) will be assigned for testuqwordiply in the following categories (CSSE2310 and 436
CSSE7231): 437
1. testuqwordiply correctly handles invalid command lines and the inability to open job files (5 marks) 438
2. testuqwordiply correctly handles errors in job files and job files containing no jobs (5 marks) 439
3. testuqwordiply is able to run the required four processes for one test job (described 440
in a single line job specification file). File descriptors need not be setup correctly. 441
Multiple valid single-job files and command line arguments will be tested. (5 marks) 442
4. testuqwordiply constructs the necessary pipes and stdin redirections for the four 443
processes in one test job (described in a single line job specification file). Multiple 444
valid single-job files and command line arguments will be tested. (5 marks) 445
5. testuqwordiply correctly implements sequential testing (including reporting 446
results and handling job files with comments and blank lines) (10 marks) 447
6. testuqwordiply correct implements parallel testing (including reporting 448
results and handling job files with comments and blank lines) (10 marks) 449
7. testuqwordiply correctly implements quiet mode (for both sequential and parallel testing) (5 marks) 450
8. testuqwordiply correctly implements test interruption (signal handling) (5 marks) 451
9. testuqwordiply correctly closes unnecessary file descriptors in child processes (5 marks) 452
10. testuqwordiply frees all allocated memory prior to exit (original process, not children) (5 marks) 453
Some functionality may be assessed in multiple categories, e.g. the ability to launch multiple test jobs sequen- 454
tially and in parallel must be working to fully test more advanced functionality such as checking for unnecessary 455
file descriptors being closed and for memory to be freed. 456
Functionality marks (out of 10) will be assigned for uqcmp in the following categories (CSSE7231 only): 457
11. uqcmp correctly rejects invalid command lines (2 marks) 458
12. uqcmp correctly handles file descriptor 3 and/or 4 not being open (2 marks) 459
13. uqcmp correctly reports matching data (3 marks) 460
14. uqcmp correctly reports non-matching data (3 marks) 461
Style Marking 462
Style marking is based on the number of style guide violations, i.e. the number of violations of version 2.3 of 463
the CSSE2310/CSSE7231 C Programming Style Guide (found on Blackboard). Style marks will be made up of 464
two components – automated style marks and human style marks. These are detailed below. 465
You should pay particular attention to commenting so that others can understand your code. The marker’s 466
decision with respect to commenting violations is final – it is the marker who has to understand your code. To 467
satisfy layout related guidelines, you may wish to consider the indent(1) tool. Your style marks can never be 468
more than your functionality mark – this prevents the submission of well styled programs which don’t meet at 469
least a minimum level of required functionality. 470
You are encouraged to use the style.sh tool installed on moss to style check your code before submission. 471
This does not check all style requirements, but it will determine your automated style mark (see below). Other 472
elements of the style guide are checked by humans. 473
All .c and .h files in your submission will be subject to style marking. This applies whether they are 474
compiled/linked into your executable or not10
. 475
9Valgrind tests for memory leaks (category 10) will be allowed to run for longer, as will tests that run many jobs sequentially.
10Make sure you remove any unneeded files from your repository, or they will be subject to style marking.
13
Automated Style Marking (5 marks) 476
Automated style marks will be calculated over all of your .c and .h files as follows. If any of your submitted 477
.c and/or .h files are unable to be compiled by themselves then your automated style mark will be zero (0). 478
(Automated style marking can only be undertaken on code that compiles. The provided style.sh script checks 479
this for you.) 480
If your code does compile then your automated style mark will be determined as follows: Let 481
• W be the total number of distinct compilation warnings recorded when your .c files are individually built 482
(using the correct compiler arguments) 483
• A be the total number of style violations detected by style.sh when it is run over each of your .c and 484
.h files individually11
. 485
Your automated style mark S will be 486
S = 5 − (W + A) 487
If W +A ≥ 5 then S will be zero (0) – no negative marks will be awarded. Note that in some cases style.sh 488
may erroneously report style violations when correct style has been followed. If you believe that you have been 489
penalised incorrectly then please bring this to the attention of the course coordinator and your mark can be 490
updated if this is the case. Note also that when style.sh is run for marking purposes it may detect style 491
errors not picked up when you run style.sh on moss. This will not be considered a marking error – it is your 492
responsibility to ensure that all of your code follows the style guide, even if styling errors are not detected in 493
some runs of style.sh. You can check the result of Gradescope style marking soon after your Gradescope 494
submission – when its test suite completes running. 495
Human Style Marking (5 marks) 496
The human style mark (out of 5 marks) will be based on the criteria/standards below for “comments”, “naming” 497
and “other”. The meanings of words like appropriate and required are determined by the requirements in the 498
style guide. Note that functions longer than 50 lines will be penalised in the automated style marking. Functions 499
that are also longer than 100 lines will be further penalised here. 500
Comments (2.5 marks) 501
Mark Description
0
The majority (50%+) of comments present are inappropriate OR there are many required comments
missing
0.5 The majority of comments present are appropriate AND the majority of required comments are
present
1.0 The vast majority (80%+) of comments present are appropriate AND there are at most a few missing
comments
1.5 All or almost all comments present are appropriate AND there are at most a few missing comments
2.0 Almost all comments present are appropriate AND there are no missing comments
2.5 All comments present are appropriate AND there are no missing comments
502
Naming (1 mark) 503
Mark Description
0 At least a few names used are inappropriate
0.5 Almost all names used are appropriate
1.0 All names used are appropriate
504
11Every .h file in your submission must make sense without reference to any other files, e.g., it must #include any .h files that
contain declarations or definitions used in that .h file.
14
Other (1.5 marks) 505
Mark Description
0
One or more functions is longer than 100 lines of code OR there is more than one global/static
variable present inappropriately OR there is a global struct variable present inappropriately OR
there are more than a few instances of poor modularity (e.g. repeated code)
0.5 All functions are 100 lines or shorter AND there is at most one inappropriate non-struct global/static
variable AND there are at most a few instances of poor modularity
1.0
All functions are 100 lines or shorter AND there are no instances of inappropriate global/static
variables AND there is no or very limited use of magic numbers AND there is at most one instance
or poor modularity
1.5 All functions are 100 lines or shorter AND there are no instances of inappropriate global/static
variables AND there is no use of magic numbers AND there are no instances of poor modularity
506
SVN Commit History Marking (5 marks) 507
Markers will review your SVN commit history for your assignment up to your submission time. This element 508
will be graded according to the following principles: 509
• Appropriate use and frequency of commits (e.g. a single monolithic commit of your entire assignment will 510
yield a score of zero for this section) 511
• Appropriate use of log messages to capture the changes represented by each commit. (Meaningful messages 512
explain briefly what has changed in the commit (e.g. in terms of functionality) and/or why the change 513
has been made and will be usually be more detailed for significant changes.) 514
The standards expected are outlined in the following rubric: 515
Mark
(out of 5) Description
0
Minimal commit history – only one or two commits OR
all commit messages are meaningless.
1
Some progressive development evident (three or more commits) AND
at least one commit message is meaningful.
2
Progressive development is evident (multiple commits) AND
at least half the commit messages are meaningful.
3
Multiple commits that show progressive development of ALL functionality (e.g. no large com￾mits with multiple features in them) AND at least half the commit messages are meaningful.
4
Multiple commits that show progressive development of ALL functionality AND
meaningful messages for all but one or two of the commits.
5
Multiple commits that show progressive development of ALL functionality AND
meaningful messages for ALL commits.
516
Total Mark 517
Let 518
• F be the functionality mark for your assignment (out of 60 for CSSE2310 students or out of 70 for 519
CSSE7231 students). 520
• S be the automated style mark for your assignment (out of 5). 521
• H be the human style mark for your assignment (out of 5). 522
• C be the SVN commit history mark (out of 5). 523
• V is the scaling factor (0 to 1) determined after interview(s) (if applicable – see the Student Conduct 524
section above) – or 0 if you fail to attend a scheduled interview without having evidence of exceptional 525
circumstances impacting your ability to attend. 526
Your total mark for the assignment will be: 527
M = (F + min{F, S + H} + min{F, C}) × V 528
15
out of 75 (for CSSE2310 students) or out of 85 (for CSSE7231 students). 529
In other words, you can’t get more marks for style or SVN commit history than you do for functionality. 530
Pretty code that doesn’t work will not be rewarded! 531
Late Penalties 532
Late penalties will apply as outlined in the course profile. 533
Specification Updates 534
Any errors or omissions discovered in the assignment specification will be added here, and new versions released 535
with adequate time for students to respond prior to due date. Potential specification errors or omissions can be 536
discussed on the discussion forum or emailed to csse2310@uq.edu.au. 537
16
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!