Answered step by step
Verified Expert Solution
Link Copied!

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 2: 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 testcases/valid and testcases/invalid:
$ make test
$ ./runtests.sh
Running tests on valid gift cards (expected return value: 0)...
Testcase Pass? Exit Status
examplefile.gft PASS 0
Running tests on invalid gift cards (expected return value: nonzero)...
Testcase Pass? Exit Status
badtype.gft PASS 1
TESTING SUMMARY:
Passed: 2
Failed: 0
Total: 2
For this part, your job will be to find some flaws in the program, and then create test cases (i.e., binary gift cards) that expose flaws in the program. You should write:
Two test cases, crash1.gft and crash2.gft, 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, part2.txt 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 testcases/valid or testcases/invalid 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 code---the 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 C/C++ GitHub Actions CI template here.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions