you are on the testing team at work. unfortunately, your company's programmers do not have good...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
you are on the testing team at work. unfortunately, your company's programmers do not have good testing practices. there aren't many tests written, and the ones that are out there don't work reliably: they pass some of the time, but they often fail for unrelated reasons. while your developers get their testing act together, your boss wants you to write a tool to at least make the tests relatively usable. you have to write an unflake program that will rerun a test if it fails the first time (or the 2nd time or 3rd time...). failing means it did not exit with a 0 exit code. unflake will keep track of stdout, stderr, and the exit code of the program. if the unflake is able to run the program successfully, it will print the stdout of the successful run to stdout, the stderr of the successful run to stderr, and exit with exit code of 0. Otherwise, it will output the stdout and stderr of the first run of the program and exit with the exit code of that run. if the test program dies due to a signal, use 100+ signal_number as the exit code. the flaky tests sometimes hang, so if a timeout is exceeded, you need to stop the program with a SIGKILL. you will use execvp to execute the program. if execvp fails, use perror passing the name of the test_command and exit with a code of 2. specification unflake max_tries max_timeout test\command args... max_tries - is the maximum amount of times you will try rerunning the test before giving up. max_timeout - the maximum allowed time for a test to run test_command - the command you will be running for the test args - any arguments the test may take you will probably create temporary files to track output. make sure they are deleted before unflake exits. USAGE $ ./unflake USAGE: ./unflake max_tries max_timeout test_command args... max_tries - must be greater than or equal to 1 max_timeout - number of seconds greater than or equal to 1 $ echo $? 1 $ ./unflake not_num not_num cmd asdf USAGE: /unflake max_tries max_timeout test_command args... max_tries must be greater than or equal to 1 max_timeout - number of seconds greater than or equal to 1 $ echo $? 1 calls to use when you implement unflake, you will need to use the following system calls: fork, execvp, wait, open, dup2, signal, kill, and alarm. to get the exit codes from that status returned from wait please look at the macros (they act like functions) in the man page for wait (man 2 wait). when you open a file with create, you will need to set the mode, so you will probably invoke it like: open (name, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR) Compiling Your Code gcc -g -std-gnu2x -Wall -o unflake unflake.c Examples Command to RUN: ./runvalgrind.sh ./unflake Expected Exit Code: 1 USAGE: ./unflake max_tries max_timeout test_command args... max_tries must be greater than or equal to 1. max_timeout number of seconds greater than or equal to 1. Command to RUN: ./runvalgrind.sh ./unflake 1 1 echo hi Expected Exit Code: 0 hi Command to RUN: ./runvalgrind.sh ./unflake 1 1 badcmd the command is invalid Expected Exit Code: 2 badcmd: No such file or directory Command to RUN: ./runvalgrind.sh ./unflake 3 3 sleep 2 Expected Exit Code: 0 Command to RUN: ./unflake 1 1 sleep 2. Expected Exit Code: 109. Suggested Steps implement the usage message implement the max_tries and max_timeout argument processing. use fork and execvp to run the test code use wait and related macros to get the exit code collect stdout and stderr into a file using open and dup2. read from those files and write to stdout and stderr and delete the files before exiting unflake. implement timeouts using alarm and signal add a loop to retry if the exit code is not successful. you are on the testing team at work. unfortunately, your company's programmers do not have good testing practices. there aren't many tests written, and the ones that are out there don't work reliably: they pass some of the time, but they often fail for unrelated reasons. while your developers get their testing act together, your boss wants you to write a tool to at least make the tests relatively usable. you have to write an unflake program that will rerun a test if it fails the first time (or the 2nd time or 3rd time...). failing means it did not exit with a 0 exit code. unflake will keep track of stdout, stderr, and the exit code of the program. if the unflake is able to run the program successfully, it will print the stdout of the successful run to stdout, the stderr of the successful run to stderr, and exit with exit code of 0. Otherwise, it will output the stdout and stderr of the first run of the program and exit with the exit code of that run. if the test program dies due to a signal, use 100+ signal_number as the exit code. the flaky tests sometimes hang, so if a timeout is exceeded, you need to stop the program with a SIGKILL. you will use execvp to execute the program. if execvp fails, use perror passing the name of the test_command and exit with a code of 2. specification unflake max_tries max_timeout test\command args... max_tries - is the maximum amount of times you will try rerunning the test before giving up. max_timeout - the maximum allowed time for a test to run test_command - the command you will be running for the test args - any arguments the test may take you will probably create temporary files to track output. make sure they are deleted before unflake exits. USAGE $ ./unflake USAGE: ./unflake max_tries max_timeout test_command args... max_tries - must be greater than or equal to 1 max_timeout - number of seconds greater than or equal to 1 $ echo $? 1 $ ./unflake not_num not_num cmd asdf USAGE: /unflake max_tries max_timeout test_command args... max_tries must be greater than or equal to 1 max_timeout - number of seconds greater than or equal to 1 $ echo $? 1 calls to use when you implement unflake, you will need to use the following system calls: fork, execvp, wait, open, dup2, signal, kill, and alarm. to get the exit codes from that status returned from wait please look at the macros (they act like functions) in the man page for wait (man 2 wait). when you open a file with create, you will need to set the mode, so you will probably invoke it like: open (name, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR) Compiling Your Code gcc -g -std-gnu2x -Wall -o unflake unflake.c Examples Command to RUN: ./runvalgrind.sh ./unflake Expected Exit Code: 1 USAGE: ./unflake max_tries max_timeout test_command args... max_tries must be greater than or equal to 1. max_timeout number of seconds greater than or equal to 1. Command to RUN: ./runvalgrind.sh ./unflake 1 1 echo hi Expected Exit Code: 0 hi Command to RUN: ./runvalgrind.sh ./unflake 1 1 badcmd the command is invalid Expected Exit Code: 2 badcmd: No such file or directory Command to RUN: ./runvalgrind.sh ./unflake 3 3 sleep 2 Expected Exit Code: 0 Command to RUN: ./unflake 1 1 sleep 2. Expected Exit Code: 109. Suggested Steps implement the usage message implement the max_tries and max_timeout argument processing. use fork and execvp to run the test code use wait and related macros to get the exit code collect stdout and stderr into a file using open and dup2. read from those files and write to stdout and stderr and delete the files before exiting unflake. implement timeouts using alarm and signal add a loop to retry if the exit code is not successful.
Expert Answer:
Related Book For
Auditing a risk based approach to conducting a quality audit
ISBN: 978-1133939153
9th edition
Authors: Karla Johnstone, Audrey Gramling, Larry Rittenberg
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
From the attached article: 1) Introduction - Describe the case. What happened? When did that happen? Who got involved? 2) Identify the link between the case and global market changes?...
-
Draw and name the eight isomeric alcohols with formula C5H12O.
-
(a) What is the minimum index of refraction for a glass or plastic prism to be used in binoculars (Fig. 23-28) so that total internal reflection occurs at 45? (b) Will binoculars work if their prisms...
-
Refer to Figure 8.28. Given: H 1 = 4 m D 1 = 6 m H 2 = 1.5 m D = 3.6 m Calculate the seepage loss in m 3 /day per meter length of the sheet pile (at right angles to the cross section shown). Use...
-
On January 2, 2018, The Register, a science and technology news site based in Britain, published an article revealing the existence of two major bugs leaving virtually all computers and smartphones...
-
Norman Concrete Company pours concrete slabs for single-family dwellings. Wayne Construction Company, which operates outside Normans normal sales territory, asks Norman to pour 40 slabs for Waynes...
-
A clinical resear would like to know if his diet program is effective in lowering patients blood pressure. The following patient. Blood pressure before diet blood pressure after diet 1. 15. 12 2. 15....
-
A steel company has two mills. Mill I costs $70,000 per day to operate, and it can produce 400 tons of high-grade steel,500 tons of medium-grade steel, and 450 tons of low-grade steel each day. Mill...
-
list 6 examples of forms that are used in a manual control system . list 6 examples of stock items in the the industry . list 4 methods you can use to identify slow moving stock items.
-
"Financial Intelligence" gave examples of firms that had: 1) profit (positive net income) without cash (negative cash flow from operations) and 2) cash (positive cash flow from operations) without...
-
Can credit cards be issued to consumers who have been irresponsible with credit?
-
What are the three primary controls used in protecting corporate assets?
-
For the past several years, an audit client has bought company vehicles and depreciated them over a 10-year period. In the current year, the company determined that a more realistic estimated life...
-
Data: A and b. Output: ak Initialization choice of xo ro = b Axo zo = C-'ro po = z0 Iterations preconditioning For k >1 and rk #0 (k-1,rk-1) (Apk-1 Pk-1) Ik = xk-1 + ak-1Pk-1 ak-1 = Tk = rk-1 -...
-
Construct a 4 x 25 design confounded in two blocks of 16 observations each. Outline the analysis of variance for this design.
-
Exhibit lists types of audit procedures. Describe how you would you use those procedures to test the inventory account. For each procedure, indicate the purpose of the procedureis it a risk...
-
In those audits where a heightened risk of fraud exists related to inventory and cost of goods sold, the auditor will want to consider performing certain fraud-related substantive procedures. List at...
-
Refer to the Professional Judgment in Context feature Deficiencies in Auditing Debt Obligations and Stockholders Equity Accounts: Insights from SEC Releases and review the panel related to Delphi...
-
The figure below illustrates a thin plate of thickness \(t\). An approximate displacement field, which accounts for displacements due to the weight of the plate, is given by a. Determine the...
-
For a plane stress problem, the strain components in the xyplane at a point \(P\) are computed as: a. Compute the state of stress at this point if Young's modulus \(E=2 \times 10^{11} \mathrm{~Pa}\)...
-
The stress matrix at a particular point in a body is Determine the corresponding strain if \(E=20 \times 10^{10} \mathrm{~Pa}\) and \(v=0.3\). -2 1-3 [0] = 104 -345 107 Pa.
Study smarter with the SolutionInn App