Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 2 : Auditing and Test Cases Read through the giftcardreader.c program ( and its accompanying header, giftcard.h ) to get a feel for it
Part : Auditing and Test Cases
Read through the giftcardreader.c program and its accompanying header, giftcard.h to get a feel for it You should also try building and running it with the included examplefile.gft file, to see what its normal output is You may find it helpful to use a debugger like gdb or lldb to step through the program as it executes.
There is also a Makefile included in the repository. You can use this to build the program by typing make. You can also use it to run the very minimal and incomplete test suite for the program by typing make test, which uses runtests.sh to run the gift card reader on the gift cards found in testcasesvalid and testcasesinvalid:
$ make test
$ runtestssh
Running tests on valid gift cards expected return value:
Testcase Pass? Exit Status
examplefile.gft PASS
Running tests on invalid gift cards expected return value: nonzero
Testcase Pass? Exit Status
badtype.gft PASS
TESTING SUMMARY:
Passed:
Failed:
Total:
For this part, your job will be to find some flaws in the program, and then create test cases ie binary gift cards that expose flaws in the program. You should write:
Two test cases, crashgft and crashgft that cause the program to crash; each crash should have a different root cause.
One test case, hang.gft that causes the program to loop infinitely. Hint: you may want to examine the "animation" record type to find a bug that causes the program to loop infinitely.
A text file, parttxt explaining the bug triggered by each of your three test cases.
To create your own test files, you may want to refer to the gengift.py and genanim.py programs, which are Python scripts that create gift card files of different types.
Finally, fix the bugs that are triggered by your test cases, and verify that the program no longer crashes hangs on your test cases. To make sure that these bugs don't come up again as the code evolves, have GitHub Actions automatically build and run the program in your test suite. You can do this by placing the new test cases in the testcasesvalid or testcasesinvalid directories depending on whether the gift card reader should accept or reject them Then have GitHub Actions run make test. Note that you do not need to run your tests on the unfixed version of the codethe tests are intended to verify that the code is fixed and prevent the bugs from being reintroduced in later versions known as regression tests You are welcome to use this CC GitHub Actions CI template here.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started