Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use makefile to test my shell implementation?
    text
    copied!<p>Here is my current makefile, which does not run test correctly: </p> <pre><code>shell2: shell2.o shell2.o: shell2.c clean: rm -f *.o test: shell2 ./shell2 pwd ./shell2 cd .. ./shell2 jobs ./shell2 sleep 100 &amp; jobs ./shell2 exit </code></pre> <p>My program tests for newline to know when a command has been entered. This is the output of my program when I compile it myself manually: </p> <pre><code>$ pwd /students/8/[redacted]/[redacted]/Shell2 $ cd .. $ jobs Jobs: $ sleep 1000 &amp; To the background: 20203 $ jobs Jobs: 20203 $ jobs Jobs: 20203 $ killall sleep sleep(17014): Operation not permitted sleep(17305): Operation not permitted sleep(17433): Operation not permitted sleep(19741): Operation not permitted sleep(19841): Operation not permitted sleep(20041): Operation not permitted sleep(20183): Operation not permitted $ jobs Jobs: $ exit now exiting... </code></pre> <p>Here is the output when I run make test: </p> <pre><code>make test ./shell2 $ pwd /students/8/[redacted]/[redacted]/Shell2 ./shell2 $ cd .. ./shell2 $ jobs make: jobs: Command not found make: *** [test] Error 127 </code></pre> <p>Also, I have to hit ctrl+D every time for a new line to execute during make test. </p> <p>I'm trying to write this makefile for my class so that I can submit my assignment, my professor did not explain at all how to use a makefile besides the basic ./a.out [input command]</p> <p>He never explained how to use a makefile in the case that your program is running on a continuous loop like a shell is, waiting for the user to press [enter] or new line for the command to be parsed. </p> <p>I checked the GNU man for make but it didn't explain much in the "testing" section.</p> <p>Thanks for your help, I really appreciate it. </p> <p><strong>test_input.txt's output:</strong></p> <pre><code>./shell2 &lt; test_input.txt "Sending command: pwd" /students/8/[redacted]/[redacted]/Shell2 "Sending command: cd .." "Sending command: pwd" /students/8/[redacted]/[redacted] "Sending command: jobs" $ $ $ $ $ $ $ $ Jobs: $ "Sending command: sleep 1000 &amp;" $ $ To the background: 27199 "jobs" $ $ Jobs: 27199 $ "Sending command: killall sleep" $ $ $ $ Jobs: "Sending command: jobs" $ $ now exiting... "exit" </code></pre> <p><strong>test_input.txt:</strong></p> <pre><code>echo "Sending command: pwd" pwd echo "Sending command: cd .." cd .. echo "Sending command: pwd" pwd echo "Sending command: jobs" jobs echo "Sending command: sleep 1000 &amp;" sleep 1000 &amp; echo "jobs" jobs echo "Sending command: killall sleep" killall sleep echo "Sending command: jobs" jobs echo "exit" exit </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload