這裏是我當前的makefile,它不能正常運行測試:作爲換行符如何使用makefile來測試我的shell實現?
shell2: shell2.o
shell2.o: shell2.c
clean:
rm -f *.o
test: shell2
./shell2
pwd
./shell2
cd ..
./shell2
jobs
./shell2
sleep 100 &
jobs
./shell2
exit
我的程序測試時,已經進入了一個命令就知道了。這是我 程序的輸出,當我手動編譯自己:
$ pwd
/students/8/[redacted]/[redacted]/Shell2
$ cd ..
$ jobs
Jobs:
$ sleep 1000 &
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...
這裏是輸出,當我運行make測試:
make test
./shell2
$ pwd
/students/8/[redacted]/[redacted]/Shell2
./shell2
$ cd ..
./shell2
$ jobs
make: jobs: Command not found
make: *** [test] Error 127
而且,我必須按ctrl + d,每次在測試期間執行新的一行。
我想寫這個Makefile我的課,這樣我可以提交我的任務,我的教授沒有解釋在所有如何使用一個makefile除了基本的 ./a.out [輸入指令]
他從來沒有解釋如何在程序運行在像shell一樣的連續循環的情況下如何使用makefile,等待用戶按下[enter]或新行來解析命令。
我檢查了GNU man的make,但在「測試」部分沒有解釋太多。
感謝您的幫助,我非常感謝。
test_input.txt的輸出:
./shell2 < 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 &"
$ $ To the background: 27199
"jobs"
$ $ Jobs:
27199
$
"Sending command: killall sleep"
$ $ $ $ Jobs:
"Sending command: jobs"
$ $ now exiting...
"exit"
test_input.txt:
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 &"
sleep 1000 &
echo "jobs"
jobs
echo "Sending command: killall sleep"
killall sleep
echo "Sending command: jobs"
jobs
echo "exit"
exit
發佈您的代碼,以便我們可以測試它 - – 2013-02-26 04:02:58