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.
-
The case describes approaches TEK follows to minimize its international tax liability. Based on your reading of the chapter, how would you advise TEK management to reduce its taxes around the world...
-
On March 17, Advanced Technologies developed a patent related to laser surgery techniques. They spent $1,370,000 to develop the patent internally, consisting of personnel ($885,000), equipment...
-
The accountant for Flenderson Roofing, Inc., posted adjusting entries (a) through (e) to the accounts at December 31, 2010. Selected balance sheet accounts and all the revenues and expenses of the...
-
Molly and Joe Mayne own Campus Fashions. From its inception Campus Fashions has sold merchandise on either a cash or credit basis, but no credit cards have been accepted. During the past several...
-
MCV4U - Unit 7 - Unit TEST 1. [8 Marks]. Four forces of magnitude 5N, 9 N, and 14 N are arranged as shown in the diagram at the left. Determine the resultant of these forces. 9N 5N 10 N 14 N 2. [6...
-
For next month, a hotel manager forecasts revenue of $800,000. 60% of the revenue to be generated in the month will be made to customers who will not pay their bills within the same month as they are...
-
A straight, vertical wire carries a current of 2.20 A downward in a region between the poles of a large superconducting electromagnet, where the magnetic field has a magnitude of B = 0.574 T and is...
-
Nicks Novelties, Inc., is considering the purchase of new electronic games to place in its amusement houses. The games would cost a total of $304,000, have a fifteen-year useful life, and have a...
-
Suppose Nabisco Corporation just issued a dividend of $1.19 per share yesterday. Subsequent dividends will grow at a constant rate of 06.40% indefinitely. If the required rate of return for this...
-
Balance per bookP 2 , 0 0 0 , 0 0 0 Bank charges 6 , 0 0 0 Outstanding checks 4 7 0 , 0 0 0 Deposit in transit 6 0 0 , 0 0 0 Customer note collected by bank 7 5 0 , 0 0 0 Interest on customer note 3...
-
The following data have been extracted from the books of Alfa Ltd . Year. Sales Rs . Profit Rs 2 0 1 9 . 5 , 0 0 , 0 0 0 . ( Loss ) ( 2 5 , 0 0 0 ) 2 0 2 0 . 7 , 5 0 , 0 0 0 . 1 , 0 0 , 0 0 0 Explain...
-
A company purchased land for $ 1 2 0 , 0 0 0 cash; $ 7 , 0 0 0 was spent to demolish an old building on the land before construction of a new building could start; and $ 1 , 5 0 0 was received for...
-
Assuming that the demand function for this system is linear, write the equation for the demand function. Use p for price and q for quantity. p=660
-
In Problems, solve each system of equations. x + 2y + 3z = 5 y + 11z = 21 5y + 9z = 13
-
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...
-
How do you find the inverse of an upper triangular matrix?
-
What is the role of Choleski decomposition in deriving a standard eigenvalue problem?
-
A two-story shear building is shown in Fig. 7.14 in which the floors are assumed to be rigid. Using Rayleigh's method, compute the first natural frequency of the building for \(m_{1}=2 m, m_{2}=m,...
Study smarter with the SolutionInn App