Due: Friday, November 3, 2023 11:59pm
You may not drop this project assignment
In this assignment we will put our skills together. You will get more practice shell scripting and integrating different types of processes. You will additionally learn to build a useful test tool to help with HW 5.
Taken in its entirety this assignment may seem quite long. You are encouraged to read through the described approach which is designed to break the assignment into managable pieces. While it is a a good idea to read the entire description before you start, completing one section at a time will help you tackle this large project.
You are always encouraged to test your code earlier rather than later. Make sure it meets the basic big picture requirements before you move on to finishing all the details.
There are some references linked at the end of this page.
You want to build a script to help test a project you are working on. This script will allow you to specify different executables and test files, as well as an output file to which you will write results. This assignment specifies some basic functionality for this test script. While you can imagine many ways to improve this testing, the evaluation of HW3 will be based on the specifications laid out here.
You will create on bash script called tninetest
with usage:
tninetest OUTPUT EXECUTABLE TESTFILE...
tninetest
will test the EXECUTABLE by redirecting TESTFILE(s) into the executable.
Results of the tests will be written to OUTPUT. For this assignment you will be testing an executable called t9. Later in the quarter you will build your own version of t9, in HW 5. You can learn more about the details of the executable there. For this assignment you will be able to retrieve an executable and a required dictionary file from the HW3 folder in cse374-materials repository.
Running t9
is designed to be interactive, but, you can automate this with some shell
redirects. For example, this line loads a dictionary and then exits:
[hw3]$ ./t9 smallDictionary.txt <<< $'exit' Welcome to the T9 decoder Enter "exit" to quit Enter key sequence (or "#" for next word): Thank you!
You may wish to play around with the executable for a little bit. Can you open it and query for a
word? (Hint: t9 smallDictionary.txt
will start the executable and load one dictionary.
Try following the interface to query for any of the words you see in the smallDictionary file.
Enter "exit" to quit. Enter Key Sequence (or "#" for next word): > 76257 'rocks' Enter Key Sequence (or "#" for next word): > # 'socks' Enter Key Sequence (or "#" for next word): > exit
Thoroughly testing code is difficult. When we test your t9 executables for HW5 we use some sample test input. This input is in one or more files which are redirected as input to a running t9 process. For this assignment we will provide a couple of test files, and your shell script should be able to run with one or more of these files. More information about how to use these files is below.
exit 1
.Usage: tninetest OUTPUT EXECUTABLE TESTFILE...
The elements (and expected usage) of the message above are:
Testing EXECUTABLE
with the correct executable name.date
to the output filet9
,
but in the future you could create your own executable and test it here.exit 1
t9
execution. This assignment supplies Testfile1
and Testfile2
.
Handling notes are below.After you perform the basic checks and set up described above you will start testing t9
.
The idea is to perform a test, and then send a message of SUCCESS or FAILURE to the OUTPUT file.
First, do the following basic tests:
./
. This way we can call
any executable in our working directory by name.$?
). Report the results to OUTPUT with a message such asTest Usability ... SUCCESS
Test Handle Bad Dictionary ... FAILURE
Test Load Dictionary ... SUCCESS
[mh75@attu4 hw3]$ ./t9 smallDictionary.txt << INPUT > 53556 > exit > INPUT Welcome to the T9 decoder Enter "exit" to quit Enter key sequence (or "#" for next word): Your word is: jello Enter key sequence (or "#" for next word): Thank you!Hint:
>> testoutput
, grep
. Be sure to report the results
to OUTPUT with a message such asTest Find Word ... SUCCESS
Now, your script will loop through each of the TESTFILES and do the following:
https://courses.cs.washington.edu/courses/cse374/23au/assignments/TESTFILE
Skipping TESTFILE
to the output file, and proceed to the next TESTFILE.Testing TESTFILE
to the output file.
cat TESTFILE | ./t9 smallDictionary.txt
, input redirection may be combined
with a variety of output redirections.)Test TESTFILE ... SUCCESS
This is an example of running a testscript that matches the above descriptions. Testfile1 is in the directory, and Testfile2 is not.
[mh75@localhost hw3b]$ ./tninetest testrecording t9 Testfile1 'not a file' Testfile2 2> errredirect Replacing testrecording [mh75@localhost hw3b]$ more testrecording Testing t9 Wed Nov 1 12:25:14 PM PDT 2023 Test Usability ... SUCCESS Test Handle Bad Dictionary ... SUCCESS Test Load Dictionary ... SUCCESS Test Find Word ... SUCCESS Testing Testfile1 Test Testfile1 ... SUCCESS Skipping not a file Testing Testfile2 Test Testfile2 ... SUCCESS [mh75@localhost hw3b]$ more errredirect [mh75@localhost hw3b]$
You should be sure to delete any temporary files that are created. You should not
produce output other than what has been requested. If the script does not report
any errors at any time during its run, it should exit 0
In addition to the lecture notes, you may find "The Linux Pocket Guide" a useful reference for completing this assignment. You may also wish to look forward to HW 5 to better understand the C code we are testing.
Online manuals:
mktemp
program produces unique file names
for temporary files. If you create a temporary file, you should
remove it before your script exits. Generally it is best to create
temporary files like this in /tmp
. /dev/null
. For example try ls >
/dev/null
. There is also often a -q
option on processes
that prints less information.You should include a README with HW3. In this readme you will want to include:
bash
on our reference system (Seaside).Notice that this assignment is a PROJECT, which means it is not eligible to be dropped at the end of the quarter.
Set up to turn this in by adding a folder called HW3 to your personal Gitlab repository.
This folder should reside at the top leverl of your repository, and it should contain
tninetest
and README
.
Please submit your files via Gradescope. You will do this by choosing to upload from Gitlab, and submitting your repository. Gitlab will ignore files not in HW3.
There will be an autograder in place that will do some of the evaluation, but there will be additional manual grading to evaluate style and your analysis in the write-up. You may resubmit your homework as many times as you like up to the initial due-date.